Skip to content

Commit aa86d4b

Browse files
committed
cross platform filepath handeling
1 parent 374e00b commit aa86d4b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

goose/images/UpgradedImageExtractor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ def buildImagePath(self, imageSrc):
402402

403403
def loadCustomSiteMapping(self):
404404
# TODO
405-
dataFile = FileHelper.loadResourceFile("images/known-image-css.txt")
405+
path = os.path.join('images', 'known-image-css.txt')
406+
dataFile = FileHelper.loadResourceFile(path)
406407
lines = dataFile.splitlines()
407408
for line in lines:
408409
domain, css = line.split('^')

goose/text.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
See the License for the specific language governing permissions and
2121
limitations under the License.
2222
"""
23+
import os
2324
import re
2425
import string
2526
from goose.utils import FileHelper
@@ -93,7 +94,7 @@ def __init__(self, language='en'):
9394
# TODO replace 'x' with class
9495
# to generate dynamic path for file to load
9596
if not language in self._cached_stop_words:
96-
path = 'text/stopwords-%s.txt' % language
97+
path = os.path.join('text', 'stopwords-%s.txt' % language)
9798
self._cached_stop_words[language] = set(FileHelper.loadResourceFile(path).splitlines())
9899
self.STOP_WORDS = self._cached_stop_words[language]
99100

@@ -129,7 +130,7 @@ def __init__(self, language='zh'):
129130
# force zh languahe code
130131
language = 'zh'
131132
if not language in self._cached_stop_words:
132-
path = 'text/stopwords-%s.txt' % language
133+
path = os.path.join('text', 'stopwords-%s.txt' % language)
133134
self._cached_stop_words[language] = set(FileHelper.loadResourceFile(path).splitlines())
134135
self.STOP_WORDS = self._cached_stop_words[language]
135136

0 commit comments

Comments
 (0)