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.
- {nltk-3.2.1 → nltk-3.3}/LICENSE.txt +1 -1
- {nltk-3.2.1/nltk.egg-info → nltk-3.3}/PKG-INFO +13 -5
- nltk-3.3/README.md +49 -0
- nltk-3.3/nltk/VERSION +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/__init__.py +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/app/__init__.py +2 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/app/chartparser_app.py +92 -92
- {nltk-3.2.1 → nltk-3.3}/nltk/app/chunkparser_app.py +11 -13
- {nltk-3.2.1 → nltk-3.3}/nltk/app/collocations_app.py +8 -11
- {nltk-3.2.1 → nltk-3.3}/nltk/app/concordance_app.py +9 -11
- {nltk-3.2.1 → nltk-3.3}/nltk/app/nemo_app.py +18 -17
- {nltk-3.2.1 → nltk-3.3}/nltk/app/rdparser_app.py +10 -12
- {nltk-3.2.1 → nltk-3.3}/nltk/app/srparser_app.py +16 -16
- {nltk-3.2.1 → nltk-3.3}/nltk/app/wordfreq_app.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/app/wordnet_app.py +11 -11
- {nltk-3.2.1 → nltk-3.3}/nltk/book.py +2 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/ccg/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/ccg/api.py +67 -47
- {nltk-3.2.1 → nltk-3.3}/nltk/ccg/chart.py +7 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/ccg/combinator.py +42 -11
- {nltk-3.2.1 → nltk-3.3}/nltk/ccg/lexicon.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/ccg/logic.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/eliza.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/iesha.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/rude.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/suntsu.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/util.py +12 -10
- {nltk-3.2.1 → nltk-3.3}/nltk/chat/zen.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chunk/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chunk/api.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/chunk/named_entity.py +13 -13
- {nltk-3.2.1 → nltk-3.3}/nltk/chunk/regexp.py +9 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/chunk/util.py +12 -12
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/api.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/decisiontree.py +18 -18
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/maxent.py +26 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/megam.py +5 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/naivebayes.py +29 -26
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/rte_classify.py +58 -89
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/scikitlearn.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/senna.py +24 -22
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/svm.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/tadm.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/textcat.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/util.py +13 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/weka.py +7 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/cluster/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/cluster/api.py +9 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/cluster/em.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/cluster/gaac.py +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/cluster/kmeans.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/cluster/util.py +35 -20
- nltk-3.3/nltk/collections.py +640 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/collocations.py +2 -2
- nltk-3.3/nltk/compat.py +365 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/__init__.py +37 -16
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/europarl_raw.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/__init__.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/aligned.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/api.py +12 -10
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/bnc.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/bracket_parse.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/categorized_sents.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/chasen.py +5 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/childes.py +8 -9
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/chunked.py +4 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/cmudict.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/comparative_sents.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/conll.py +19 -12
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/crubadan.py +2 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/dependency.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/framenet.py +1085 -119
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ieer.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/indian.py +4 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ipipan.py +6 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/knbc.py +2 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/lin.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/mte.py +5 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/nkjp.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/nombank.py +8 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/nps_chat.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/opinion_lexicon.py +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/panlex_lite.py +1 -1
- nltk-3.3/nltk/corpus/reader/pl196x.py +292 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/plaintext.py +3 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ppattach.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/propbank.py +8 -10
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/pros_cons.py +5 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/reviews.py +3 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/rte.py +5 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/semcor.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/senseval.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/sentiwordnet.py +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/sinica_treebank.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/string_category.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/switchboard.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/tagged.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/timit.py +10 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/toolbox.py +4 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/twitter.py +4 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/util.py +7 -3
- nltk-3.3/nltk/corpus/reader/verbnet.py +595 -0
- nltk-3.3/nltk/corpus/reader/wordlist.py +134 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/wordnet.py +357 -285
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/xmldocs.py +10 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/ycoe.py +25 -24
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/util.py +22 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/data.py +65 -29
- {nltk-3.2.1 → nltk-3.3}/nltk/decorators.py +5 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/downloader.py +59 -55
- {nltk-3.2.1 → nltk-3.3}/nltk/draw/__init__.py +4 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/draw/cfg.py +5 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/draw/dispersion.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/draw/table.py +4 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/draw/tree.py +2 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/draw/util.py +17 -17
- {nltk-3.2.1 → nltk-3.3}/nltk/featstruct.py +290 -173
- {nltk-3.2.1 → nltk-3.3}/nltk/grammar.py +87 -44
- {nltk-3.2.1 → nltk-3.3}/nltk/help.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/api.py +27 -19
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/discourse.py +20 -16
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/nonmonotonic.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/prover9.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/resolution.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/tableau.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/internals.py +44 -44
- {nltk-3.2.1 → nltk-3.3}/nltk/jsontags.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/__init__.py +2 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/agreement.py +29 -9
- nltk-3.3/nltk/metrics/aline.py +607 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/association.py +8 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/confusionmatrix.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/distance.py +12 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/paice.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/scores.py +7 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/segmentation.py +4 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/metrics/spearman.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/misc/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/misc/chomsky.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/misc/minimalset.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/misc/sort.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/misc/wordfinder.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/__init__.py +2 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/api.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/bllip.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/chart.py +8 -7
- nltk-3.3/nltk/parse/corenlp.py +780 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/dependencygraph.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/earleychart.py +4 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/evaluate.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/featurechart.py +6 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/generate.py +15 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/malt.py +2 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/nonprojectivedependencyparser.py +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/pchart.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/projectivedependencyparser.py +6 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/recursivedescent.py +2 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/shiftreduce.py +2 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/stanford.py +53 -28
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/transitionparser.py +11 -9
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/util.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/parse/viterbi.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/probability.py +75 -20
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/boxer.py +15 -15
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/chat80.py +6 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/cooper_storage.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/drt.py +9 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/drt_glue_demo.py +5 -9
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/evaluate.py +9 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/glue.py +8 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/hole.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/lfg.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/linearlogic.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/logic.py +14 -14
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/relextract.py +11 -18
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/skolemize.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/sem/util.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/sentiment_analyzer.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/util.py +14 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/sentiment/vader.py +41 -42
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/__init__.py +1 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/api.py +7 -4
- nltk-3.3/nltk/stem/arlstem.py +369 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/isri.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/lancaster.py +39 -12
- nltk-3.3/nltk/stem/porter.py +710 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/regexp.py +2 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/rslp.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/snowball.py +537 -13
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/util.py +11 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/stem/wordnet.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/__init__.py +32 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/api.py +13 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/brill.py +4 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/crf.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/hmm.py +11 -11
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/hunpos.py +4 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/mapping.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/perceptron.py +25 -10
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/senna.py +25 -23
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/sequential.py +19 -15
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/stanford.py +59 -36
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/tnt.py +11 -20
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/util.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/demo.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/erroranalysis.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/feature.py +5 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/rule.py +6 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/template.py +18 -23
- {nltk-3.2.1 → nltk-3.3}/nltk/test/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/all.py +7 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/test/bnc.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/ccg.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/ccg_semantics.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/chat80.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/childes_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/chunk.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/classify.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/classify_fixt.py +2 -1
- nltk-3.3/nltk/test/collections.doctest +20 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/collocations.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/compat.doctest +0 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/test/compat_fixt.py +1 -0
- nltk-3.3/nltk/test/concordance.doctest +55 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/corpus.doctest +38 -49
- {nltk-3.2.1 → nltk-3.3}/nltk/test/crubadan.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/data.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/dependency.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/discourse.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/discourse_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/doctest_nose_plugin.py +8 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/test/drt.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/featgram.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/featstruct.doctest +2 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/test/framenet.doctest +82 -33
- {nltk-3.2.1 → nltk-3.3}/nltk/test/generate.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/gensim.doctest +6 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/test/gensim_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/gluesemantics.doctest +13 -15
- {nltk-3.2.1 → nltk-3.3}/nltk/test/gluesemantics_malt.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/gluesemantics_malt_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/grammar.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/grammartestsuites.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/index.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/inference.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/inference_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/internals.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/japanese.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/logic.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/metrics.doctest +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/test/misc.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/nonmonotonic.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/nonmonotonic_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/parse.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/portuguese_en.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/probability.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/probability_fixt.py +2 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/propbank.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/relextract.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/resolution.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/runtests.py +35 -13
- {nltk-3.2.1 → nltk-3.3}/nltk/test/semantics.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/sentiment.doctest +3 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/test/sentiwordnet.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/simple.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/stem.doctest +2 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/test/tag.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/tokenize.doctest +109 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/test/toolbox.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/translate.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/tree.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/treeprettyprinter.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/treetransforms.doctest +1 -1
- nltk-3.3/nltk/test/unit/test_aline.py +52 -0
- nltk-3.3/nltk/test/unit/test_chunk.py +56 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_classify.py +20 -18
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_collocations.py +16 -7
- nltk-3.3/nltk/test/unit/test_concordance.py +98 -0
- nltk-3.3/nltk/test/unit/test_corenlp.py +1000 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_corpora.py +18 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_json2csv_corpus.py +4 -3
- nltk-3.3/nltk/test/unit/test_rte_classify.py +86 -0
- nltk-3.3/nltk/test/unit/test_senna.py +74 -0
- nltk-3.3/nltk/test/unit/test_stem.py +121 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_tgrep.py +4 -2
- nltk-3.3/nltk/test/unit/test_tokenize.py +168 -0
- nltk-3.3/nltk/test/unit/test_wordnet.py +134 -0
- nltk-3.3/nltk/test/unit/translate/test_bleu.py +244 -0
- nltk-3.3/nltk/test/unit/translate/test_gdfa.py +57 -0
- nltk-3.3/nltk/test/unit/translate/test_nist.py +37 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_stack_decoder.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/util.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/wordnet.doctest +17 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/test/wordnet_fixt.py +1 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/wordnet_lch.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/test/wsd.doctest +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/text.py +92 -39
- {nltk-3.2.1 → nltk-3.3}/nltk/tgrep.py +8 -7
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/__init__.py +37 -15
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/api.py +3 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/casual.py +10 -9
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/mwe.py +2 -2
- nltk-3.3/nltk/tokenize/nist.py +173 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/punkt.py +186 -167
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/regexp.py +13 -7
- nltk-3.3/nltk/tokenize/repp.py +151 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/sexpr.py +4 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/simple.py +7 -5
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/stanford.py +18 -14
- nltk-3.3/nltk/tokenize/stanford_segmenter.py +246 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/tokenize/texttiling.py +43 -45
- nltk-3.3/nltk/tokenize/toktok.py +155 -0
- nltk-3.3/nltk/tokenize/treebank.py +363 -0
- nltk-3.3/nltk/tokenize/util.py +261 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/toolbox.py +4 -2
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/api.py +50 -40
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/bleu_score.py +221 -156
- nltk-3.3/nltk/translate/chrf_score.py +137 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/gale_church.py +32 -19
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/gdfa.py +14 -10
- nltk-3.3/nltk/translate/gleu_score.py +193 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm1.py +17 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm2.py +4 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm4.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm5.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm_model.py +4 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/metrics.py +1 -1
- nltk-3.3/nltk/translate/nist_score.py +178 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/phrase_based.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ribes_score.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/stack_decoder.py +5 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/tree.py +10 -8
- {nltk-3.2.1 → nltk-3.3}/nltk/treeprettyprinter.py +6 -6
- {nltk-3.2.1 → nltk-3.3}/nltk/twitter/__init__.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/twitter/api.py +8 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/twitter/common.py +9 -3
- {nltk-3.2.1 → nltk-3.3}/nltk/twitter/twitter_demo.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/twitter/twitterclient.py +1 -1
- {nltk-3.2.1 → nltk-3.3}/nltk/twitter/util.py +5 -4
- {nltk-3.2.1 → nltk-3.3}/nltk/util.py +41 -654
- {nltk-3.2.1 → nltk-3.3}/nltk/wsd.py +2 -2
- {nltk-3.2.1 → nltk-3.3/nltk.egg-info}/PKG-INFO +13 -5
- {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/SOURCES.txt +23 -1
- nltk-3.3/nltk.egg-info/requires.txt +31 -0
- {nltk-3.2.1 → nltk-3.3}/setup.cfg +0 -1
- {nltk-3.2.1 → nltk-3.3}/setup.py +32 -5
- nltk-3.2.1/nltk/VERSION +0 -1
- nltk-3.2.1/nltk/compat.py +0 -706
- nltk-3.2.1/nltk/corpus/reader/pl196x.py +0 -278
- nltk-3.2.1/nltk/corpus/reader/verbnet.py +0 -408
- nltk-3.2.1/nltk/corpus/reader/wordlist.py +0 -37
- nltk-3.2.1/nltk/six.py +0 -868
- nltk-3.2.1/nltk/stem/porter.py +0 -692
- nltk-3.2.1/nltk/test/unit/test_stem.py +0 -36
- nltk-3.2.1/nltk/test/unit/test_tokenize.py +0 -23
- nltk-3.2.1/nltk/test/unit/translate/test_bleu.py +0 -138
- nltk-3.2.1/nltk/tokenize/stanford_segmenter.py +0 -157
- nltk-3.2.1/nltk/tokenize/treebank.py +0 -124
- nltk-3.2.1/nltk/tokenize/util.py +0 -90
- {nltk-3.2.1 → nltk-3.3}/INSTALL.txt +0 -0
- {nltk-3.2.1 → nltk-3.3}/MANIFEST.in +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/classify/positivenaivebayes.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/corpus/reader/udhr.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/inference/mace.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/lazyimport.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/misc/babelfish.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/tag/brill_trainer.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/tbl/api.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/bleu.doctest +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/childes.doctest +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/corpus_fixt.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/paice.doctest +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/portuguese_en_fixt.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/segmentation_fixt.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/semantics_fixt.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/translate_fixt.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/__init__.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_2x_compat.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_corpus_views.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_hmm.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_naivebayes.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_seekable_unicode_stream_reader.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_tag.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/test_twitter_auth.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/__init__.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm1.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm2.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm3.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm4.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm5.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/translate/test_ibm_model.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/test/unit/utils.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/translate/ibm3.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk/treetransforms.py +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/dependency_links.txt +0 -0
- {nltk-3.2.1 → nltk-3.3}/nltk.egg-info/not-zip-safe +0 -0
- {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: Interface to the Stanford Part-of-speech and Named-Entity Taggers
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Nitin Madnani <nmadnani@ets.org>
|
|
6
6
|
# Rami Al-Rfou' <ralrfou@cs.stonybrook.edu>
|
|
7
7
|
# URL: <http://nltk.org/>
|
|
@@ -10,23 +10,26 @@
|
|
|
10
10
|
"""
|
|
11
11
|
A module for interfacing with the Stanford taggers.
|
|
12
12
|
|
|
13
|
-
Tagger models need to be downloaded from
|
|
13
|
+
Tagger models need to be downloaded from https://nlp.stanford.edu/software
|
|
14
14
|
and the STANFORD_MODELS environment variable set (a colon-separated
|
|
15
15
|
list of paths).
|
|
16
16
|
|
|
17
17
|
For more details see the documentation for StanfordPOSTagger and StanfordNERTagger.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
+
from abc import abstractmethod
|
|
20
21
|
import os
|
|
21
22
|
import tempfile
|
|
22
23
|
from subprocess import PIPE
|
|
23
24
|
import warnings
|
|
24
25
|
|
|
25
|
-
from
|
|
26
|
+
from six import text_type
|
|
27
|
+
|
|
28
|
+
from nltk.internals import find_file, find_jar, config_java, java, _java_options
|
|
26
29
|
from nltk.tag.api import TaggerI
|
|
27
|
-
from nltk import compat
|
|
28
30
|
|
|
29
|
-
_stanford_url = '
|
|
31
|
+
_stanford_url = 'https://nlp.stanford.edu/software'
|
|
32
|
+
|
|
30
33
|
|
|
31
34
|
class StanfordTagger(TaggerI):
|
|
32
35
|
"""
|
|
@@ -42,33 +45,40 @@ class StanfordTagger(TaggerI):
|
|
|
42
45
|
_SEPARATOR = ''
|
|
43
46
|
_JAR = ''
|
|
44
47
|
|
|
45
|
-
def __init__(self, model_filename, path_to_jar=None, encoding='utf8',
|
|
48
|
+
def __init__(self, model_filename, path_to_jar=None, encoding='utf8',
|
|
49
|
+
verbose=False, java_options='-mx1000m'):
|
|
50
|
+
# Raise deprecation warning.
|
|
51
|
+
warnings.warn(str("\nThe StanfordTokenizer will "
|
|
52
|
+
"be deprecated in version 3.2.6.\n"
|
|
53
|
+
"Please use \033[91mnltk.parse.corenlp.CoreNLPParser\033[0m instead."),
|
|
54
|
+
DeprecationWarning, stacklevel=2)
|
|
46
55
|
|
|
47
56
|
if not self._JAR:
|
|
48
57
|
warnings.warn('The StanfordTagger class is not meant to be '
|
|
49
|
-
|
|
58
|
+
'instantiated directly. Did you mean '
|
|
59
|
+
'StanfordPOSTagger or StanfordNERTagger?')
|
|
50
60
|
self._stanford_jar = find_jar(
|
|
51
61
|
self._JAR, path_to_jar,
|
|
52
62
|
searchpath=(), url=_stanford_url,
|
|
53
63
|
verbose=verbose)
|
|
54
64
|
|
|
55
65
|
self._stanford_model = find_file(model_filename,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
stanford_dir = os.path.split(self._stanford_jar)[0]
|
|
60
|
-
self._stanford_jar = tuple(find_jars_within_path(stanford_dir))
|
|
61
|
-
|
|
66
|
+
env_vars=('STANFORD_MODELS',),
|
|
67
|
+
verbose=verbose)
|
|
68
|
+
|
|
62
69
|
self._encoding = encoding
|
|
63
70
|
self.java_options = java_options
|
|
64
71
|
|
|
65
72
|
@property
|
|
73
|
+
@abstractmethod
|
|
66
74
|
def _cmd(self):
|
|
67
|
-
|
|
75
|
+
"""
|
|
76
|
+
A property that returns the command that will be executed.
|
|
77
|
+
"""
|
|
68
78
|
|
|
69
79
|
def tag(self, tokens):
|
|
70
|
-
# This function should return list of tuple rather than list of list
|
|
71
|
-
return sum(self.tag_sents([tokens]), [])
|
|
80
|
+
# This function should return list of tuple rather than list of list
|
|
81
|
+
return sum(self.tag_sents([tokens]), [])
|
|
72
82
|
|
|
73
83
|
def tag_sents(self, sentences):
|
|
74
84
|
encoding = self._encoding
|
|
@@ -80,29 +90,29 @@ class StanfordTagger(TaggerI):
|
|
|
80
90
|
|
|
81
91
|
cmd = list(self._cmd)
|
|
82
92
|
cmd.extend(['-encoding', encoding])
|
|
83
|
-
|
|
93
|
+
|
|
84
94
|
# Write the actual sentences to the temporary input file
|
|
85
95
|
_input_fh = os.fdopen(_input_fh, 'wb')
|
|
86
96
|
_input = '\n'.join((' '.join(x) for x in sentences))
|
|
87
|
-
if isinstance(_input,
|
|
97
|
+
if isinstance(_input, text_type) and encoding:
|
|
88
98
|
_input = _input.encode(encoding)
|
|
89
99
|
_input_fh.write(_input)
|
|
90
100
|
_input_fh.close()
|
|
91
|
-
|
|
101
|
+
|
|
92
102
|
# Run the tagger and get the output
|
|
93
103
|
stanpos_output, _stderr = java(cmd, classpath=self._stanford_jar,
|
|
94
|
-
|
|
104
|
+
stdout=PIPE, stderr=PIPE)
|
|
95
105
|
stanpos_output = stanpos_output.decode(encoding)
|
|
96
|
-
|
|
106
|
+
|
|
97
107
|
# Delete the temporary file
|
|
98
|
-
os.unlink(self._input_file_path)
|
|
108
|
+
os.unlink(self._input_file_path)
|
|
99
109
|
|
|
100
110
|
# Return java configurations to their default values
|
|
101
111
|
config_java(options=default_options, verbose=False)
|
|
102
|
-
|
|
112
|
+
|
|
103
113
|
return self.parse_output(stanpos_output, sentences)
|
|
104
114
|
|
|
105
|
-
def parse_output(self, text, sentences
|
|
115
|
+
def parse_output(self, text, sentences=None):
|
|
106
116
|
# Output the tagged sentences
|
|
107
117
|
tagged_sentences = []
|
|
108
118
|
for tagged_sentence in text.strip().split("\n"):
|
|
@@ -113,6 +123,7 @@ class StanfordTagger(TaggerI):
|
|
|
113
123
|
tagged_sentences.append(sentence)
|
|
114
124
|
return tagged_sentences
|
|
115
125
|
|
|
126
|
+
|
|
116
127
|
class StanfordPOSTagger(StanfordTagger):
|
|
117
128
|
"""
|
|
118
129
|
A class for pos tagging with Stanford Tagger. The input is the paths to:
|
|
@@ -124,11 +135,10 @@ class StanfordPOSTagger(StanfordTagger):
|
|
|
124
135
|
Example:
|
|
125
136
|
|
|
126
137
|
>>> from nltk.tag import StanfordPOSTagger
|
|
127
|
-
>>> st = StanfordPOSTagger('english-bidirectional-distsim.tagger')
|
|
128
|
-
>>> st.tag('What is the airspeed of an unladen swallow ?'.split())
|
|
138
|
+
>>> st = StanfordPOSTagger('english-bidirectional-distsim.tagger')
|
|
139
|
+
>>> st.tag('What is the airspeed of an unladen swallow ?'.split())
|
|
129
140
|
[('What', 'WP'), ('is', 'VBZ'), ('the', 'DT'), ('airspeed', 'NN'), ('of', 'IN'), ('an', 'DT'), ('unladen', 'JJ'), ('swallow', 'VB'), ('?', '.')]
|
|
130
141
|
"""
|
|
131
|
-
|
|
132
142
|
_SEPARATOR = '_'
|
|
133
143
|
_JAR = 'stanford-postagger.jar'
|
|
134
144
|
|
|
@@ -139,7 +149,9 @@ class StanfordPOSTagger(StanfordTagger):
|
|
|
139
149
|
def _cmd(self):
|
|
140
150
|
return ['edu.stanford.nlp.tagger.maxent.MaxentTagger',
|
|
141
151
|
'-model', self._stanford_model, '-textFile',
|
|
142
|
-
self._input_file_path, '-tokenize', 'false',
|
|
152
|
+
self._input_file_path, '-tokenize', 'false',
|
|
153
|
+
'-outputFormatOptions', 'keepEmptySentences']
|
|
154
|
+
|
|
143
155
|
|
|
144
156
|
class StanfordNERTagger(StanfordTagger):
|
|
145
157
|
"""
|
|
@@ -169,28 +181,39 @@ class StanfordNERTagger(StanfordTagger):
|
|
|
169
181
|
|
|
170
182
|
@property
|
|
171
183
|
def _cmd(self):
|
|
172
|
-
# Adding -tokenizerFactory edu.stanford.nlp.process.WhitespaceTokenizer -tokenizerOptions tokenizeNLs=false for not using stanford Tokenizer
|
|
184
|
+
# Adding -tokenizerFactory edu.stanford.nlp.process.WhitespaceTokenizer -tokenizerOptions tokenizeNLs=false for not using stanford Tokenizer
|
|
173
185
|
return ['edu.stanford.nlp.ie.crf.CRFClassifier',
|
|
174
186
|
'-loadClassifier', self._stanford_model, '-textFile',
|
|
175
|
-
self._input_file_path, '-outputFormat', self._FORMAT,
|
|
187
|
+
self._input_file_path, '-outputFormat', self._FORMAT,
|
|
188
|
+
'-tokenizerFactory',
|
|
189
|
+
'edu.stanford.nlp.process.WhitespaceTokenizer',
|
|
190
|
+
'-tokenizerOptions', '\"tokenizeNLs=false\"']
|
|
176
191
|
|
|
177
192
|
def parse_output(self, text, sentences):
|
|
178
193
|
if self._FORMAT == 'slashTags':
|
|
179
|
-
# Joint together to a big list
|
|
194
|
+
# Joint together to a big list
|
|
180
195
|
tagged_sentences = []
|
|
181
196
|
for tagged_sentence in text.strip().split("\n"):
|
|
182
197
|
for tagged_word in tagged_sentence.strip().split():
|
|
183
198
|
word_tags = tagged_word.strip().split(self._SEPARATOR)
|
|
184
|
-
tagged_sentences.append((''.join(word_tags[:-1]),
|
|
185
|
-
|
|
199
|
+
tagged_sentences.append((''.join(word_tags[:-1]),
|
|
200
|
+
word_tags[-1]))
|
|
201
|
+
|
|
186
202
|
# Separate it according to the input
|
|
187
203
|
result = []
|
|
188
|
-
start = 0
|
|
204
|
+
start = 0
|
|
189
205
|
for sent in sentences:
|
|
190
206
|
result.append(tagged_sentences[start:start + len(sent)])
|
|
191
|
-
start += len(sent)
|
|
192
|
-
return result
|
|
207
|
+
start += len(sent)
|
|
208
|
+
return result
|
|
193
209
|
|
|
194
210
|
raise NotImplementedError
|
|
195
211
|
|
|
212
|
+
def setup_module(module):
|
|
213
|
+
from nose import SkipTest
|
|
196
214
|
|
|
215
|
+
try:
|
|
216
|
+
StanfordPOSTagger('english-bidirectional-distsim.tagger')
|
|
217
|
+
except LookupError:
|
|
218
|
+
raise SkipTest('Doctests from nltk.tag.stanford are skipped because one \
|
|
219
|
+
of the stanford jars cannot be found.')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Natural Language Toolkit: TnT Tagger
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2001-
|
|
3
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
4
4
|
# Author: Sam Huston <sjh900@gmail.com>
|
|
5
5
|
#
|
|
6
6
|
# URL: <http://nltk.org/>
|
|
@@ -357,30 +357,24 @@ class TnT(TaggerI):
|
|
|
357
357
|
# if word is known
|
|
358
358
|
# compute the set of possible tags
|
|
359
359
|
# and their associated log probabilities
|
|
360
|
-
if word in self._wd
|
|
360
|
+
if word in self._wd:
|
|
361
361
|
self.known += 1
|
|
362
362
|
|
|
363
363
|
for (history, curr_sent_logprob) in current_states:
|
|
364
364
|
logprobs = []
|
|
365
365
|
|
|
366
366
|
for t in self._wd[word].keys():
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
367
|
+
tC = (t,C)
|
|
368
|
+
p_uni = self._uni.freq(tC)
|
|
369
|
+
p_bi = self._bi[history[-1]].freq(tC)
|
|
370
|
+
p_tri = self._tri[tuple(history[-2:])].freq(tC)
|
|
371
|
+
p_wd = self._wd[word][t] / self._uni[tC]
|
|
371
372
|
p = self._l1 *p_uni + self._l2 *p_bi + self._l3 *p_tri
|
|
372
373
|
p2 = log(p, 2) + log(p_wd, 2)
|
|
373
374
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
# compute the result of appending each tag to this history
|
|
378
|
-
for (tag, logprob) in logprobs:
|
|
379
|
-
new_states.append((history + [tag],
|
|
380
|
-
curr_sent_logprob + logprob))
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
375
|
+
# compute the result of appending each tag to this history
|
|
376
|
+
new_states.append((history + [tC],
|
|
377
|
+
curr_sent_logprob + p2))
|
|
384
378
|
|
|
385
379
|
# otherwise a new word, set of possible tags is unknown
|
|
386
380
|
else:
|
|
@@ -398,7 +392,7 @@ class TnT(TaggerI):
|
|
|
398
392
|
tag = ('Unk',C)
|
|
399
393
|
|
|
400
394
|
# otherwise apply the unknown word tagger
|
|
401
|
-
else
|
|
395
|
+
else:
|
|
402
396
|
[(_w, t)] = list(self._unk.tag([word]))
|
|
403
397
|
tag = (t,C)
|
|
404
398
|
|
|
@@ -407,8 +401,6 @@ class TnT(TaggerI):
|
|
|
407
401
|
|
|
408
402
|
new_states = current_states
|
|
409
403
|
|
|
410
|
-
|
|
411
|
-
|
|
412
404
|
# now have computed a set of possible new_states
|
|
413
405
|
|
|
414
406
|
# sort states by log prob
|
|
@@ -420,7 +412,6 @@ class TnT(TaggerI):
|
|
|
420
412
|
if len(new_states) > self._N:
|
|
421
413
|
new_states = new_states[:self._N]
|
|
422
414
|
|
|
423
|
-
|
|
424
415
|
# compute the tags for the rest of the sentence
|
|
425
416
|
# return the best list of tags for the sentence
|
|
426
417
|
return self._tagword(sent, new_states)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Natural Language Toolkit: Transformation-based learning
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Marcus Uneson <marcus.uneson@gmail.com>
|
|
6
6
|
# based on previous (nltk2) version by
|
|
7
7
|
# Christopher Maloof, Edward Loper, Steven Bird
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Natural Language Toolkit: Transformation-based learning
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Marcus Uneson <marcus.uneson@gmail.com>
|
|
6
6
|
# based on previous (nltk2) version by
|
|
7
7
|
# Christopher Maloof, Edward Loper, Steven Bird
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Natural Language Toolkit: Transformation-based learning
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Marcus Uneson <marcus.uneson@gmail.com>
|
|
6
6
|
# based on previous (nltk2) version by
|
|
7
7
|
# Christopher Maloof, Edward Loper, Steven Bird
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Natural Language Toolkit: Transformation-based learning
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Marcus Uneson <marcus.uneson@gmail.com>
|
|
6
6
|
# based on previous (nltk2) version by
|
|
7
7
|
# Christopher Maloof, Edward Loper, Steven Bird
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
# For license information, see LICENSE.TXT
|
|
10
10
|
|
|
11
11
|
from __future__ import division, print_function, unicode_literals
|
|
12
|
+
from abc import ABCMeta, abstractmethod
|
|
13
|
+
from six import add_metaclass
|
|
12
14
|
|
|
13
15
|
|
|
16
|
+
@add_metaclass(ABCMeta)
|
|
14
17
|
class Feature(object):
|
|
15
18
|
"""
|
|
16
19
|
An abstract base class for Features. A Feature is a combination of
|
|
@@ -29,9 +32,6 @@ class Feature(object):
|
|
|
29
32
|
to the classname.
|
|
30
33
|
|
|
31
34
|
"""
|
|
32
|
-
# !!FOR_FUTURE: when targeting python3 only, consider @abc.abstractmethod
|
|
33
|
-
# and metaclass=abc.ABCMeta rather than NotImplementedError
|
|
34
|
-
# http://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods
|
|
35
35
|
|
|
36
36
|
json_tag = 'nltk.tbl.Feature'
|
|
37
37
|
PROPERTY_NAME = None
|
|
@@ -245,6 +245,7 @@ class Feature(object):
|
|
|
245
245
|
return self < other or self == other
|
|
246
246
|
|
|
247
247
|
@staticmethod
|
|
248
|
+
@abstractmethod
|
|
248
249
|
def extract_property(tokens, index):
|
|
249
250
|
"""
|
|
250
251
|
Any subclass of Feature must define static method extract_property(tokens, index)
|
|
@@ -256,6 +257,3 @@ class Feature(object):
|
|
|
256
257
|
:return: feature value
|
|
257
258
|
:rtype: any (but usually scalar)
|
|
258
259
|
"""
|
|
259
|
-
raise NotImplementedError
|
|
260
|
-
|
|
261
|
-
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Natural Language Toolkit: Transformation-based learning
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Marcus Uneson <marcus.uneson@gmail.com>
|
|
6
6
|
# based on previous (nltk2) version by
|
|
7
7
|
# Christopher Maloof, Edward Loper, Steven Bird
|
|
@@ -9,15 +9,17 @@
|
|
|
9
9
|
# For license information, see LICENSE.TXT
|
|
10
10
|
|
|
11
11
|
from __future__ import print_function
|
|
12
|
+
from abc import ABCMeta, abstractmethod
|
|
13
|
+
from six import add_metaclass
|
|
12
14
|
|
|
13
15
|
from nltk.compat import python_2_unicode_compatible, unicode_repr
|
|
14
16
|
from nltk import jsontags
|
|
15
17
|
|
|
18
|
+
|
|
16
19
|
######################################################################
|
|
17
20
|
# Tag Rules
|
|
18
21
|
######################################################################
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
@add_metaclass(ABCMeta)
|
|
21
23
|
class TagRule(object):
|
|
22
24
|
"""
|
|
23
25
|
An interface for tag transformations on a tagged corpus, as
|
|
@@ -71,6 +73,7 @@ class TagRule(object):
|
|
|
71
73
|
|
|
72
74
|
return change
|
|
73
75
|
|
|
76
|
+
@abstractmethod
|
|
74
77
|
def applies(self, tokens, index):
|
|
75
78
|
"""
|
|
76
79
|
:return: True if the rule would change the tag of
|
|
@@ -81,7 +84,6 @@ class TagRule(object):
|
|
|
81
84
|
:param index: The index to check
|
|
82
85
|
:type index: int
|
|
83
86
|
"""
|
|
84
|
-
raise NotImplementedError
|
|
85
87
|
|
|
86
88
|
# Rules must be comparable and hashable for the algorithm to work
|
|
87
89
|
def __eq__(self, other):
|
|
@@ -317,5 +319,3 @@ class Rule(TagRule):
|
|
|
317
319
|
condition_to_str(f, v) for (f, v) in self._conditions
|
|
318
320
|
)
|
|
319
321
|
return replacement + conditions
|
|
320
|
-
|
|
321
|
-
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Natural Language Toolkit: Transformation-based learning
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
4
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
5
5
|
# Author: Marcus Uneson <marcus.uneson@gmail.com>
|
|
6
6
|
# based on previous (nltk2) version by
|
|
7
7
|
# Christopher Maloof, Edward Loper, Steven Bird
|
|
@@ -9,19 +9,21 @@
|
|
|
9
9
|
# For license information, see LICENSE.TXT
|
|
10
10
|
|
|
11
11
|
from __future__ import print_function
|
|
12
|
+
from abc import ABCMeta, abstractmethod
|
|
13
|
+
from six import add_metaclass
|
|
12
14
|
import itertools as it
|
|
13
15
|
from nltk.tbl.feature import Feature
|
|
16
|
+
from nltk.tbl.rule import Rule
|
|
14
17
|
|
|
15
18
|
|
|
19
|
+
@add_metaclass(ABCMeta)
|
|
16
20
|
class BrillTemplateI(object):
|
|
17
21
|
"""
|
|
18
22
|
An interface for generating lists of transformational rules that
|
|
19
23
|
apply at given sentence positions. ``BrillTemplateI`` is used by
|
|
20
24
|
``Brill`` training algorithms to generate candidate rules.
|
|
21
25
|
"""
|
|
22
|
-
|
|
23
|
-
# and metaclass=abc.ABCMeta rather than NotImplementedError
|
|
24
|
-
#http://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods
|
|
26
|
+
@abstractmethod
|
|
25
27
|
def applicable_rules(self, tokens, i, correctTag):
|
|
26
28
|
"""
|
|
27
29
|
Return a list of the transformational rules that would correct
|
|
@@ -41,8 +43,8 @@ class BrillTemplateI(object):
|
|
|
41
43
|
:type correctTag: any
|
|
42
44
|
:rtype: list(BrillRule)
|
|
43
45
|
"""
|
|
44
|
-
raise NotImplementedError
|
|
45
46
|
|
|
47
|
+
@abstractmethod
|
|
46
48
|
def get_neighborhood(self, token, index):
|
|
47
49
|
"""
|
|
48
50
|
Returns the set of indices *i* such that
|
|
@@ -57,10 +59,6 @@ class BrillTemplateI(object):
|
|
|
57
59
|
:type index: int
|
|
58
60
|
:rtype: set
|
|
59
61
|
"""
|
|
60
|
-
raise NotImplementedError
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
from nltk.tbl.rule import Rule
|
|
64
62
|
|
|
65
63
|
|
|
66
64
|
class Template(BrillTemplateI):
|
|
@@ -75,8 +73,8 @@ class Template(BrillTemplateI):
|
|
|
75
73
|
- are applicable to the given token.
|
|
76
74
|
"""
|
|
77
75
|
ALLTEMPLATES = []
|
|
78
|
-
#record a unique id of form "001", for each template created
|
|
79
|
-
#
|
|
76
|
+
# record a unique id of form "001", for each template created
|
|
77
|
+
# _ids = it.count(0)
|
|
80
78
|
|
|
81
79
|
def __init__(self, *features):
|
|
82
80
|
|
|
@@ -129,9 +127,9 @@ class Template(BrillTemplateI):
|
|
|
129
127
|
:type features: list of Features
|
|
130
128
|
:param features: the features to build this Template on
|
|
131
129
|
"""
|
|
132
|
-
#determine the calling form: either
|
|
133
|
-
#Template(Feature, args1, [args2, ...)]
|
|
134
|
-
#Template(Feature1(args), Feature2(args), ...)
|
|
130
|
+
# determine the calling form: either
|
|
131
|
+
# Template(Feature, args1, [args2, ...)]
|
|
132
|
+
# Template(Feature1(args), Feature2(args), ...)
|
|
135
133
|
if all(isinstance(f, Feature) for f in features):
|
|
136
134
|
self._features = features
|
|
137
135
|
elif issubclass(features[0], Feature) and all(isinstance(a, tuple) for a in features[1:]):
|
|
@@ -267,13 +265,13 @@ class Template(BrillTemplateI):
|
|
|
267
265
|
|
|
268
266
|
"""
|
|
269
267
|
def nonempty_powerset(xs): #xs is a list
|
|
270
|
-
#itertools docnonempty_powerset([1,2,3]) --> (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
|
|
268
|
+
# itertools docnonempty_powerset([1,2,3]) --> (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
|
|
271
269
|
|
|
272
|
-
#find the correct tuple given combinations, one of {None, k, (k1,k2)}
|
|
270
|
+
# find the correct tuple given combinations, one of {None, k, (k1,k2)}
|
|
273
271
|
k = combinations #for brevity
|
|
274
|
-
combrange = ((1, len(xs)+1) if k is None else #n over 1 .. n over n (all non-empty combinations)
|
|
275
|
-
(k, k+1) if isinstance(k, int) else #n over k (only
|
|
276
|
-
(k[0], k[1]+1)) #n over k1, n over k1+1... n over k2
|
|
272
|
+
combrange = ((1, len(xs)+1) if k is None else # n over 1 .. n over n (all non-empty combinations)
|
|
273
|
+
(k, k+1) if isinstance(k, int) else # n over k (only
|
|
274
|
+
(k[0], k[1]+1)) # n over k1, n over k1+1... n over k2
|
|
277
275
|
return it.chain.from_iterable(it.combinations(xs, r)
|
|
278
276
|
for r in range(*combrange))
|
|
279
277
|
seentemplates = set()
|
|
@@ -281,7 +279,7 @@ class Template(BrillTemplateI):
|
|
|
281
279
|
for pick in it.product(*picks):
|
|
282
280
|
if any(i != j and x.issuperset(y)
|
|
283
281
|
for (i, x) in enumerate(pick)
|
|
284
|
-
for (j,y) in enumerate(pick)):
|
|
282
|
+
for (j, y) in enumerate(pick)):
|
|
285
283
|
continue
|
|
286
284
|
if skipintersecting and any(i != j and x.intersects(y)
|
|
287
285
|
for (i, x) in enumerate(pick)
|
|
@@ -303,6 +301,3 @@ class Template(BrillTemplateI):
|
|
|
303
301
|
@classmethod
|
|
304
302
|
def _poptemplate(cls):
|
|
305
303
|
return cls.ALLTEMPLATES.pop() if cls.ALLTEMPLATES else None
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
@@ -10,14 +10,15 @@ import doctest, unittest
|
|
|
10
10
|
from glob import glob
|
|
11
11
|
import os.path
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
def additional_tests():
|
|
14
|
-
#print "here-000000000000000"
|
|
15
|
-
#print "-----", glob(os.path.join(os.path.dirname(__file__), '*.doctest'))
|
|
15
|
+
# print "here-000000000000000"
|
|
16
|
+
# print "-----", glob(os.path.join(os.path.dirname(__file__), '*.doctest'))
|
|
16
17
|
dir = os.path.dirname(__file__)
|
|
17
18
|
paths = glob(os.path.join(dir, '*.doctest'))
|
|
18
|
-
files = [
|
|
19
|
+
files = [os.path.basename(path) for path in paths]
|
|
19
20
|
return unittest.TestSuite(
|
|
20
|
-
[
|
|
21
|
-
|
|
22
|
-
#if os.path.split(path)[-1] != 'index.rst'
|
|
21
|
+
[doctest.DocFileSuite(file) for file in files]
|
|
22
|
+
)
|
|
23
|
+
# if os.path.split(path)[-1] != 'index.rst'
|
|
23
24
|
# skips time-dependent doctest in index.rst
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
from __future__ import absolute_import
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
# most of classify.doctest requires numpy
|
|
5
6
|
def setup_module(module):
|
|
6
7
|
from nose import SkipTest
|
|
7
8
|
try:
|
|
8
9
|
import numpy
|
|
9
10
|
except ImportError:
|
|
10
|
-
raise SkipTest("classify.doctest requires numpy")
|
|
11
|
+
raise SkipTest("classify.doctest requires numpy")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.. Copyright (C) 2001-2018 NLTK Project
|
|
2
|
+
.. For license information, see LICENSE.TXT
|
|
3
|
+
|
|
4
|
+
===========
|
|
5
|
+
Collections
|
|
6
|
+
===========
|
|
7
|
+
|
|
8
|
+
>>> import nltk
|
|
9
|
+
>>> from nltk.collections import *
|
|
10
|
+
|
|
11
|
+
Trie
|
|
12
|
+
----
|
|
13
|
+
|
|
14
|
+
Trie can be pickled:
|
|
15
|
+
|
|
16
|
+
>>> import pickle
|
|
17
|
+
>>> trie = nltk.collections.Trie(['a'])
|
|
18
|
+
>>> s = pickle.dumps(trie)
|
|
19
|
+
>>> pickle.loads(s)
|
|
20
|
+
{'a': {True: None}}
|
|
@@ -9,10 +9,6 @@ NLTK comes with a Python 2.x/3.x compatibility layer, nltk.compat
|
|
|
9
9
|
>>> from nltk import compat
|
|
10
10
|
>>> compat.PY3
|
|
11
11
|
False
|
|
12
|
-
>>> compat.integer_types
|
|
13
|
-
(<type 'int'>, <type 'long'>)
|
|
14
|
-
>>> compat.string_types
|
|
15
|
-
(<type 'basestring'>,)
|
|
16
12
|
>>> # and so on
|
|
17
13
|
|
|
18
14
|
@python_2_unicode_compatible
|