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,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Natural Language Toolkit: Probability and Statistics
3
3
  #
4
- # Copyright (C) 2001-2016 NLTK Project
4
+ # Copyright (C) 2001-2018 NLTK Project
5
5
  # Author: Edward Loper <edloper@gmail.com>
6
6
  # Steven Bird <stevenbird1@gmail.com> (additions)
7
7
  # Trevor Cohn <tacohn@cs.mu.oz.au> (additions)
@@ -44,11 +44,13 @@ import random
44
44
  import warnings
45
45
  import array
46
46
  from operator import itemgetter
47
- from collections import defaultdict
47
+ from collections import defaultdict, Counter
48
48
  from functools import reduce
49
- from nltk import compat
50
- from nltk.compat import Counter
49
+ from abc import ABCMeta, abstractmethod
50
+
51
+ from six import itervalues, text_type, add_metaclass
51
52
 
53
+ from nltk import compat
52
54
  from nltk.internals import raise_unorderable_types
53
55
 
54
56
  _NINF = float('-1e300')
@@ -105,6 +107,9 @@ class FreqDist(Counter):
105
107
  """
106
108
  Counter.__init__(self, samples)
107
109
 
110
+ # Cached number of samples in this FreqDist
111
+ self._N = None
112
+
108
113
  def N(self):
109
114
  """
110
115
  Return the total number of sample outcomes that have been
@@ -114,7 +119,38 @@ class FreqDist(Counter):
114
119
 
115
120
  :rtype: int
116
121
  """
117
- return sum(self.values())
122
+ if self._N is None:
123
+ # Not already cached, or cache has been invalidated
124
+ self._N = sum(self.values())
125
+ return self._N
126
+
127
+ def __setitem__(self, key, val):
128
+ """
129
+ Override ``Counter.__setitem__()`` to invalidate the cached N
130
+ """
131
+ self._N = None
132
+ super(FreqDist, self).__setitem__(key, val)
133
+
134
+ def __delitem__(self, key):
135
+ """
136
+ Override ``Counter.__delitem__()`` to invalidate the cached N
137
+ """
138
+ self._N = None
139
+ super(FreqDist, self).__delitem__(key)
140
+
141
+ def update(self, *args, **kwargs):
142
+ """
143
+ Override ``Counter.update()`` to invalidate the cached N
144
+ """
145
+ self._N = None
146
+ super(FreqDist, self).update(*args, **kwargs)
147
+
148
+ def setdefault(self, key, val):
149
+ """
150
+ Override ``Counter.setdefault()`` to invalidate the cached N
151
+ """
152
+ self._N = None
153
+ super(FreqDist, self).setdefault(key, val)
118
154
 
119
155
  def B(self):
120
156
  """
@@ -192,9 +228,10 @@ class FreqDist(Counter):
192
228
  :type sample: any
193
229
  :rtype: float
194
230
  """
195
- if self.N() == 0:
231
+ n = self.N()
232
+ if n == 0:
196
233
  return 0
197
- return self[sample] / self.N()
234
+ return self[sample] / n
198
235
 
199
236
  def max(self):
200
237
  """
@@ -251,7 +288,7 @@ class FreqDist(Counter):
251
288
  pylab.title(kwargs["title"])
252
289
  del kwargs["title"]
253
290
  pylab.plot(freqs, **kwargs)
254
- pylab.xticks(range(len(samples)), [compat.text_type(s) for s in samples], rotation=90)
291
+ pylab.xticks(range(len(samples)), [text_type(s) for s in samples], rotation=90)
255
292
  pylab.xlabel("Samples")
256
293
  pylab.ylabel(ylabel)
257
294
  pylab.show()
@@ -297,8 +334,8 @@ class FreqDist(Counter):
297
334
  """
298
335
  return self.__class__(self)
299
336
 
300
- # Mathematical operatiors
301
-
337
+ # Mathematical operatiors
338
+
302
339
  def __add__(self, other):
303
340
  """
304
341
  Add counts from two counters.
@@ -393,6 +430,7 @@ class FreqDist(Counter):
393
430
  ## Probability Distributions
394
431
  ##//////////////////////////////////////////////////////
395
432
 
433
+ @add_metaclass(ABCMeta)
396
434
  class ProbDistI(object):
397
435
  """
398
436
  A probability distribution for the outcomes of an experiment. A
@@ -410,10 +448,13 @@ class ProbDistI(object):
410
448
  """True if the probabilities of the samples in this probability
411
449
  distribution will always sum to one."""
412
450
 
451
+ @abstractmethod
413
452
  def __init__(self):
414
- if self.__class__ == ProbDistI:
415
- raise NotImplementedError("Interfaces can't be instantiated")
453
+ """
454
+ Classes inheriting from ProbDistI should implement __init__.
455
+ """
416
456
 
457
+ @abstractmethod
417
458
  def prob(self, sample):
418
459
  """
419
460
  Return the probability for a given sample. Probabilities
@@ -424,7 +465,6 @@ class ProbDistI(object):
424
465
  :type sample: any
425
466
  :rtype: float
426
467
  """
427
- raise NotImplementedError()
428
468
 
429
469
  def logprob(self, sample):
430
470
  """
@@ -439,6 +479,7 @@ class ProbDistI(object):
439
479
  p = self.prob(sample)
440
480
  return (math.log(p, 2) if p != 0 else _NINF)
441
481
 
482
+ @abstractmethod
442
483
  def max(self):
443
484
  """
444
485
  Return the sample with the greatest probability. If two or
@@ -447,8 +488,8 @@ class ProbDistI(object):
447
488
 
448
489
  :rtype: any
449
490
  """
450
- raise NotImplementedError()
451
491
 
492
+ @abstractmethod
452
493
  def samples(self):
453
494
  """
454
495
  Return a list of all samples that have nonzero probabilities.
@@ -456,7 +497,6 @@ class ProbDistI(object):
456
497
 
457
498
  :rtype: list
458
499
  """
459
- raise NotImplementedError()
460
500
 
461
501
  # cf self.SUM_TO_ONE
462
502
  def discount(self):
@@ -549,6 +589,7 @@ class RandomProbDist(ProbDistI):
549
589
  it can still be passed to MutableProbDist and called with identical
550
590
  syntax to UniformProbDist
551
591
  """
592
+ samples = set(samples)
552
593
  randrow = [random.random() for i in range(len(samples))]
553
594
  total = sum(randrow)
554
595
  for i, x in enumerate(randrow):
@@ -562,6 +603,11 @@ class RandomProbDist(ProbDistI):
562
603
 
563
604
  return dict((s, randrow[i]) for i, s in enumerate(samples))
564
605
 
606
+ def max(self):
607
+ if not hasattr(self, '_max'):
608
+ self._max = max((p,v) for (v,p) in self._probs.items())[1]
609
+ return self._max
610
+
565
611
  def prob(self, sample):
566
612
  return self._probs.get(sample, 0)
567
613
 
@@ -1481,6 +1527,10 @@ class MutableProbDist(ProbDistI):
1481
1527
  self._data[i] = prob_dist.prob(samples[i])
1482
1528
  self._logs = store_logs
1483
1529
 
1530
+ def max(self):
1531
+ # inherit documentation
1532
+ return max((p,v) for (v,p) in self._sample_dict.items())[1]
1533
+
1484
1534
  def samples(self):
1485
1535
  # inherit documentation
1486
1536
  return self._samples
@@ -1748,6 +1798,7 @@ class ConditionalFreqDist(defaultdict):
1748
1798
  :type cond_samples: Sequence of (condition, sample) tuples
1749
1799
  """
1750
1800
  defaultdict.__init__(self, FreqDist)
1801
+
1751
1802
  if cond_samples:
1752
1803
  for (cond, sample) in cond_samples:
1753
1804
  self[cond][sample] += 1
@@ -1775,7 +1826,7 @@ class ConditionalFreqDist(defaultdict):
1775
1826
 
1776
1827
  :rtype: int
1777
1828
  """
1778
- return sum(fdist.N() for fdist in compat.itervalues(self))
1829
+ return sum(fdist.N() for fdist in itervalues(self))
1779
1830
 
1780
1831
  def plot(self, *args, **kwargs):
1781
1832
  """
@@ -1819,7 +1870,7 @@ class ConditionalFreqDist(defaultdict):
1819
1870
 
1820
1871
  pylab.legend(loc=legend_loc)
1821
1872
  pylab.grid(True, color="silver")
1822
- pylab.xticks(range(len(samples)), [compat.text_type(s) for s in samples], rotation=90)
1873
+ pylab.xticks(range(len(samples)), [text_type(s) for s in samples], rotation=90)
1823
1874
  if title:
1824
1875
  pylab.title(title)
1825
1876
  pylab.xlabel("Samples")
@@ -1864,7 +1915,7 @@ class ConditionalFreqDist(defaultdict):
1864
1915
  print()
1865
1916
 
1866
1917
  # Mathematical operators
1867
-
1918
+
1868
1919
  def __add__(self, other):
1869
1920
  """
1870
1921
  Add counts from two ConditionalFreqDists.
@@ -1920,7 +1971,7 @@ class ConditionalFreqDist(defaultdict):
1920
1971
  return result
1921
1972
 
1922
1973
  def __and__(self, other):
1923
- """
1974
+ """
1924
1975
  Intersection is the minimum of corresponding counts.
1925
1976
  """
1926
1977
  if not isinstance(other, ConditionalFreqDist):
@@ -1961,6 +2012,7 @@ class ConditionalFreqDist(defaultdict):
1961
2012
 
1962
2013
 
1963
2014
  @compat.python_2_unicode_compatible
2015
+ @add_metaclass(ABCMeta)
1964
2016
  class ConditionalProbDistI(dict):
1965
2017
  """
1966
2018
  A collection of probability distributions for a single experiment
@@ -1974,8 +2026,11 @@ class ConditionalProbDistI(dict):
1974
2026
  condition to the ``ProbDist`` for the experiment under that
1975
2027
  condition.
1976
2028
  """
2029
+ @abstractmethod
1977
2030
  def __init__(self):
1978
- raise NotImplementedError("Interfaces can't be instantiated")
2031
+ """
2032
+ Classes inheriting from ConditionalProbDistI should implement __init__.
2033
+ """
1979
2034
 
1980
2035
  def conditions(self):
1981
2036
  """
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: Semantic Interpretation
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
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # Author: Dan Garrette <dhgarrette@gmail.com>
5
5
  #
6
- # Copyright (C) 2001-2016 NLTK Project
6
+ # Copyright (C) 2001-2018 NLTK Project
7
7
  # URL: <http://nltk.org/>
8
8
  # For license information, see LICENSE.TXT
9
9
 
@@ -34,7 +34,7 @@ from optparse import OptionParser
34
34
  import tempfile
35
35
  from functools import reduce
36
36
 
37
- from nltk.internals import Counter, find_binary
37
+ from nltk.internals import find_binary
38
38
 
39
39
  from nltk.sem.logic import (ExpectedMoreTokensException, LogicalExpressionException,
40
40
  UnexpectedTokenException, Variable)
@@ -89,7 +89,7 @@ class Boxer(object):
89
89
  discourse_ids = ([discourse_id] if discourse_id is not None else None)
90
90
  d, = self.interpret_multi_sents([[input]], discourse_ids, question, verbose)
91
91
  if not d:
92
- raise Exception('Unable to interpret: "%s"' % input)
92
+ raise Exception('Unable to interpret: "{0}"'.format(input))
93
93
  return d
94
94
 
95
95
  def interpret_multi(self, input, discourse_id=None, question=False, verbose=False):
@@ -104,7 +104,7 @@ class Boxer(object):
104
104
  discourse_ids = ([discourse_id] if discourse_id is not None else None)
105
105
  d, = self.interpret_multi_sents([input], discourse_ids, question, verbose)
106
106
  if not d:
107
- raise Exception('Unable to interpret: "%s"' % input)
107
+ raise Exception('Unable to interpret: "{0}"'.format(input))
108
108
  return d
109
109
 
110
110
  def interpret_sents(self, inputs, discourse_ids=None, question=False, verbose=False):
@@ -155,7 +155,7 @@ class Boxer(object):
155
155
  """
156
156
  args = ['--models', os.path.join(self._candc_models_path, ['boxer','questions'][question]),
157
157
  '--candc-printer', 'boxer']
158
- return self._call('\n'.join(sum((["<META>'%s'" % id] + d for d,id in zip(inputs,discourse_ids)), [])), self._candc_bin, args, verbose)
158
+ return self._call('\n'.join(sum((["<META>'{0}'".format(id)] + d for d,id in zip(inputs,discourse_ids)), [])), self._candc_bin, args, verbose)
159
159
 
160
160
  def _call_boxer(self, candc_out, verbose=False):
161
161
  """
@@ -212,7 +212,7 @@ class Boxer(object):
212
212
  cmd = [binary] + args
213
213
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
214
214
  else:
215
- cmd = 'echo "%s" | %s %s' % (input_str, binary, ' '.join(args))
215
+ cmd = 'echo "{0}" | {1} {2}'.format(input_str, binary, ' '.join(args))
216
216
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
217
217
  stdout, stderr = p.communicate()
218
218
 
@@ -221,7 +221,7 @@ class Boxer(object):
221
221
  if stdout: print('stdout:\n', stdout, '\n')
222
222
  if stderr: print('stderr:\n', stderr, '\n')
223
223
  if p.returncode != 0:
224
- raise Exception('ERROR CALLING: %s %s\nReturncode: %d\n%s' % (binary, ' '.join(args), p.returncode, stderr))
224
+ raise Exception('ERROR CALLING: {0} {1}\nReturncode: {2}\n{3}'.format(binary, ' '.join(args), p.returncode, stderr))
225
225
 
226
226
  return stdout
227
227
 
@@ -239,12 +239,12 @@ class Boxer(object):
239
239
  drs_id = line[comma_idx+1:line.index(')')]
240
240
  i += 1
241
241
  line = lines[i]
242
- assert line.startswith('sem(%s,' % drs_id)
242
+ assert line.startswith('sem({0},'.format(drs_id))
243
243
  if line[-4:] == "').'":
244
244
  line = line[:-4] + ")."
245
- assert line.endswith(').'), "can't parse line: %s" % line
245
+ assert line.endswith(').'), "can't parse line: {0}".format(line)
246
246
 
247
- search_start = len('sem(%s,[' % drs_id)
247
+ search_start = len('sem({0},['.format(drs_id))
248
248
  brace_count = 1
249
249
  drs_start = -1
250
250
  for j,c in enumerate(line[search_start:]):
@@ -464,26 +464,26 @@ class BoxerOutputDrsParser(DrtParser):
464
464
  self.assertToken(self.token(), '(')
465
465
  pol = self.token()
466
466
  self.assertToken(self.token(), ')')
467
- conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_pol_%s' % (pol), 'a', 0))
467
+ conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_pol_{0}'.format(pol), 'a', 0))
468
468
  self.assertToken(self.token(), ',')
469
469
 
470
470
  (sent_index, word_indices), = self._sent_and_word_indices(self._parse_index_list())
471
471
  year = self.token()
472
472
  if year != 'XXXX':
473
473
  year = year.replace(':', '_')
474
- conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_year_%s' % (year), 'a', 0))
474
+ conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_year_{0}'.format(year), 'a', 0))
475
475
  self.assertToken(self.token(), ',')
476
476
 
477
477
  (sent_index, word_indices), = self._sent_and_word_indices(self._parse_index_list())
478
478
  month = self.token()
479
479
  if month != 'XX':
480
- conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_month_%s' % (month), 'a', 0))
480
+ conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_month_{0}'.format(month), 'a', 0))
481
481
  self.assertToken(self.token(), ',')
482
482
 
483
483
  (sent_index, word_indices), = self._sent_and_word_indices(self._parse_index_list())
484
484
  day = self.token()
485
485
  if day != 'XX':
486
- conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_day_%s' % (day), 'a', 0))
486
+ conds.append(BoxerPred(self.discourse_id, sent_index, word_indices, arg, 'date_day_{0}'.format(day), 'a', 0))
487
487
 
488
488
  return conds
489
489
 
@@ -864,7 +864,7 @@ class AbstractBoxerDrs(object):
864
864
  return self
865
865
 
866
866
  def __hash__(self):
867
- return hash("%s" % self)
867
+ return hash("{0}".format(self))
868
868
 
869
869
 
870
870
  @python_2_unicode_compatible
@@ -1,7 +1,7 @@
1
1
  # Natural Language Toolkit: Chat-80 KB Reader
2
2
  # See http://www.w3.org/TR/swbp-skos-core-guide/
3
3
  #
4
- # Copyright (C) 2001-2016 NLTK Project
4
+ # Copyright (C) 2001-2018 NLTK Project
5
5
  # Author: Ewan Klein <ewan@inf.ed.ac.uk>,
6
6
  # URL: <http://nltk.sourceforge.net>
7
7
  # For license information, see LICENSE.TXT
@@ -129,8 +129,10 @@ import shelve
129
129
  import os
130
130
  import sys
131
131
 
132
+ from six import string_types
133
+
132
134
  import nltk.data
133
- from nltk.compat import string_types, python_2_unicode_compatible
135
+ from nltk.compat import python_2_unicode_compatible
134
136
 
135
137
  ###########################################################################
136
138
  # Chat-80 relation metadata bundles needed to build the valuation
@@ -505,7 +507,7 @@ def process_bundle(rels):
505
507
  :param rels: bundle of metadata needed for constructing a concept
506
508
  :type rels: list(dict)
507
509
  :return: a dictionary of concepts, indexed by the relation name.
508
- :rtype: dict(str): Concept
510
+ :rtype: dict(str): Concept
509
511
  """
510
512
  concepts = {}
511
513
  for rel in rels:
@@ -641,7 +643,7 @@ def make_lex(symbols):
641
643
  create a lexical rule for the proper name 'Zloty'.
642
644
 
643
645
  :param symbols: a list of individual constants in the semantic representation
644
- :type symbols: sequence -- set(str)
646
+ :type symbols: sequence -- set(str)
645
647
  :rtype: list(str)
646
648
  """
647
649
  lex = []
@@ -778,5 +780,3 @@ def sql_demo():
778
780
  if __name__ == '__main__':
779
781
  main()
780
782
  sql_demo()
781
-
782
-
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: Cooper storage for Quantifier Ambiguity
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
@@ -2,15 +2,18 @@
2
2
  #
3
3
  # Author: Dan Garrette <dhgarrette@gmail.com>
4
4
  #
5
- # Copyright (C) 2001-2016 NLTK Project
5
+ # Copyright (C) 2001-2018 NLTK Project
6
6
  # URL: <http://nltk.org/>
7
7
  # For license information, see LICENSE.TXT
8
8
  from __future__ import print_function, unicode_literals
9
9
 
10
10
  import operator
11
11
  from functools import reduce
12
+ from itertools import chain
12
13
 
13
- from nltk.compat import string_types, python_2_unicode_compatible
14
+ from six import string_types
15
+
16
+ from nltk.compat import python_2_unicode_compatible
14
17
  from nltk.sem.logic import (APP, AbstractVariableExpression, AllExpression,
15
18
  AndExpression, ApplicationExpression, BinaryExpression,
16
19
  BooleanExpression, ConstantExpression, EqualityExpression,
@@ -22,10 +25,8 @@ from nltk.sem.logic import (APP, AbstractVariableExpression, AllExpression,
22
25
 
23
26
  # Import Tkinter-based modules if they are available
24
27
  try:
25
- # imports are fixed for Python 2.x by nltk.compat
26
- from tkinter import Canvas
27
- from tkinter import Tk
28
- from tkinter.font import Font
28
+ from six.moves.tkinter import Canvas, Tk
29
+ from six.moves.tkinter_font import Font
29
30
  from nltk.util import in_idle
30
31
 
31
32
  except ImportError:
@@ -339,7 +340,7 @@ class DRS(DrtExpression, Expression):
339
340
  def get_refs(self, recursive=False):
340
341
  """:see: AbstractExpression.get_refs()"""
341
342
  if recursive:
342
- conds_refs = self.refs + sum((c.get_refs(True) for c in self.conds), [])
343
+ conds_refs = self.refs + list(chain(*(c.get_refs(True) for c in self.conds)))
343
344
  if self.consequent:
344
345
  conds_refs.extend(self.consequent.get_refs(True))
345
346
  return conds_refs
@@ -1227,7 +1228,7 @@ def demo():
1227
1228
 
1228
1229
  def test_draw():
1229
1230
  try:
1230
- from tkinter import Tk
1231
+ from six.moves.tkinter import Tk
1231
1232
  except ImportError:
1232
1233
  from nose import SkipTest
1233
1234
  raise SkipTest("tkinter is required, but it's not available.")
@@ -3,18 +3,14 @@
3
3
  #
4
4
  # Author: Dan Garrette <dhgarrette@gmail.com>
5
5
  #
6
- # Copyright (C) 2001-2016 NLTK Project
6
+ # Copyright (C) 2001-2018 NLTK Project
7
7
  # URL: <http://nltk.org/>
8
8
  # For license information, see LICENSE.TXT
9
9
 
10
-
11
- from nltk import compat # this fixes tkinter imports for Python 2.x
12
-
13
10
  try:
14
- from tkinter.font import Font
15
-
16
- from tkinter import (Button, Frame, IntVar, Label,
17
- Listbox, Menu, Scrollbar, Tk)
11
+ from six.moves.tkinter import (Button, Frame, IntVar, Label, Listbox, Menu,
12
+ Scrollbar, Tk)
13
+ from six.moves.tkinter_font import Font
18
14
  from nltk.draw.util import CanvasFrame, ShowText
19
15
 
20
16
  except ImportError:
@@ -346,7 +342,7 @@ class DrtGlueDemo(object):
346
342
  "Written by Daniel H. Garrette")
347
343
  TITLE = 'About: NLTK DRT Glue Demo'
348
344
  try:
349
- from tkMessageBox import Message
345
+ from six.moves.tkinter_messagebox import Message
350
346
  Message(message=ABOUT, title=TITLE).show()
351
347
  except:
352
348
  ShowText(self._top, TITLE, ABOUT)
@@ -1,6 +1,6 @@
1
1
  # Natural Language Toolkit: Models for first-order languages with lambda
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.sourceforge.net>
6
6
  # For license information, see LICENSE.TXT
@@ -19,9 +19,12 @@ from pprint import pformat
19
19
  import inspect
20
20
  import textwrap
21
21
  import re
22
+ import sys
23
+
24
+ from six import string_types
22
25
 
23
26
  from nltk.decorators import decorator # this used in code that is commented out
24
- from nltk.compat import string_types, python_2_unicode_compatible
27
+ from nltk.compat import python_2_unicode_compatible
25
28
 
26
29
  from nltk.sem.logic import (AbstractVariableExpression, AllExpression, Expression,
27
30
  AndExpression, ApplicationExpression, EqualityExpression,
@@ -36,7 +39,10 @@ class Error(Exception): pass
36
39
  class Undefined(Error): pass
37
40
 
38
41
  def trace(f, *args, **kw):
39
- argspec = inspect.getargspec(f)
42
+ if sys.version_info[0] >= 3:
43
+ argspec = inspect.getfullargspec(f)
44
+ else:
45
+ argspec = inspect.getargspec(f)
40
46
  d = dict(zip(argspec[0], args))
41
47
  if d.pop('trace', None):
42
48
  print()
@@ -2,16 +2,18 @@
2
2
  #
3
3
  # Author: Dan Garrette <dhgarrette@gmail.com>
4
4
  #
5
- # Copyright (C) 2001-2016 NLTK Project
5
+ # Copyright (C) 2001-2018 NLTK Project
6
6
  # URL: <http://nltk.org/>
7
7
  # For license information, see LICENSE.TXT
8
8
  from __future__ import print_function, division, unicode_literals
9
9
 
10
10
  import os
11
+ from itertools import chain
12
+
13
+ from six import string_types
11
14
 
12
15
  import nltk
13
16
  from nltk.internals import Counter
14
- from nltk.compat import string_types
15
17
  from nltk.tag import UnigramTagger, BigramTagger, TrigramTagger, RegexpTagger
16
18
  from nltk.sem.logic import (Expression, Variable, VariableExpression,
17
19
  LambdaExpression, AbstractVariableExpression)
@@ -235,13 +237,13 @@ class GlueDict(dict):
235
237
  if node is None:
236
238
  # TODO: should it be depgraph.root? Is this code tested?
237
239
  top = depgraph.nodes[0]
238
- depList = sum(list(top['deps'].values()), [])
240
+ depList = list(chain(*top['deps'].values()))
239
241
  root = depgraph.nodes[depList[0]]
240
242
 
241
243
  return self.to_glueformula_list(depgraph, root, Counter(), verbose)
242
244
 
243
245
  glueformulas = self.lookup(node, depgraph, counter)
244
- for dep_idx in sum(list(node['deps'].values()), []):
246
+ for dep_idx in chain(*node['deps'].values()):
245
247
  dep = depgraph.nodes[dep_idx]
246
248
  glueformulas.extend(self.to_glueformula_list(depgraph, dep, counter, verbose))
247
249
  return glueformulas
@@ -285,7 +287,7 @@ class GlueDict(dict):
285
287
  def _lookup_semtype_option(self, semtype, node, depgraph):
286
288
  relationships = frozenset(
287
289
  depgraph.nodes[dep]['rel'].lower()
288
- for dep in sum(list(node['deps'].values()), [])
290
+ for dep in chain(*node['deps'].values())
289
291
  if depgraph.nodes[dep]['rel'].lower() not in OPTIONAL_RELATIONSHIPS
290
292
  )
291
293
 
@@ -418,7 +420,7 @@ class GlueDict(dict):
418
420
  """
419
421
  deps = [
420
422
  depgraph.nodes[dep]
421
- for dep in sum(list(node['deps'].values()), [])
423
+ for dep in chain(*node['deps'].values())
422
424
  if depgraph.nodes[dep]['rel'].lower() == rel.lower()
423
425
  ]
424
426
 
@@ -3,7 +3,7 @@
3
3
  # Author: Peter Wang
4
4
  # Updated by: Dan Garrette <dhgarrette@gmail.com>
5
5
  #
6
- # Copyright (C) 2001-2016 NLTK Project
6
+ # Copyright (C) 2001-2018 NLTK Project
7
7
  # URL: <http://nltk.org>
8
8
  # For license information, see LICENSE.TXT
9
9
 
@@ -23,6 +23,8 @@ from __future__ import print_function, unicode_literals
23
23
 
24
24
  from functools import reduce
25
25
 
26
+ from six import itervalues
27
+
26
28
  from nltk import compat
27
29
  from nltk.parse import load_parser
28
30
 
@@ -129,7 +131,7 @@ class HoleSemantics(object):
129
131
 
130
132
  def _find_top_nodes(self, node_list):
131
133
  top_nodes = node_list.copy()
132
- for f in compat.itervalues(self.fragments):
134
+ for f in itervalues(self.fragments):
133
135
  # the label is the first argument of the predicate
134
136
  args = f[1]
135
137
  for arg in args:
@@ -2,11 +2,13 @@
2
2
  #
3
3
  # Author: Dan Garrette <dhgarrette@gmail.com>
4
4
  #
5
- # Copyright (C) 2001-2016 NLTK Project
5
+ # Copyright (C) 2001-2018 NLTK Project
6
6
  # URL: <http://nltk.org/>
7
7
  # For license information, see LICENSE.TXT
8
8
  from __future__ import print_function, division, unicode_literals
9
9
 
10
+ from itertools import chain
11
+
10
12
  from nltk.internals import Counter
11
13
  from nltk.compat import python_2_unicode_compatible
12
14
 
@@ -117,7 +119,7 @@ class FStructure(dict):
117
119
  if not fstruct.pred:
118
120
  fstruct.pred = (word, tag)
119
121
 
120
- children = [depgraph.nodes[idx] for idx in sum(list(node['deps'].values()), [])]
122
+ children = [depgraph.nodes[idx] for idx in chain(*node['deps'].values())]
121
123
  for child in children:
122
124
  fstruct.safeappend(child['rel'], FStructure._read_depgraph(child, depgraph, label_counter, fstruct))
123
125
 
@@ -2,13 +2,15 @@
2
2
  #
3
3
  # Author: Dan Garrette <dhgarrette@gmail.com>
4
4
  #
5
- # Copyright (C) 2001-2016 NLTK Project
5
+ # Copyright (C) 2001-2018 NLTK Project
6
6
  # URL: <http://nltk.org/>
7
7
  # For license information, see LICENSE.TXT
8
8
  from __future__ import print_function, unicode_literals
9
9
 
10
+ from six import string_types
11
+
10
12
  from nltk.internals import Counter
11
- from nltk.compat import string_types, python_2_unicode_compatible
13
+ from nltk.compat import python_2_unicode_compatible
12
14
  from nltk.sem.logic import LogicParser, APP
13
15
 
14
16
  _counter = Counter()