Added language checks
authorThierry Florac <thierry.florac@onf.fr>
Wed, 15 Apr 2015 14:32:28 +0200
changeset 2 959d098e49d9
parent 1 5add0249012c
child 3 7c6f10ffdda0
Added language checks
src/pyams_catalog/nltk.py
--- a/src/pyams_catalog/nltk.py	Thu Mar 19 15:18:24 2015 +0100
+++ b/src/pyams_catalog/nltk.py	Wed Apr 15 14:32:28 2015 +0200
@@ -20,6 +20,7 @@
 
 # import packages
 import nltk
+from pyams_i18n.language import BASE_LANGUAGES
 from pyams_utils.unicode import translate_string
 from zope.interface import implementer
 
@@ -29,6 +30,8 @@
     """NLTK based text processor using stemmer"""
 
     def __init__(self, language='english'):
+        if language in BASE_LANGUAGES:
+            language = BASE_LANGUAGES[language].lower()
         self.language = language
         self.stemmer = nltk.stem.SnowballStemmer(language, ignore_stopwords=True)
 
@@ -58,6 +61,8 @@
     """NLTK based full text processor"""
 
     def __init__(self, language='english'):
+        if language in BASE_LANGUAGES:
+            language = BASE_LANGUAGES[language].lower()
         self.language = language
 
     def process(self, lst):