| Total Complexity | 2 |
| Total Lines | 19 |
| Duplicated Lines | 63.16 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 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): |
|
|
|
|||
| 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 |