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.
Files changed (382) hide show
  1. package/.editorconfig +7 -0
  2. package/README.md +3 -3
  3. package/lib/natural/inflectors/present_verb_inflector.js +1 -0
  4. package/lib/natural/phonetics/double_metaphone.js +9 -4
  5. package/lib/natural/phonetics/metaphone.js +4 -0
  6. package/lib/natural/phonetics/soundex.js +11 -7
  7. package/lib/natural/stemmers/porter_stemmer.js +90 -62
  8. package/lib/natural/stemmers/porter_stemmer_pt.js +302 -0
  9. package/lib/natural/stemmers/stemmer_pt.js +65 -0
  10. package/lib/natural/stemmers/token.js +163 -0
  11. package/lib/natural/util/stopwords_pt.js +136 -0
  12. package/package.json +2 -2
  13. package/spec/double_metaphone_spec.js +10 -1
  14. package/spec/metaphone_spec.js +5 -0
  15. package/spec/porter_stemmer_pt_spec.js +50 -0
  16. package/spec/porter_stemmer_spec.js +45 -0
  17. package/spec/present_verb_inflector_spec.js +3 -0
  18. package/spec/soundex_spec.js +13 -9
  19. package/spec/stemmer_token_spec.js +161 -0
  20. package/spec/test_data/snowball_pt.txt +32016 -0
  21. package/coverage/coverage.json +0 -1
  22. package/coverage/lcov-report/index.html +0 -584
  23. package/coverage/lcov-report/io_spec/index.html +0 -350
  24. package/coverage/lcov-report/io_spec/tfidf_spec.js.html +0 -469
  25. package/coverage/lcov-report/lib/natural/analyzers/index.html +0 -350
  26. package/coverage/lcov-report/lib/natural/analyzers/sentence_analyzer.js.html +0 -850
  27. package/coverage/lcov-report/lib/natural/classifiers/bayes_classifier.js.html +0 -496
  28. package/coverage/lcov-report/lib/natural/classifiers/classifier.js.html +0 -823
  29. package/coverage/lcov-report/lib/natural/classifiers/index.html +0 -376
  30. package/coverage/lcov-report/lib/natural/classifiers/logistic_regression_classifier.js.html +0 -502
  31. package/coverage/lcov-report/lib/natural/distance/dice_coefficient.js.html +0 -529
  32. package/coverage/lcov-report/lib/natural/distance/index.html +0 -376
  33. package/coverage/lcov-report/lib/natural/distance/jaro-winkler_distance.js.html +0 -670
  34. package/coverage/lcov-report/lib/natural/distance/levenshtein_distance.js.html +0 -526
  35. package/coverage/lcov-report/lib/natural/index.html +0 -350
  36. package/coverage/lcov-report/lib/natural/index.js.html +0 -547
  37. package/coverage/lcov-report/lib/natural/inflectors/count_inflector.js.html +0 -484
  38. package/coverage/lcov-report/lib/natural/inflectors/form_set.js.html +0 -406
  39. package/coverage/lcov-report/lib/natural/inflectors/fr/count_inflector.js.html +0 -520
  40. package/coverage/lcov-report/lib/natural/inflectors/fr/index.html +0 -363
  41. package/coverage/lcov-report/lib/natural/inflectors/fr/noun_inflector.js.html +0 -1027
  42. package/coverage/lcov-report/lib/natural/inflectors/index.html +0 -402
  43. package/coverage/lcov-report/lib/natural/inflectors/ja/index.html +0 -350
  44. package/coverage/lcov-report/lib/natural/inflectors/ja/noun_inflector.js.html +0 -727
  45. package/coverage/lcov-report/lib/natural/inflectors/noun_inflector.js.html +0 -637
  46. package/coverage/lcov-report/lib/natural/inflectors/present_verb_inflector.js.html +0 -544
  47. package/coverage/lcov-report/lib/natural/inflectors/singular_plural_inflector.js.html +0 -649
  48. package/coverage/lcov-report/lib/natural/ngrams/index.html +0 -363
  49. package/coverage/lcov-report/lib/natural/ngrams/ngrams.js.html +0 -595
  50. package/coverage/lcov-report/lib/natural/ngrams/ngrams_zh.js.html +0 -571
  51. package/coverage/lcov-report/lib/natural/normalizers/index.html +0 -389
  52. package/coverage/lcov-report/lib/natural/normalizers/normalizer.js.html +0 -607
  53. package/coverage/lcov-report/lib/natural/normalizers/normalizer_ja.js.html +0 -2194
  54. package/coverage/lcov-report/lib/natural/normalizers/normalizer_no.js.html +0 -496
  55. package/coverage/lcov-report/lib/natural/normalizers/remove_diacritics.js.html +0 -685
  56. package/coverage/lcov-report/lib/natural/phonetics/dm_soundex.js.html +0 -1063
  57. package/coverage/lcov-report/lib/natural/phonetics/double_metaphone.js.html +0 -1840
  58. package/coverage/lcov-report/lib/natural/phonetics/index.html +0 -402
  59. package/coverage/lcov-report/lib/natural/phonetics/metaphone.js.html +0 -886
  60. package/coverage/lcov-report/lib/natural/phonetics/phonetic.js.html +0 -484
  61. package/coverage/lcov-report/lib/natural/phonetics/soundex.js.html +0 -562
  62. package/coverage/lcov-report/lib/natural/spellcheck/index.html +0 -350
  63. package/coverage/lcov-report/lib/natural/spellcheck/spellcheck.js.html +0 -562
  64. package/coverage/lcov-report/lib/natural/stemmers/index.html +0 -571
  65. package/coverage/lcov-report/lib/natural/stemmers/lancaster_rules.js.html +0 -2692
  66. package/coverage/lcov-report/lib/natural/stemmers/lancaster_stemmer.js.html +0 -544
  67. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer.js.html +0 -937
  68. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_es.js.html +0 -985
  69. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_fa.js.html +0 -418
  70. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_fr.js.html +0 -1450
  71. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_it.js.html +0 -1018
  72. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_no.js.html +0 -784
  73. package/coverage/lcov-report/lib/natural/stemmers/porter_stemmer_ru.js.html +0 -775
  74. package/coverage/lcov-report/lib/natural/stemmers/stemmer.js.html +0 -505
  75. package/coverage/lcov-report/lib/natural/stemmers/stemmer_es.js.html +0 -496
  76. package/coverage/lcov-report/lib/natural/stemmers/stemmer_fa.js.html +0 -484
  77. package/coverage/lcov-report/lib/natural/stemmers/stemmer_fr.js.html +0 -496
  78. package/coverage/lcov-report/lib/natural/stemmers/stemmer_it.js.html +0 -427
  79. package/coverage/lcov-report/lib/natural/stemmers/stemmer_ja.js.html +0 -736
  80. package/coverage/lcov-report/lib/natural/stemmers/stemmer_no.js.html +0 -505
  81. package/coverage/lcov-report/lib/natural/stemmers/stemmer_pl.js.html +0 -496
  82. package/coverage/lcov-report/lib/natural/stemmers/stemmer_ru.js.html +0 -496
  83. package/coverage/lcov-report/lib/natural/tfidf/index.html +0 -350
  84. package/coverage/lcov-report/lib/natural/tfidf/tfidf.js.html +0 -904
  85. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer.js.html +0 -430
  86. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_es.js.html +0 -430
  87. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_fa.js.html +0 -466
  88. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_fr.js.html +0 -430
  89. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_it.js.html +0 -430
  90. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_nl.js.html +0 -430
  91. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_no.js.html +0 -439
  92. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_pl.js.html +0 -457
  93. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_pt.js.html +0 -442
  94. package/coverage/lcov-report/lib/natural/tokenizers/aggressive_tokenizer_ru.js.html +0 -457
  95. package/coverage/lcov-report/lib/natural/tokenizers/index.html +0 -519
  96. package/coverage/lcov-report/lib/natural/tokenizers/regexp_tokenizer.js.html +0 -580
  97. package/coverage/lcov-report/lib/natural/tokenizers/tokenizer.js.html +0 -475
  98. package/coverage/lcov-report/lib/natural/tokenizers/tokenizer_ja.js.html +0 -1153
  99. package/coverage/lcov-report/lib/natural/tokenizers/treebank_word_tokenizer.js.html +0 -544
  100. package/coverage/lcov-report/lib/natural/transliterators/ja/index.html +0 -350
  101. package/coverage/lcov-report/lib/natural/transliterators/ja/index.js.html +0 -2068
  102. package/coverage/lcov-report/lib/natural/trie/index.html +0 -350
  103. package/coverage/lcov-report/lib/natural/trie/trie.js.html +0 -1012
  104. package/coverage/lcov-report/lib/natural/util/bag.js.html +0 -472
  105. package/coverage/lcov-report/lib/natural/util/edge_weighted_digraph.js.html +0 -658
  106. package/coverage/lcov-report/lib/natural/util/index.html +0 -532
  107. package/coverage/lcov-report/lib/natural/util/longest_path_tree.js.html +0 -619
  108. package/coverage/lcov-report/lib/natural/util/shortest_path_tree.js.html +0 -622
  109. package/coverage/lcov-report/lib/natural/util/stopwords.js.html +0 -445
  110. package/coverage/lcov-report/lib/natural/util/stopwords_es.js.html +0 -430
  111. package/coverage/lcov-report/lib/natural/util/stopwords_fa.js.html +0 -436
  112. package/coverage/lcov-report/lib/natural/util/stopwords_fr.js.html +0 -904
  113. package/coverage/lcov-report/lib/natural/util/stopwords_it.js.html +0 -478
  114. package/coverage/lcov-report/lib/natural/util/stopwords_ja.js.html +0 -499
  115. package/coverage/lcov-report/lib/natural/util/stopwords_no.js.html +0 -445
  116. package/coverage/lcov-report/lib/natural/util/stopwords_pl.js.html +0 -508
  117. package/coverage/lcov-report/lib/natural/util/stopwords_ru.js.html +0 -445
  118. package/coverage/lcov-report/lib/natural/util/topological.js.html +0 -616
  119. package/coverage/lcov-report/lib/natural/util/utils.js.html +0 -679
  120. package/coverage/lcov-report/lib/natural/wordnet/data_file.js.html +0 -580
  121. package/coverage/lcov-report/lib/natural/wordnet/index.html +0 -389
  122. package/coverage/lcov-report/lib/natural/wordnet/index_file.js.html +0 -742
  123. package/coverage/lcov-report/lib/natural/wordnet/wordnet.js.html +0 -829
  124. package/coverage/lcov-report/lib/natural/wordnet/wordnet_file.js.html +0 -529
  125. package/coverage/lcov-report/natural/analyzers/index.html +0 -350
  126. package/coverage/lcov-report/natural/analyzers/sentence_analyzer.js.html +0 -850
  127. package/coverage/lcov-report/natural/classifiers/bayes_classifier.js.html +0 -496
  128. package/coverage/lcov-report/natural/classifiers/classifier.js.html +0 -823
  129. package/coverage/lcov-report/natural/classifiers/index.html +0 -376
  130. package/coverage/lcov-report/natural/classifiers/logistic_regression_classifier.js.html +0 -502
  131. package/coverage/lcov-report/natural/distance/dice_coefficient.js.html +0 -529
  132. package/coverage/lcov-report/natural/distance/index.html +0 -376
  133. package/coverage/lcov-report/natural/distance/jaro-winkler_distance.js.html +0 -670
  134. package/coverage/lcov-report/natural/distance/levenshtein_distance.js.html +0 -526
  135. package/coverage/lcov-report/natural/index.html +0 -350
  136. package/coverage/lcov-report/natural/index.js.html +0 -433
  137. package/coverage/lcov-report/natural/inflectors/count_inflector.js.html +0 -484
  138. package/coverage/lcov-report/natural/inflectors/form_set.js.html +0 -406
  139. package/coverage/lcov-report/natural/inflectors/fr/index.html +0 -350
  140. package/coverage/lcov-report/natural/inflectors/fr/noun_inflector.js.html +0 -1027
  141. package/coverage/lcov-report/natural/inflectors/index.html +0 -402
  142. package/coverage/lcov-report/natural/inflectors/ja/index.html +0 -350
  143. package/coverage/lcov-report/natural/inflectors/ja/noun_inflector.js.html +0 -727
  144. package/coverage/lcov-report/natural/inflectors/noun_inflector.js.html +0 -637
  145. package/coverage/lcov-report/natural/inflectors/present_verb_inflector.js.html +0 -544
  146. package/coverage/lcov-report/natural/inflectors/singular_plural_inflector.js.html +0 -649
  147. package/coverage/lcov-report/natural/lib/natural/analyzers/index.html +0 -350
  148. package/coverage/lcov-report/natural/lib/natural/analyzers/sentence_analyzer.js.html +0 -850
  149. package/coverage/lcov-report/natural/lib/natural/classifiers/bayes_classifier.js.html +0 -496
  150. package/coverage/lcov-report/natural/lib/natural/classifiers/classifier.js.html +0 -823
  151. package/coverage/lcov-report/natural/lib/natural/classifiers/index.html +0 -376
  152. package/coverage/lcov-report/natural/lib/natural/classifiers/logistic_regression_classifier.js.html +0 -502
  153. package/coverage/lcov-report/natural/lib/natural/distance/dice_coefficient.js.html +0 -529
  154. package/coverage/lcov-report/natural/lib/natural/distance/index.html +0 -376
  155. package/coverage/lcov-report/natural/lib/natural/distance/jaro-winkler_distance.js.html +0 -670
  156. package/coverage/lcov-report/natural/lib/natural/distance/levenshtein_distance.js.html +0 -526
  157. package/coverage/lcov-report/natural/lib/natural/index.html +0 -350
  158. package/coverage/lcov-report/natural/lib/natural/index.js.html +0 -547
  159. package/coverage/lcov-report/natural/lib/natural/inflectors/count_inflector.js.html +0 -484
  160. package/coverage/lcov-report/natural/lib/natural/inflectors/form_set.js.html +0 -406
  161. package/coverage/lcov-report/natural/lib/natural/inflectors/fr/index.html +0 -350
  162. package/coverage/lcov-report/natural/lib/natural/inflectors/fr/noun_inflector.js.html +0 -1027
  163. package/coverage/lcov-report/natural/lib/natural/inflectors/index.html +0 -402
  164. package/coverage/lcov-report/natural/lib/natural/inflectors/ja/index.html +0 -350
  165. package/coverage/lcov-report/natural/lib/natural/inflectors/ja/noun_inflector.js.html +0 -727
  166. package/coverage/lcov-report/natural/lib/natural/inflectors/noun_inflector.js.html +0 -637
  167. package/coverage/lcov-report/natural/lib/natural/inflectors/present_verb_inflector.js.html +0 -544
  168. package/coverage/lcov-report/natural/lib/natural/inflectors/singular_plural_inflector.js.html +0 -649
  169. package/coverage/lcov-report/natural/lib/natural/ngrams/index.html +0 -363
  170. package/coverage/lcov-report/natural/lib/natural/ngrams/ngrams.js.html +0 -595
  171. package/coverage/lcov-report/natural/lib/natural/ngrams/ngrams_zh.js.html +0 -571
  172. package/coverage/lcov-report/natural/lib/natural/normalizers/index.html +0 -389
  173. package/coverage/lcov-report/natural/lib/natural/normalizers/normalizer.js.html +0 -607
  174. package/coverage/lcov-report/natural/lib/natural/normalizers/normalizer_ja.js.html +0 -2194
  175. package/coverage/lcov-report/natural/lib/natural/normalizers/normalizer_no.js.html +0 -496
  176. package/coverage/lcov-report/natural/lib/natural/normalizers/remove_diacritics.js.html +0 -685
  177. package/coverage/lcov-report/natural/lib/natural/phonetics/dm_soundex.js.html +0 -1063
  178. package/coverage/lcov-report/natural/lib/natural/phonetics/double_metaphone.js.html +0 -1840
  179. package/coverage/lcov-report/natural/lib/natural/phonetics/index.html +0 -402
  180. package/coverage/lcov-report/natural/lib/natural/phonetics/metaphone.js.html +0 -886
  181. package/coverage/lcov-report/natural/lib/natural/phonetics/phonetic.js.html +0 -484
  182. package/coverage/lcov-report/natural/lib/natural/phonetics/soundex.js.html +0 -562
  183. package/coverage/lcov-report/natural/lib/natural/stemmers/index.html +0 -571
  184. package/coverage/lcov-report/natural/lib/natural/stemmers/lancaster_rules.js.html +0 -2692
  185. package/coverage/lcov-report/natural/lib/natural/stemmers/lancaster_stemmer.js.html +0 -544
  186. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer.js.html +0 -937
  187. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_es.js.html +0 -985
  188. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_fa.js.html +0 -418
  189. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_fr.js.html +0 -1450
  190. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_it.js.html +0 -1018
  191. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_no.js.html +0 -784
  192. package/coverage/lcov-report/natural/lib/natural/stemmers/porter_stemmer_ru.js.html +0 -775
  193. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer.js.html +0 -505
  194. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_es.js.html +0 -496
  195. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_fa.js.html +0 -484
  196. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_fr.js.html +0 -496
  197. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_it.js.html +0 -427
  198. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_ja.js.html +0 -736
  199. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_no.js.html +0 -505
  200. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_pl.js.html +0 -496
  201. package/coverage/lcov-report/natural/lib/natural/stemmers/stemmer_ru.js.html +0 -496
  202. package/coverage/lcov-report/natural/lib/natural/tfidf/index.html +0 -350
  203. package/coverage/lcov-report/natural/lib/natural/tfidf/tfidf.js.html +0 -904
  204. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer.js.html +0 -430
  205. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_es.js.html +0 -430
  206. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_fa.js.html +0 -466
  207. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_fr.js.html +0 -430
  208. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_it.js.html +0 -430
  209. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_nl.js.html +0 -430
  210. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_no.js.html +0 -439
  211. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_pl.js.html +0 -457
  212. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_pt.js.html +0 -442
  213. package/coverage/lcov-report/natural/lib/natural/tokenizers/aggressive_tokenizer_ru.js.html +0 -457
  214. package/coverage/lcov-report/natural/lib/natural/tokenizers/index.html +0 -519
  215. package/coverage/lcov-report/natural/lib/natural/tokenizers/regexp_tokenizer.js.html +0 -580
  216. package/coverage/lcov-report/natural/lib/natural/tokenizers/tokenizer.js.html +0 -475
  217. package/coverage/lcov-report/natural/lib/natural/tokenizers/tokenizer_ja.js.html +0 -1153
  218. package/coverage/lcov-report/natural/lib/natural/tokenizers/treebank_word_tokenizer.js.html +0 -544
  219. package/coverage/lcov-report/natural/lib/natural/transliterators/ja/index.html +0 -350
  220. package/coverage/lcov-report/natural/lib/natural/transliterators/ja/index.js.html +0 -2068
  221. package/coverage/lcov-report/natural/lib/natural/trie/index.html +0 -350
  222. package/coverage/lcov-report/natural/lib/natural/trie/trie.js.html +0 -1012
  223. package/coverage/lcov-report/natural/lib/natural/util/bag.js.html +0 -472
  224. package/coverage/lcov-report/natural/lib/natural/util/edge_weighted_digraph.js.html +0 -658
  225. package/coverage/lcov-report/natural/lib/natural/util/index.html +0 -532
  226. package/coverage/lcov-report/natural/lib/natural/util/longest_path_tree.js.html +0 -619
  227. package/coverage/lcov-report/natural/lib/natural/util/shortest_path_tree.js.html +0 -622
  228. package/coverage/lcov-report/natural/lib/natural/util/stopwords.js.html +0 -445
  229. package/coverage/lcov-report/natural/lib/natural/util/stopwords_es.js.html +0 -430
  230. package/coverage/lcov-report/natural/lib/natural/util/stopwords_fa.js.html +0 -436
  231. package/coverage/lcov-report/natural/lib/natural/util/stopwords_fr.js.html +0 -904
  232. package/coverage/lcov-report/natural/lib/natural/util/stopwords_it.js.html +0 -478
  233. package/coverage/lcov-report/natural/lib/natural/util/stopwords_ja.js.html +0 -499
  234. package/coverage/lcov-report/natural/lib/natural/util/stopwords_no.js.html +0 -445
  235. package/coverage/lcov-report/natural/lib/natural/util/stopwords_pl.js.html +0 -508
  236. package/coverage/lcov-report/natural/lib/natural/util/stopwords_ru.js.html +0 -445
  237. package/coverage/lcov-report/natural/lib/natural/util/topological.js.html +0 -616
  238. package/coverage/lcov-report/natural/lib/natural/util/utils.js.html +0 -679
  239. package/coverage/lcov-report/natural/lib/natural/wordnet/data_file.js.html +0 -580
  240. package/coverage/lcov-report/natural/lib/natural/wordnet/index.html +0 -389
  241. package/coverage/lcov-report/natural/lib/natural/wordnet/index_file.js.html +0 -742
  242. package/coverage/lcov-report/natural/lib/natural/wordnet/wordnet.js.html +0 -829
  243. package/coverage/lcov-report/natural/lib/natural/wordnet/wordnet_file.js.html +0 -529
  244. package/coverage/lcov-report/natural/ngrams/index.html +0 -363
  245. package/coverage/lcov-report/natural/ngrams/ngrams.js.html +0 -595
  246. package/coverage/lcov-report/natural/ngrams/ngrams_zh.js.html +0 -571
  247. package/coverage/lcov-report/natural/normalizers/index.html +0 -389
  248. package/coverage/lcov-report/natural/normalizers/normalizer.js.html +0 -607
  249. package/coverage/lcov-report/natural/normalizers/normalizer_ja.js.html +0 -2194
  250. package/coverage/lcov-report/natural/normalizers/normalizer_no.js.html +0 -496
  251. package/coverage/lcov-report/natural/normalizers/remove_diacritics.js.html +0 -685
  252. package/coverage/lcov-report/natural/phonetics/dm_soundex.js.html +0 -1063
  253. package/coverage/lcov-report/natural/phonetics/double_metaphone.js.html +0 -1840
  254. package/coverage/lcov-report/natural/phonetics/index.html +0 -402
  255. package/coverage/lcov-report/natural/phonetics/metaphone.js.html +0 -886
  256. package/coverage/lcov-report/natural/phonetics/phonetic.js.html +0 -484
  257. package/coverage/lcov-report/natural/phonetics/soundex.js.html +0 -562
  258. package/coverage/lcov-report/natural/stemmers/index.html +0 -571
  259. package/coverage/lcov-report/natural/stemmers/lancaster_rules.js.html +0 -2692
  260. package/coverage/lcov-report/natural/stemmers/lancaster_stemmer.js.html +0 -544
  261. package/coverage/lcov-report/natural/stemmers/porter_stemmer.js.html +0 -937
  262. package/coverage/lcov-report/natural/stemmers/porter_stemmer_es.js.html +0 -985
  263. package/coverage/lcov-report/natural/stemmers/porter_stemmer_fa.js.html +0 -418
  264. package/coverage/lcov-report/natural/stemmers/porter_stemmer_fr.js.html +0 -1450
  265. package/coverage/lcov-report/natural/stemmers/porter_stemmer_it.js.html +0 -1018
  266. package/coverage/lcov-report/natural/stemmers/porter_stemmer_no.js.html +0 -784
  267. package/coverage/lcov-report/natural/stemmers/porter_stemmer_ru.js.html +0 -775
  268. package/coverage/lcov-report/natural/stemmers/stemmer.js.html +0 -505
  269. package/coverage/lcov-report/natural/stemmers/stemmer_es.js.html +0 -496
  270. package/coverage/lcov-report/natural/stemmers/stemmer_fa.js.html +0 -484
  271. package/coverage/lcov-report/natural/stemmers/stemmer_fr.js.html +0 -496
  272. package/coverage/lcov-report/natural/stemmers/stemmer_it.js.html +0 -427
  273. package/coverage/lcov-report/natural/stemmers/stemmer_ja.js.html +0 -736
  274. package/coverage/lcov-report/natural/stemmers/stemmer_no.js.html +0 -505
  275. package/coverage/lcov-report/natural/stemmers/stemmer_pl.js.html +0 -496
  276. package/coverage/lcov-report/natural/stemmers/stemmer_ru.js.html +0 -496
  277. package/coverage/lcov-report/natural/tfidf/index.html +0 -350
  278. package/coverage/lcov-report/natural/tfidf/tfidf.js.html +0 -904
  279. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer.js.html +0 -430
  280. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_es.js.html +0 -430
  281. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_fa.js.html +0 -466
  282. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_fr.js.html +0 -430
  283. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_it.js.html +0 -430
  284. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_nl.js.html +0 -430
  285. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_no.js.html +0 -439
  286. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_pl.js.html +0 -457
  287. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_pt.js.html +0 -442
  288. package/coverage/lcov-report/natural/tokenizers/aggressive_tokenizer_ru.js.html +0 -457
  289. package/coverage/lcov-report/natural/tokenizers/index.html +0 -519
  290. package/coverage/lcov-report/natural/tokenizers/regexp_tokenizer.js.html +0 -580
  291. package/coverage/lcov-report/natural/tokenizers/tokenizer.js.html +0 -475
  292. package/coverage/lcov-report/natural/tokenizers/tokenizer_ja.js.html +0 -1153
  293. package/coverage/lcov-report/natural/tokenizers/treebank_word_tokenizer.js.html +0 -544
  294. package/coverage/lcov-report/natural/transliterators/ja/index.html +0 -350
  295. package/coverage/lcov-report/natural/transliterators/ja/index.js.html +0 -2068
  296. package/coverage/lcov-report/natural/trie/index.html +0 -350
  297. package/coverage/lcov-report/natural/trie/trie.js.html +0 -1012
  298. package/coverage/lcov-report/natural/util/bag.js.html +0 -472
  299. package/coverage/lcov-report/natural/util/edge_weighted_digraph.js.html +0 -658
  300. package/coverage/lcov-report/natural/util/index.html +0 -532
  301. package/coverage/lcov-report/natural/util/longest_path_tree.js.html +0 -619
  302. package/coverage/lcov-report/natural/util/shortest_path_tree.js.html +0 -622
  303. package/coverage/lcov-report/natural/util/stopwords.js.html +0 -445
  304. package/coverage/lcov-report/natural/util/stopwords_es.js.html +0 -430
  305. package/coverage/lcov-report/natural/util/stopwords_fa.js.html +0 -436
  306. package/coverage/lcov-report/natural/util/stopwords_fr.js.html +0 -904
  307. package/coverage/lcov-report/natural/util/stopwords_it.js.html +0 -478
  308. package/coverage/lcov-report/natural/util/stopwords_ja.js.html +0 -499
  309. package/coverage/lcov-report/natural/util/stopwords_no.js.html +0 -445
  310. package/coverage/lcov-report/natural/util/stopwords_pl.js.html +0 -508
  311. package/coverage/lcov-report/natural/util/stopwords_ru.js.html +0 -445
  312. package/coverage/lcov-report/natural/util/topological.js.html +0 -616
  313. package/coverage/lcov-report/natural/util/utils.js.html +0 -679
  314. package/coverage/lcov-report/natural/wordnet/data_file.js.html +0 -580
  315. package/coverage/lcov-report/natural/wordnet/index.html +0 -389
  316. package/coverage/lcov-report/natural/wordnet/index_file.js.html +0 -742
  317. package/coverage/lcov-report/natural/wordnet/wordnet.js.html +0 -829
  318. package/coverage/lcov-report/natural/wordnet/wordnet_file.js.html +0 -529
  319. package/coverage/lcov-report/normalizers/index.html +0 -350
  320. package/coverage/lcov-report/normalizers/normalizer.js.html +0 -607
  321. package/coverage/lcov-report/prettify.css +0 -1
  322. package/coverage/lcov-report/prettify.js +0 -1
  323. package/coverage/lcov-report/spec/aggressive_tokenizer_es_spec.js.html +0 -430
  324. package/coverage/lcov-report/spec/aggressive_tokenizer_fr_spec.js.html +0 -625
  325. package/coverage/lcov-report/spec/aggressive_tokenizer_nl_spec.js.html +0 -430
  326. package/coverage/lcov-report/spec/aggressive_tokenizer_pt_spec.js.html +0 -490
  327. package/coverage/lcov-report/spec/aggressive_tokenizer_spec.js.html +0 -490
  328. package/coverage/lcov-report/spec/bayes_classifier_spec.js.html +0 -841
  329. package/coverage/lcov-report/spec/classifier_spec.js.html +0 -847
  330. package/coverage/lcov-report/spec/count_inflector_fr_spec.js.html +0 -454
  331. package/coverage/lcov-report/spec/count_inflector_spec.js.html +0 -538
  332. package/coverage/lcov-report/spec/dice_coefficient_spec.js.html +0 -400
  333. package/coverage/lcov-report/spec/double_metaphone_spec.js.html +0 -2548
  334. package/coverage/lcov-report/spec/index.html +0 -883
  335. package/coverage/lcov-report/spec/jaro-winkler_spec.js.html +0 -481
  336. package/coverage/lcov-report/spec/lancaster_stemmer_spec.js.html +0 -541
  337. package/coverage/lcov-report/spec/levenshtein_spec.js.html +0 -520
  338. package/coverage/lcov-report/spec/logistic_regression_classifier_spec.js.html +0 -688
  339. package/coverage/lcov-report/spec/longest_path_tree_spec.js.html +0 -628
  340. package/coverage/lcov-report/spec/metaphone_spec.js.html +0 -1063
  341. package/coverage/lcov-report/spec/ngram_spec.js.html +0 -712
  342. package/coverage/lcov-report/spec/ngram_zh_spec.js.html +0 -688
  343. package/coverage/lcov-report/spec/normalizer_ja_spec.js.html +0 -802
  344. package/coverage/lcov-report/spec/normalizer_no_spec.js.html +0 -655
  345. package/coverage/lcov-report/spec/normalizer_spec.js.html +0 -742
  346. package/coverage/lcov-report/spec/noun_inflector_fr_spec.js.html +0 -1750
  347. package/coverage/lcov-report/spec/noun_inflector_ja_spec.js.html +0 -658
  348. package/coverage/lcov-report/spec/noun_inflector_spec.js.html +0 -1132
  349. package/coverage/lcov-report/spec/porter_stemmer_fr_spec.js.html +0 -625
  350. package/coverage/lcov-report/spec/porter_stemmer_it_spec.js.html +0 -454
  351. package/coverage/lcov-report/spec/porter_stemmer_no_spec.js.html +0 -751
  352. package/coverage/lcov-report/spec/porter_stemmer_ru_spec.js.html +0 -511
  353. package/coverage/lcov-report/spec/porter_stemmer_spec.js.html +0 -733
  354. package/coverage/lcov-report/spec/present_verb_inflector_spec.js.html +0 -697
  355. package/coverage/lcov-report/spec/remove_diacritics_spec.js.html +0 -415
  356. package/coverage/lcov-report/spec/sentence_analyzer_spec.js.html +0 -1153
  357. package/coverage/lcov-report/spec/shortest_path_tree_spec.js.html +0 -718
  358. package/coverage/lcov-report/spec/soundex_spec.js.html +0 -784
  359. package/coverage/lcov-report/spec/spellcheck_spec.js.html +0 -598
  360. package/coverage/lcov-report/spec/stemmer_ja_spec.js.html +0 -520
  361. package/coverage/lcov-report/spec/tfidf_spec.js.html +0 -1288
  362. package/coverage/lcov-report/spec/tokenizer_ja_spec.js.html +0 -496
  363. package/coverage/lcov-report/spec/transliterator_ja_spec.js.html +0 -631
  364. package/coverage/lcov-report/spec/treebank_word_tokenizer_spec.js.html +0 -430
  365. package/coverage/lcov-report/spec/trie_spec.js.html +0 -940
  366. package/coverage/lcov-report/util/index.html +0 -350
  367. package/coverage/lcov-report/util/utils.js.html +0 -679
  368. package/coverage/lcov.info +0 -11094
  369. package/lib/natural/parsers/Agenda.js +0 -68
  370. package/lib/natural/parsers/CYKParser.js +0 -87
  371. package/lib/natural/parsers/CYK_Item.js +0 -159
  372. package/lib/natural/parsers/Chart.js +0 -211
  373. package/lib/natural/parsers/ChartParser.js +0 -60
  374. package/lib/natural/parsers/DoubleDottedItem.js +0 -226
  375. package/lib/natural/parsers/EarleyItem.js +0 -155
  376. package/lib/natural/parsers/EarleyParser.js +0 -58
  377. package/lib/natural/parsers/FunctionWordTagger.js +0 -84
  378. package/lib/natural/parsers/GoalItem.js +0 -206
  379. package/lib/natural/parsers/GrammarParser.js +0 -1289
  380. package/lib/natural/parsers/HeadCornerParser.js +0 -101
  381. package/lib/natural/parsers/LeftCornerParser.js +0 -58
  382. 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.0",
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.6",
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
- expect(doubleMetaphone.process('ptah')).toEqual(['PT', 'PT']);
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
  });