Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cache layer to Tagger #3

Open
bung87 opened this issue May 19, 2018 · 4 comments
Open

add cache layer to Tagger #3

bung87 opened this issue May 19, 2018 · 4 comments

Comments

@bung87
Copy link
Contributor

bung87 commented May 19, 2018

if instantiating Tagger at function level it will load dictionary every time,
if instantiating Tagger at module level it will load dictionary therefore may not actually use
refer to https://github.com/fxsjy/jieba/blob/master/jieba/__init__.py

@taishi-i
Copy link
Owner

Thanks for the advice. I interpreted adding some lines tagger = Tagger() and functions (e.g, tagging = tagger.taggging) to __init__.py. , is it correct?

@bung87
Copy link
Contributor Author

bung87 commented May 20, 2018

you may add a singleton tagger instance to init.py as a shorthand method that use the default dictionary and implement a initialize method for actually make io happen and use a cache layer, when call tagger.tagging or some else methods for end developer interface,check if it is initialized,if not initialize it.

@taishi-i
Copy link
Owner

Regarding a cache layer, should I refer to methods written on lines 91 to 168 in https://github.com/fxsjy/jieba/blob/master/jieba/__init__.py and add them to the class Tagger?

@bung87
Copy link
Contributor Author

bung87 commented May 20, 2018

not sure about.that ,you.may consider use https://docs.python.org/3/library/functools.html#functools.lru_cache for keep code simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants