Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def init_factory():
global _factory
if _factory is None:
_factory = DetectorFactory()
_factory.load_profile(PROFILES_DIRECTORY)
def _init_langdetect():
"""
Initialize language detection.
"""
# Imports
import langdetect.detector_factory
from langdetect.detector_factory import DetectorFactory
# Init factory (to load the profiles at startup)
langdetect.detector_factory.init_factory()
# Language detection algorithm is non-deterministic, we might get different results every time you run it.
# To enforce consistent results, call following code before the first language detection
DetectorFactory.seed = 0