Skip to content

Commit

Permalink
check if stopwords dir exists
Browse files Browse the repository at this point in the history
  • Loading branch information
nandajavarma committed Aug 20, 2024
1 parent d028c1c commit ee5fedd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/multilinguality.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os.path import dirname, join, realpath, isfile
from os.path import dirname, join, realpath, isfile, isdir

def read_language_codes():
dir_path = dirname(dirname(realpath(__file__)))
Expand All @@ -14,6 +14,9 @@ def read_stopwords(lang):
dir_path = dirname(dirname(realpath(__file__)))
ling_dir = join(dir_path,'app','ling','stopwords')
STOPWORDS = []
if not isdir(ling_dir) or not isfile(join(ling_dir,lang)):
return STOPWORDS

with open(join(ling_dir,lang),'r') as f:
STOPWORDS = f.read().splitlines()
return STOPWORDS
Expand Down

0 comments on commit ee5fedd

Please sign in to comment.