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,6 +1,6 @@
|
|
|
1
1
|
# Natural Language Toolkit: TextTiling
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2001-
|
|
3
|
+
# Copyright (C) 2001-2018 NLTK Project
|
|
4
4
|
# Author: George Boutsioukis
|
|
5
5
|
#
|
|
6
6
|
# URL: <http://nltk.org/>
|
|
@@ -55,12 +55,10 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
55
55
|
|
|
56
56
|
>>> from nltk.corpus import brown
|
|
57
57
|
>>> tt = TextTilingTokenizer(demo_mode=True)
|
|
58
|
-
>>> text = brown.raw()[:
|
|
58
|
+
>>> text = brown.raw()[:4000]
|
|
59
59
|
>>> s, ss, d, b = tt.tokenize(text)
|
|
60
60
|
>>> b
|
|
61
|
-
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
|
62
|
-
0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
|
63
|
-
0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0]
|
|
61
|
+
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0]
|
|
64
62
|
"""
|
|
65
63
|
|
|
66
64
|
def __init__(self,
|
|
@@ -74,7 +72,6 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
74
72
|
cutoff_policy=HC,
|
|
75
73
|
demo_mode=False):
|
|
76
74
|
|
|
77
|
-
|
|
78
75
|
if stopwords is None:
|
|
79
76
|
from nltk.corpus import stopwords
|
|
80
77
|
stopwords = stopwords.words('english')
|
|
@@ -118,9 +115,13 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
118
115
|
gap_scores = self._block_comparison(tokseqs, token_table)
|
|
119
116
|
elif self.similarity_method == VOCABULARY_INTRODUCTION:
|
|
120
117
|
raise NotImplementedError("Vocabulary introduction not implemented")
|
|
118
|
+
else:
|
|
119
|
+
raise ValueError("Similarity method {} not recognized".format(self.similarity_method))
|
|
121
120
|
|
|
122
121
|
if self.smoothing_method == DEFAULT_SMOOTHING:
|
|
123
122
|
smooth_scores = self._smooth_scores(gap_scores)
|
|
123
|
+
else:
|
|
124
|
+
raise ValueError("Smoothing method {} not recognized".format(self.smoothing_method))
|
|
124
125
|
# End of Lexical score Determination
|
|
125
126
|
|
|
126
127
|
# Boundary identification
|
|
@@ -140,7 +141,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
140
141
|
segmented_text.append(text[prevb:b])
|
|
141
142
|
prevb = b
|
|
142
143
|
|
|
143
|
-
if prevb < text_length:
|
|
144
|
+
if prevb < text_length: # append any text that may be remaining
|
|
144
145
|
segmented_text.append(text[prevb:])
|
|
145
146
|
|
|
146
147
|
if not segmented_text:
|
|
@@ -151,7 +152,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
151
152
|
return segmented_text
|
|
152
153
|
|
|
153
154
|
def _block_comparison(self, tokseqs, token_table):
|
|
154
|
-
"Implements the block comparison method"
|
|
155
|
+
"""Implements the block comparison method"""
|
|
155
156
|
def blk_frq(tok, block):
|
|
156
157
|
ts_occs = filter(lambda o: o[0] in block,
|
|
157
158
|
token_table[tok].ts_occurences)
|
|
@@ -164,7 +165,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
164
165
|
for curr_gap in range(numgaps):
|
|
165
166
|
score_dividend, score_divisor_b1, score_divisor_b2 = 0.0, 0.0, 0.0
|
|
166
167
|
score = 0.0
|
|
167
|
-
#adjust window size for boundary conditions
|
|
168
|
+
# adjust window size for boundary conditions
|
|
168
169
|
if curr_gap < self.k-1:
|
|
169
170
|
window_size = curr_gap + 1
|
|
170
171
|
elif curr_gap > numgaps-self.k:
|
|
@@ -182,10 +183,10 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
182
183
|
score_divisor_b1 += blk_frq(t, b1)**2
|
|
183
184
|
score_divisor_b2 += blk_frq(t, b2)**2
|
|
184
185
|
try:
|
|
185
|
-
score = score_dividend/math.sqrt(score_divisor_b1*
|
|
186
|
-
|
|
186
|
+
score = score_dividend / math.sqrt(score_divisor_b1 *
|
|
187
|
+
score_divisor_b2)
|
|
187
188
|
except ZeroDivisionError:
|
|
188
|
-
pass
|
|
189
|
+
pass # score += 0.0
|
|
189
190
|
|
|
190
191
|
gap_scores.append(score)
|
|
191
192
|
|
|
@@ -194,12 +195,11 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
194
195
|
def _smooth_scores(self, gap_scores):
|
|
195
196
|
"Wraps the smooth function from the SciPy Cookbook"
|
|
196
197
|
return list(smooth(numpy.array(gap_scores[:]),
|
|
197
|
-
window_len
|
|
198
|
+
window_len=self.smoothing_width+1))
|
|
198
199
|
|
|
199
200
|
def _mark_paragraph_breaks(self, text):
|
|
200
201
|
"""Identifies indented text or line breaks as the beginning of
|
|
201
202
|
paragraphs"""
|
|
202
|
-
|
|
203
203
|
MIN_PARAGRAPH = 100
|
|
204
204
|
pattern = re.compile("[ \t\r\f\v]*\n[ \t\r\f\v]*\n[ \t\r\f\v]*")
|
|
205
205
|
matches = pattern.finditer(text)
|
|
@@ -234,7 +234,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
234
234
|
current_par_break = next(pb_iter)
|
|
235
235
|
if current_par_break == 0:
|
|
236
236
|
try:
|
|
237
|
-
current_par_break = next(pb_iter)
|
|
237
|
+
current_par_break = next(pb_iter) # skip break at 0
|
|
238
238
|
except StopIteration:
|
|
239
239
|
raise ValueError(
|
|
240
240
|
"No paragraph breaks were found(text too short perhaps?)"
|
|
@@ -246,7 +246,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
246
246
|
current_par_break = next(pb_iter)
|
|
247
247
|
current_par += 1
|
|
248
248
|
except StopIteration:
|
|
249
|
-
#hit bottom
|
|
249
|
+
# hit bottom
|
|
250
250
|
pass
|
|
251
251
|
|
|
252
252
|
if word in token_table:
|
|
@@ -258,19 +258,16 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
258
258
|
|
|
259
259
|
if token_table[word].last_tok_seq != current_tok_seq:
|
|
260
260
|
token_table[word].last_tok_seq = current_tok_seq
|
|
261
|
-
token_table[word]
|
|
262
|
-
.ts_occurences.append([current_tok_seq,1])
|
|
261
|
+
token_table[word].ts_occurences.append([current_tok_seq, 1])
|
|
263
262
|
else:
|
|
264
263
|
token_table[word].ts_occurences[-1][1] += 1
|
|
265
|
-
else:
|
|
264
|
+
else: # new word
|
|
266
265
|
token_table[word] = TokenTableField(first_pos=index,
|
|
267
|
-
ts_occurences=
|
|
268
|
-
[[current_tok_seq,1]],
|
|
266
|
+
ts_occurences=[[current_tok_seq, 1]],
|
|
269
267
|
total_count=1,
|
|
270
268
|
par_count=1,
|
|
271
269
|
last_par=current_par,
|
|
272
|
-
last_tok_seq=
|
|
273
|
-
current_tok_seq)
|
|
270
|
+
last_tok_seq=current_tok_seq)
|
|
274
271
|
|
|
275
272
|
current_tok_seq += 1
|
|
276
273
|
|
|
@@ -285,7 +282,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
285
282
|
avg = sum(depth_scores)/len(depth_scores)
|
|
286
283
|
stdev = numpy.std(depth_scores)
|
|
287
284
|
|
|
288
|
-
#SB: what is the purpose of this conditional?
|
|
285
|
+
# SB: what is the purpose of this conditional?
|
|
289
286
|
if self.cutoff_policy == LC:
|
|
290
287
|
cutoff = avg-stdev/2.0
|
|
291
288
|
else:
|
|
@@ -293,11 +290,11 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
293
290
|
|
|
294
291
|
depth_tuples = sorted(zip(depth_scores, range(len(depth_scores))))
|
|
295
292
|
depth_tuples.reverse()
|
|
296
|
-
hp = list(filter(lambda x:x[0]>cutoff, depth_tuples))
|
|
293
|
+
hp = list(filter(lambda x: x[0] > cutoff, depth_tuples))
|
|
297
294
|
|
|
298
295
|
for dt in hp:
|
|
299
296
|
boundaries[dt[1]] = 1
|
|
300
|
-
for dt2 in hp:
|
|
297
|
+
for dt2 in hp: # undo if there is a boundary close already
|
|
301
298
|
if dt[1] != dt2[1] and abs(dt2[1]-dt[1]) < 4 \
|
|
302
299
|
and boundaries[dt2[1]] == 1:
|
|
303
300
|
boundaries[dt[1]] = 0
|
|
@@ -308,11 +305,11 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
308
305
|
between the left and right peaks and the gap's score"""
|
|
309
306
|
|
|
310
307
|
depth_scores = [0 for x in scores]
|
|
311
|
-
#clip boundaries: this holds on the rule of thumb(my thumb)
|
|
312
|
-
#that a section shouldn't be smaller than at least 2
|
|
313
|
-
#pseudosentences for small texts and around 5 for larger ones.
|
|
308
|
+
# clip boundaries: this holds on the rule of thumb(my thumb)
|
|
309
|
+
# that a section shouldn't be smaller than at least 2
|
|
310
|
+
# pseudosentences for small texts and around 5 for larger ones.
|
|
314
311
|
|
|
315
|
-
clip = min(max(len(scores)
|
|
312
|
+
clip = min(max(len(scores) // 10, 2), 5)
|
|
316
313
|
index = clip
|
|
317
314
|
|
|
318
315
|
for gapscore in scores[clip:-clip]:
|
|
@@ -347,11 +344,11 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
347
344
|
seen_word = False
|
|
348
345
|
word_count += 1
|
|
349
346
|
if char not in " \t\n" and not seen_word:
|
|
350
|
-
seen_word=True
|
|
347
|
+
seen_word = True
|
|
351
348
|
if gaps_seen < len(boundaries) and word_count > \
|
|
352
|
-
|
|
349
|
+
(max(gaps_seen*self.w, self.w)):
|
|
353
350
|
if boundaries[gaps_seen] == 1:
|
|
354
|
-
#find closest paragraph break
|
|
351
|
+
# find closest paragraph break
|
|
355
352
|
best_fit = len(text)
|
|
356
353
|
for br in paragraph_breaks:
|
|
357
354
|
if best_fit > abs(br-char_count):
|
|
@@ -359,7 +356,7 @@ class TextTilingTokenizer(TokenizerI):
|
|
|
359
356
|
bestbr = br
|
|
360
357
|
else:
|
|
361
358
|
break
|
|
362
|
-
if bestbr not in norm_boundaries:
|
|
359
|
+
if bestbr not in norm_boundaries: # avoid duplicates
|
|
363
360
|
norm_boundaries.append(bestbr)
|
|
364
361
|
gaps_seen += 1
|
|
365
362
|
|
|
@@ -379,18 +376,20 @@ class TokenTableField(object):
|
|
|
379
376
|
self.__dict__.update(locals())
|
|
380
377
|
del self.__dict__['self']
|
|
381
378
|
|
|
379
|
+
|
|
382
380
|
class TokenSequence(object):
|
|
383
381
|
"A token list with its original length and its index"
|
|
384
382
|
def __init__(self,
|
|
385
383
|
index,
|
|
386
384
|
wrdindex_list,
|
|
387
385
|
original_length=None):
|
|
388
|
-
original_length=original_length or len(wrdindex_list)
|
|
386
|
+
original_length = original_length or len(wrdindex_list)
|
|
389
387
|
self.__dict__.update(locals())
|
|
390
388
|
del self.__dict__['self']
|
|
391
389
|
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
|
|
391
|
+
# Pasted from the SciPy cookbook: http://www.scipy.org/Cookbook/SignalSmooth
|
|
392
|
+
def smooth(x, window_len=11, window='flat'):
|
|
394
393
|
"""smooth the data using a window with requested size.
|
|
395
394
|
|
|
396
395
|
This method is based on the convolution of a scaled window with the signal.
|
|
@@ -426,14 +425,14 @@ def smooth(x,window_len=11,window='flat'):
|
|
|
426
425
|
if window_len < 3:
|
|
427
426
|
return x
|
|
428
427
|
|
|
429
|
-
if not
|
|
428
|
+
if window not in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']:
|
|
430
429
|
raise ValueError("Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'")
|
|
431
430
|
|
|
432
|
-
s=numpy.r_[2*x[0]-x[window_len:1:-1],x,2*x[-1]-x[-1:-window_len:-1]]
|
|
431
|
+
s = numpy.r_[2*x[0]-x[window_len:1:-1], x, 2*x[-1]-x[-1:-window_len:-1]]
|
|
433
432
|
|
|
434
|
-
#print(len(s))
|
|
435
|
-
if window == 'flat':
|
|
436
|
-
w = numpy.ones(window_len,'d')
|
|
433
|
+
# print(len(s))
|
|
434
|
+
if window == 'flat': # moving average
|
|
435
|
+
w = numpy.ones(window_len, 'd')
|
|
437
436
|
else:
|
|
438
437
|
w = eval('numpy.' + window + '(window_len)')
|
|
439
438
|
|
|
@@ -446,7 +445,8 @@ def demo(text=None):
|
|
|
446
445
|
from nltk.corpus import brown
|
|
447
446
|
from matplotlib import pylab
|
|
448
447
|
tt = TextTilingTokenizer(demo_mode=True)
|
|
449
|
-
if text is None:
|
|
448
|
+
if text is None:
|
|
449
|
+
text = brown.raw()[:10000]
|
|
450
450
|
s, ss, d, b = tt.tokenize(text)
|
|
451
451
|
pylab.xlabel("Sentence Gap index")
|
|
452
452
|
pylab.ylabel("Gap Scores")
|
|
@@ -456,5 +456,3 @@ def demo(text=None):
|
|
|
456
456
|
pylab.stem(range(len(b)), b)
|
|
457
457
|
pylab.legend()
|
|
458
458
|
pylab.show()
|
|
459
|
-
|
|
460
|
-
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Natural Language Toolkit: Python port of the tok-tok.pl tokenizer.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2001-2015 NLTK Project
|
|
5
|
+
# Author: Jon Dehdari
|
|
6
|
+
# Contributors: Liling Tan, Selcuk Ayguney, ikegami, Martijn Pieters
|
|
7
|
+
#
|
|
8
|
+
# URL: <http://nltk.sourceforge.net>
|
|
9
|
+
# For license information, see LICENSE.TXT
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
The tok-tok tokenizer is a simple, general tokenizer, where the input has one
|
|
13
|
+
sentence per line; thus only final period is tokenized.
|
|
14
|
+
|
|
15
|
+
Tok-tok has been tested on, and gives reasonably good results for English,
|
|
16
|
+
Persian, Russian, Czech, French, German, Vietnamese, Tajik, and a few others.
|
|
17
|
+
The input should be in UTF-8 encoding.
|
|
18
|
+
|
|
19
|
+
Reference:
|
|
20
|
+
Jon Dehdari. 2014. A Neurophysiologically-Inspired Statistical Language
|
|
21
|
+
Model (Doctoral dissertation). Columbus, OH, USA: The Ohio State University.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import re
|
|
25
|
+
from six import text_type
|
|
26
|
+
|
|
27
|
+
from nltk.tokenize.api import TokenizerI
|
|
28
|
+
|
|
29
|
+
class ToktokTokenizer(TokenizerI):
|
|
30
|
+
"""
|
|
31
|
+
This is a Python port of the tok-tok.pl from
|
|
32
|
+
https://github.com/jonsafari/tok-tok/blob/master/tok-tok.pl
|
|
33
|
+
|
|
34
|
+
>>> toktok = ToktokTokenizer()
|
|
35
|
+
>>> text = u'Is 9.5 or 525,600 my favorite number?'
|
|
36
|
+
>>> print (toktok.tokenize(text, return_str=True))
|
|
37
|
+
Is 9.5 or 525,600 my favorite number ?
|
|
38
|
+
>>> text = u'The https://github.com/jonsafari/tok-tok/blob/master/tok-tok.pl is a website with/and/or slashes and sort of weird : things'
|
|
39
|
+
>>> print (toktok.tokenize(text, return_str=True))
|
|
40
|
+
The https://github.com/jonsafari/tok-tok/blob/master/tok-tok.pl is a website with/and/or slashes and sort of weird : things
|
|
41
|
+
>>> text = u'\xa1This, is a sentence with weird\xbb symbols\u2026 appearing everywhere\xbf'
|
|
42
|
+
>>> expected = u'\xa1 This , is a sentence with weird \xbb symbols \u2026 appearing everywhere \xbf'
|
|
43
|
+
>>> assert toktok.tokenize(text, return_str=True) == expected
|
|
44
|
+
>>> toktok.tokenize(text) == [u'\xa1', u'This', u',', u'is', u'a', u'sentence', u'with', u'weird', u'\xbb', u'symbols', u'\u2026', u'appearing', u'everywhere', u'\xbf']
|
|
45
|
+
True
|
|
46
|
+
"""
|
|
47
|
+
# Replace non-breaking spaces with normal spaces.
|
|
48
|
+
NON_BREAKING = re.compile(u"\u00A0"), " "
|
|
49
|
+
|
|
50
|
+
# Pad some funky punctuation.
|
|
51
|
+
FUNKY_PUNCT_1 = re.compile(u'([،;؛¿!"\])}»›”؟¡%٪°±©®।॥…])'), r" \1 "
|
|
52
|
+
# Pad more funky punctuation.
|
|
53
|
+
FUNKY_PUNCT_2 = re.compile(u'([({\[“‘„‚«‹「『])'), r" \1 "
|
|
54
|
+
# Pad En dash and em dash
|
|
55
|
+
EN_EM_DASHES = re.compile(u'([–—])'), r" \1 "
|
|
56
|
+
|
|
57
|
+
# Replace problematic character with numeric character reference.
|
|
58
|
+
AMPERCENT = re.compile('& '), '& '
|
|
59
|
+
TAB = re.compile('\t'), ' 	 '
|
|
60
|
+
PIPE = re.compile('\|'), ' | '
|
|
61
|
+
|
|
62
|
+
# Pad numbers with commas to keep them from further tokenization.
|
|
63
|
+
COMMA_IN_NUM = re.compile(r'(?<!,)([,،])(?![,\d])'), r' \1 '
|
|
64
|
+
|
|
65
|
+
# Just pad problematic (often neurotic) hyphen/single quote, etc.
|
|
66
|
+
PROB_SINGLE_QUOTES = re.compile(r"(['’`])"), r' \1 '
|
|
67
|
+
# Group ` ` stupid quotes ' ' into a single token.
|
|
68
|
+
STUPID_QUOTES_1 = re.compile(r" ` ` "), r" `` "
|
|
69
|
+
STUPID_QUOTES_2 = re.compile(r" ' ' "), r" '' "
|
|
70
|
+
|
|
71
|
+
# Don't tokenize period unless it ends the line and that it isn't
|
|
72
|
+
# preceded by another period, e.g.
|
|
73
|
+
# "something ..." -> "something ..."
|
|
74
|
+
# "something." -> "something ."
|
|
75
|
+
FINAL_PERIOD_1 = re.compile(r"(?<!\.)\.$"), r" ."
|
|
76
|
+
# Don't tokenize period unless it ends the line eg.
|
|
77
|
+
# " ... stuff." -> "... stuff ."
|
|
78
|
+
FINAL_PERIOD_2 = re.compile(r"""(?<!\.)\.\s*(["'’»›”]) *$"""), r" . \1"
|
|
79
|
+
|
|
80
|
+
# Treat continuous commas as fake German,Czech, etc.: „
|
|
81
|
+
MULTI_COMMAS = re.compile(r'(,{2,})'), r' \1 '
|
|
82
|
+
# Treat continuous dashes as fake en-dash, etc.
|
|
83
|
+
MULTI_DASHES = re.compile(r'(-{2,})'), r' \1 '
|
|
84
|
+
# Treat multiple periods as a thing (eg. ellipsis)
|
|
85
|
+
MULTI_DOTS = re.compile(r'(\.{2,})'), r' \1 '
|
|
86
|
+
|
|
87
|
+
# This is the \p{Open_Punctuation} from Perl's perluniprops
|
|
88
|
+
# see http://perldoc.perl.org/perluniprops.html
|
|
89
|
+
OPEN_PUNCT = text_type(u'([{\u0f3a\u0f3c\u169b\u201a\u201e\u2045\u207d'
|
|
90
|
+
u'\u208d\u2329\u2768\u276a\u276c\u276e\u2770\u2772'
|
|
91
|
+
u'\u2774\u27c5\u27e6\u27e8\u27ea\u27ec\u27ee\u2983'
|
|
92
|
+
u'\u2985\u2987\u2989\u298b\u298d\u298f\u2991\u2993'
|
|
93
|
+
u'\u2995\u2997\u29d8\u29da\u29fc\u2e22\u2e24\u2e26'
|
|
94
|
+
u'\u2e28\u3008\u300a\u300c\u300e\u3010\u3014\u3016'
|
|
95
|
+
u'\u3018\u301a\u301d\ufd3e\ufe17\ufe35\ufe37\ufe39'
|
|
96
|
+
u'\ufe3b\ufe3d\ufe3f\ufe41\ufe43\ufe47\ufe59\ufe5b'
|
|
97
|
+
u'\ufe5d\uff08\uff3b\uff5b\uff5f\uff62')
|
|
98
|
+
# This is the \p{Close_Punctuation} from Perl's perluniprops
|
|
99
|
+
CLOSE_PUNCT = text_type(u')]}\u0f3b\u0f3d\u169c\u2046\u207e\u208e\u232a'
|
|
100
|
+
u'\u2769\u276b\u276d\u276f\u2771\u2773\u2775\u27c6'
|
|
101
|
+
u'\u27e7\u27e9\u27eb\u27ed\u27ef\u2984\u2986\u2988'
|
|
102
|
+
u'\u298a\u298c\u298e\u2990\u2992\u2994\u2996\u2998'
|
|
103
|
+
u'\u29d9\u29db\u29fd\u2e23\u2e25\u2e27\u2e29\u3009'
|
|
104
|
+
u'\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b'
|
|
105
|
+
u'\u301e\u301f\ufd3f\ufe18\ufe36\ufe38\ufe3a\ufe3c'
|
|
106
|
+
u'\ufe3e\ufe40\ufe42\ufe44\ufe48\ufe5a\ufe5c\ufe5e'
|
|
107
|
+
u'\uff09\uff3d\uff5d\uff60\uff63')
|
|
108
|
+
# This is the \p{Close_Punctuation} from Perl's perluniprops
|
|
109
|
+
CURRENCY_SYM = text_type(u'$\xa2\xa3\xa4\xa5\u058f\u060b\u09f2\u09f3\u09fb'
|
|
110
|
+
u'\u0af1\u0bf9\u0e3f\u17db\u20a0\u20a1\u20a2\u20a3'
|
|
111
|
+
u'\u20a4\u20a5\u20a6\u20a7\u20a8\u20a9\u20aa\u20ab'
|
|
112
|
+
u'\u20ac\u20ad\u20ae\u20af\u20b0\u20b1\u20b2\u20b3'
|
|
113
|
+
u'\u20b4\u20b5\u20b6\u20b7\u20b8\u20b9\u20ba\ua838'
|
|
114
|
+
u'\ufdfc\ufe69\uff04\uffe0\uffe1\uffe5\uffe6')
|
|
115
|
+
|
|
116
|
+
# Pad spaces after opening punctuations.
|
|
117
|
+
OPEN_PUNCT_RE = re.compile(u'([{}])'.format(OPEN_PUNCT)), r'\1 '
|
|
118
|
+
# Pad spaces before closing punctuations.
|
|
119
|
+
CLOSE_PUNCT_RE = re.compile(u'([{}])'.format(CLOSE_PUNCT)), r'\1 '
|
|
120
|
+
# Pad spaces after currency symbols.
|
|
121
|
+
CURRENCY_SYM_RE = re.compile(u'([{}])'.format(CURRENCY_SYM)), r'\1 '
|
|
122
|
+
|
|
123
|
+
# Use for tokenizing URL-unfriendly characters: [:/?#]
|
|
124
|
+
URL_FOE_1 = re.compile(r':(?!//)'), r' : ' # in perl s{:(?!//)}{ : }g;
|
|
125
|
+
URL_FOE_2 = re.compile(r'\?(?!\S)'), r' ? ' # in perl s{\?(?!\S)}{ ? }g;
|
|
126
|
+
# in perl: m{://} or m{\S+\.\S+/\S+} or s{/}{ / }g;
|
|
127
|
+
URL_FOE_3 = re.compile(r'(:\/\/)[\S+\.\S+\/\S+][\/]'), ' / '
|
|
128
|
+
URL_FOE_4 = re.compile(r' /'), r' / ' # s{ /}{ / }g;
|
|
129
|
+
|
|
130
|
+
# Left/Right strip, i.e. remove heading/trailing spaces.
|
|
131
|
+
# These strip regexes should NOT be used,
|
|
132
|
+
# instead use str.lstrip(), str.rstrip() or str.strip()
|
|
133
|
+
# (They are kept for reference purposes to the original toktok.pl code)
|
|
134
|
+
LSTRIP = re.compile(r'^ +'), ''
|
|
135
|
+
RSTRIP = re.compile(r'\s+$'),'\n'
|
|
136
|
+
# Merge multiple spaces.
|
|
137
|
+
ONE_SPACE = re.compile(r' {2,}'), ' '
|
|
138
|
+
|
|
139
|
+
TOKTOK_REGEXES = [NON_BREAKING, FUNKY_PUNCT_1,
|
|
140
|
+
URL_FOE_1, URL_FOE_2, URL_FOE_3, URL_FOE_4,
|
|
141
|
+
AMPERCENT, TAB, PIPE,
|
|
142
|
+
OPEN_PUNCT_RE, CLOSE_PUNCT_RE,
|
|
143
|
+
MULTI_COMMAS, COMMA_IN_NUM, FINAL_PERIOD_2,
|
|
144
|
+
PROB_SINGLE_QUOTES, STUPID_QUOTES_1, STUPID_QUOTES_2,
|
|
145
|
+
CURRENCY_SYM_RE, EN_EM_DASHES, MULTI_DASHES, MULTI_DOTS,
|
|
146
|
+
FINAL_PERIOD_1, FINAL_PERIOD_2, ONE_SPACE]
|
|
147
|
+
|
|
148
|
+
def tokenize(self, text, return_str=False):
|
|
149
|
+
text = text_type(text) # Converts input string into unicode.
|
|
150
|
+
for regexp, subsitution in self.TOKTOK_REGEXES:
|
|
151
|
+
text = regexp.sub(subsitution, text)
|
|
152
|
+
# Finally, strips heading and trailing spaces
|
|
153
|
+
# and converts output string into unicode.
|
|
154
|
+
text = text_type(text.strip())
|
|
155
|
+
return text if return_str else text.split()
|