def setUp(self): self.factory = DetectorFactory() profile_en = LangProfile('en') for w in self.TRAINING_EN.split(): profile_en.add(w) self.factory.add_profile(profile_en, 0, 3) profile_fr = LangProfile('fr') for w in self.TRAINING_FR.split(): profile_fr.add(w) self.factory.add_profile(profile_fr, 1, 3) profile_ja = LangProfile('ja') for w in self.TRAINING_JA.split(): profile_ja.add(w) self.factory.add_profile(profile_ja, 2, 3)
from logging import getLogger from pprint import pformat from langdetect.detector_factory import DetectorFactory, PROFILES_DIRECTORY logger = getLogger(__name__) factory = DetectorFactory() factory.load_profile(PROFILES_DIRECTORY) lang_list = factory.get_lang_list() + [ 'und', ] logger.debug("lang_list=\n{}".format(pformat(lang_list)))