nltk 3.2.1__zip → 3.3__zip

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 (404) hide show
  1. {nltk-3.2.1 → nltk-3.3}/LICENSE.txt +1 -1
  2. {nltk-3.2.1/nltk.egg-info → nltk-3.3}/PKG-INFO +13 -5
  3. nltk-3.3/README.md +49 -0
  4. nltk-3.3/nltk/VERSION +1 -0
  5. {nltk-3.2.1 → nltk-3.3}/nltk/__init__.py +3 -3
  6. {nltk-3.2.1 → nltk-3.3}/nltk/app/__init__.py +2 -3
  7. {nltk-3.2.1 → nltk-3.3}/nltk/app/chartparser_app.py +92 -92
  8. {nltk-3.2.1 → nltk-3.3}/nltk/app/chunkparser_app.py +11 -13
  9. {nltk-3.2.1 → nltk-3.3}/nltk/app/collocations_app.py +8 -11
  10. {nltk-3.2.1 → nltk-3.3}/nltk/app/concordance_app.py +9 -11
  11. {nltk-3.2.1 → nltk-3.3}/nltk/app/nemo_app.py +18 -17
  12. {nltk-3.2.1 → nltk-3.3}/nltk/app/rdparser_app.py +10 -12
  13. {nltk-3.2.1 → nltk-3.3}/nltk/app/srparser_app.py +16 -16
  14. {nltk-3.2.1 → nltk-3.3}/nltk/app/wordfreq_app.py +1 -1
  15. {nltk-3.2.1 → nltk-3.3}/nltk/app/wordnet_app.py +11 -11
  16. {nltk-3.2.1 → nltk-3.3}/nltk/book.py +2 -1
  17. {nltk-3.2.1 → nltk-3.3}/nltk/ccg/__init__.py +1 -1
  18. {nltk-3.2.1 → nltk-3.3}/nltk/ccg/api.py +67 -47
  19. {nltk-3.2.1 → nltk-3.3}/nltk/ccg/chart.py +7 -5
  20. {nltk-3.2.1 → nltk-3.3}/nltk/ccg/combinator.py +42 -11
  21. {nltk-3.2.1 → nltk-3.3}/nltk/ccg/lexicon.py +1 -1
  22. {nltk-3.2.1 → nltk-3.3}/nltk/ccg/logic.py +1 -1
  23. {nltk-3.2.1 → nltk-3.3}/nltk/chat/__init__.py +1 -1
  24. {nltk-3.2.1 → nltk-3.3}/nltk/chat/eliza.py +1 -1
  25. {nltk-3.2.1 → nltk-3.3}/nltk/chat/iesha.py +1 -1
  26. {nltk-3.2.1 → nltk-3.3}/nltk/chat/rude.py +1 -1
  27. {nltk-3.2.1 → nltk-3.3}/nltk/chat/suntsu.py +1 -1
  28. {nltk-3.2.1 → nltk-3.3}/nltk/chat/util.py +12 -10
  29. {nltk-3.2.1 → nltk-3.3}/nltk/chat/zen.py +1 -1
  30. {nltk-3.2.1 → nltk-3.3}/nltk/chunk/__init__.py +1 -1
  31. {nltk-3.2.1 → nltk-3.3}/nltk/chunk/api.py +1 -1
  32. {nltk-3.2.1 → nltk-3.3}/nltk/chunk/named_entity.py +13 -13
  33. {nltk-3.2.1 → nltk-3.3}/nltk/chunk/regexp.py +9 -3
  34. {nltk-3.2.1 → nltk-3.3}/nltk/chunk/util.py +12 -12
  35. {nltk-3.2.1 → nltk-3.3}/nltk/classify/__init__.py +1 -1
  36. {nltk-3.2.1 → nltk-3.3}/nltk/classify/api.py +1 -1
  37. {nltk-3.2.1 → nltk-3.3}/nltk/classify/decisiontree.py +18 -18
  38. {nltk-3.2.1 → nltk-3.3}/nltk/classify/maxent.py +26 -8
  39. {nltk-3.2.1 → nltk-3.3}/nltk/classify/megam.py +5 -4
  40. {nltk-3.2.1 → nltk-3.3}/nltk/classify/naivebayes.py +29 -26
  41. {nltk-3.2.1 → nltk-3.3}/nltk/classify/rte_classify.py +58 -89
  42. {nltk-3.2.1 → nltk-3.3}/nltk/classify/scikitlearn.py +4 -2
  43. {nltk-3.2.1 → nltk-3.3}/nltk/classify/senna.py +24 -22
  44. {nltk-3.2.1 → nltk-3.3}/nltk/classify/svm.py +1 -1
  45. {nltk-3.2.1 → nltk-3.3}/nltk/classify/tadm.py +4 -3
  46. {nltk-3.2.1 → nltk-3.3}/nltk/classify/textcat.py +1 -1
  47. {nltk-3.2.1 → nltk-3.3}/nltk/classify/util.py +13 -1
  48. {nltk-3.2.1 → nltk-3.3}/nltk/classify/weka.py +7 -6
  49. {nltk-3.2.1 → nltk-3.3}/nltk/cluster/__init__.py +1 -1
  50. {nltk-3.2.1 → nltk-3.3}/nltk/cluster/api.py +9 -5
  51. {nltk-3.2.1 → nltk-3.3}/nltk/cluster/em.py +1 -1
  52. {nltk-3.2.1 → nltk-3.3}/nltk/cluster/gaac.py +3 -3
  53. {nltk-3.2.1 → nltk-3.3}/nltk/cluster/kmeans.py +1 -1
  54. {nltk-3.2.1 → nltk-3.3}/nltk/cluster/util.py +35 -20
  55. nltk-3.3/nltk/collections.py +640 -0
  56. {nltk-3.2.1 → nltk-3.3}/nltk/collocations.py +2 -2
  57. nltk-3.3/nltk/compat.py +365 -0
  58. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/__init__.py +37 -16
  59. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/europarl_raw.py +1 -1
  60. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/__init__.py +4 -2
  61. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/aligned.py +4 -3
  62. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/api.py +12 -10
  63. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/bnc.py +1 -1
  64. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/bracket_parse.py +1 -1
  65. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/categorized_sents.py +4 -3
  66. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/chasen.py +5 -4
  67. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/childes.py +8 -9
  68. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/chunked.py +4 -4
  69. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/cmudict.py +4 -2
  70. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/comparative_sents.py +4 -2
  71. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/conll.py +19 -12
  72. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/crubadan.py +2 -2
  73. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/dependency.py +1 -1
  74. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/framenet.py +1085 -119
  75. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ieer.py +4 -3
  76. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/indian.py +4 -5
  77. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ipipan.py +6 -5
  78. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/knbc.py +2 -2
  79. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/lin.py +1 -1
  80. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/mte.py +5 -4
  81. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/nkjp.py +4 -3
  82. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/nombank.py +8 -8
  83. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/nps_chat.py +1 -1
  84. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/opinion_lexicon.py +3 -3
  85. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/panlex_lite.py +1 -1
  86. nltk-3.3/nltk/corpus/reader/pl196x.py +292 -0
  87. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/plaintext.py +3 -4
  88. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ppattach.py +4 -3
  89. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/propbank.py +8 -10
  90. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/pros_cons.py +5 -3
  91. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/reviews.py +3 -1
  92. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/rte.py +5 -7
  93. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/semcor.py +1 -1
  94. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/senseval.py +4 -2
  95. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/sentiwordnet.py +3 -3
  96. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/sinica_treebank.py +1 -1
  97. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/string_category.py +4 -3
  98. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/switchboard.py +1 -1
  99. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/tagged.py +4 -3
  100. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/timit.py +10 -8
  101. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/toolbox.py +4 -4
  102. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/twitter.py +4 -6
  103. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/util.py +7 -3
  104. nltk-3.3/nltk/corpus/reader/verbnet.py +595 -0
  105. nltk-3.3/nltk/corpus/reader/wordlist.py +134 -0
  106. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/wordnet.py +357 -285
  107. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/xmldocs.py +10 -5
  108. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ycoe.py +25 -24
  109. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/util.py +22 -5
  110. {nltk-3.2.1 → nltk-3.3}/nltk/data.py +65 -29
  111. {nltk-3.2.1 → nltk-3.3}/nltk/decorators.py +5 -1
  112. {nltk-3.2.1 → nltk-3.3}/nltk/downloader.py +59 -55
  113. {nltk-3.2.1 → nltk-3.3}/nltk/draw/__init__.py +4 -4
  114. {nltk-3.2.1 → nltk-3.3}/nltk/draw/cfg.py +5 -8
  115. {nltk-3.2.1 → nltk-3.3}/nltk/draw/dispersion.py +1 -1
  116. {nltk-3.2.1 → nltk-3.3}/nltk/draw/table.py +4 -4
  117. {nltk-3.2.1 → nltk-3.3}/nltk/draw/tree.py +2 -5
  118. {nltk-3.2.1 → nltk-3.3}/nltk/draw/util.py +17 -17
  119. {nltk-3.2.1 → nltk-3.3}/nltk/featstruct.py +290 -173
  120. {nltk-3.2.1 → nltk-3.3}/nltk/grammar.py +87 -44
  121. {nltk-3.2.1 → nltk-3.3}/nltk/help.py +1 -1
  122. {nltk-3.2.1 → nltk-3.3}/nltk/inference/__init__.py +1 -1
  123. {nltk-3.2.1 → nltk-3.3}/nltk/inference/api.py +27 -19
  124. {nltk-3.2.1 → nltk-3.3}/nltk/inference/discourse.py +20 -16
  125. {nltk-3.2.1 → nltk-3.3}/nltk/inference/nonmonotonic.py +1 -1
  126. {nltk-3.2.1 → nltk-3.3}/nltk/inference/prover9.py +1 -1
  127. {nltk-3.2.1 → nltk-3.3}/nltk/inference/resolution.py +1 -1
  128. {nltk-3.2.1 → nltk-3.3}/nltk/inference/tableau.py +1 -1
  129. {nltk-3.2.1 → nltk-3.3}/nltk/internals.py +44 -44
  130. {nltk-3.2.1 → nltk-3.3}/nltk/jsontags.py +1 -1
  131. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/__init__.py +2 -1
  132. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/agreement.py +29 -9
  133. nltk-3.3/nltk/metrics/aline.py +607 -0
  134. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/association.py +8 -4
  135. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/confusionmatrix.py +1 -1
  136. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/distance.py +12 -7
  137. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/paice.py +1 -1
  138. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/scores.py +7 -7
  139. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/segmentation.py +4 -5
  140. {nltk-3.2.1 → nltk-3.3}/nltk/metrics/spearman.py +1 -1
  141. {nltk-3.2.1 → nltk-3.3}/nltk/misc/__init__.py +1 -1
  142. {nltk-3.2.1 → nltk-3.3}/nltk/misc/chomsky.py +4 -2
  143. {nltk-3.2.1 → nltk-3.3}/nltk/misc/minimalset.py +1 -1
  144. {nltk-3.2.1 → nltk-3.3}/nltk/misc/sort.py +1 -1
  145. {nltk-3.2.1 → nltk-3.3}/nltk/misc/wordfinder.py +1 -1
  146. {nltk-3.2.1 → nltk-3.3}/nltk/parse/__init__.py +2 -1
  147. {nltk-3.2.1 → nltk-3.3}/nltk/parse/api.py +1 -1
  148. {nltk-3.2.1 → nltk-3.3}/nltk/parse/bllip.py +1 -1
  149. {nltk-3.2.1 → nltk-3.3}/nltk/parse/chart.py +8 -7
  150. nltk-3.3/nltk/parse/corenlp.py +780 -0
  151. {nltk-3.2.1 → nltk-3.3}/nltk/parse/dependencygraph.py +4 -2
  152. {nltk-3.2.1 → nltk-3.3}/nltk/parse/earleychart.py +4 -3
  153. {nltk-3.2.1 → nltk-3.3}/nltk/parse/evaluate.py +1 -1
  154. {nltk-3.2.1 → nltk-3.3}/nltk/parse/featurechart.py +6 -4
  155. {nltk-3.2.1 → nltk-3.3}/nltk/parse/generate.py +15 -4
  156. {nltk-3.2.1 → nltk-3.3}/nltk/parse/malt.py +2 -2
  157. {nltk-3.2.1 → nltk-3.3}/nltk/parse/nonprojectivedependencyparser.py +3 -3
  158. {nltk-3.2.1 → nltk-3.3}/nltk/parse/pchart.py +1 -1
  159. {nltk-3.2.1 → nltk-3.3}/nltk/parse/projectivedependencyparser.py +6 -5
  160. {nltk-3.2.1 → nltk-3.3}/nltk/parse/recursivedescent.py +2 -3
  161. {nltk-3.2.1 → nltk-3.3}/nltk/parse/shiftreduce.py +2 -3
  162. {nltk-3.2.1 → nltk-3.3}/nltk/parse/stanford.py +53 -28
  163. {nltk-3.2.1 → nltk-3.3}/nltk/parse/transitionparser.py +11 -9
  164. {nltk-3.2.1 → nltk-3.3}/nltk/parse/util.py +1 -1
  165. {nltk-3.2.1 → nltk-3.3}/nltk/parse/viterbi.py +1 -1
  166. {nltk-3.2.1 → nltk-3.3}/nltk/probability.py +75 -20
  167. {nltk-3.2.1 → nltk-3.3}/nltk/sem/__init__.py +1 -1
  168. {nltk-3.2.1 → nltk-3.3}/nltk/sem/boxer.py +15 -15
  169. {nltk-3.2.1 → nltk-3.3}/nltk/sem/chat80.py +6 -6
  170. {nltk-3.2.1 → nltk-3.3}/nltk/sem/cooper_storage.py +1 -1
  171. {nltk-3.2.1 → nltk-3.3}/nltk/sem/drt.py +9 -8
  172. {nltk-3.2.1 → nltk-3.3}/nltk/sem/drt_glue_demo.py +5 -9
  173. {nltk-3.2.1 → nltk-3.3}/nltk/sem/evaluate.py +9 -3
  174. {nltk-3.2.1 → nltk-3.3}/nltk/sem/glue.py +8 -6
  175. {nltk-3.2.1 → nltk-3.3}/nltk/sem/hole.py +4 -2
  176. {nltk-3.2.1 → nltk-3.3}/nltk/sem/lfg.py +4 -2
  177. {nltk-3.2.1 → nltk-3.3}/nltk/sem/linearlogic.py +4 -2
  178. {nltk-3.2.1 → nltk-3.3}/nltk/sem/logic.py +14 -14
  179. {nltk-3.2.1 → nltk-3.3}/nltk/sem/relextract.py +11 -18
  180. {nltk-3.2.1 → nltk-3.3}/nltk/sem/skolemize.py +1 -1
  181. {nltk-3.2.1 → nltk-3.3}/nltk/sem/util.py +1 -1
  182. {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/__init__.py +1 -1
  183. {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/sentiment_analyzer.py +1 -1
  184. {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/util.py +14 -4
  185. {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/vader.py +41 -42
  186. {nltk-3.2.1 → nltk-3.3}/nltk/stem/__init__.py +1 -3
  187. {nltk-3.2.1 → nltk-3.3}/nltk/stem/api.py +7 -4
  188. nltk-3.3/nltk/stem/arlstem.py +369 -0
  189. {nltk-3.2.1 → nltk-3.3}/nltk/stem/isri.py +1 -1
  190. {nltk-3.2.1 → nltk-3.3}/nltk/stem/lancaster.py +39 -12
  191. nltk-3.3/nltk/stem/porter.py +710 -0
  192. {nltk-3.2.1 → nltk-3.3}/nltk/stem/regexp.py +2 -2
  193. {nltk-3.2.1 → nltk-3.3}/nltk/stem/rslp.py +1 -1
  194. {nltk-3.2.1 → nltk-3.3}/nltk/stem/snowball.py +537 -13
  195. {nltk-3.2.1 → nltk-3.3}/nltk/stem/util.py +11 -1
  196. {nltk-3.2.1 → nltk-3.3}/nltk/stem/wordnet.py +1 -1
  197. {nltk-3.2.1 → nltk-3.3}/nltk/tag/__init__.py +32 -7
  198. {nltk-3.2.1 → nltk-3.3}/nltk/tag/api.py +13 -8
  199. {nltk-3.2.1 → nltk-3.3}/nltk/tag/brill.py +4 -6
  200. {nltk-3.2.1 → nltk-3.3}/nltk/tag/crf.py +1 -1
  201. {nltk-3.2.1 → nltk-3.3}/nltk/tag/hmm.py +11 -11
  202. {nltk-3.2.1 → nltk-3.3}/nltk/tag/hunpos.py +4 -4
  203. {nltk-3.2.1 → nltk-3.3}/nltk/tag/mapping.py +1 -1
  204. {nltk-3.2.1 → nltk-3.3}/nltk/tag/perceptron.py +25 -10
  205. {nltk-3.2.1 → nltk-3.3}/nltk/tag/senna.py +25 -23
  206. {nltk-3.2.1 → nltk-3.3}/nltk/tag/sequential.py +19 -15
  207. {nltk-3.2.1 → nltk-3.3}/nltk/tag/stanford.py +59 -36
  208. {nltk-3.2.1 → nltk-3.3}/nltk/tag/tnt.py +11 -20
  209. {nltk-3.2.1 → nltk-3.3}/nltk/tag/util.py +1 -1
  210. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/__init__.py +1 -1
  211. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/demo.py +1 -1
  212. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/erroranalysis.py +1 -1
  213. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/feature.py +5 -7
  214. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/rule.py +6 -6
  215. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/template.py +18 -23
  216. {nltk-3.2.1 → nltk-3.3}/nltk/test/__init__.py +1 -1
  217. {nltk-3.2.1 → nltk-3.3}/nltk/test/all.py +7 -6
  218. {nltk-3.2.1 → nltk-3.3}/nltk/test/bnc.doctest +1 -1
  219. {nltk-3.2.1 → nltk-3.3}/nltk/test/ccg.doctest +1 -1
  220. {nltk-3.2.1 → nltk-3.3}/nltk/test/ccg_semantics.doctest +1 -1
  221. {nltk-3.2.1 → nltk-3.3}/nltk/test/chat80.doctest +1 -1
  222. {nltk-3.2.1 → nltk-3.3}/nltk/test/childes_fixt.py +1 -0
  223. {nltk-3.2.1 → nltk-3.3}/nltk/test/chunk.doctest +1 -1
  224. {nltk-3.2.1 → nltk-3.3}/nltk/test/classify.doctest +1 -1
  225. {nltk-3.2.1 → nltk-3.3}/nltk/test/classify_fixt.py +2 -1
  226. nltk-3.3/nltk/test/collections.doctest +20 -0
  227. {nltk-3.2.1 → nltk-3.3}/nltk/test/collocations.doctest +1 -1
  228. {nltk-3.2.1 → nltk-3.3}/nltk/test/compat.doctest +0 -4
  229. {nltk-3.2.1 → nltk-3.3}/nltk/test/compat_fixt.py +1 -0
  230. nltk-3.3/nltk/test/concordance.doctest +55 -0
  231. {nltk-3.2.1 → nltk-3.3}/nltk/test/corpus.doctest +38 -49
  232. {nltk-3.2.1 → nltk-3.3}/nltk/test/crubadan.doctest +1 -1
  233. {nltk-3.2.1 → nltk-3.3}/nltk/test/data.doctest +1 -1
  234. {nltk-3.2.1 → nltk-3.3}/nltk/test/dependency.doctest +1 -1
  235. {nltk-3.2.1 → nltk-3.3}/nltk/test/discourse.doctest +1 -1
  236. {nltk-3.2.1 → nltk-3.3}/nltk/test/discourse_fixt.py +1 -0
  237. {nltk-3.2.1 → nltk-3.3}/nltk/test/doctest_nose_plugin.py +8 -5
  238. {nltk-3.2.1 → nltk-3.3}/nltk/test/drt.doctest +1 -1
  239. {nltk-3.2.1 → nltk-3.3}/nltk/test/featgram.doctest +1 -1
  240. {nltk-3.2.1 → nltk-3.3}/nltk/test/featstruct.doctest +2 -3
  241. {nltk-3.2.1 → nltk-3.3}/nltk/test/framenet.doctest +82 -33
  242. {nltk-3.2.1 → nltk-3.3}/nltk/test/generate.doctest +1 -1
  243. {nltk-3.2.1 → nltk-3.3}/nltk/test/gensim.doctest +6 -7
  244. {nltk-3.2.1 → nltk-3.3}/nltk/test/gensim_fixt.py +1 -0
  245. {nltk-3.2.1 → nltk-3.3}/nltk/test/gluesemantics.doctest +13 -15
  246. {nltk-3.2.1 → nltk-3.3}/nltk/test/gluesemantics_malt.doctest +1 -1
  247. {nltk-3.2.1 → nltk-3.3}/nltk/test/gluesemantics_malt_fixt.py +1 -0
  248. {nltk-3.2.1 → nltk-3.3}/nltk/test/grammar.doctest +1 -1
  249. {nltk-3.2.1 → nltk-3.3}/nltk/test/grammartestsuites.doctest +1 -1
  250. {nltk-3.2.1 → nltk-3.3}/nltk/test/index.doctest +1 -1
  251. {nltk-3.2.1 → nltk-3.3}/nltk/test/inference.doctest +1 -1
  252. {nltk-3.2.1 → nltk-3.3}/nltk/test/inference_fixt.py +1 -0
  253. {nltk-3.2.1 → nltk-3.3}/nltk/test/internals.doctest +1 -1
  254. {nltk-3.2.1 → nltk-3.3}/nltk/test/japanese.doctest +1 -1
  255. {nltk-3.2.1 → nltk-3.3}/nltk/test/logic.doctest +1 -1
  256. {nltk-3.2.1 → nltk-3.3}/nltk/test/metrics.doctest +3 -3
  257. {nltk-3.2.1 → nltk-3.3}/nltk/test/misc.doctest +1 -1
  258. {nltk-3.2.1 → nltk-3.3}/nltk/test/nonmonotonic.doctest +1 -1
  259. {nltk-3.2.1 → nltk-3.3}/nltk/test/nonmonotonic_fixt.py +1 -0
  260. {nltk-3.2.1 → nltk-3.3}/nltk/test/parse.doctest +1 -1
  261. {nltk-3.2.1 → nltk-3.3}/nltk/test/portuguese_en.doctest +1 -1
  262. {nltk-3.2.1 → nltk-3.3}/nltk/test/probability.doctest +1 -1
  263. {nltk-3.2.1 → nltk-3.3}/nltk/test/probability_fixt.py +2 -1
  264. {nltk-3.2.1 → nltk-3.3}/nltk/test/propbank.doctest +1 -1
  265. {nltk-3.2.1 → nltk-3.3}/nltk/test/relextract.doctest +1 -1
  266. {nltk-3.2.1 → nltk-3.3}/nltk/test/resolution.doctest +1 -1
  267. {nltk-3.2.1 → nltk-3.3}/nltk/test/runtests.py +35 -13
  268. {nltk-3.2.1 → nltk-3.3}/nltk/test/semantics.doctest +1 -1
  269. {nltk-3.2.1 → nltk-3.3}/nltk/test/sentiment.doctest +3 -3
  270. {nltk-3.2.1 → nltk-3.3}/nltk/test/sentiwordnet.doctest +1 -1
  271. {nltk-3.2.1 → nltk-3.3}/nltk/test/simple.doctest +1 -1
  272. {nltk-3.2.1 → nltk-3.3}/nltk/test/stem.doctest +2 -2
  273. {nltk-3.2.1 → nltk-3.3}/nltk/test/tag.doctest +1 -1
  274. {nltk-3.2.1 → nltk-3.3}/nltk/test/tokenize.doctest +109 -2
  275. {nltk-3.2.1 → nltk-3.3}/nltk/test/toolbox.doctest +1 -1
  276. {nltk-3.2.1 → nltk-3.3}/nltk/test/translate.doctest +1 -1
  277. {nltk-3.2.1 → nltk-3.3}/nltk/test/tree.doctest +1 -1
  278. {nltk-3.2.1 → nltk-3.3}/nltk/test/treeprettyprinter.doctest +1 -1
  279. {nltk-3.2.1 → nltk-3.3}/nltk/test/treetransforms.doctest +1 -1
  280. nltk-3.3/nltk/test/unit/test_aline.py +52 -0
  281. nltk-3.3/nltk/test/unit/test_chunk.py +56 -0
  282. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_classify.py +20 -18
  283. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_collocations.py +16 -7
  284. nltk-3.3/nltk/test/unit/test_concordance.py +98 -0
  285. nltk-3.3/nltk/test/unit/test_corenlp.py +1000 -0
  286. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_corpora.py +18 -1
  287. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_json2csv_corpus.py +4 -3
  288. nltk-3.3/nltk/test/unit/test_rte_classify.py +86 -0
  289. nltk-3.3/nltk/test/unit/test_senna.py +74 -0
  290. nltk-3.3/nltk/test/unit/test_stem.py +121 -0
  291. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_tgrep.py +4 -2
  292. nltk-3.3/nltk/test/unit/test_tokenize.py +168 -0
  293. nltk-3.3/nltk/test/unit/test_wordnet.py +134 -0
  294. nltk-3.3/nltk/test/unit/translate/test_bleu.py +244 -0
  295. nltk-3.3/nltk/test/unit/translate/test_gdfa.py +57 -0
  296. nltk-3.3/nltk/test/unit/translate/test_nist.py +37 -0
  297. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_stack_decoder.py +1 -1
  298. {nltk-3.2.1 → nltk-3.3}/nltk/test/util.doctest +1 -1
  299. {nltk-3.2.1 → nltk-3.3}/nltk/test/wordnet.doctest +17 -3
  300. {nltk-3.2.1 → nltk-3.3}/nltk/test/wordnet_fixt.py +1 -0
  301. {nltk-3.2.1 → nltk-3.3}/nltk/test/wordnet_lch.doctest +1 -1
  302. {nltk-3.2.1 → nltk-3.3}/nltk/test/wsd.doctest +1 -1
  303. {nltk-3.2.1 → nltk-3.3}/nltk/text.py +92 -39
  304. {nltk-3.2.1 → nltk-3.3}/nltk/tgrep.py +8 -7
  305. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/__init__.py +37 -15
  306. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/api.py +3 -4
  307. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/casual.py +10 -9
  308. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/mwe.py +2 -2
  309. nltk-3.3/nltk/tokenize/nist.py +173 -0
  310. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/punkt.py +186 -167
  311. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/regexp.py +13 -7
  312. nltk-3.3/nltk/tokenize/repp.py +151 -0
  313. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/sexpr.py +4 -6
  314. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/simple.py +7 -5
  315. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/stanford.py +18 -14
  316. nltk-3.3/nltk/tokenize/stanford_segmenter.py +246 -0
  317. {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/texttiling.py +43 -45
  318. nltk-3.3/nltk/tokenize/toktok.py +155 -0
  319. nltk-3.3/nltk/tokenize/treebank.py +363 -0
  320. nltk-3.3/nltk/tokenize/util.py +261 -0
  321. {nltk-3.2.1 → nltk-3.3}/nltk/toolbox.py +4 -2
  322. {nltk-3.2.1 → nltk-3.3}/nltk/translate/__init__.py +1 -1
  323. {nltk-3.2.1 → nltk-3.3}/nltk/translate/api.py +50 -40
  324. {nltk-3.2.1 → nltk-3.3}/nltk/translate/bleu_score.py +221 -156
  325. nltk-3.3/nltk/translate/chrf_score.py +137 -0
  326. {nltk-3.2.1 → nltk-3.3}/nltk/translate/gale_church.py +32 -19
  327. {nltk-3.2.1 → nltk-3.3}/nltk/translate/gdfa.py +14 -10
  328. nltk-3.3/nltk/translate/gleu_score.py +193 -0
  329. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm1.py +17 -8
  330. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm2.py +4 -4
  331. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm4.py +1 -1
  332. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm5.py +1 -1
  333. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm_model.py +4 -1
  334. {nltk-3.2.1 → nltk-3.3}/nltk/translate/metrics.py +1 -1
  335. nltk-3.3/nltk/translate/nist_score.py +178 -0
  336. {nltk-3.2.1 → nltk-3.3}/nltk/translate/phrase_based.py +1 -1
  337. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ribes_score.py +1 -1
  338. {nltk-3.2.1 → nltk-3.3}/nltk/translate/stack_decoder.py +5 -1
  339. {nltk-3.2.1 → nltk-3.3}/nltk/tree.py +10 -8
  340. {nltk-3.2.1 → nltk-3.3}/nltk/treeprettyprinter.py +6 -6
  341. {nltk-3.2.1 → nltk-3.3}/nltk/twitter/__init__.py +1 -1
  342. {nltk-3.2.1 → nltk-3.3}/nltk/twitter/api.py +8 -3
  343. {nltk-3.2.1 → nltk-3.3}/nltk/twitter/common.py +9 -3
  344. {nltk-3.2.1 → nltk-3.3}/nltk/twitter/twitter_demo.py +1 -1
  345. {nltk-3.2.1 → nltk-3.3}/nltk/twitter/twitterclient.py +1 -1
  346. {nltk-3.2.1 → nltk-3.3}/nltk/twitter/util.py +5 -4
  347. {nltk-3.2.1 → nltk-3.3}/nltk/util.py +41 -654
  348. {nltk-3.2.1 → nltk-3.3}/nltk/wsd.py +2 -2
  349. {nltk-3.2.1 → nltk-3.3/nltk.egg-info}/PKG-INFO +13 -5
  350. {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/SOURCES.txt +23 -1
  351. nltk-3.3/nltk.egg-info/requires.txt +31 -0
  352. {nltk-3.2.1 → nltk-3.3}/setup.cfg +0 -1
  353. {nltk-3.2.1 → nltk-3.3}/setup.py +32 -5
  354. nltk-3.2.1/nltk/VERSION +0 -1
  355. nltk-3.2.1/nltk/compat.py +0 -706
  356. nltk-3.2.1/nltk/corpus/reader/pl196x.py +0 -278
  357. nltk-3.2.1/nltk/corpus/reader/verbnet.py +0 -408
  358. nltk-3.2.1/nltk/corpus/reader/wordlist.py +0 -37
  359. nltk-3.2.1/nltk/six.py +0 -868
  360. nltk-3.2.1/nltk/stem/porter.py +0 -692
  361. nltk-3.2.1/nltk/test/unit/test_stem.py +0 -36
  362. nltk-3.2.1/nltk/test/unit/test_tokenize.py +0 -23
  363. nltk-3.2.1/nltk/test/unit/translate/test_bleu.py +0 -138
  364. nltk-3.2.1/nltk/tokenize/stanford_segmenter.py +0 -157
  365. nltk-3.2.1/nltk/tokenize/treebank.py +0 -124
  366. nltk-3.2.1/nltk/tokenize/util.py +0 -90
  367. {nltk-3.2.1 → nltk-3.3}/INSTALL.txt +0 -0
  368. {nltk-3.2.1 → nltk-3.3}/MANIFEST.in +0 -0
  369. {nltk-3.2.1 → nltk-3.3}/nltk/classify/positivenaivebayes.py +0 -0
  370. {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/udhr.py +0 -0
  371. {nltk-3.2.1 → nltk-3.3}/nltk/inference/mace.py +0 -0
  372. {nltk-3.2.1 → nltk-3.3}/nltk/lazyimport.py +0 -0
  373. {nltk-3.2.1 → nltk-3.3}/nltk/misc/babelfish.py +0 -0
  374. {nltk-3.2.1 → nltk-3.3}/nltk/tag/brill_trainer.py +0 -0
  375. {nltk-3.2.1 → nltk-3.3}/nltk/tbl/api.py +0 -0
  376. {nltk-3.2.1 → nltk-3.3}/nltk/test/bleu.doctest +0 -0
  377. {nltk-3.2.1 → nltk-3.3}/nltk/test/childes.doctest +0 -0
  378. {nltk-3.2.1 → nltk-3.3}/nltk/test/corpus_fixt.py +0 -0
  379. {nltk-3.2.1 → nltk-3.3}/nltk/test/paice.doctest +0 -0
  380. {nltk-3.2.1 → nltk-3.3}/nltk/test/portuguese_en_fixt.py +0 -0
  381. {nltk-3.2.1 → nltk-3.3}/nltk/test/segmentation_fixt.py +0 -0
  382. {nltk-3.2.1 → nltk-3.3}/nltk/test/semantics_fixt.py +0 -0
  383. {nltk-3.2.1 → nltk-3.3}/nltk/test/translate_fixt.py +0 -0
  384. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/__init__.py +0 -0
  385. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_2x_compat.py +0 -0
  386. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_corpus_views.py +0 -0
  387. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_hmm.py +0 -0
  388. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_naivebayes.py +0 -0
  389. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_seekable_unicode_stream_reader.py +0 -0
  390. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_tag.py +0 -0
  391. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_twitter_auth.py +0 -0
  392. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/__init__.py +0 -0
  393. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm1.py +0 -0
  394. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm2.py +0 -0
  395. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm3.py +0 -0
  396. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm4.py +0 -0
  397. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm5.py +0 -0
  398. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm_model.py +0 -0
  399. {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/utils.py +0 -0
  400. {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm3.py +0 -0
  401. {nltk-3.2.1 → nltk-3.3}/nltk/treetransforms.py +0 -0
  402. {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/dependency_links.txt +0 -0
  403. {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/not-zip-safe +0 -0
  404. {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/top_level.txt +0 -0
@@ -1,36 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from __future__ import print_function, unicode_literals
3
- import unittest
4
- from nltk.stem.snowball import SnowballStemmer
5
-
6
-
7
- class SnowballTest(unittest.TestCase):
8
-
9
- def test_russian(self):
10
- # Russian words both consisting of Cyrillic
11
- # and Roman letters can be stemmed.
12
- stemmer_russian = SnowballStemmer("russian")
13
- assert stemmer_russian.stem("авантненькая") == "авантненьк"
14
- assert stemmer_russian.stem("avenantnen'kai^a") == "avenantnen'k"
15
-
16
- def test_german(self):
17
- stemmer_german = SnowballStemmer("german")
18
- stemmer_german2 = SnowballStemmer("german", ignore_stopwords=True)
19
-
20
- assert stemmer_german.stem("Schr\xe4nke") == 'schrank'
21
- assert stemmer_german2.stem("Schr\xe4nke") == 'schrank'
22
-
23
- assert stemmer_german.stem("keinen") == 'kein'
24
- assert stemmer_german2.stem("keinen") == 'keinen'
25
-
26
- def test_spanish(self):
27
- stemmer = SnowballStemmer('spanish')
28
-
29
- assert stemmer.stem("Visionado") == 'vision'
30
-
31
- # The word 'algue' was raising an IndexError
32
- assert stemmer.stem("algue") == 'algu'
33
-
34
- def test_short_strings_bug(self):
35
- stemmer = SnowballStemmer('english')
36
- assert stemmer.stem("y's") == 'y'
@@ -1,23 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Unit tests for nltk.tokenize.
4
- See also nltk/test/tokenize.doctest
5
- """
6
-
7
- from __future__ import unicode_literals
8
- from nltk.tokenize import TweetTokenizer
9
- import unittest
10
-
11
- class TestTokenize(unittest.TestCase):
12
-
13
- def test_tweet_tokenizer(self):
14
- """
15
- Test TweetTokenizer using words with special and accented characters.
16
- """
17
-
18
- tokenizer = TweetTokenizer(strip_handles=True, reduce_len=True)
19
- s9 = "@myke: Let's test these words: resumé España München français"
20
- tokens = tokenizer.tokenize(s9)
21
- expected = [':', "Let's", 'test', 'these', 'words', ':', 'resumé',
22
- 'España', 'München', 'français']
23
- self.assertEqual(tokens, expected)
@@ -1,138 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Tests for BLEU translation evaluation metric
4
- """
5
-
6
- import unittest
7
- from nltk.translate.bleu_score import modified_precision, brevity_penalty
8
- from nltk.translate.bleu_score import sentence_bleu, corpus_bleu
9
-
10
-
11
- class TestBLEU(unittest.TestCase):
12
- def test_modified_precision(self):
13
- """
14
- Examples from the original BLEU paper
15
- http://www.aclweb.org/anthology/P02-1040.pdf
16
- """
17
- # Example 1: the "the*" example.
18
- # Reference sentences.
19
- ref1 = 'the cat is on the mat'.split()
20
- ref2 = 'there is a cat on the mat'.split()
21
- # Hypothesis sentence(s).
22
- hyp1 = 'the the the the the the the'.split()
23
-
24
- references = [ref1, ref2]
25
-
26
- # Testing modified unigram precision.
27
- hyp1_unigram_precision = float(modified_precision(references, hyp1, n=1))
28
- assert (round(hyp1_unigram_precision, 4) == 0.2857)
29
- # With assertAlmostEqual at 4 place precision.
30
- self.assertAlmostEqual(hyp1_unigram_precision, 0.28571428, places=4)
31
-
32
- # Testing modified bigram precision.
33
- assert(float(modified_precision(references, hyp1, n=2)) == 0.0)
34
-
35
-
36
- # Example 2: the "of the" example.
37
- # Reference sentences
38
- ref1 = str('It is a guide to action that ensures that the military '
39
- 'will forever heed Party commands').split()
40
- ref2 = str('It is the guiding principle which guarantees the military '
41
- 'forces always being under the command of the Party').split()
42
- ref3 = str('It is the practical guide for the army always to heed '
43
- 'the directions of the party').split()
44
- # Hypothesis sentence(s).
45
- hyp1 = 'of the'.split()
46
-
47
- references = [ref1, ref2, ref3]
48
- # Testing modified unigram precision.
49
- assert (float(modified_precision(references, hyp1, n=1)) == 1.0)
50
-
51
- # Testing modified bigram precision.
52
- assert(float(modified_precision(references, hyp1, n=2)) == 1.0)
53
-
54
-
55
- # Example 3: Proper MT outputs.
56
- hyp1 = str('It is a guide to action which ensures that the military '
57
- 'always obeys the commands of the party').split()
58
- hyp2 = str('It is to insure the troops forever hearing the activity '
59
- 'guidebook that party direct').split()
60
-
61
- references = [ref1, ref2, ref3]
62
-
63
- # Unigram precision.
64
- hyp1_unigram_precision = float(modified_precision(references, hyp1, n=1))
65
- hyp2_unigram_precision = float(modified_precision(references, hyp2, n=1))
66
- # Test unigram precision with assertAlmostEqual at 4 place precision.
67
- self.assertAlmostEqual(hyp1_unigram_precision, 0.94444444, places=4)
68
- self.assertAlmostEqual(hyp2_unigram_precision, 0.57142857, places=4)
69
- # Test unigram precision with rounding.
70
- assert (round(hyp1_unigram_precision, 4) == 0.9444)
71
- assert (round(hyp2_unigram_precision, 4) == 0.5714)
72
-
73
- # Bigram precision
74
- hyp1_bigram_precision = float(modified_precision(references, hyp1, n=2))
75
- hyp2_bigram_precision = float(modified_precision(references, hyp2, n=2))
76
- # Test bigram precision with assertAlmostEqual at 4 place precision.
77
- self.assertAlmostEqual(hyp1_bigram_precision, 0.58823529, places=4)
78
- self.assertAlmostEqual(hyp2_bigram_precision, 0.07692307, places=4)
79
- # Test bigram precision with rounding.
80
- assert (round(hyp1_bigram_precision, 4) == 0.5882)
81
- assert (round(hyp2_bigram_precision, 4) == 0.0769)
82
-
83
- def test_zero_matches(self):
84
- # Test case where there's 0 matches
85
- references = ['The candidate has no alignment to any of the references'.split()]
86
- hypothesis = 'John loves Mary'.split()
87
-
88
- # Test BLEU to nth order of n-grams, where n is len(hypothesis).
89
- for n in range(1,len(hypothesis)):
90
- weights = [1.0/n] * n # Uniform weights.
91
- assert(sentence_bleu(references, hypothesis, weights) == 0)
92
-
93
- def test_full_matches(self):
94
- # Test case where there's 100% matches
95
- references = ['John loves Mary'.split()]
96
- hypothesis = 'John loves Mary'.split()
97
-
98
- # Test BLEU to nth order of n-grams, where n is len(hypothesis).
99
- for n in range(1,len(hypothesis)):
100
- weights = [1.0/n] * n # Uniform weights.
101
- assert(sentence_bleu(references, hypothesis, weights) == 1.0)
102
-
103
- def test_partial_matches_hypothesis_longer_than_reference(self):
104
- references = ['John loves Mary'.split()]
105
- hypothesis = 'John loves Mary who loves Mike'.split()
106
- self.assertAlmostEqual(sentence_bleu(references, hypothesis), 0.4729, places=4)
107
-
108
-
109
- @unittest.skip("Skipping fringe cases for BLEU.")
110
- class TestBLEUFringeCases(unittest.TestCase):
111
-
112
- def test_case_where_n_is_bigger_than_hypothesis_length(self):
113
- # Test BLEU to nth order of n-grams, where n > len(hypothesis).
114
- # TODO: Currently this test breaks the BLEU implementation (13.03.2016)
115
- references = ['John loves Mary'.split()]
116
- hypothesis = 'John loves Mary'.split()
117
- n = len(hypothesis) + 1 #
118
- weights = [1.0/n] * n # Uniform weights.
119
- assert(sentence_bleu(references, hypothesis, weights) == 1.0)
120
-
121
- def test_empty_hypothesis(self):
122
- # Test case where there's hypothesis is empty.
123
- # TODO: Currently this test breaks the BLEU implementation (13.03.2016)
124
- references = ['The candidate has no alignment to any of the references'.split()]
125
- hypothesis = []
126
- assert(sentence_bleu(references, hypothesis) == 0)
127
-
128
- def test_empty_references(self):
129
- # Test case where there's reference is empty.
130
- # TODO: Currently this test breaks the BLEU implementation (13.03.2016)
131
- references = [[]]
132
- hypothesis = 'John loves Mary'.split()
133
- assert(sentence_bleu(references, hypothesis) == 0)
134
-
135
-
136
- def test_brevity_penalty(self):
137
- pass
138
-
@@ -1,157 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Natural Language Toolkit: Interface to the Stanford Chinese Segmenter
4
- #
5
- # Copyright (C) 2001-2016 NLTK Project
6
- # Author: 52nlp <52nlpcn@gmail.com>
7
- # Casper Lehmann-Strøm <casperlehmann@gmail.com>
8
- #
9
- # URL: <http://nltk.org/>
10
- # For license information, see LICENSE.TXT
11
-
12
- from __future__ import unicode_literals, print_function
13
-
14
- import tempfile
15
- import os
16
- import json
17
- from subprocess import PIPE
18
-
19
- from nltk import compat
20
- from nltk.internals import find_jar, config_java, java, _java_options
21
-
22
- from nltk.tokenize.api import TokenizerI
23
-
24
- _stanford_url = 'http://nlp.stanford.edu/software'
25
-
26
- class StanfordSegmenter(TokenizerI):
27
- r"""
28
- Interface to the Stanford Segmenter
29
- >>> from nltk.tokenize.stanford_segmenter import StanfordSegmenter
30
- >>> segmenter = StanfordSegmenter(
31
- ... path_to_jar="stanford-segmenter-3.6.0.jar",
32
- ... path_to_slf4j = "slf4j-api.jar"
33
- ... path_to_sihan_corpora_dict="./data",
34
- ... path_to_model="./data/pku.gz",
35
- ... path_to_dict="./data/dict-chris6.ser.gz")
36
- >>> sentence = u"这是斯坦福中文分词器测试"
37
- >>> segmenter.segment(sentence)
38
- >>> u'\u8fd9 \u662f \u65af\u5766\u798f \u4e2d\u6587 \u5206\u8bcd\u5668 \u6d4b\u8bd5\n'
39
- >>> segmenter.segment_file("test.simp.utf8")
40
- >>> u'\u9762\u5bf9 \u65b0 \u4e16\u7eaa \uff0c \u4e16\u754c \u5404\u56fd ...
41
- """
42
-
43
- _JAR = 'stanford-segmenter.jar'
44
- _SLF4J = 'slf4j-api.jar'
45
-
46
- def __init__(self, path_to_jar=None, path_to_slf4j=None,
47
- path_to_sihan_corpora_dict=None,
48
- path_to_model=None, path_to_dict=None,
49
- encoding='UTF-8', options=None,
50
- verbose=False, java_options='-mx2g'):
51
- stanford_segmenter = find_jar(
52
- self._JAR, path_to_jar,
53
- env_vars=('STANFORD_SEGMENTER',),
54
- searchpath=(), url=_stanford_url,
55
- verbose=verbose)
56
- slf4j = find_jar(
57
- self._SLF4J, path_to_slf4j,
58
- env_vars=('SLF4J',),
59
- searchpath=(), url=_stanford_url,
60
- verbose=verbose)
61
-
62
- # This is passed to java as the -cp option, the segmenter needs slf4j.
63
- self._stanford_jar = ':'.join(
64
- [_ for _ in [stanford_segmenter, slf4j] if not _ is None])
65
-
66
- self._sihan_corpora_dict = path_to_sihan_corpora_dict
67
- self._model = path_to_model
68
- self._dict = path_to_dict
69
-
70
- self._encoding = encoding
71
- self.java_options = java_options
72
- options = {} if options is None else options
73
- self._options_cmd = ','.join('{0}={1}'.format(key, json.dumps(val)) for key, val in options.items())
74
-
75
- def tokenize(self, s):
76
- super().tokenize(s)
77
-
78
- def segment_file(self, input_file_path):
79
- """
80
- """
81
- cmd = [
82
- 'edu.stanford.nlp.ie.crf.CRFClassifier',
83
- '-sighanCorporaDict', self._sihan_corpora_dict,
84
- '-textFile', input_file_path,
85
- '-sighanPostProcessing', 'true',
86
- '-keepAllWhitespaces', 'false',
87
- '-loadClassifier', self._model,
88
- '-serDictionary', self._dict
89
- ]
90
-
91
- stdout = self._execute(cmd)
92
-
93
- return stdout
94
-
95
- def segment(self, tokens):
96
- return self.segment_sents([tokens])
97
-
98
- def segment_sents(self, sentences):
99
- """
100
- """
101
- encoding = self._encoding
102
- # Create a temporary input file
103
- _input_fh, self._input_file_path = tempfile.mkstemp(text=True)
104
-
105
- # Write the actural sentences to the temporary input file
106
- _input_fh = os.fdopen(_input_fh, 'wb')
107
- _input = '\n'.join((' '.join(x) for x in sentences))
108
- if isinstance(_input, compat.text_type) and encoding:
109
- _input = _input.encode(encoding)
110
- _input_fh.write(_input)
111
- _input_fh.close()
112
-
113
- cmd = [
114
- 'edu.stanford.nlp.ie.crf.CRFClassifier',
115
- '-sighanCorporaDict', self._sihan_corpora_dict,
116
- '-textFile', self._input_file_path,
117
- '-sighanPostProcessing', 'true',
118
- '-keepAllWhitespaces', 'false',
119
- '-loadClassifier', self._model,
120
- '-serDictionary', self._dict
121
- ]
122
-
123
- stdout = self._execute(cmd)
124
-
125
- # Delete the temporary file
126
- os.unlink(self._input_file_path)
127
-
128
- return stdout
129
-
130
- def _execute(self, cmd, verbose=False):
131
- encoding = self._encoding
132
- cmd.extend(['-inputEncoding', encoding])
133
- _options_cmd = self._options_cmd
134
- if _options_cmd:
135
- cmd.extend(['-options', self._options_cmd])
136
-
137
- default_options = ' '.join(_java_options)
138
-
139
- # Configure java.
140
- config_java(options=self.java_options, verbose=verbose)
141
-
142
- stdout, _stderr = java(
143
- cmd,classpath=self._stanford_jar, stdout=PIPE, stderr=PIPE)
144
- stdout = stdout.decode(encoding)
145
-
146
- # Return java configurations to their default values.
147
- config_java(options=default_options, verbose=False)
148
-
149
- return stdout
150
-
151
- def setup_module(module):
152
- from nose import SkipTest
153
-
154
- try:
155
- StanfordSegmenter()
156
- except LookupError:
157
- raise SkipTest('doctests from nltk.tokenize.stanford_segmenter are skipped because the stanford segmenter jar doesn\'t exist')
@@ -1,124 +0,0 @@
1
- # Natural Language Toolkit: Tokenizers
2
- #
3
- # Copyright (C) 2001-2016 NLTK Project
4
- # Author: Edward Loper <edloper@gmail.com>
5
- # Michael Heilman <mheilman@cmu.edu> (re-port from http://www.cis.upenn.edu/~treebank/tokenizer.sed)
6
- #
7
- # URL: <http://nltk.sourceforge.net>
8
- # For license information, see LICENSE.TXT
9
-
10
- r"""
11
-
12
- Penn Treebank Tokenizer
13
-
14
- The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank.
15
- This implementation is a port of the tokenizer sed script written by Robert McIntyre
16
- and available at http://www.cis.upenn.edu/~treebank/tokenizer.sed.
17
- """
18
-
19
- import re
20
- from nltk.tokenize.api import TokenizerI
21
-
22
-
23
- class TreebankWordTokenizer(TokenizerI):
24
- """
25
- The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank.
26
- This is the method that is invoked by ``word_tokenize()``. It assumes that the
27
- text has already been segmented into sentences, e.g. using ``sent_tokenize()``.
28
-
29
- This tokenizer performs the following steps:
30
-
31
- - split standard contractions, e.g. ``don't`` -> ``do n't`` and ``they'll`` -> ``they 'll``
32
- - treat most punctuation characters as separate tokens
33
- - split off commas and single quotes, when followed by whitespace
34
- - separate periods that appear at the end of line
35
-
36
- >>> from nltk.tokenize import TreebankWordTokenizer
37
- >>> s = '''Good muffins cost $3.88\\nin New York. Please buy me\\ntwo of them.\\nThanks.'''
38
- >>> TreebankWordTokenizer().tokenize(s)
39
- ['Good', 'muffins', 'cost', '$', '3.88', 'in', 'New', 'York.', 'Please', 'buy', 'me', 'two', 'of', 'them.', 'Thanks', '.']
40
- >>> s = "They'll save and invest more."
41
- >>> TreebankWordTokenizer().tokenize(s)
42
- ['They', "'ll", 'save', 'and', 'invest', 'more', '.']
43
- >>> s = "hi, my name can't hello,"
44
- >>> TreebankWordTokenizer().tokenize(s)
45
- ['hi', ',', 'my', 'name', 'ca', "n't", 'hello', ',']
46
- """
47
-
48
- #starting quotes
49
- STARTING_QUOTES = [
50
- (re.compile(r'^\"'), r'``'),
51
- (re.compile(r'(``)'), r' \1 '),
52
- (re.compile(r'([ (\[{<])"'), r'\1 `` '),
53
- ]
54
-
55
- #punctuation
56
- PUNCTUATION = [
57
- (re.compile(r'([:,])([^\d])'), r' \1 \2'),
58
- (re.compile(r'([:,])$'), r' \1 '),
59
- (re.compile(r'\.\.\.'), r' ... '),
60
- (re.compile(r'[;@#$%&]'), r' \g<0> '),
61
- (re.compile(r'([^\.])(\.)([\]\)}>"\']*)\s*$'), r'\1 \2\3 '),
62
- (re.compile(r'[?!]'), r' \g<0> '),
63
-
64
- (re.compile(r"([^'])' "), r"\1 ' "),
65
- ]
66
-
67
- #parens, brackets, etc.
68
- PARENS_BRACKETS = [
69
- (re.compile(r'[\]\[\(\)\{\}\<\>]'), r' \g<0> '),
70
- (re.compile(r'--'), r' -- '),
71
- ]
72
-
73
- #ending quotes
74
- ENDING_QUOTES = [
75
- (re.compile(r'"'), " '' "),
76
- (re.compile(r'(\S)(\'\')'), r'\1 \2 '),
77
-
78
- (re.compile(r"([^' ])('[sS]|'[mM]|'[dD]|') "), r"\1 \2 "),
79
- (re.compile(r"([^' ])('ll|'LL|'re|'RE|'ve|'VE|n't|N'T) "), r"\1 \2 "),
80
- ]
81
-
82
- # List of contractions adapted from Robert MacIntyre's tokenizer.
83
- CONTRACTIONS2 = [re.compile(r"(?i)\b(can)(not)\b"),
84
- re.compile(r"(?i)\b(d)('ye)\b"),
85
- re.compile(r"(?i)\b(gim)(me)\b"),
86
- re.compile(r"(?i)\b(gon)(na)\b"),
87
- re.compile(r"(?i)\b(got)(ta)\b"),
88
- re.compile(r"(?i)\b(lem)(me)\b"),
89
- re.compile(r"(?i)\b(mor)('n)\b"),
90
- re.compile(r"(?i)\b(wan)(na) ")]
91
- CONTRACTIONS3 = [re.compile(r"(?i) ('t)(is)\b"),
92
- re.compile(r"(?i) ('t)(was)\b")]
93
- CONTRACTIONS4 = [re.compile(r"(?i)\b(whad)(dd)(ya)\b"),
94
- re.compile(r"(?i)\b(wha)(t)(cha)\b")]
95
-
96
- def tokenize(self, text):
97
- for regexp, substitution in self.STARTING_QUOTES:
98
- text = regexp.sub(substitution, text)
99
-
100
- for regexp, substitution in self.PUNCTUATION:
101
- text = regexp.sub(substitution, text)
102
-
103
- for regexp, substitution in self.PARENS_BRACKETS:
104
- text = regexp.sub(substitution, text)
105
-
106
- #add extra space to make things easier
107
- text = " " + text + " "
108
-
109
- for regexp, substitution in self.ENDING_QUOTES:
110
- text = regexp.sub(substitution, text)
111
-
112
- for regexp in self.CONTRACTIONS2:
113
- text = regexp.sub(r' \1 \2 ', text)
114
- for regexp in self.CONTRACTIONS3:
115
- text = regexp.sub(r' \1 \2 ', text)
116
-
117
- # We are not using CONTRACTIONS4 since
118
- # they are also commented out in the SED scripts
119
- # for regexp in self.CONTRACTIONS4:
120
- # text = regexp.sub(r' \1 \2 \3 ', text)
121
-
122
- return text.split()
123
-
124
-
@@ -1,90 +0,0 @@
1
- # Natural Language Toolkit: Tokenizer Utilities
2
- #
3
- # Copyright (C) 2001-2016 NLTK Project
4
- # Author: Steven Bird <stevenbird1@gmail.com>
5
- # URL: <http://nltk.sourceforge.net>
6
- # For license information, see LICENSE.TXT
7
-
8
- from re import finditer
9
-
10
- def string_span_tokenize(s, sep):
11
- r"""
12
- Return the offsets of the tokens in *s*, as a sequence of ``(start, end)``
13
- tuples, by splitting the string at each occurrence of *sep*.
14
-
15
- >>> from nltk.tokenize.util import string_span_tokenize
16
- >>> s = '''Good muffins cost $3.88\nin New York. Please buy me
17
- ... two of them.\n\nThanks.'''
18
- >>> list(string_span_tokenize(s, " "))
19
- [(0, 4), (5, 12), (13, 17), (18, 26), (27, 30), (31, 36), (37, 37),
20
- (38, 44), (45, 48), (49, 55), (56, 58), (59, 73)]
21
-
22
- :param s: the string to be tokenized
23
- :type s: str
24
- :param sep: the token separator
25
- :type sep: str
26
- :rtype: iter(tuple(int, int))
27
- """
28
- if len(sep) == 0:
29
- raise ValueError("Token delimiter must not be empty")
30
- left = 0
31
- while True:
32
- try:
33
- right = s.index(sep, left)
34
- if right != 0:
35
- yield left, right
36
- except ValueError:
37
- if left != len(s):
38
- yield left, len(s)
39
- break
40
-
41
- left = right + len(sep)
42
-
43
- def regexp_span_tokenize(s, regexp):
44
- r"""
45
- Return the offsets of the tokens in *s*, as a sequence of ``(start, end)``
46
- tuples, by splitting the string at each successive match of *regexp*.
47
-
48
- >>> from nltk.tokenize.util import regexp_span_tokenize
49
- >>> s = '''Good muffins cost $3.88\nin New York. Please buy me
50
- ... two of them.\n\nThanks.'''
51
- >>> list(regexp_span_tokenize(s, r'\s'))
52
- [(0, 4), (5, 12), (13, 17), (18, 23), (24, 26), (27, 30), (31, 36),
53
- (38, 44), (45, 48), (49, 51), (52, 55), (56, 58), (59, 64), (66, 73)]
54
-
55
- :param s: the string to be tokenized
56
- :type s: str
57
- :param regexp: regular expression that matches token separators (must not be empty)
58
- :type regexp: str
59
- :rtype: iter(tuple(int, int))
60
- """
61
- left = 0
62
- for m in finditer(regexp, s):
63
- right, next = m.span()
64
- if right != left:
65
- yield left, right
66
- left = next
67
- yield left, len(s)
68
-
69
- def spans_to_relative(spans):
70
- r"""
71
- Return a sequence of relative spans, given a sequence of spans.
72
-
73
- >>> from nltk.tokenize import WhitespaceTokenizer
74
- >>> from nltk.tokenize.util import spans_to_relative
75
- >>> s = '''Good muffins cost $3.88\nin New York. Please buy me
76
- ... two of them.\n\nThanks.'''
77
- >>> list(spans_to_relative(WhitespaceTokenizer().span_tokenize(s)))
78
- [(0, 4), (1, 7), (1, 4), (1, 5), (1, 2), (1, 3), (1, 5), (2, 6),
79
- (1, 3), (1, 2), (1, 3), (1, 2), (1, 5), (2, 7)]
80
-
81
- :param spans: a sequence of (start, end) offsets of the tokens
82
- :type spans: iter(tuple(int, int))
83
- :rtype: iter(tuple(int, int))
84
- """
85
- prev = 0
86
- for left, right in spans:
87
- yield left - prev, right - left
88
- prev = right
89
-
90
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes