Skip to content

Commit

Permalink
chore(nlp): stemmer and normalizer tests implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
elozano98 committed Jan 15, 2021
1 parent 00a87db commit faa1fb3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/botonic-plugin-contentful/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/botonic-plugin-contentful/src/nlp/stemmer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ const stemmers = new SingletonMap<Stemmer>({
return new StemmerSl()
},
[locales.HUNGARIAN]: () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires,node/no-missing-require
const { StemmerHu } = require('@nlpjs/lang-hu/src/stemmer-hu')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const StemmerHu = require('@nlpjs/lang-hu/src/stemmer-hu')
return new StemmerHu()
},
})
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-plugin-contentful/src/nlp/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ const lazyTokenizers = new SingletonMap<Tokenizer>({
return new TokenizerSl()
},
[locales.HUNGARIAN]: () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires,node/no-missing-require
const { TokenizerHu } = require('@nlpjs/lang-hu/src/tokenizer-hu')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const TokenizerHu = require('@nlpjs/lang-hu/src/tokenizer-hu')
return new TokenizerHu()
},
})
Expand Down
10 changes: 10 additions & 0 deletions packages/botonic-plugin-contentful/tests/nlp/normalizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ test.each<any>([
new Word('narediti', 'nared'),
],
],
[
'hu',
'ne csinálj semmi hülyeséget',
[
Word.StopWord('ne'),
new Word('csinalj', 'csinalj'),
Word.StopWord('semmi'),
new Word('hulyeseget', 'hulyeseg'),
],
],
])(
'TEST: stemmer removes stopwords: lang=%s input="%j"',
(locale: string, raw: string, words: Word[]) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/botonic-plugin-contentful/tests/nlp/stemmer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ test.each<any>([
['sk', 'európskej', ['europsk']],
['sl', 'Evropski', ['evrop']],
['sl', 'hoditi', ['hodit']],
['hu', 'Európai', ['europ']],
['hu', 'érvelni', ['erveln']],
])(
'TEST: stemmer removes final letters(%s) =>%j',
(locale: string, raw: string, expected: string) => {
Expand Down

0 comments on commit faa1fb3

Please sign in to comment.