Skip to content

Commit 25ef609

Browse files
author
theblackcat102
committed
add a detect function with cache
1 parent 1243565 commit 25ef609

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

fastlangid/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
from .langid import LID
1+
from .langid import LID
2+
3+
_CACHE = {}
4+
5+
def detect(text, **params):
6+
if 'model' not in _CACHE:
7+
_CACHE['model'] = LID()
8+
return _CACHE['model'].predict(text, **params)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Authors:
1313
Ray : ray@currentsapi.services
1414
'''
15-
from setuptools import setup, Extension
15+
from setuptools import setup
1616

1717
try:
1818
from setuptools import setup
@@ -27,7 +27,7 @@
2727

2828
setup(
2929
name='fastlangid',
30-
version='1.0.9',
30+
version='1.0.10',
3131
description='Language detection for news powered by fasttext',
3232
long_description=readme,
3333
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)