natural 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +7 -0
- package/README.md +3 -3
- package/lib/natural/inflectors/present_verb_inflector.js +1 -0
- package/lib/natural/phonetics/double_metaphone.js +9 -4
- package/lib/natural/phonetics/metaphone.js +4 -0
- package/lib/natural/phonetics/soundex.js +11 -7
- package/lib/natural/stemmers/porter_stemmer.js +90 -62
- package/lib/natural/stemmers/porter_stemmer_pt.js +302 -0
- package/lib/natural/stemmers/stemmer_pt.js +65 -0
- package/lib/natural/stemmers/token.js +163 -0
- package/lib/natural/util/stopwords_pt.js +136 -0
- package/package.json +2 -2
- package/spec/double_metaphone_spec.js +10 -1
- package/spec/metaphone_spec.js +5 -0
- package/spec/porter_stemmer_pt_spec.js +50 -0
- package/spec/porter_stemmer_spec.js +45 -0
- package/spec/present_verb_inflector_spec.js +3 -0
- package/spec/soundex_spec.js +13 -9
- package/spec/stemmer_token_spec.js +161 -0
- package/spec/test_data/snowball_pt.txt +32016 -0
- package/coverage/coverage.json +0 -1
- package/coverage/lcov-report/index.html +0 -584
- package/coverage/lcov-report/io_spec/index.html +0 -350
- package/coverage/lcov-report/io_spec/tfidf_spec.js.html +0 -469
- package/coverage/lcov-report/lib/natural/analyzers/index.html +0 -350
- package/coverage/lcov-report/lib/natural/analyzers/sentence_analyzer.js.html +0 -850
- package/coverage/lcov-report/lib/natural/classifiers/bayes_classifier.js.html +0 -496
- package/coverage/lcov-report/lib/natural/classifiers/classifier.js.html +0 -823
- package/coverage/lcov-report/lib/natural/classifiers/index.html +0 -376
- package/coverage/lcov-report/lib/natural/classifiers/logistic_regression_classifier.js.html +0 -502
- package/coverage/lcov-report/lib/natural/distance/dice_coefficient.js.html +0 -529
- package/coverage/lcov-report/lib/natural/distance/index.html +0 -376
- package/coverage/lcov-report/lib/natural/distance/jaro-winkler_distance.js.html +0 -670
- package/coverage/lcov-report/lib/natural/distance/levenshtein_distance.js.html +0 -526
- package/coverage/lcov-report/lib/natural/index.html +0 -350
- package/coverage/lcov-report/lib/natural/index.js.html +0 -547
- package/coverage/lcov-report/lib/natural/inflectors/count_inflector.js.html +0 -484
- package/coverage/lcov-report/lib/natural/inflectors/form_set.js.html +0 -406
- package/coverage/lcov-report/lib/natural/inflectors/fr/count_inflector.js.html +0 -520
- package/coverage/lcov-report/lib/natural/inflectors/fr/index.html +0 -363
- package/coverage/lcov-report/lib/natural/inflectors/fr/noun_inflector.js.html +0 -1027
- package/coverage/lcov-report/lib/natural/inflectors/index.html +0 -402
- package/coverage/lcov-report/lib/natural/inflectors/ja/index.html +0 -350
- package/coverage/lcov-report/lib/natural/inflectors/ja/noun_inflector.js.html +0 -727
- package/coverage/lcov-report/lib/natural/inflectors/noun_inflector.js.html +0 -637
- package/coverage/lcov-report/lib/natural/inflectors/present_verb_inflector.js.html +0 -544
- package/coverage/lcov-report/lib/natural/inflectors/singular_plural_inflector.js.html +0 -649
- package/coverage/lcov-report/lib/natural/ngrams/index.html +0 -363
- package/coverage/lcov-report/lib/natural/ngrams/ngrams.js.html +0 -595
- package/coverage/lcov-report/lib/natural/ngrams/ngrams_zh.js.html +0 -571
- package/coverage/lcov-report/lib/natural/normalizers/index.html +0 -389
- package/coverage/lcov-report/lib/natural/normalizers/normalizer.js.html +0 -607
- package/coverage/lcov-report/lib/natural/normalizers/normalizer_ja.js.html +0 -2194
- package/coverage/lcov-report/lib/natural/normalizers/normalizer_no.js.html +0 -496
- package/coverage/lcov-report/lib/natural/normalizers/remove_diacritics.js.html +0 -685
- package/coverage/lcov-report/lib/natural/phonetics/dm_soundex.js.html +0 -1063
- package/coverage/lcov-report/lib/natural/phonetics/double_metaphone.js.html +0 -1840
- package/coverage/lcov-report/lib/natural/phonetics/index.html +0 -402
- package/coverage/lcov-report/lib/natural/phonetics/metaphone.js.html +0 -886
- package/coverage/lcov-report/lib/natural/phonetics/phonetic.js.html +0 -484
- package/coverage/lcov-report/lib/natural/phonetics/soundex.js.html +0 -562
- package/coverage/lcov-report/lib/natural/spellcheck/index.html +0 -350
- package/coverage/lcov-report/lib/natural/spellcheck/spellcheck.js.html +0 -562
- package/coverage/lcov-report/lib/natural/stemmers/index.html +0 -571
- package/coverage/lcov-report/lib/natural/stemmers/lancaster_rules.js.html +0 -2692
- package/coverage/lcov-report/lib/natural/stemmers/lancaster_stemmer.js.html +0 -544
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer.js.html +0 -937
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_es.js.html +0 -985
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_fa.js.html +0 -418
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_fr.js.html +0 -1450
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_it.js.html +0 -1018
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_no.js.html +0 -784
- package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_ru.js.html +0 -775
- package/coverage/lcov-report/lib/natural/stemmers/stemmer.js.html +0 -505
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_es.js.html +0 -496
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_fa.js.html +0 -484
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_fr.js.html +0 -496
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_it.js.html +0 -427
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_ja.js.html +0 -736
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_no.js.html +0 -505
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_pl.js.html +0 -496
- package/coverage/lcov-report/lib/natural/stemmers/stemmer_ru.js.html +0 -496
- package/coverage/lcov-report/lib/natural/tfidf/index.html +0 -350
- package/coverage/lcov-report/lib/natural/tfidf/tfidf.js.html +0 -904
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer.js.html +0 -430
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_es.js.html +0 -430
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_fa.js.html +0 -466
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_fr.js.html +0 -430
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_it.js.html +0 -430
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_nl.js.html +0 -430
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_no.js.html +0 -439
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_pl.js.html +0 -457
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_pt.js.html +0 -442
- package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_ru.js.html +0 -457
- package/coverage/lcov-report/lib/natural/tokenizers/index.html +0 -519
- package/coverage/lcov-report/lib/natural/tokenizers/regexp_tokenizer.js.html +0 -580
- package/coverage/lcov-report/lib/natural/tokenizers/tokenizer.js.html +0 -475
- package/coverage/lcov-report/lib/natural/tokenizers/tokenizer_ja.js.html +0 -1153
- package/coverage/lcov-report/lib/natural/tokenizers/treebank_word_tokenizer.js.html +0 -544
- package/coverage/lcov-report/lib/natural/transliterators/ja/index.html +0 -350
- package/coverage/lcov-report/lib/natural/transliterators/ja/index.js.html +0 -2068
- package/coverage/lcov-report/lib/natural/trie/index.html +0 -350
- package/coverage/lcov-report/lib/natural/trie/trie.js.html +0 -1012
- package/coverage/lcov-report/lib/natural/util/bag.js.html +0 -472
- package/coverage/lcov-report/lib/natural/util/edge_weighted_digraph.js.html +0 -658
- package/coverage/lcov-report/lib/natural/util/index.html +0 -532
- package/coverage/lcov-report/lib/natural/util/longest_path_tree.js.html +0 -619
- package/coverage/lcov-report/lib/natural/util/shortest_path_tree.js.html +0 -622
- package/coverage/lcov-report/lib/natural/util/stopwords.js.html +0 -445
- package/coverage/lcov-report/lib/natural/util/stopwords_es.js.html +0 -430
- package/coverage/lcov-report/lib/natural/util/stopwords_fa.js.html +0 -436
- package/coverage/lcov-report/lib/natural/util/stopwords_fr.js.html +0 -904
- package/coverage/lcov-report/lib/natural/util/stopwords_it.js.html +0 -478
- package/coverage/lcov-report/lib/natural/util/stopwords_ja.js.html +0 -499
- package/coverage/lcov-report/lib/natural/util/stopwords_no.js.html +0 -445
- package/coverage/lcov-report/lib/natural/util/stopwords_pl.js.html +0 -508
- package/coverage/lcov-report/lib/natural/util/stopwords_ru.js.html +0 -445
- package/coverage/lcov-report/lib/natural/util/topological.js.html +0 -616
- package/coverage/lcov-report/lib/natural/util/utils.js.html +0 -679
- package/coverage/lcov-report/lib/natural/wordnet/data_file.js.html +0 -580
- package/coverage/lcov-report/lib/natural/wordnet/index.html +0 -389
- package/coverage/lcov-report/lib/natural/wordnet/index_file.js.html +0 -742
- package/coverage/lcov-report/lib/natural/wordnet/wordnet.js.html +0 -829
- package/coverage/lcov-report/lib/natural/wordnet/wordnet_file.js.html +0 -529
- package/coverage/lcov-report/natural/analyzers/index.html +0 -350
- package/coverage/lcov-report/natural/analyzers/sentence_analyzer.js.html +0 -850
- package/coverage/lcov-report/natural/classifiers/bayes_classifier.js.html +0 -496
- package/coverage/lcov-report/natural/classifiers/classifier.js.html +0 -823
- package/coverage/lcov-report/natural/classifiers/index.html +0 -376
- package/coverage/lcov-report/natural/classifiers/logistic_regression_classifier.js.html +0 -502
- package/coverage/lcov-report/natural/distance/dice_coefficient.js.html +0 -529
- package/coverage/lcov-report/natural/distance/index.html +0 -376
- package/coverage/lcov-report/natural/distance/jaro-winkler_distance.js.html +0 -670
- package/coverage/lcov-report/natural/distance/levenshtein_distance.js.html +0 -526
- package/coverage/lcov-report/natural/index.html +0 -350
- package/coverage/lcov-report/natural/index.js.html +0 -433
- package/coverage/lcov-report/natural/inflectors/count_inflector.js.html +0 -484
- package/coverage/lcov-report/natural/inflectors/form_set.js.html +0 -406
- package/coverage/lcov-report/natural/inflectors/fr/index.html +0 -350
- package/coverage/lcov-report/natural/inflectors/fr/noun_inflector.js.html +0 -1027
- package/coverage/lcov-report/natural/inflectors/index.html +0 -402
- package/coverage/lcov-report/natural/inflectors/ja/index.html +0 -350
- package/coverage/lcov-report/natural/inflectors/ja/noun_inflector.js.html +0 -727
- package/coverage/lcov-report/natural/inflectors/noun_inflector.js.html +0 -637
- package/coverage/lcov-report/natural/inflectors/present_verb_inflector.js.html +0 -544
- package/coverage/lcov-report/natural/inflectors/singular_plural_inflector.js.html +0 -649
- package/coverage/lcov-report/natural/lib/natural/analyzers/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/analyzers/sentence_analyzer.js.html +0 -850
- package/coverage/lcov-report/natural/lib/natural/classifiers/bayes_classifier.js.html +0 -496
- package/coverage/lcov-report/natural/lib/natural/classifiers/classifier.js.html +0 -823
- package/coverage/lcov-report/natural/lib/natural/classifiers/index.html +0 -376
- package/coverage/lcov-report/natural/lib/natural/classifiers/logistic_regression_classifier.js.html +0 -502
- package/coverage/lcov-report/natural/lib/natural/distance/dice_coefficient.js.html +0 -529
- package/coverage/lcov-report/natural/lib/natural/distance/index.html +0 -376
- package/coverage/lcov-report/natural/lib/natural/distance/jaro-winkler_distance.js.html +0 -670
- package/coverage/lcov-report/natural/lib/natural/distance/levenshtein_distance.js.html +0 -526
- package/coverage/lcov-report/natural/lib/natural/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/index.js.html +0 -547
- package/coverage/lcov-report/natural/lib/natural/inflectors/count_inflector.js.html +0 -484
- package/coverage/lcov-report/natural/lib/natural/inflectors/form_set.js.html +0 -406
- package/coverage/lcov-report/natural/lib/natural/inflectors/fr/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/inflectors/fr/noun_inflector.js.html +0 -1027
- package/coverage/lcov-report/natural/lib/natural/inflectors/index.html +0 -402
- package/coverage/lcov-report/natural/lib/natural/inflectors/ja/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/inflectors/ja/noun_inflector.js.html +0 -727
- package/coverage/lcov-report/natural/lib/natural/inflectors/noun_inflector.js.html +0 -637
- package/coverage/lcov-report/natural/lib/natural/inflectors/present_verb_inflector.js.html +0 -544
- package/coverage/lcov-report/natural/lib/natural/inflectors/singular_plural_inflector.js.html +0 -649
- package/coverage/lcov-report/natural/lib/natural/ngrams/index.html +0 -363
- package/coverage/lcov-report/natural/lib/natural/ngrams/ngrams.js.html +0 -595
- package/coverage/lcov-report/natural/lib/natural/ngrams/ngrams_zh.js.html +0 -571
- package/coverage/lcov-report/natural/lib/natural/normalizers/index.html +0 -389
- package/coverage/lcov-report/natural/lib/natural/normalizers/normalizer.js.html +0 -607
- package/coverage/lcov-report/natural/lib/natural/normalizers/normalizer_ja.js.html +0 -2194
- package/coverage/lcov-report/natural/lib/natural/normalizers/normalizer_no.js.html +0 -496
- package/coverage/lcov-report/natural/lib/natural/normalizers/remove_diacritics.js.html +0 -685
- package/coverage/lcov-report/natural/lib/natural/phonetics/dm_soundex.js.html +0 -1063
- package/coverage/lcov-report/natural/lib/natural/phonetics/double_metaphone.js.html +0 -1840
- package/coverage/lcov-report/natural/lib/natural/phonetics/index.html +0 -402
- package/coverage/lcov-report/natural/lib/natural/phonetics/metaphone.js.html +0 -886
- package/coverage/lcov-report/natural/lib/natural/phonetics/phonetic.js.html +0 -484
- package/coverage/lcov-report/natural/lib/natural/phonetics/soundex.js.html +0 -562
- package/coverage/lcov-report/natural/lib/natural/stemmers/index.html +0 -571
- package/coverage/lcov-report/natural/lib/natural/stemmers/lancaster_rules.js.html +0 -2692
- package/coverage/lcov-report/natural/lib/natural/stemmers/lancaster_stemmer.js.html +0 -544
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer.js.html +0 -937
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_es.js.html +0 -985
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_fa.js.html +0 -418
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_fr.js.html +0 -1450
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_it.js.html +0 -1018
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_no.js.html +0 -784
- package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_ru.js.html +0 -775
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer.js.html +0 -505
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_es.js.html +0 -496
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_fa.js.html +0 -484
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_fr.js.html +0 -496
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_it.js.html +0 -427
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_ja.js.html +0 -736
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_no.js.html +0 -505
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_pl.js.html +0 -496
- package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_ru.js.html +0 -496
- package/coverage/lcov-report/natural/lib/natural/tfidf/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/tfidf/tfidf.js.html +0 -904
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer.js.html +0 -430
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_es.js.html +0 -430
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_fa.js.html +0 -466
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_fr.js.html +0 -430
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_it.js.html +0 -430
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_nl.js.html +0 -430
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_no.js.html +0 -439
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_pl.js.html +0 -457
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_pt.js.html +0 -442
- package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_ru.js.html +0 -457
- package/coverage/lcov-report/natural/lib/natural/tokenizers/index.html +0 -519
- package/coverage/lcov-report/natural/lib/natural/tokenizers/regexp_tokenizer.js.html +0 -580
- package/coverage/lcov-report/natural/lib/natural/tokenizers/tokenizer.js.html +0 -475
- package/coverage/lcov-report/natural/lib/natural/tokenizers/tokenizer_ja.js.html +0 -1153
- package/coverage/lcov-report/natural/lib/natural/tokenizers/treebank_word_tokenizer.js.html +0 -544
- package/coverage/lcov-report/natural/lib/natural/transliterators/ja/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/transliterators/ja/index.js.html +0 -2068
- package/coverage/lcov-report/natural/lib/natural/trie/index.html +0 -350
- package/coverage/lcov-report/natural/lib/natural/trie/trie.js.html +0 -1012
- package/coverage/lcov-report/natural/lib/natural/util/bag.js.html +0 -472
- package/coverage/lcov-report/natural/lib/natural/util/edge_weighted_digraph.js.html +0 -658
- package/coverage/lcov-report/natural/lib/natural/util/index.html +0 -532
- package/coverage/lcov-report/natural/lib/natural/util/longest_path_tree.js.html +0 -619
- package/coverage/lcov-report/natural/lib/natural/util/shortest_path_tree.js.html +0 -622
- package/coverage/lcov-report/natural/lib/natural/util/stopwords.js.html +0 -445
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_es.js.html +0 -430
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_fa.js.html +0 -436
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_fr.js.html +0 -904
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_it.js.html +0 -478
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_ja.js.html +0 -499
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_no.js.html +0 -445
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_pl.js.html +0 -508
- package/coverage/lcov-report/natural/lib/natural/util/stopwords_ru.js.html +0 -445
- package/coverage/lcov-report/natural/lib/natural/util/topological.js.html +0 -616
- package/coverage/lcov-report/natural/lib/natural/util/utils.js.html +0 -679
- package/coverage/lcov-report/natural/lib/natural/wordnet/data_file.js.html +0 -580
- package/coverage/lcov-report/natural/lib/natural/wordnet/index.html +0 -389
- package/coverage/lcov-report/natural/lib/natural/wordnet/index_file.js.html +0 -742
- package/coverage/lcov-report/natural/lib/natural/wordnet/wordnet.js.html +0 -829
- package/coverage/lcov-report/natural/lib/natural/wordnet/wordnet_file.js.html +0 -529
- package/coverage/lcov-report/natural/ngrams/index.html +0 -363
- package/coverage/lcov-report/natural/ngrams/ngrams.js.html +0 -595
- package/coverage/lcov-report/natural/ngrams/ngrams_zh.js.html +0 -571
- package/coverage/lcov-report/natural/normalizers/index.html +0 -389
- package/coverage/lcov-report/natural/normalizers/normalizer.js.html +0 -607
- package/coverage/lcov-report/natural/normalizers/normalizer_ja.js.html +0 -2194
- package/coverage/lcov-report/natural/normalizers/normalizer_no.js.html +0 -496
- package/coverage/lcov-report/natural/normalizers/remove_diacritics.js.html +0 -685
- package/coverage/lcov-report/natural/phonetics/dm_soundex.js.html +0 -1063
- package/coverage/lcov-report/natural/phonetics/double_metaphone.js.html +0 -1840
- package/coverage/lcov-report/natural/phonetics/index.html +0 -402
- package/coverage/lcov-report/natural/phonetics/metaphone.js.html +0 -886
- package/coverage/lcov-report/natural/phonetics/phonetic.js.html +0 -484
- package/coverage/lcov-report/natural/phonetics/soundex.js.html +0 -562
- package/coverage/lcov-report/natural/stemmers/index.html +0 -571
- package/coverage/lcov-report/natural/stemmers/lancaster_rules.js.html +0 -2692
- package/coverage/lcov-report/natural/stemmers/lancaster_stemmer.js.html +0 -544
- package/coverage/lcov-report/natural/stemmers/porter_stemmer.js.html +0 -937
- package/coverage/lcov-report/natural/stemmers/porter_stemmer_es.js.html +0 -985
- package/coverage/lcov-report/natural/stemmers/porter_stemmer_fa.js.html +0 -418
- package/coverage/lcov-report/natural/stemmers/porter_stemmer_fr.js.html +0 -1450
- package/coverage/lcov-report/natural/stemmers/porter_stemmer_it.js.html +0 -1018
- package/coverage/lcov-report/natural/stemmers/porter_stemmer_no.js.html +0 -784
- package/coverage/lcov-report/natural/stemmers/porter_stemmer_ru.js.html +0 -775
- package/coverage/lcov-report/natural/stemmers/stemmer.js.html +0 -505
- package/coverage/lcov-report/natural/stemmers/stemmer_es.js.html +0 -496
- package/coverage/lcov-report/natural/stemmers/stemmer_fa.js.html +0 -484
- package/coverage/lcov-report/natural/stemmers/stemmer_fr.js.html +0 -496
- package/coverage/lcov-report/natural/stemmers/stemmer_it.js.html +0 -427
- package/coverage/lcov-report/natural/stemmers/stemmer_ja.js.html +0 -736
- package/coverage/lcov-report/natural/stemmers/stemmer_no.js.html +0 -505
- package/coverage/lcov-report/natural/stemmers/stemmer_pl.js.html +0 -496
- package/coverage/lcov-report/natural/stemmers/stemmer_ru.js.html +0 -496
- package/coverage/lcov-report/natural/tfidf/index.html +0 -350
- package/coverage/lcov-report/natural/tfidf/tfidf.js.html +0 -904
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer.js.html +0 -430
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_es.js.html +0 -430
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_fa.js.html +0 -466
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_fr.js.html +0 -430
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_it.js.html +0 -430
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_nl.js.html +0 -430
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_no.js.html +0 -439
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_pl.js.html +0 -457
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_pt.js.html +0 -442
- package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_ru.js.html +0 -457
- package/coverage/lcov-report/natural/tokenizers/index.html +0 -519
- package/coverage/lcov-report/natural/tokenizers/regexp_tokenizer.js.html +0 -580
- package/coverage/lcov-report/natural/tokenizers/tokenizer.js.html +0 -475
- package/coverage/lcov-report/natural/tokenizers/tokenizer_ja.js.html +0 -1153
- package/coverage/lcov-report/natural/tokenizers/treebank_word_tokenizer.js.html +0 -544
- package/coverage/lcov-report/natural/transliterators/ja/index.html +0 -350
- package/coverage/lcov-report/natural/transliterators/ja/index.js.html +0 -2068
- package/coverage/lcov-report/natural/trie/index.html +0 -350
- package/coverage/lcov-report/natural/trie/trie.js.html +0 -1012
- package/coverage/lcov-report/natural/util/bag.js.html +0 -472
- package/coverage/lcov-report/natural/util/edge_weighted_digraph.js.html +0 -658
- package/coverage/lcov-report/natural/util/index.html +0 -532
- package/coverage/lcov-report/natural/util/longest_path_tree.js.html +0 -619
- package/coverage/lcov-report/natural/util/shortest_path_tree.js.html +0 -622
- package/coverage/lcov-report/natural/util/stopwords.js.html +0 -445
- package/coverage/lcov-report/natural/util/stopwords_es.js.html +0 -430
- package/coverage/lcov-report/natural/util/stopwords_fa.js.html +0 -436
- package/coverage/lcov-report/natural/util/stopwords_fr.js.html +0 -904
- package/coverage/lcov-report/natural/util/stopwords_it.js.html +0 -478
- package/coverage/lcov-report/natural/util/stopwords_ja.js.html +0 -499
- package/coverage/lcov-report/natural/util/stopwords_no.js.html +0 -445
- package/coverage/lcov-report/natural/util/stopwords_pl.js.html +0 -508
- package/coverage/lcov-report/natural/util/stopwords_ru.js.html +0 -445
- package/coverage/lcov-report/natural/util/topological.js.html +0 -616
- package/coverage/lcov-report/natural/util/utils.js.html +0 -679
- package/coverage/lcov-report/natural/wordnet/data_file.js.html +0 -580
- package/coverage/lcov-report/natural/wordnet/index.html +0 -389
- package/coverage/lcov-report/natural/wordnet/index_file.js.html +0 -742
- package/coverage/lcov-report/natural/wordnet/wordnet.js.html +0 -829
- package/coverage/lcov-report/natural/wordnet/wordnet_file.js.html +0 -529
- package/coverage/lcov-report/normalizers/index.html +0 -350
- package/coverage/lcov-report/normalizers/normalizer.js.html +0 -607
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/spec/aggressive_tokenizer_es_spec.js.html +0 -430
- package/coverage/lcov-report/spec/aggressive_tokenizer_fr_spec.js.html +0 -625
- package/coverage/lcov-report/spec/aggressive_tokenizer_nl_spec.js.html +0 -430
- package/coverage/lcov-report/spec/aggressive_tokenizer_pt_spec.js.html +0 -490
- package/coverage/lcov-report/spec/aggressive_tokenizer_spec.js.html +0 -490
- package/coverage/lcov-report/spec/bayes_classifier_spec.js.html +0 -841
- package/coverage/lcov-report/spec/classifier_spec.js.html +0 -847
- package/coverage/lcov-report/spec/count_inflector_fr_spec.js.html +0 -454
- package/coverage/lcov-report/spec/count_inflector_spec.js.html +0 -538
- package/coverage/lcov-report/spec/dice_coefficient_spec.js.html +0 -400
- package/coverage/lcov-report/spec/double_metaphone_spec.js.html +0 -2548
- package/coverage/lcov-report/spec/index.html +0 -883
- package/coverage/lcov-report/spec/jaro-winkler_spec.js.html +0 -481
- package/coverage/lcov-report/spec/lancaster_stemmer_spec.js.html +0 -541
- package/coverage/lcov-report/spec/levenshtein_spec.js.html +0 -520
- package/coverage/lcov-report/spec/logistic_regression_classifier_spec.js.html +0 -688
- package/coverage/lcov-report/spec/longest_path_tree_spec.js.html +0 -628
- package/coverage/lcov-report/spec/metaphone_spec.js.html +0 -1063
- package/coverage/lcov-report/spec/ngram_spec.js.html +0 -712
- package/coverage/lcov-report/spec/ngram_zh_spec.js.html +0 -688
- package/coverage/lcov-report/spec/normalizer_ja_spec.js.html +0 -802
- package/coverage/lcov-report/spec/normalizer_no_spec.js.html +0 -655
- package/coverage/lcov-report/spec/normalizer_spec.js.html +0 -742
- package/coverage/lcov-report/spec/noun_inflector_fr_spec.js.html +0 -1750
- package/coverage/lcov-report/spec/noun_inflector_ja_spec.js.html +0 -658
- package/coverage/lcov-report/spec/noun_inflector_spec.js.html +0 -1132
- package/coverage/lcov-report/spec/porter_stemmer_fr_spec.js.html +0 -625
- package/coverage/lcov-report/spec/porter_stemmer_it_spec.js.html +0 -454
- package/coverage/lcov-report/spec/porter_stemmer_no_spec.js.html +0 -751
- package/coverage/lcov-report/spec/porter_stemmer_ru_spec.js.html +0 -511
- package/coverage/lcov-report/spec/porter_stemmer_spec.js.html +0 -733
- package/coverage/lcov-report/spec/present_verb_inflector_spec.js.html +0 -697
- package/coverage/lcov-report/spec/remove_diacritics_spec.js.html +0 -415
- package/coverage/lcov-report/spec/sentence_analyzer_spec.js.html +0 -1153
- package/coverage/lcov-report/spec/shortest_path_tree_spec.js.html +0 -718
- package/coverage/lcov-report/spec/soundex_spec.js.html +0 -784
- package/coverage/lcov-report/spec/spellcheck_spec.js.html +0 -598
- package/coverage/lcov-report/spec/stemmer_ja_spec.js.html +0 -520
- package/coverage/lcov-report/spec/tfidf_spec.js.html +0 -1288
- package/coverage/lcov-report/spec/tokenizer_ja_spec.js.html +0 -496
- package/coverage/lcov-report/spec/transliterator_ja_spec.js.html +0 -631
- package/coverage/lcov-report/spec/treebank_word_tokenizer_spec.js.html +0 -430
- package/coverage/lcov-report/spec/trie_spec.js.html +0 -940
- package/coverage/lcov-report/util/index.html +0 -350
- package/coverage/lcov-report/util/utils.js.html +0 -679
- package/coverage/lcov.info +0 -11094
- package/lib/natural/parsers/Agenda.js +0 -68
- package/lib/natural/parsers/CYKParser.js +0 -87
- package/lib/natural/parsers/CYK_Item.js +0 -159
- package/lib/natural/parsers/Chart.js +0 -211
- package/lib/natural/parsers/ChartParser.js +0 -60
- package/lib/natural/parsers/DoubleDottedItem.js +0 -226
- package/lib/natural/parsers/EarleyItem.js +0 -155
- package/lib/natural/parsers/EarleyParser.js +0 -58
- package/lib/natural/parsers/FunctionWordTagger.js +0 -84
- package/lib/natural/parsers/GoalItem.js +0 -206
- package/lib/natural/parsers/GrammarParser.js +0 -1289
- package/lib/natural/parsers/HeadCornerParser.js +0 -101
- package/lib/natural/parsers/LeftCornerParser.js +0 -58
- package/lib/natural/parsers/PEG-grammar-for-unification-grammar.txt +0 -345
package/spec/metaphone_spec.js
CHANGED
|
@@ -211,6 +211,11 @@ describe('metaphone', function() {
|
|
|
211
211
|
expect(metaphone.compare('PHONETICS', 'garbonzo')).toBeFalsy();
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
+
it('#173', function() {
|
|
215
|
+
//expect(metaphone.process('caesar')).toBe('KSR');
|
|
216
|
+
//expect(metaphone.process('chemical')).toBe('KMKL');
|
|
217
|
+
});
|
|
218
|
+
|
|
214
219
|
it('should compare strings with string patch', function() {
|
|
215
220
|
metaphone.attach();
|
|
216
221
|
expect('phonetics'.soundsLike('fonetix')).toBeTruthy();
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2014, Luís Rodrigues
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
var PorterStemmer = require('../lib/natural/stemmers/porter_stemmer_pt'),
|
|
24
|
+
fs = require('fs');
|
|
25
|
+
|
|
26
|
+
describe('porter_stemmer_pt', function() {
|
|
27
|
+
|
|
28
|
+
it('should perform stemming on a lot of words', function() {
|
|
29
|
+
var errors = [];
|
|
30
|
+
|
|
31
|
+
fs.readFileSync('spec/test_data/snowball_pt.txt').toString().split('\n').forEach(function(line) {
|
|
32
|
+
if (line) {
|
|
33
|
+
var fields = line.replace(/\s+/g, ' ').split(' '),
|
|
34
|
+
stemmed = PorterStemmer.stem(fields[0]);
|
|
35
|
+
|
|
36
|
+
if (stemmed !== fields[1]) {
|
|
37
|
+
console.log('Error:', fields[0], 'Expected:', fields[1], 'Got:', stemmed);
|
|
38
|
+
errors.push({
|
|
39
|
+
word: fields[0],
|
|
40
|
+
expected: fields[1],
|
|
41
|
+
actual: stemmed
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(errors.length).toBe(0);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
});
|
|
@@ -23,6 +23,15 @@ THE SOFTWARE.
|
|
|
23
23
|
var stemmer = require('../lib/natural/stemmers/porter_stemmer');
|
|
24
24
|
|
|
25
25
|
describe('porter_stemmer', function() {
|
|
26
|
+
it('should categorizeGroups', function() {
|
|
27
|
+
expect(stemmer.categorizeGroups('syllog')).toBe('CVCVC');
|
|
28
|
+
expect(stemmer.categorizeGroups('gypsy')).toBe('CVCV');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should measure', function() {
|
|
32
|
+
expect(stemmer.measure('syllog')).toBe(2);
|
|
33
|
+
});
|
|
34
|
+
|
|
26
35
|
it('should perform step 1a', function() {
|
|
27
36
|
expect(stemmer.step1a('caresses')).toBe('caress');
|
|
28
37
|
expect(stemmer.step1a('ponies')).toBe('poni');
|
|
@@ -129,6 +138,42 @@ describe('porter_stemmer', function() {
|
|
|
129
138
|
expect(stemmer.stem('animated')).toBe('anim');
|
|
130
139
|
});
|
|
131
140
|
|
|
141
|
+
it('issue 176 - attemptReplace ed|ing', function() {
|
|
142
|
+
expect(stemmer.stem('aedile')).toBe('aedil');
|
|
143
|
+
expect(stemmer.stem('adoptedly')).toBe('adoptedli');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('issue 176 - minimum length for final e', function() {
|
|
147
|
+
expect(stemmer.stem('ace')).toBe('ac');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('issue 176 - minimum length for final s', function() {
|
|
151
|
+
expect(stemmer.stem('yes')).toBe('ye');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('issue 176 - s/tion measure', function() {
|
|
155
|
+
expect(stemmer.stem('invasion')).toBe('invas');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('issue 176 - vehement - step 4', function() {
|
|
159
|
+
expect(stemmer.stem('vehement')).toBe('vehement');
|
|
160
|
+
expect(stemmer.stem('syllogism')).toBe('syllog');
|
|
161
|
+
expect(stemmer.stem('gypsy')).toBe('gypsi');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('issue 176 step 2', function() {
|
|
165
|
+
expect(stemmer.stem('terribly')).toBe('terribl');
|
|
166
|
+
expect(stemmer.stem('apology')).toBe('apolog');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('issue 176 - step 5a', function() {
|
|
170
|
+
expect(stemmer.stem('type')).toBe('type');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('issue 176 - corruptiblity', function() {
|
|
174
|
+
expect(stemmer.stem('corruptibility')).toBe('corrupt');
|
|
175
|
+
});
|
|
176
|
+
|
|
132
177
|
it('should tokenize and stem attached', function() {
|
|
133
178
|
stemmer.attach();
|
|
134
179
|
expect('scoring stinks'.tokenizeAndStem()).toEqual(['score', 'stink']);
|
|
@@ -57,6 +57,7 @@ describe('present verb inflector', function() {
|
|
|
57
57
|
it('should singularize irregular forms', function() {
|
|
58
58
|
expect(inflector.singularize('are')).toBe('is');
|
|
59
59
|
expect(inflector.singularize('were')).toBe('was');
|
|
60
|
+
expect(inflector.singularize('have')).toBe('has');
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
it('should singularize ies forms', function() {
|
|
@@ -105,6 +106,8 @@ describe('present verb inflector', function() {
|
|
|
105
106
|
it('should pluralize irregular forms', function() {
|
|
106
107
|
expect(inflector.pluralize('was')).toBe('were');
|
|
107
108
|
expect(inflector.pluralize('is')).toBe('are');
|
|
109
|
+
expect(inflector.pluralize('am')).toBe('are');
|
|
110
|
+
expect(inflector.pluralize('has')).toBe('have');
|
|
108
111
|
});
|
|
109
112
|
|
|
110
113
|
it('should pluralize ies forms', function() {
|
package/spec/soundex_spec.js
CHANGED
|
@@ -65,15 +65,6 @@ describe('soundex', function() {
|
|
|
65
65
|
it('sound condense sequences', function() {
|
|
66
66
|
expect(soundex.condense('11222556')).toBe('1256');
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
it('sound condense sequences around H and W', function() {
|
|
70
|
-
expect(soundex.condense('113w355')).toBe('135');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('sound drop irrelevant H and W', function() {
|
|
74
|
-
expect(soundex.condense('phonetics')).toBe('ponetics');
|
|
75
|
-
expect(soundex.condense('towering')).toBe('toering');
|
|
76
|
-
});
|
|
77
68
|
});
|
|
78
69
|
|
|
79
70
|
describe('padRight0', function() {
|
|
@@ -132,6 +123,19 @@ describe('soundex', function() {
|
|
|
132
123
|
expect('phonetics'.phonetics()).toBe('P532');
|
|
133
124
|
expect('PHONETICS'.phonetics()).toBe('P532');
|
|
134
125
|
});
|
|
126
|
+
|
|
127
|
+
it('issue 221 -- inital vowels that duplicate cons codes', function() {
|
|
128
|
+
soundex.attach();
|
|
129
|
+
expect('Lloyd'.phonetics()).toBe('L300');
|
|
130
|
+
expect('Pfister'.phonetics()).toBe('P236');
|
|
131
|
+
|
|
132
|
+
expect('manhattan'.phonetics()).toBe('M535');
|
|
133
|
+
expect('Lukasiewicz'.phonetics()).toBe('L222');
|
|
134
|
+
|
|
135
|
+
expect('Gauss'.phonetics()).toBe('G200');
|
|
136
|
+
expect('Tymczak'.phonetics()).toBe('T522');
|
|
137
|
+
expect('Jackson'.phonetics()).toBe('J250');
|
|
138
|
+
});
|
|
135
139
|
|
|
136
140
|
it('should tokenize and return string phonetics with string patch', function() {
|
|
137
141
|
soundex.attach();
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2014, Luís Rodrigues
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
var StemmerToken = require('../lib/natural/stemmers/token');
|
|
24
|
+
|
|
25
|
+
describe('stemmer token', function () {
|
|
26
|
+
|
|
27
|
+
it('should receive a string', function () {
|
|
28
|
+
var string = 'test',
|
|
29
|
+
token = new StemmerToken(string);
|
|
30
|
+
|
|
31
|
+
expect(token.string).toBe(string);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should hold the original token string', function () {
|
|
35
|
+
var string = 'test',
|
|
36
|
+
token = new StemmerToken(string);
|
|
37
|
+
|
|
38
|
+
expect(token.original).toBe(string);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should replace all instances of a string', function () {
|
|
42
|
+
var string = 'tester',
|
|
43
|
+
token = new StemmerToken(string);
|
|
44
|
+
|
|
45
|
+
token.replaceAll('e', 'a');
|
|
46
|
+
expect(token.string).toBe('tastar');
|
|
47
|
+
|
|
48
|
+
token.replaceAll('ar', 'er');
|
|
49
|
+
expect(token.string).toBe('taster');
|
|
50
|
+
|
|
51
|
+
token.replaceAll('r', '');
|
|
52
|
+
expect(token.string).toBe('taste');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should allow vowels to be set', function () {
|
|
56
|
+
var vowels = 'aeiou',
|
|
57
|
+
vowelsArray = vowels.split(''),
|
|
58
|
+
token = new StemmerToken('');
|
|
59
|
+
|
|
60
|
+
token.usingVowels(vowels);
|
|
61
|
+
expect(token.vowels).toBe(vowels);
|
|
62
|
+
|
|
63
|
+
token.usingVowels(vowelsArray);
|
|
64
|
+
expect(token.vowels).toBe(vowelsArray);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should check for vowels', function () {
|
|
68
|
+
var vowels = 'aeiou',
|
|
69
|
+
token = new StemmerToken('test');
|
|
70
|
+
|
|
71
|
+
token.usingVowels(vowels);
|
|
72
|
+
|
|
73
|
+
expect(token.hasVowelAtIndex(0)).toBe(false);
|
|
74
|
+
expect(token.hasVowelAtIndex(1)).toBe(true);
|
|
75
|
+
expect(token.hasVowelAtIndex(99)).toBe(false);
|
|
76
|
+
|
|
77
|
+
token.usingVowels(vowels.split(''));
|
|
78
|
+
|
|
79
|
+
expect(token.hasVowelAtIndex(0)).toBe(false);
|
|
80
|
+
expect(token.hasVowelAtIndex(1)).toBe(true);
|
|
81
|
+
expect(token.hasVowelAtIndex(99)).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should find the next vowel', function () {
|
|
85
|
+
var token = new StemmerToken('tester').usingVowels('aeiou');
|
|
86
|
+
|
|
87
|
+
expect(token.nextVowelIndex(0)).toBe(1);
|
|
88
|
+
expect(token.nextVowelIndex(1)).toBe(1);
|
|
89
|
+
expect(token.nextVowelIndex(2)).toBe(4);
|
|
90
|
+
expect(token.nextVowelIndex(5)).toBe(6);
|
|
91
|
+
expect(token.nextVowelIndex(99)).toBe(6);
|
|
92
|
+
expect(token.nextVowelIndex(-1)).toBe(6);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should find the next consonant', function () {
|
|
96
|
+
var token = new StemmerToken('testee').usingVowels('aeiou');
|
|
97
|
+
|
|
98
|
+
expect(token.nextConsonantIndex(0)).toBe(0);
|
|
99
|
+
expect(token.nextConsonantIndex(1)).toBe(2);
|
|
100
|
+
expect(token.nextConsonantIndex(5)).toBe(6);
|
|
101
|
+
expect(token.nextConsonantIndex(99)).toBe(6);
|
|
102
|
+
expect(token.nextConsonantIndex(-1)).toBe(6);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should mark regions', function() {
|
|
106
|
+
var token = new StemmerToken('tester');
|
|
107
|
+
|
|
108
|
+
token.markRegion('test', 1);
|
|
109
|
+
expect(token.regions.test).toBe(1);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should mark regions with a callback', function() {
|
|
113
|
+
var token = new StemmerToken('tester'),
|
|
114
|
+
context = { value: 99 };
|
|
115
|
+
|
|
116
|
+
token.markRegion('test', 1, function (arg) { return arg; });
|
|
117
|
+
expect(token.regions.test).toBe(1);
|
|
118
|
+
|
|
119
|
+
token.markRegion('test', [1], function (arg) { return arg; });
|
|
120
|
+
expect(token.regions.test).toBe(1);
|
|
121
|
+
|
|
122
|
+
token.markRegion('test', [1, 1], function (a1, a2) { return a1 + a2; });
|
|
123
|
+
expect(token.regions.test).toBe(2);
|
|
124
|
+
|
|
125
|
+
token.markRegion('test', null, function () { return this.string.length; });
|
|
126
|
+
expect(token.regions.test).toBe(6);
|
|
127
|
+
|
|
128
|
+
token.markRegion('test', null, function () { return this.value; }, context);
|
|
129
|
+
expect(token.regions.test).toBe(99);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should check for suffixes', function() {
|
|
133
|
+
var token = new StemmerToken('tester');
|
|
134
|
+
|
|
135
|
+
expect(token.hasSuffix('er')).toBe(true);
|
|
136
|
+
expect(token.hasSuffix('st')).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should check for suffixes within a region', function() {
|
|
140
|
+
var token = new StemmerToken('tester').markRegion('region', 2);
|
|
141
|
+
|
|
142
|
+
expect(token.hasSuffixInRegion('st', 'region')).toBe(false);
|
|
143
|
+
expect(token.hasSuffixInRegion('ster', 'region')).toBe(true);
|
|
144
|
+
expect(token.hasSuffixInRegion('ester', 'region')).toBe(false);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should replace the suffix within a region', function() {
|
|
148
|
+
var t1 = new StemmerToken('tester').markRegion('region', 4),
|
|
149
|
+
t2 = new StemmerToken('tester').markRegion('region', 0);
|
|
150
|
+
|
|
151
|
+
t1.replaceSuffixInRegion('ter', '<s>', 'region');
|
|
152
|
+
expect(t1.string).toBe('tester');
|
|
153
|
+
|
|
154
|
+
t1.replaceSuffixInRegion('er', '<s>', 'region');
|
|
155
|
+
expect(t1.string).toBe('test<s>');
|
|
156
|
+
|
|
157
|
+
t2.replaceSuffixInRegion('protester', '<s>', 'region');
|
|
158
|
+
expect(t2.string).toBe('tester');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
});
|