Completed
Push — master ( cf5fd0...1b4762 )
by Osma
15s queued 12s
created

SnowballAnalyzer._normalize_word()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 3
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 2
dl 3
loc 3
rs 10
c 0
b 0
f 0
1
"""Snowball analyzer for Annif, based on nltk Snowball stemmer."""
2
3
import functools
4
from . import analyzer
5
6
7 View Code Duplication
class SnowballAnalyzer(analyzer.Analyzer):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8
    name = "snowball"
9
10
    def __init__(self, param, **kwargs):
11
        self.param = param
12
        import nltk.stem.snowball
13
        self.stemmer = nltk.stem.snowball.SnowballStemmer(param)
14
        super().__init__(**kwargs)
15
16
    @functools.lru_cache(maxsize=500000)
17
    def _normalize_word(self, word):
18
        return self.stemmer.stem(word.lower())
19