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: Probability and Statistics
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2001-
|
|
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
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
231
|
+
n = self.N()
|
|
232
|
+
if n == 0:
|
|
196
233
|
return 0
|
|
197
|
-
return self[sample] /
|
|
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)), [
|
|
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
|
-
|
|
415
|
-
|
|
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
|
|
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)), [
|
|
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
|
-
|
|
2031
|
+
"""
|
|
2032
|
+
Classes inheriting from ConditionalProbDistI should implement __init__.
|
|
2033
|
+
"""
|
|
1979
2034
|
|
|
1980
2035
|
def conditions(self):
|
|
1981
2036
|
"""
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Author: Dan Garrette <dhgarrette@gmail.com>
|
|
5
5
|
#
|
|
6
|
-
# Copyright (C) 2001-
|
|
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
|
|
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: "
|
|
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: "
|
|
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>'
|
|
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 "
|
|
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:
|
|
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(
|
|
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:
|
|
245
|
+
assert line.endswith(').'), "can't parse line: {0}".format(line)
|
|
246
246
|
|
|
247
|
-
search_start = len('sem(
|
|
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_
|
|
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_
|
|
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_
|
|
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_
|
|
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("
|
|
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-
|
|
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
|
|
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-
|
|
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-
|
|
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
|
|
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
|
-
|
|
26
|
-
from
|
|
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 +
|
|
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-
|
|
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
|
|
15
|
-
|
|
16
|
-
from
|
|
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
|
|
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-
|
|
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
|
|
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
|
-
|
|
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-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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-
|
|
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
|
|
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-
|
|
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
|
|
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-
|
|
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
|
|
13
|
+
from nltk.compat import python_2_unicode_compatible
|
|
12
14
|
from nltk.sem.logic import LogicParser, APP
|
|
13
15
|
|
|
14
16
|
_counter = Counter()
|