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
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2015, 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
|
+
module.exports = (function () {
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
var Stemmer = require('./stemmer_pt'),
|
|
27
|
+
Token = require('./token'),
|
|
28
|
+
PorterStemmer = new Stemmer();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Marks a region after the first non-vowel following a vowel, or the
|
|
32
|
+
* null region at the end of the word if there is no such non-vowel.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} token Token to stem.
|
|
35
|
+
* @param {Number} start Start index (defaults to 0).
|
|
36
|
+
* @param {Number} Region start index.
|
|
37
|
+
*/
|
|
38
|
+
var markRegionN = function (start) {
|
|
39
|
+
var index = start || 0,
|
|
40
|
+
length = this.string.length,
|
|
41
|
+
region = length;
|
|
42
|
+
|
|
43
|
+
while (index < length - 1 && region === length) {
|
|
44
|
+
if (this.hasVowelAtIndex(index) && !this.hasVowelAtIndex(index + 1)) {
|
|
45
|
+
region = index + 2;
|
|
46
|
+
}
|
|
47
|
+
index++;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return region;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Mark RV.
|
|
55
|
+
*
|
|
56
|
+
* @param {Object} token Token to stem.
|
|
57
|
+
* @return {Number} Region start index.
|
|
58
|
+
*/
|
|
59
|
+
var markRegionV = function () {
|
|
60
|
+
var rv = this.string.length;
|
|
61
|
+
|
|
62
|
+
if (rv > 3) {
|
|
63
|
+
if (!this.hasVowelAtIndex(1)) {
|
|
64
|
+
rv = this.nextVowelIndex(2) + 1;
|
|
65
|
+
|
|
66
|
+
} else if (this.hasVowelAtIndex(0) && this.hasVowelAtIndex(1)) {
|
|
67
|
+
rv = this.nextConsonantIndex(2) + 1;
|
|
68
|
+
|
|
69
|
+
} else {
|
|
70
|
+
rv = 3;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return rv;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Prelude.
|
|
79
|
+
*
|
|
80
|
+
* Nasalised vowel forms should be treated as a vowel followed by a consonant.
|
|
81
|
+
*
|
|
82
|
+
* @param {String} token Word to stem.
|
|
83
|
+
* @return {String} Stemmed token.
|
|
84
|
+
*/
|
|
85
|
+
function prelude (token) {
|
|
86
|
+
return token
|
|
87
|
+
.replaceAll('ã', 'a~')
|
|
88
|
+
.replaceAll('õ', 'o~');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Step 1: Standard suffix removal.
|
|
93
|
+
*
|
|
94
|
+
* This step should always be performed.
|
|
95
|
+
*
|
|
96
|
+
* @param {Token} token Word to stem.
|
|
97
|
+
* @return {Token} Stemmed token.
|
|
98
|
+
*/
|
|
99
|
+
function standardSuffix (token) {
|
|
100
|
+
|
|
101
|
+
token.replaceSuffixInRegion([
|
|
102
|
+
'amentos', 'imentos', 'aço~es', 'adoras', 'adores', 'amento', 'imento',
|
|
103
|
+
|
|
104
|
+
'aça~o', 'adora', 'ância', 'antes', 'ismos', 'istas',
|
|
105
|
+
|
|
106
|
+
'ador', 'ante', 'ável', 'ezas', 'icas', 'icos', 'ismo', 'ista', 'ível',
|
|
107
|
+
'osas', 'osos',
|
|
108
|
+
|
|
109
|
+
'eza', 'ica', 'ico', 'osa', 'oso'
|
|
110
|
+
|
|
111
|
+
], '', 'r2');
|
|
112
|
+
|
|
113
|
+
token.replaceSuffixInRegion(['logias', 'logia'], 'log', 'r2');
|
|
114
|
+
|
|
115
|
+
// token.replaceSuffixInRegion(['uço~es', 'uça~o'], 'u', 'r1');
|
|
116
|
+
|
|
117
|
+
token.replaceSuffixInRegion(['ências', 'ência'], 'ente', 'r2');
|
|
118
|
+
|
|
119
|
+
token.replaceSuffixInRegion([
|
|
120
|
+
'ativamente', 'icamente', 'ivamente', 'osamente', 'adamente'
|
|
121
|
+
], '', 'r2');
|
|
122
|
+
|
|
123
|
+
token.replaceSuffixInRegion('amente', '', 'r1');
|
|
124
|
+
|
|
125
|
+
token.replaceSuffixInRegion([
|
|
126
|
+
'antemente', 'avelmente', 'ivelmente', 'mente'
|
|
127
|
+
], '', 'r2');
|
|
128
|
+
|
|
129
|
+
token.replaceSuffixInRegion([
|
|
130
|
+
'abilidades', 'abilidade',
|
|
131
|
+
'icidades', 'icidade',
|
|
132
|
+
'ividades', 'ividade',
|
|
133
|
+
'idades', 'idade'
|
|
134
|
+
], '', 'r2');
|
|
135
|
+
|
|
136
|
+
token.replaceSuffixInRegion([
|
|
137
|
+
'ativas', 'ativos', 'ativa', 'ativo',
|
|
138
|
+
'ivas', 'ivos', 'iva', 'ivo'
|
|
139
|
+
], '', 'r2');
|
|
140
|
+
|
|
141
|
+
if (token.hasSuffix('eiras') || token.hasSuffix('eira')) {
|
|
142
|
+
token.replaceSuffixInRegion(['iras', 'ira'], 'ir', 'rv');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return token;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Step 2: Verb suffix removal.
|
|
150
|
+
*
|
|
151
|
+
* Perform this step if no ending was removed in step 1.
|
|
152
|
+
*
|
|
153
|
+
* @param {Token} token Token to stem.
|
|
154
|
+
* @return {Token} Stemmed token.
|
|
155
|
+
*/
|
|
156
|
+
function verbSuffix (token) {
|
|
157
|
+
|
|
158
|
+
token.replaceSuffixInRegion([
|
|
159
|
+
'aríamos', 'ássemos', 'eríamos', 'êssemos', 'iríamos', 'íssemos',
|
|
160
|
+
|
|
161
|
+
'áramos', 'aremos', 'aríeis', 'ásseis', 'ávamos', 'éramos', 'eremos',
|
|
162
|
+
'eríeis', 'ésseis', 'íramos', 'iremos', 'iríeis', 'ísseis',
|
|
163
|
+
|
|
164
|
+
'ara~o', 'ardes', 'areis', 'áreis', 'ariam', 'arias', 'armos', 'assem',
|
|
165
|
+
'asses', 'astes', 'áveis', 'era~o', 'erdes', 'ereis', 'éreis', 'eriam',
|
|
166
|
+
'erias', 'ermos', 'essem', 'esses', 'estes', 'íamos', 'ira~o', 'irdes',
|
|
167
|
+
'ireis', 'íreis', 'iriam', 'irias', 'irmos', 'issem', 'isses', 'istes',
|
|
168
|
+
|
|
169
|
+
'adas', 'ados', 'amos', 'ámos', 'ando', 'aram', 'aras', 'arás', 'arei',
|
|
170
|
+
'arem', 'ares', 'aria', 'asse', 'aste', 'avam', 'avas', 'emos', 'endo',
|
|
171
|
+
'eram', 'eras', 'erás', 'erei', 'erem', 'eres', 'eria', 'esse', 'este',
|
|
172
|
+
'idas', 'idos', 'íeis', 'imos', 'indo', 'iram', 'iras', 'irás', 'irei',
|
|
173
|
+
'irem', 'ires', 'iria', 'isse', 'iste',
|
|
174
|
+
|
|
175
|
+
'ada', 'ado', 'ais', 'ara', 'ará', 'ava', 'eis', 'era', 'erá', 'iam',
|
|
176
|
+
'ias', 'ida', 'ido', 'ira', 'irá',
|
|
177
|
+
|
|
178
|
+
'am', 'ar', 'as', 'ei', 'em', 'er', 'es', 'eu', 'ia', 'ir', 'is', 'iu', 'ou'
|
|
179
|
+
|
|
180
|
+
], '', 'rv');
|
|
181
|
+
|
|
182
|
+
return token;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Step 3: Delete suffix i.
|
|
187
|
+
*
|
|
188
|
+
* Perform this step if the word was changed, in RV and preceded by c.
|
|
189
|
+
*
|
|
190
|
+
* @param {Token} token Token to stem.
|
|
191
|
+
* @return {Token} Stemmed token.
|
|
192
|
+
*/
|
|
193
|
+
function iPrecededByCSuffix (token) {
|
|
194
|
+
|
|
195
|
+
if (token.hasSuffix('ci')) {
|
|
196
|
+
token.replaceSuffixInRegion('i', '', 'rv');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return token;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Step 4: Residual suffix.
|
|
204
|
+
*
|
|
205
|
+
* Perform this step if steps 1 and 2 did not alter the word.
|
|
206
|
+
*
|
|
207
|
+
* @param {Token} token Token to stem.
|
|
208
|
+
* @return {Token} Stemmed token.
|
|
209
|
+
*/
|
|
210
|
+
function residualSuffix (token) {
|
|
211
|
+
|
|
212
|
+
token.replaceSuffixInRegion(['os', 'a', 'i', 'o', 'á', 'í', 'ó'], '', 'rv');
|
|
213
|
+
|
|
214
|
+
return token;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Step 5: Residual form.
|
|
219
|
+
*
|
|
220
|
+
* This step should always be performed.
|
|
221
|
+
*
|
|
222
|
+
* @param {Token} token Token to stem.
|
|
223
|
+
* @return {Token} Stemmed token.
|
|
224
|
+
*/
|
|
225
|
+
function residualForm (token) {
|
|
226
|
+
|
|
227
|
+
var tokenString = token.string;
|
|
228
|
+
|
|
229
|
+
if (token.hasSuffix('gue') || token.hasSuffix('gué') || token.hasSuffix('guê')) {
|
|
230
|
+
token.replaceSuffixInRegion(['ue', 'ué', 'uê'], '', 'rv');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (token.hasSuffix('cie') || token.hasSuffix('cié') || token.hasSuffix('ciê')) {
|
|
234
|
+
token.replaceSuffixInRegion(['ie', 'ié', 'iê'], '', 'rv');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (tokenString === token.string) {
|
|
238
|
+
token.replaceSuffixInRegion(['e', 'é', 'ê'], '', 'rv');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
token.replaceSuffixInRegion('ç', 'c', 'all');
|
|
242
|
+
|
|
243
|
+
return token;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Postlude.
|
|
248
|
+
*
|
|
249
|
+
* Turns a~, o~ back into ã, õ.
|
|
250
|
+
*
|
|
251
|
+
* @param {String} token Word to stem.
|
|
252
|
+
* @return {String} Stemmed token.
|
|
253
|
+
*/
|
|
254
|
+
function postlude (token) {
|
|
255
|
+
return token
|
|
256
|
+
.replaceAll('a~', 'ã')
|
|
257
|
+
.replaceAll('o~', 'õ');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Stems a word using a Porter stemmer algorithm.
|
|
262
|
+
*
|
|
263
|
+
* @param {String} word Word to stem.
|
|
264
|
+
* @return {String} Stemmed token.
|
|
265
|
+
*/
|
|
266
|
+
PorterStemmer.stem = function (word) {
|
|
267
|
+
var token = new Token(word.toLowerCase()),
|
|
268
|
+
original;
|
|
269
|
+
|
|
270
|
+
token = prelude(token);
|
|
271
|
+
|
|
272
|
+
token.usingVowels('aeiouáéíóúâêôàãõ')
|
|
273
|
+
.markRegion('all', 0)
|
|
274
|
+
.markRegion('r1', null, markRegionN)
|
|
275
|
+
.markRegion('r2', token.regions.r1, markRegionN)
|
|
276
|
+
.markRegion('rv', null, markRegionV);
|
|
277
|
+
|
|
278
|
+
original = token.string;
|
|
279
|
+
|
|
280
|
+
// Always do step 1.
|
|
281
|
+
token = standardSuffix(token);
|
|
282
|
+
|
|
283
|
+
// Do step 2 if no ending was removed by step 1.
|
|
284
|
+
if (token.string === original) {
|
|
285
|
+
token = verbSuffix(token);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// If the last step to be obeyed — either step 1 or 2 — altered the word,
|
|
289
|
+
// do step 3. Alternatively, if neither steps 1 nor 2 altered the word, do
|
|
290
|
+
// step 4.
|
|
291
|
+
token = token.string !== original ? iPrecededByCSuffix(token) : residualSuffix(token);
|
|
292
|
+
|
|
293
|
+
// Always do step 5.
|
|
294
|
+
token = residualForm(token);
|
|
295
|
+
|
|
296
|
+
token = postlude(token);
|
|
297
|
+
|
|
298
|
+
return token.string;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
return PorterStemmer;
|
|
302
|
+
})();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2014, Ismaël Héry
|
|
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
|
+
module.exports = function () {
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
var Stemmer = this,
|
|
27
|
+
stopwords = require('../util/stopwords_pt'),
|
|
28
|
+
Tokenizer = require('../tokenizers/aggressive_tokenizer_pt');
|
|
29
|
+
|
|
30
|
+
Stemmer.stem = function (token) {
|
|
31
|
+
return token;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Stemmer.addStopWords = function (word) {
|
|
35
|
+
stopwords.words.push(word);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Stemmer.addStopWords = function (words) {
|
|
39
|
+
stopwords.words = stopwords.words.concat(words);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Stemmer.tokenizeAndStem = function(text, keepStops) {
|
|
43
|
+
var stemmedTokens = [];
|
|
44
|
+
|
|
45
|
+
var tokenStemmer = function (token) {
|
|
46
|
+
if (keepStops || stopwords.words.indexOf(token.toLowerCase()) === -1) {
|
|
47
|
+
stemmedTokens.push(Stemmer.stem(token));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
new Tokenizer().tokenize(text).forEach(tokenStemmer);
|
|
52
|
+
|
|
53
|
+
return stemmedTokens;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Stemmer.attach = function () {
|
|
57
|
+
String.prototype.stem = function () {
|
|
58
|
+
return Stemmer.stem(this);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
String.prototype.tokenizeAndStem = function (keepStops) {
|
|
62
|
+
return Stemmer.tokenizeAndStem(this, keepStops);
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2015, 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
|
+
module.exports = (function () {
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Stemmer token constructor.
|
|
28
|
+
*
|
|
29
|
+
* @param {String} string Token string.
|
|
30
|
+
*/
|
|
31
|
+
var Token = function (string) {
|
|
32
|
+
this.vowels = '';
|
|
33
|
+
this.regions = {};
|
|
34
|
+
this.string = string;
|
|
35
|
+
this.original = string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Set vowels.
|
|
40
|
+
*
|
|
41
|
+
* @param {String|Array} vowels List of vowels.
|
|
42
|
+
* @return {Token} Token instance.
|
|
43
|
+
*/
|
|
44
|
+
Token.prototype.usingVowels = function (vowels) {
|
|
45
|
+
this.vowels = vowels;
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Marks a region by defining its starting index or providing a callback
|
|
51
|
+
* function that does.
|
|
52
|
+
*
|
|
53
|
+
* @param {String} region Region name.
|
|
54
|
+
* @param {Array|Number} args Callback arguments or region start index.
|
|
55
|
+
* @param {Function} callback Function that determines the start index (optional).
|
|
56
|
+
* @param {Object} context Callback context (optional, defaults to this).
|
|
57
|
+
* @return {Token} Token instance.
|
|
58
|
+
*/
|
|
59
|
+
Token.prototype.markRegion = function (region, args, callback, context) {
|
|
60
|
+
if (typeof callback === 'function') {
|
|
61
|
+
this.regions[region] = callback.apply(context || this, [].concat(args));
|
|
62
|
+
|
|
63
|
+
} else if (!isNaN(args)) {
|
|
64
|
+
this.regions[region] = args;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Replaces all instances of a string with another.
|
|
72
|
+
*
|
|
73
|
+
* @param {String} find String to be replaced.
|
|
74
|
+
* @param {String} replace Replacement string.
|
|
75
|
+
* @return {Token} Token instance.
|
|
76
|
+
*/
|
|
77
|
+
Token.prototype.replaceAll = function (find, replace) {
|
|
78
|
+
this.string = this.string.split(find).join(replace);
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Replaces the token suffix if in a region.
|
|
84
|
+
*
|
|
85
|
+
* @param {String} suffix Suffix to replace.
|
|
86
|
+
* @param {String} replace Replacement string.
|
|
87
|
+
* @param {String} region Region name.
|
|
88
|
+
* @return {Token} Token instance.
|
|
89
|
+
*/
|
|
90
|
+
Token.prototype.replaceSuffixInRegion = function (suffix, replace, region) {
|
|
91
|
+
var suffixes = [].concat(suffix);
|
|
92
|
+
for (var i = 0; i < suffixes.length; i++) {
|
|
93
|
+
if (this.hasSuffixInRegion(suffixes[i], region)) {
|
|
94
|
+
this.string = this.string.slice(0, -suffixes[i].length) + replace;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return this;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Determines whether the token has a vowel at the provided index.
|
|
103
|
+
*
|
|
104
|
+
* @param {Integer} index Character index.
|
|
105
|
+
* @return {Boolean} Whether the token has a vowel at the provided index.
|
|
106
|
+
*/
|
|
107
|
+
Token.prototype.hasVowelAtIndex = function (index) {
|
|
108
|
+
return this.vowels.indexOf(this.string[index]) !== -1;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Finds the next vowel in the token.
|
|
113
|
+
*
|
|
114
|
+
* @param {Integer} start Starting index offset.
|
|
115
|
+
* @return {Integer} Vowel index, or the end of the string.
|
|
116
|
+
*/
|
|
117
|
+
Token.prototype.nextVowelIndex = function (start) {
|
|
118
|
+
var index = (start >= 0 && start < this.string.length) ? start : this.string.length;
|
|
119
|
+
while (index < this.string.length && !this.hasVowelAtIndex(index)) {
|
|
120
|
+
index++;
|
|
121
|
+
}
|
|
122
|
+
return index;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Finds the next consonant in the token.
|
|
127
|
+
*
|
|
128
|
+
* @param {Integer} start Starting index offset.
|
|
129
|
+
* @return {Integer} Consonant index, or the end of the string.
|
|
130
|
+
*/
|
|
131
|
+
Token.prototype.nextConsonantIndex = function (start) {
|
|
132
|
+
var index = (start >= 0 && start < this.string.length) ? start : this.string.length;
|
|
133
|
+
while (index < this.string.length && this.hasVowelAtIndex(index)) {
|
|
134
|
+
index++;
|
|
135
|
+
}
|
|
136
|
+
return index;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Determines whether the token has the provided suffix.
|
|
141
|
+
* @param {String} suffix Suffix to match.
|
|
142
|
+
* @return {Boolean} Whether the token string ends in suffix.
|
|
143
|
+
*/
|
|
144
|
+
Token.prototype.hasSuffix = function (suffix) {
|
|
145
|
+
return this.string.slice(-suffix.length) === suffix;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Determines whether the token has the provided suffix within the specified
|
|
150
|
+
* region.
|
|
151
|
+
*
|
|
152
|
+
* @param {String} suffix Suffix to match.
|
|
153
|
+
* @param {String} region Region name.
|
|
154
|
+
* @return {Boolean} Whether the token string ends in suffix.
|
|
155
|
+
*/
|
|
156
|
+
Token.prototype.hasSuffixInRegion = function (suffix, region) {
|
|
157
|
+
var regionStart = this.regions[region] || 0,
|
|
158
|
+
suffixStart = this.string.length - suffix.length;
|
|
159
|
+
return this.hasSuffix(suffix) && suffixStart >= regionStart;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return Token;
|
|
163
|
+
})();
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2011, 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
|
+
// a list of commonly used words that have little meaning and can be excluded
|
|
24
|
+
// from analysis.
|
|
25
|
+
var words = [
|
|
26
|
+
'a',
|
|
27
|
+
'à',
|
|
28
|
+
'ao',
|
|
29
|
+
'aos',
|
|
30
|
+
'aquela',
|
|
31
|
+
'aquelas',
|
|
32
|
+
'aquele',
|
|
33
|
+
'aqueles',
|
|
34
|
+
'aquilo',
|
|
35
|
+
'as',
|
|
36
|
+
'às',
|
|
37
|
+
'até',
|
|
38
|
+
'com',
|
|
39
|
+
'como',
|
|
40
|
+
'da',
|
|
41
|
+
'das',
|
|
42
|
+
'de',
|
|
43
|
+
'dela',
|
|
44
|
+
'delas',
|
|
45
|
+
'dele',
|
|
46
|
+
'deles',
|
|
47
|
+
'depois',
|
|
48
|
+
'do',
|
|
49
|
+
'dos',
|
|
50
|
+
'e',
|
|
51
|
+
'ela',
|
|
52
|
+
'elas',
|
|
53
|
+
'ele',
|
|
54
|
+
'eles',
|
|
55
|
+
'em',
|
|
56
|
+
'entre',
|
|
57
|
+
'essa',
|
|
58
|
+
'essas',
|
|
59
|
+
'esse',
|
|
60
|
+
'esses',
|
|
61
|
+
'esta',
|
|
62
|
+
'estas',
|
|
63
|
+
'este',
|
|
64
|
+
'estes',
|
|
65
|
+
'eu',
|
|
66
|
+
'isso',
|
|
67
|
+
'isto',
|
|
68
|
+
'já',
|
|
69
|
+
'lhe',
|
|
70
|
+
'lhes',
|
|
71
|
+
'mais',
|
|
72
|
+
'mas',
|
|
73
|
+
'me',
|
|
74
|
+
'mesmo',
|
|
75
|
+
'meu',
|
|
76
|
+
'meus',
|
|
77
|
+
'minha',
|
|
78
|
+
'minhas',
|
|
79
|
+
'muito',
|
|
80
|
+
'muitos',
|
|
81
|
+
'na',
|
|
82
|
+
'não',
|
|
83
|
+
'nas',
|
|
84
|
+
'nem',
|
|
85
|
+
'no',
|
|
86
|
+
'nos',
|
|
87
|
+
'nós',
|
|
88
|
+
'nossa',
|
|
89
|
+
'nossas',
|
|
90
|
+
'nosso',
|
|
91
|
+
'nossos',
|
|
92
|
+
'num',
|
|
93
|
+
'nuns',
|
|
94
|
+
'numa',
|
|
95
|
+
'numas',
|
|
96
|
+
'o',
|
|
97
|
+
'os',
|
|
98
|
+
'ou',
|
|
99
|
+
'para',
|
|
100
|
+
'pela',
|
|
101
|
+
'pelas',
|
|
102
|
+
'pelo',
|
|
103
|
+
'pelos',
|
|
104
|
+
'por',
|
|
105
|
+
'quais',
|
|
106
|
+
'qual',
|
|
107
|
+
'quando',
|
|
108
|
+
'que',
|
|
109
|
+
'quem',
|
|
110
|
+
'se',
|
|
111
|
+
'sem',
|
|
112
|
+
'seu',
|
|
113
|
+
'seus',
|
|
114
|
+
'só',
|
|
115
|
+
'sua',
|
|
116
|
+
'suas',
|
|
117
|
+
'também',
|
|
118
|
+
'te',
|
|
119
|
+
'teu',
|
|
120
|
+
'teus',
|
|
121
|
+
'tu',
|
|
122
|
+
'tua',
|
|
123
|
+
'tuas',
|
|
124
|
+
'um',
|
|
125
|
+
'uma',
|
|
126
|
+
'umas',
|
|
127
|
+
'você',
|
|
128
|
+
'vocês',
|
|
129
|
+
'vos',
|
|
130
|
+
'vosso',
|
|
131
|
+
'vossos',
|
|
132
|
+
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '_'
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
// tell the world about the noise words.
|
|
136
|
+
exports.words = words;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natural",
|
|
3
3
|
"description": "General natural language (tokenizing, stemming (English, Russian, Spanish), classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"homepage": "https://github.com/NaturalNode/natural",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"sylvester": ">= 0.0.12",
|
|
15
|
-
"apparatus": ">= 0.0.
|
|
15
|
+
"apparatus": ">= 0.0.9",
|
|
16
16
|
"underscore": ">=1.3.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -737,7 +737,16 @@ describe('double metaphone', function() {
|
|
|
737
737
|
|
|
738
738
|
describe('issue #34', function() {
|
|
739
739
|
it('terminate words ending in H', function() {
|
|
740
|
-
|
|
740
|
+
expect(doubleMetaphone.process('ptah')).toEqual(['PT', 'PT']);
|
|
741
741
|
});
|
|
742
742
|
});
|
|
743
|
+
|
|
744
|
+
describe('issue #173', function() {
|
|
745
|
+
it('handle initial cons correctly', function() {
|
|
746
|
+
expect(doubleMetaphone.process('ceasar')).toEqual(['SSR', 'SSR']);
|
|
747
|
+
expect(doubleMetaphone.process('ach')).toEqual(['AK', 'AK']);
|
|
748
|
+
expect(doubleMetaphone.process('chemical')).toEqual(['KMKL', 'KMKL']);
|
|
749
|
+
expect(doubleMetaphone.process('choral')).toEqual(['KRL', 'KRL']);
|
|
750
|
+
});
|
|
751
|
+
});
|
|
743
752
|
});
|