Skip to content

Commit fa81e34

Browse files
authored
Merge pull request nltk#3303 from strangetom/perf/pos-lru-cache
Use LRU cache when getting POS tagger
2 parents c52a3b2 + 6b6ac47 commit fa81e34

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
- Akihiro Yamazaki <https://github.com/zakkie>
303303
- Ron Urbach <https://github.com/sharpblade4>
304304
- Vivek Kalyan <https://github.com/vivekkalyan>
305+
- Tom Strange https://github.com/strangetom
305306

306307
## Others whose work we've taken and included in NLTK, but who didn't directly contribute it:
307308

nltk/tag/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
isort:skip_file
6666
"""
6767

68+
import functools
69+
6870
from nltk.tag.api import TaggerI
6971
from nltk.tag.util import str2tuple, tuple2str, untag
7072
from nltk.tag.sequential import (
@@ -100,6 +102,7 @@
100102
}
101103

102104

105+
@functools.lru_cache
103106
def _get_tagger(lang=None):
104107
if lang == "rus":
105108
tagger = PerceptronTagger(lang=lang)

0 commit comments

Comments
 (0)