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,6 +1,6 @@
1
1
  # Natural Language Toolkit: Decision Tree Classifiers
2
2
  #
3
- # Copyright (C) 2001-2016 NLTK Project
3
+ # Copyright (C) 2001-2018 NLTK Project
4
4
  # Author: Edward Loper <edloper@gmail.com>
5
5
  # URL: <http://nltk.org/>
6
6
  # For license information, see LICENSE.TXT
@@ -81,17 +81,17 @@ class DecisionTreeClassifier(ClassifierI):
81
81
  # [xx] display default!!
82
82
  if self._fname is None:
83
83
  n = width-len(prefix)-15
84
- return '%s%s %s\n' % (prefix, '.'*n, self._label)
84
+ return '{0}{1} {2}\n'.format(prefix, '.'*n, self._label)
85
85
  s = ''
86
86
  for i, (fval, result) in enumerate(sorted(self._decisions.items())):
87
- hdr = '%s%s=%s? ' % (prefix, self._fname, fval)
87
+ hdr = '{0}{1}={2}? '.format(prefix, self._fname, fval)
88
88
  n = width-15-len(hdr)
89
- s += '%s%s %s\n' % (hdr, '.'*(n), result._label)
89
+ s += '{0}{1} {2}\n'.format(hdr, '.'*(n), result._label)
90
90
  if result._fname is not None and depth>1:
91
91
  s += result.pretty_format(width, prefix+' ', depth-1)
92
92
  if self._default is not None:
93
93
  n = width-len(prefix)-21
94
- s += '%selse: %s %s\n' % (prefix, '.'*n, self._default._label)
94
+ s += '{0}else: {1} {2}\n'.format(prefix, '.'*n, self._default._label)
95
95
  if self._default._fname is not None and depth>1:
96
96
  s += self._default.pretty_format(width, prefix+' ', depth-1)
97
97
  return s
@@ -103,24 +103,24 @@ class DecisionTreeClassifier(ClassifierI):
103
103
  if statements.
104
104
  """
105
105
  if self._fname is None:
106
- return "%sreturn %r\n" % (prefix, self._label)
106
+ return "{0}return {1!r}\n".format(prefix, self._label)
107
107
  s = ''
108
108
  for (fval, result) in sorted(self._decisions.items()):
109
- s += '%sif %s == %r: ' % (prefix, self._fname, fval)
109
+ s += '{0}if {1} == {2!r}: '.format(prefix, self._fname, fval)
110
110
  if result._fname is not None and depth>1:
111
111
  s += '\n'+result.pseudocode(prefix+' ', depth-1)
112
112
  else:
113
- s += 'return %r\n' % result._label
113
+ s += 'return {0!r}\n'.format(result._label)
114
114
  if self._default is not None:
115
115
  if len(self._decisions) == 1:
116
- s += '%sif %s != %r: '% (prefix, self._fname,
116
+ s += '{0}if {1} != {2!r}: '.format(prefix, self._fname,
117
117
  list(self._decisions.keys())[0])
118
118
  else:
119
- s += '%selse: ' % (prefix,)
119
+ s += '{0}else: '.format(prefix)
120
120
  if self._default._fname is not None and depth>1:
121
121
  s += '\n'+self._default.pseudocode(prefix+' ', depth-1)
122
122
  else:
123
- s += 'return %r\n' % self._default._label
123
+ s += 'return {0!r}\n'.format(self._default._label)
124
124
  return s
125
125
 
126
126
  def __str__(self):
@@ -224,7 +224,7 @@ class DecisionTreeClassifier(ClassifierI):
224
224
  best_error = stump_error
225
225
  best_stump = stump
226
226
  if verbose:
227
- print(('best stump for %6d toks uses %-20s err=%6.4f' %
227
+ print(('best stump for {:6d} toks uses {:20} err={:6.4f}'.format \
228
228
  (len(labeled_featuresets), best_stump._fname, best_error)))
229
229
  return best_stump
230
230
 
@@ -266,13 +266,13 @@ class DecisionTreeClassifier(ClassifierI):
266
266
  if stump_error < best_error:
267
267
  best_error = stump_error
268
268
  best_stump = stump
269
- if best_stump._decisions:
270
- descr = '%s=%s' % (best_stump._fname,
271
- list(best_stump._decisions.keys())[0])
272
- else:
273
- descr = '(default)'
274
269
  if verbose:
275
- print(('best stump for %6d toks uses %-20s err=%6.4f' %
270
+ if best_stump._decisions:
271
+ descr = '{0}={1}'.format(best_stump._fname,
272
+ list(best_stump._decisions.keys())[0])
273
+ else:
274
+ descr = '(default)'
275
+ print(('best stump for {:6d} toks uses {:20} err={:6.4f}'.format \
276
276
  (len(labeled_featuresets), descr, best_error)))
277
277
  return best_stump
278
278
 
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: Maximum Entropy Classifiers
2
2
  #
3
- # Copyright (C) 2001-2016 NLTK Project
3
+ # Copyright (C) 2001-2018 NLTK Project
4
4
  # Author: Edward Loper <edloper@gmail.com>
5
5
  # Dmitry Chichkov <dchichkov@gmail.com> (TypedMaxentFeatureEncoding)
6
6
  # URL: <http://nltk.org/>
@@ -52,7 +52,6 @@ performed by classes that implement the ``MaxentFeatureEncodingI``
52
52
  interface.
53
53
  """
54
54
  from __future__ import print_function, unicode_literals
55
- __docformat__ = 'epytext en'
56
55
 
57
56
  try:
58
57
  import numpy
@@ -61,8 +60,11 @@ except ImportError:
61
60
 
62
61
  import tempfile
63
62
  import os
63
+ import re
64
64
  from collections import defaultdict
65
65
 
66
+ from six import integer_types
67
+
66
68
  from nltk import compat
67
69
  from nltk.data import gzip_open_unicode
68
70
  from nltk.util import OrderedDict
@@ -74,6 +76,8 @@ from nltk.classify.megam import (call_megam,
74
76
  write_megam_file, parse_megam_weights)
75
77
  from nltk.classify.tadm import call_tadm, write_tadm_file, parse_tadm_weights
76
78
 
79
+ __docformat__ = 'epytext en'
80
+
77
81
  ######################################################################
78
82
  #{ Classifier Model
79
83
  ######################################################################
@@ -200,13 +204,27 @@ class MaxentClassifier(ClassifierI):
200
204
  print(' PROBS:'.ljust(descr_width)+''.join(
201
205
  '%8.3f' % pdist.prob(l) for l in labels))
202
206
 
207
+ def most_informative_features(self, n=10):
208
+ """
209
+ Generates the ranked list of informative features from most to least.
210
+ """
211
+ if hasattr(self, '_most_informative_features'):
212
+ return self._most_informative_features[:n]
213
+ else:
214
+ self._most_informative_features = sorted(list(range(len(self._weights))),
215
+ key=lambda fid: abs(self._weights[fid]),
216
+ reverse=True)
217
+ return self._most_informative_features[:n]
218
+
203
219
  def show_most_informative_features(self, n=10, show='all'):
204
220
  """
205
221
  :param show: all, neg, or pos (for negative-only or positive-only)
222
+ :type show: str
223
+ :param n: The no. of top features
224
+ :type n: int
206
225
  """
207
- fids = sorted(list(range(len(self._weights))),
208
- key=lambda fid: abs(self._weights[fid]),
209
- reverse=True)
226
+ # Use None the full list of ranked features.
227
+ fids = self.most_informative_features(None)
210
228
  if show == 'pos':
211
229
  fids = [fid for fid in fids if self._weights[fid] > 0]
212
230
  elif show == 'neg':
@@ -547,7 +565,7 @@ class BinaryMaxentFeatureEncoding(MaxentFeatureEncodingI):
547
565
 
548
566
  def describe(self, f_id):
549
567
  # Inherit docs.
550
- if not isinstance(f_id, compat.integer_types):
568
+ if not isinstance(f_id, integer_types):
551
569
  raise TypeError('describe() expected an int')
552
570
  try:
553
571
  self._inv_mapping
@@ -854,7 +872,7 @@ class TypedMaxentFeatureEncoding(MaxentFeatureEncodingI):
854
872
 
855
873
  # Convert input-features to joint-features:
856
874
  for fname, fval in featureset.items():
857
- if isinstance(fval, (compat.integer_types, float)):
875
+ if isinstance(fval, (integer_types, float)):
858
876
  # Known feature name & value:
859
877
  if (fname, type(fval), label) in self._mapping:
860
878
  encoding.append((self._mapping[fname, type(fval),
@@ -884,7 +902,7 @@ class TypedMaxentFeatureEncoding(MaxentFeatureEncodingI):
884
902
 
885
903
  def describe(self, f_id):
886
904
  # Inherit docs.
887
- if not isinstance(f_id, compat.integer_types):
905
+ if not isinstance(f_id, integer_types):
888
906
  raise TypeError('describe() expected an int')
889
907
  try:
890
908
  self._inv_mapping
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: Interface to Megam Classifier
2
2
  #
3
- # Copyright (C) 2001-2016 NLTK Project
3
+ # Copyright (C) 2001-2018 NLTK Project
4
4
  # Author: Edward Loper <edloper@gmail.com>
5
5
  # URL: <http://nltk.org/>
6
6
  # For license information, see LICENSE.TXT
@@ -26,6 +26,8 @@ from __future__ import print_function
26
26
 
27
27
  import subprocess
28
28
 
29
+ from six import string_types
30
+
29
31
  from nltk import compat
30
32
  from nltk.internals import find_binary
31
33
  try:
@@ -155,7 +157,7 @@ def call_megam(args):
155
157
  """
156
158
  Call the ``megam`` binary with the given arguments.
157
159
  """
158
- if isinstance(args, compat.string_types):
160
+ if isinstance(args, string_types):
159
161
  raise TypeError('args should be a list of strings')
160
162
  if _megam_bin is None:
161
163
  config_megam()
@@ -171,8 +173,7 @@ def call_megam(args):
171
173
  print(stderr)
172
174
  raise OSError('megam command failed!')
173
175
 
174
- if isinstance(stdout, compat.string_types):
176
+ if isinstance(stdout, string_types):
175
177
  return stdout
176
178
  else:
177
179
  return stdout.decode('utf-8')
178
-
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: Naive Bayes Classifiers
2
2
  #
3
- # Copyright (C) 2001-2016 NLTK Project
3
+ # Copyright (C) 2001-2018 NLTK Project
4
4
  # Author: Edward Loper <edloper@gmail.com>
5
5
  # URL: <http://nltk.org/>
6
6
  # For license information, see LICENSE.TXT
@@ -21,8 +21,8 @@ independent, given the label:
21
21
  | P(label|features) = --------------------------------------------
22
22
  | P(features)
23
23
 
24
- Rather than computing P(featues) explicitly, the algorithm just
25
- calculates the denominator for each label, and normalizes them so they
24
+ Rather than computing P(features) explicitly, the algorithm just
25
+ calculates the numerator for each label, and normalizes them so they
26
26
  sum to one:
27
27
 
28
28
  | P(label) * P(f1|label) * ... * P(fn|label)
@@ -154,29 +154,32 @@ class NaiveBayesClassifier(ClassifierI):
154
154
 
155
155
  | max[ P(fname=fval|label1) / P(fname=fval|label2) ]
156
156
  """
157
- # The set of (fname, fval) pairs used by this classifier.
158
- features = set()
159
- # The max & min probability associated w/ each (fname, fval)
160
- # pair. Maps (fname,fval) -> float.
161
- maxprob = defaultdict(lambda: 0.0)
162
- minprob = defaultdict(lambda: 1.0)
163
-
164
- for (label, fname), probdist in self._feature_probdist.items():
165
- for fval in probdist.samples():
166
- feature = (fname, fval)
167
- features.add(feature)
168
- p = probdist.prob(fval)
169
- maxprob[feature] = max(p, maxprob[feature])
170
- minprob[feature] = min(p, minprob[feature])
171
- if minprob[feature] == 0:
172
- features.discard(feature)
173
-
174
- # Convert features to a list, & sort it by how informative
175
- # features are.
176
- features = sorted(features,
177
- key=lambda feature_:
178
- minprob[feature_]/maxprob[feature_])
179
- return features[:n]
157
+ if hasattr(self, '_most_informative_features'):
158
+ return self._most_informative_features[:n]
159
+ else:
160
+ # The set of (fname, fval) pairs used by this classifier.
161
+ features = set()
162
+ # The max & min probability associated w/ each (fname, fval)
163
+ # pair. Maps (fname,fval) -> float.
164
+ maxprob = defaultdict(lambda: 0.0)
165
+ minprob = defaultdict(lambda: 1.0)
166
+
167
+ for (label, fname), probdist in self._feature_probdist.items():
168
+ for fval in probdist.samples():
169
+ feature = (fname, fval)
170
+ features.add(feature)
171
+ p = probdist.prob(fval)
172
+ maxprob[feature] = max(p, maxprob[feature])
173
+ minprob[feature] = min(p, minprob[feature])
174
+ if minprob[feature] == 0:
175
+ features.discard(feature)
176
+
177
+ # Convert features to a list, & sort it by how informative
178
+ # features are.
179
+ self._most_informative_features = sorted(features,
180
+ key=lambda feature_:
181
+ minprob[feature_]/maxprob[feature_])
182
+ return self._most_informative_features[:n]
180
183
 
181
184
  @classmethod
182
185
  def train(cls, labeled_featuresets, estimator=ELEProbDist):
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: RTE Classifier
2
2
  #
3
- # Copyright (C) 2001-2016 NLTK Project
3
+ # Copyright (C) 2001-2018 NLTK Project
4
4
  # Author: Ewan Klein <ewan@inf.ed.ac.uk>
5
5
  # URL: <http://nltk.org/>
6
6
  # For license information, see LICENSE.TXT
@@ -18,35 +18,16 @@ TO DO: add lemmatization
18
18
  """
19
19
  from __future__ import print_function
20
20
 
21
- import nltk
22
- from nltk.classify.util import accuracy
23
-
24
- def ne(token):
25
- """
26
- This just assumes that words in all caps or titles are
27
- named entities.
28
-
29
- :type token: str
30
- """
31
- if token.istitle() or token.isupper():
32
- return True
33
- return False
34
-
35
- def lemmatize(word):
36
- """
37
- Use morphy from WordNet to find the base form of verbs.
38
- """
39
- lemma = nltk.corpus.wordnet.morphy(word, pos=nltk.corpus.wordnet.VERB)
40
- if lemma is not None:
41
- return lemma
42
- return word
21
+ from nltk.tokenize import RegexpTokenizer
22
+ from nltk.classify.util import accuracy, check_megam_config
23
+ from nltk.classify.maxent import MaxentClassifier
43
24
 
44
25
  class RTEFeatureExtractor(object):
45
26
  """
46
27
  This builds a bag of words for both the text and the hypothesis after
47
28
  throwing away some stopwords, then calculates overlap and difference.
48
29
  """
49
- def __init__(self, rtepair, stop=True, lemmatize=False):
30
+ def __init__(self, rtepair, stop=True, use_lemmatize=False):
50
31
  """
51
32
  :param rtepair: a ``RTEPair`` from which features should be extracted
52
33
  :param stop: if ``True``, stopwords are thrown away.
@@ -58,10 +39,9 @@ class RTEFeatureExtractor(object):
58
39
 
59
40
  self.negwords = set(['no', 'not', 'never', 'failed', 'rejected',
60
41
  'denied'])
61
- # Try to tokenize so that abbreviations like U.S.and monetary amounts
62
- # like "$23.00" are kept as tokens.
63
- from nltk.tokenize import RegexpTokenizer
64
- tokenizer = RegexpTokenizer('([A-Z]\.)+|\w+|\$[\d\.]+')
42
+ # Try to tokenize so that abbreviations, monetary amounts, email
43
+ # addresses, URLs are single tokens.
44
+ tokenizer = RegexpTokenizer('[\w.@:/]+|\w+|\$[\d.]+')
65
45
 
66
46
  #Get the set of word types for text and hypothesis
67
47
  self.text_tokens = tokenizer.tokenize(rtepair.text)
@@ -69,9 +49,9 @@ class RTEFeatureExtractor(object):
69
49
  self.text_words = set(self.text_tokens)
70
50
  self.hyp_words = set(self.hyp_tokens)
71
51
 
72
- if lemmatize:
73
- self.text_words = set(lemmatize(token) for token in self.text_tokens)
74
- self.hyp_words = set(lemmatize(token) for token in self.hyp_tokens)
52
+ if use_lemmatize:
53
+ self.text_words = set(self._lemmatize(token) for token in self.text_tokens)
54
+ self.hyp_words = set(self._lemmatize(token) for token in self.hyp_tokens)
75
55
 
76
56
  if self.stop:
77
57
  self.text_words = self.text_words - self.stopwords
@@ -89,7 +69,7 @@ class RTEFeatureExtractor(object):
89
69
  :param toktype: distinguish Named Entities from ordinary words
90
70
  :type toktype: 'ne' or 'word'
91
71
  """
92
- ne_overlap = set(token for token in self._overlap if ne(token))
72
+ ne_overlap = set(token for token in self._overlap if self._ne(token))
93
73
  if toktype == 'ne':
94
74
  if debug:
95
75
  print("ne overlap", ne_overlap)
@@ -108,7 +88,7 @@ class RTEFeatureExtractor(object):
108
88
  :param toktype: distinguish Named Entities from ordinary words
109
89
  :type toktype: 'ne' or 'word'
110
90
  """
111
- ne_extra = set(token for token in self._hyp_extra if ne(token))
91
+ ne_extra = set(token for token in self._hyp_extra if self._ne(token))
112
92
  if toktype == 'ne':
113
93
  return ne_extra
114
94
  elif toktype == 'word':
@@ -116,6 +96,28 @@ class RTEFeatureExtractor(object):
116
96
  else:
117
97
  raise ValueError("Type not recognized: '%s'" % toktype)
118
98
 
99
+ @staticmethod
100
+ def _ne(token):
101
+ """
102
+ This just assumes that words in all caps or titles are
103
+ named entities.
104
+
105
+ :type token: str
106
+ """
107
+ if token.istitle() or token.isupper():
108
+ return True
109
+ return False
110
+
111
+ @staticmethod
112
+ def _lemmatize(word):
113
+ """
114
+ Use morphy from WordNet to find the base form of verbs.
115
+ """
116
+ lemma = nltk.corpus.wordnet.morphy(word, pos=nltk.corpus.wordnet.VERB)
117
+ if lemma is not None:
118
+ return lemma
119
+ return word
120
+
119
121
 
120
122
  def rte_features(rtepair):
121
123
  extractor = RTEFeatureExtractor(rtepair)
@@ -130,62 +132,29 @@ def rte_features(rtepair):
130
132
  return features
131
133
 
132
134
 
133
- def rte_classifier(trainer, features=rte_features):
134
- """
135
- Classify RTEPairs
136
- """
137
- train = ((pair, pair.value) for pair in
138
- nltk.corpus.rte.pairs(['rte1_dev.xml', 'rte2_dev.xml',
139
- 'rte3_dev.xml']))
140
- test = ((pair, pair.value) for pair in
141
- nltk.corpus.rte.pairs(['rte1_test.xml', 'rte2_test.xml',
142
- 'rte3_test.xml']))
143
-
144
- # Train up a classifier.
145
- print('Training classifier...')
146
- classifier = trainer([(features(pair), label) for (pair, label) in train])
135
+ def rte_featurize(rte_pairs):
136
+ return [(rte_features(pair), pair.value) for pair in rte_pairs]
147
137
 
148
- # Run the classifier on the test data.
138
+
139
+ def rte_classifier(algorithm):
140
+ from nltk.corpus import rte as rte_corpus
141
+ train_set = rte_corpus.pairs(['rte1_dev.xml', 'rte2_dev.xml', 'rte3_dev.xml'])
142
+ test_set = rte_corpus.pairs(['rte1_test.xml', 'rte2_test.xml', 'rte3_test.xml'])
143
+ featurized_train_set = rte_featurize(train_set)
144
+ featurized_test_set = rte_featurize(test_set)
145
+ # Train the classifier
146
+ print('Training classifier...')
147
+ if algorithm in ['megam', 'BFGS']: # MEGAM based algorithms.
148
+ # Ensure that MEGAM is configured first.
149
+ check_megam_config()
150
+ clf = lambda x: MaxentClassifier.train(featurized_train_set, algorithm)
151
+ elif algorithm in ['GIS', 'IIS']: # Use default GIS/IIS MaxEnt algorithm
152
+ clf = MaxentClassifier.train(featurized_train_set, algorithm)
153
+ else:
154
+ err_msg = str("RTEClassifier only supports these algorithms:\n "
155
+ "'megam', 'BFGS', 'GIS', 'IIS'.\n")
156
+ raise Exception(err_msg)
149
157
  print('Testing classifier...')
150
- acc = accuracy(classifier, [(features(pair), label)
151
- for (pair, label) in test])
158
+ acc = accuracy(clf, featurized_test_set)
152
159
  print('Accuracy: %6.4f' % acc)
153
-
154
- # Return the classifier
155
- return classifier
156
-
157
-
158
- def demo_features():
159
- pairs = nltk.corpus.rte.pairs(['rte1_dev.xml'])[:6]
160
- for pair in pairs:
161
- print()
162
- for key in sorted(rte_features(pair)):
163
- print("%-15s => %s" % (key, rte_features(pair)[key]))
164
-
165
-
166
- def demo_feature_extractor():
167
- rtepair = nltk.corpus.rte.pairs(['rte3_dev.xml'])[33]
168
- extractor = RTEFeatureExtractor(rtepair)
169
- print(extractor.hyp_words)
170
- print(extractor.overlap('word'))
171
- print(extractor.overlap('ne'))
172
- print(extractor.hyp_extra('word'))
173
-
174
-
175
- def demo():
176
- import nltk
177
- try:
178
- nltk.config_megam('/usr/local/bin/megam')
179
- trainer = lambda x: nltk.MaxentClassifier.train(x, 'megam')
180
- except ValueError:
181
- try:
182
- trainer = lambda x: nltk.MaxentClassifier.train(x, 'BFGS')
183
- except ValueError:
184
- trainer = nltk.MaxentClassifier.train
185
- nltk.classify.rte_classifier(trainer)
186
-
187
- if __name__ == '__main__':
188
- demo_features()
189
- demo_feature_extractor()
190
- demo()
191
-
160
+ return clf
@@ -8,7 +8,7 @@ scikit-learn (http://scikit-learn.org) is a machine learning library for
8
8
  Python. It supports many classification algorithms, including SVMs,
9
9
  Naive Bayes, logistic regression (MaxEnt) and decision trees.
10
10
 
11
- This package implement a wrapper around scikit-learn classifiers. To use this
11
+ This package implements a wrapper around scikit-learn classifiers. To use this
12
12
  wrapper, construct a scikit-learn estimator object, then use that to construct
13
13
  a SklearnClassifier. E.g., to wrap a linear SVM with default settings:
14
14
 
@@ -32,6 +32,8 @@ best 1000 features:
32
32
  """
33
33
  from __future__ import print_function, unicode_literals
34
34
 
35
+ from six.moves import zip
36
+
35
37
  from nltk.classify.api import ClassifierI
36
38
  from nltk.probability import DictionaryProbDist
37
39
  from nltk import compat
@@ -111,7 +113,7 @@ class SklearnClassifier(ClassifierI):
111
113
  numbers, booleans or strings.
112
114
  """
113
115
 
114
- X, y = list(compat.izip(*labeled_featuresets))
116
+ X, y = list(zip(*labeled_featuresets))
115
117
  X = self._vectorizer.fit_transform(X)
116
118
  y = self._encoder.fit_transform(y)
117
119
  self._clf.fit(X, y)
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # Natural Language Toolkit: Senna Interface
3
3
  #
4
- # Copyright (C) 2001-2016 NLTK Project
4
+ # Copyright (C) 2001-2018 NLTK Project
5
5
  # Author: Rami Al-Rfou' <ralrfou@cs.stonybrook.edu>
6
6
  # URL: <http://nltk.org/>
7
7
  # For license information, see LICENSE.TXT
@@ -22,17 +22,19 @@ system specific binary should be rebuilt. Otherwise this could introduce
22
22
  misalignment errors.
23
23
 
24
24
  The input is:
25
- - path to the directory that contains SENNA executables. If the path is incorrect,
25
+ - path to the directory that contains SENNA executables. If the path is incorrect,
26
26
  Senna will automatically search for executable file specified in SENNA environment variable
27
27
  - List of the operations needed to be performed.
28
28
  - (optionally) the encoding of the input data (default:utf-8)
29
29
 
30
+ Note: Unit tests for this module can be found in test/unit/test_senna.py
31
+
30
32
  >>> from __future__ import unicode_literals
31
33
  >>> from nltk.classify import Senna
32
- >>> pipeline = Senna('/usr/share/senna-v2.0', ['pos', 'chk', 'ner'])
34
+ >>> pipeline = Senna('/usr/share/senna-v3.0', ['pos', 'chk', 'ner'])
33
35
  >>> sent = 'Dusseldorf is an international business center'.split()
34
- >>> [(token['word'], token['chk'], token['ner'], token['pos']) for token in pipeline.tag(sent)]
35
- [('Dusseldorf', 'B-NP', 'B-LOC', 'NNP'), ('is', 'B-VP', 'O', 'VBZ'), ('an', 'B-NP', 'O', 'DT'),
36
+ >>> [(token['word'], token['chk'], token['ner'], token['pos']) for token in pipeline.tag(sent)] # doctest: +SKIP
37
+ [('Dusseldorf', 'B-NP', 'B-LOC', 'NNP'), ('is', 'B-VP', 'O', 'VBZ'), ('an', 'B-NP', 'O', 'DT'),
36
38
  ('international', 'I-NP', 'O', 'JJ'), ('business', 'I-NP', 'O', 'NN'), ('center', 'I-NP', 'O', 'NN')]
37
39
  """
38
40
 
@@ -42,8 +44,10 @@ from os import path, sep, environ
42
44
  from subprocess import Popen, PIPE
43
45
  from platform import architecture, system
44
46
 
47
+ from six import text_type
48
+
45
49
  from nltk.tag.api import TaggerI
46
- from nltk.compat import text_type, python_2_unicode_compatible
50
+ from nltk.compat import python_2_unicode_compatible
47
51
 
48
52
  _senna_url = 'http://ml.nec-labs.com/senna/'
49
53
 
@@ -55,29 +59,29 @@ class Senna(TaggerI):
55
59
 
56
60
  def __init__(self, senna_path, operations, encoding='utf-8'):
57
61
  self._encoding = encoding
58
- self._path = path.normpath(senna_path) + sep
59
-
60
- # Verifies the existence of the executable on the self._path first
62
+ self._path = path.normpath(senna_path) + sep
63
+
64
+ # Verifies the existence of the executable on the self._path first
61
65
  #senna_binary_file_1 = self.executable(self._path)
62
66
  exe_file_1 = self.executable(self._path)
63
67
  if not path.isfile(exe_file_1):
64
- # Check for the system environment
68
+ # Check for the system environment
65
69
  if 'SENNA' in environ:
66
- #self._path = path.join(environ['SENNA'],'')
67
- self._path = path.normpath(environ['SENNA']) + sep
70
+ #self._path = path.join(environ['SENNA'],'')
71
+ self._path = path.normpath(environ['SENNA']) + sep
68
72
  exe_file_2 = self.executable(self._path)
69
73
  if not path.isfile(exe_file_2):
70
74
  raise OSError("Senna executable expected at %s or %s but not found" % (exe_file_1,exe_file_2))
71
-
75
+
72
76
  self.operations = operations
73
77
 
74
-
78
+
75
79
  def executable(self, base_path):
76
80
  """
77
81
  The function that determines the system specific binary that should be
78
82
  used in the pipeline. In case, the system is not known the default senna binary will
79
83
  be used.
80
- """
84
+ """
81
85
  os_name = system()
82
86
  if os_name == 'Linux':
83
87
  bits = architecture()[0]
@@ -89,7 +93,7 @@ class Senna(TaggerI):
89
93
  if os_name == 'Darwin':
90
94
  return path.join(base_path, 'senna-osx')
91
95
  return path.join(base_path, 'senna')
92
-
96
+
93
97
  def _map(self):
94
98
  """
95
99
  A method that calculates the order of the columns that SENNA pipeline
@@ -116,11 +120,11 @@ class Senna(TaggerI):
116
120
  calculated annotations/tags.
117
121
  """
118
122
  encoding = self._encoding
119
-
123
+
120
124
  if not path.isfile(self.executable(self._path)):
121
125
  raise OSError("Senna executable expected at %s but not found" % self.executable(self._path))
122
-
123
-
126
+
127
+
124
128
  # Build the senna command to run the tagger
125
129
  _senna_cmd = [self.executable(self._path), '-path', self._path, '-usrtokens', '-iobtags']
126
130
  _senna_cmd.extend(['-'+op for op in self.operations])
@@ -174,8 +178,6 @@ class Senna(TaggerI):
174
178
  def setup_module(module):
175
179
  from nose import SkipTest
176
180
  try:
177
- tagger = Senna('/usr/share/senna-v2.0', ['pos', 'chk', 'ner'])
181
+ tagger = Senna('/usr/share/senna-v3.0', ['pos', 'chk', 'ner'])
178
182
  except OSError:
179
183
  raise SkipTest("Senna executable not found")
180
-
181
-
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: SVM-based classifier
2
2
  #
3
- # Copyright (C) 2001-2016 NLTK Project
3
+ # Copyright (C) 2001-2018 NLTK Project
4
4
  # Author: Leon Derczynski <leon@dcs.shef.ac.uk>
5
5
  #
6
6
  # URL: <http://nltk.org/>