repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
nltk-develop
nltk-develop/nltk/test/portuguese_en_fixt.py
def setup_module(): import pytest pytest.skip("portuguese_en.doctest imports nltk.examples.pt which doesn't exist!")
126
24.4
86
py
nltk-develop
nltk-develop/nltk/test/all.py
"""Test suite that runs all NLTK tests. This module, `nltk.test.all`, is named as the NLTK ``test_suite`` in the project's ``setup-eggs.py`` file. Here, we create a test suite that runs all of our doctests, and return it for processing by the setuptools test harness. """ import doctest import os.path import unittest...
794
29.576923
80
py
nltk-develop
nltk-develop/nltk/test/gluesemantics_malt_fixt.py
def setup_module(): import pytest from nltk.parse.malt import MaltParser try: depparser = MaltParser() except (AssertionError, LookupError) as e: pytest.skip("MaltParser is not available")
223
21.4
50
py
nltk-develop
nltk-develop/nltk/test/childes_fixt.py
def setup_module(): import pytest import nltk.data try: nltk.data.find("corpora/childes/data-xml/Eng-USA-MOR/") except LookupError as e: pytest.skip( "The CHILDES corpus is not found. " "It should be manually downloaded and saved/unpacked " "to [NLTK...
359
24.714286
66
py
nltk-develop
nltk-develop/nltk/test/probability_fixt.py
# probability.doctest uses HMM which requires numpy; # skip probability.doctest if numpy is not available def setup_module(): import pytest pytest.importorskip("numpy")
180
19.111111
52
py
nltk-develop
nltk-develop/nltk/test/gensim_fixt.py
def setup_module(): import pytest pytest.importorskip("gensim")
73
13.8
33
py
nltk-develop
nltk-develop/nltk/test/classify_fixt.py
# most of classify.doctest requires numpy def setup_module(): import pytest pytest.importorskip("numpy")
114
18.166667
41
py
nltk-develop
nltk-develop/nltk/test/setup_fixt.py
from nltk.internals import find_binary, find_jar def check_binary(binary: str, **args): """Skip a test via `pytest.skip` if the `binary` executable is not found. Keyword arguments are passed to `nltk.internals.find_binary`.""" import pytest try: find_binary(binary, **args) except LookupEr...
886
31.851852
87
py
nltk-develop
nltk-develop/nltk/test/__init__.py
# Natural Language Toolkit: Unit Tests # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Unit tests for the NLTK modules. These tests are intended to ensure that source code changes don't accidentally intro...
469
23.736842
68
py
nltk-develop
nltk-develop/nltk/test/unit/test_cfd_mutation.py
import unittest import pytest from nltk import ConditionalFreqDist, tokenize class TestEmptyCondFreq(unittest.TestCase): def test_tabulate(self): empty = ConditionalFreqDist() self.assertEqual(empty.conditions(), []) with pytest.raises(ValueError): empty.tabulate(conditions="...
1,334
32.375
83
py
nltk-develop
nltk-develop/nltk/test/unit/test_data.py
import pytest import nltk.data def test_find_raises_exception(): with pytest.raises(LookupError): nltk.data.find("no_such_resource/foo") def test_find_raises_exception_with_full_resource_name(): no_such_thing = "no_such_thing/bar" with pytest.raises(LookupError) as exc: nltk.data.find(n...
375
22.5
57
py
nltk-develop
nltk-develop/nltk/test/unit/test_distance.py
from typing import Tuple import pytest from nltk.metrics.distance import edit_distance class TestEditDistance: @pytest.mark.parametrize( "left,right,substitution_cost,expecteds", [ # Allowing transpositions reduces the number of edits required. # with transpositions: ...
5,710
42.930769
100
py
nltk-develop
nltk-develop/nltk/test/unit/test_concordance.py
import contextlib import sys import unittest from io import StringIO from nltk.corpus import gutenberg from nltk.text import Text @contextlib.contextmanager def stdout_redirect(where): sys.stdout = where try: yield where finally: sys.stdout = sys.__stdout__ class TestConcordance(unittes...
4,010
39.515152
95
py
nltk-develop
nltk-develop/nltk/test/unit/test_tag.py
def test_basic(): from nltk.tag import pos_tag from nltk.tokenize import word_tokenize result = pos_tag(word_tokenize("John's big idea isn't all that bad.")) assert result == [ ("John", "NNP"), ("'s", "POS"), ("big", "JJ"), ("idea", "NN"), ("is", "VBZ"), ...
512
20.375
74
py
nltk-develop
nltk-develop/nltk/test/unit/test_bllip.py
import pytest from nltk.data import find from nltk.parse.bllip import BllipParser from nltk.tree import Tree @pytest.fixture(scope="module") def parser(): model_dir = find("models/bllip_wsj_no_aux").path return BllipParser.from_unified_model_dir(model_dir) def setup_module(): pytest.importorskip("bllip...
1,073
23.976744
70
py
nltk-develop
nltk-develop/nltk/test/unit/test_pl196x.py
import unittest import nltk from nltk.corpus.reader import pl196x class TestCorpusViews(unittest.TestCase): def test_corpus_reader(self): pl196x_dir = nltk.data.find("corpora/pl196x") pl = pl196x.Pl196xCorpusReader( pl196x_dir, r".*\.xml", textids="textids.txt", cat_file="cats.txt" ...
397
27.428571
78
py
nltk-develop
nltk-develop/nltk/test/unit/test_hmm.py
import pytest from nltk.tag import hmm def _wikipedia_example_hmm(): # Example from wikipedia # (https://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm) states = ["rain", "no rain"] symbols = ["umbrella", "no umbrella"] A = [[0.7, 0.3], [0.3, 0.7]] # transition probabilities B = ...
2,203
25.554217
73
py
nltk-develop
nltk-develop/nltk/test/unit/test_seekable_unicode_stream_reader.py
import os from io import BytesIO import pytest from nltk.corpus.reader import SeekableUnicodeStreamReader def check_reader(unicode_string, encoding): bytestr = unicode_string.encode(encoding) stream = BytesIO(bytestr) reader = SeekableUnicodeStreamReader(stream, encoding) # Should open at the start...
2,179
24.057471
70
py
nltk-develop
nltk-develop/nltk/test/unit/test_util.py
import pytest from nltk.util import everygrams @pytest.fixture def everygram_input(): """Form test data for tests.""" return iter(["a", "b", "c"]) def test_everygrams_without_padding(everygram_input): expected_output = [ ("a",), ("a", "b"), ("a", "b", "c"), ("b",), ...
1,806
20.771084
73
py
nltk-develop
nltk-develop/nltk/test/unit/test_corpus_views.py
""" Corpus View Regression Tests """ import unittest import nltk.data from nltk.corpus.reader.util import ( StreamBackedCorpusView, read_line_block, read_whitespace_block, ) class TestCorpusViews(unittest.TestCase): linetok = nltk.LineTokenizer(blanklines="keep") names = [ "corpora/inaug...
1,552
30.693878
87
py
nltk-develop
nltk-develop/nltk/test/unit/test_json_serialization.py
import unittest from nltk.corpus import brown from nltk.jsontags import JSONTaggedDecoder, JSONTaggedEncoder from nltk.tag import ( AffixTagger, BigramTagger, BrillTagger, BrillTaggerTrainer, DefaultTagger, NgramTagger, PerceptronTagger, RegexpTagger, TrigramTagger, UnigramTagge...
3,539
35.875
85
py
nltk-develop
nltk-develop/nltk/test/unit/test_cfg2chomsky.py
import unittest import nltk from nltk.grammar import CFG class ChomskyNormalFormForCFGTest(unittest.TestCase): def test_simple(self): grammar = CFG.fromstring( """ S -> NP VP PP -> P NP NP -> Det N | NP PP P VP -> V NP | VP PP VP -> Det ...
1,677
32.56
68
py
nltk-develop
nltk-develop/nltk/test/unit/test_nombank.py
""" Unit tests for nltk.corpus.nombank """ import unittest from nltk.corpus import nombank # Load the nombank once. nombank.nouns() class NombankDemo(unittest.TestCase): def test_numbers(self): # No. of instances. self.assertEqual(len(nombank.instances()), 114574) # No. of rolesets ...
733
25.214286
85
py
nltk-develop
nltk-develop/nltk/test/unit/test_tgrep.py
#!/usr/bin/env python # # Natural Language Toolkit: TGrep search # # Copyright (C) 2001-2023 NLTK Project # Author: Will Roberts <wildwilhelm@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Unit tests for nltk.tgrep. """ import unittest from nltk import tgrep from nltk.tree ...
30,928
38.601793
88
py
nltk-develop
nltk-develop/nltk/test/unit/test_stem.py
import unittest from contextlib import closing from nltk import data from nltk.stem.porter import PorterStemmer from nltk.stem.snowball import SnowballStemmer class SnowballTest(unittest.TestCase): def test_arabic(self): """ this unit testing for test the snowball arabic light stemmer thi...
5,966
36.765823
91
py
nltk-develop
nltk-develop/nltk/test/unit/test_pos_tag.py
""" Tests for nltk.pos_tag """ import unittest from nltk import pos_tag, word_tokenize class TestPosTag(unittest.TestCase): def test_pos_tag_eng(self): text = "John's big idea isn't all that bad." expected_tagged = [ ("John", "NNP"), ("'s", "POS"), ("big", "J...
2,523
29.047619
88
py
nltk-develop
nltk-develop/nltk/test/unit/test_senna.py
""" Unit tests for Senna """ import unittest from os import environ, path, sep from nltk.classify import Senna from nltk.tag import SennaChunkTagger, SennaNERTagger, SennaTagger # Set Senna executable path for tests if it is not specified as an environment variable if "SENNA" in environ: SENNA_EXECUTABLE_PATH = ...
3,600
30.867257
88
py
nltk-develop
nltk-develop/nltk/test/unit/test_collocations.py
from nltk.collocations import BigramCollocationFinder from nltk.metrics import BigramAssocMeasures ## Test bigram counters with discontinuous bigrams and repeated words _EPSILON = 1e-8 SENT = "this this is is a a test test".split() def close_enough(x, y): """Verify that two sequences of n-gram association value...
3,570
28.512397
88
py
nltk-develop
nltk-develop/nltk/test/unit/test_freqdist.py
import nltk def test_iterating_returns_an_iterator_ordered_by_frequency(): samples = ["one", "two", "two"] distribution = nltk.FreqDist(samples) assert list(distribution) == ["two", "one"]
203
24.5
62
py
nltk-develop
nltk-develop/nltk/test/unit/test_brill.py
""" Tests for Brill tagger. """ import unittest from nltk.corpus import treebank from nltk.tag import UnigramTagger, brill, brill_trainer from nltk.tbl import demo class TestBrill(unittest.TestCase): def test_pos_template(self): train_sents = treebank.tagged_sents()[:1000] tagger = UnigramTagger...
990
27.314286
71
py
nltk-develop
nltk-develop/nltk/test/unit/test_ribes.py
from nltk.translate.ribes_score import corpus_ribes, word_rank_alignment def test_ribes_empty_worder(): # worder as in word order # Verifies that these two sentences have no alignment, # and hence have the lowest possible RIBES score. hyp = "This is a nice sentence which I quite like".split() ref = "...
4,958
19.076923
82
py
nltk-develop
nltk-develop/nltk/test/unit/test_corenlp.py
""" Mock test for Stanford CoreNLP wrappers. """ from unittest import TestCase from unittest.mock import MagicMock import pytest from nltk.parse import corenlp from nltk.tree import Tree def setup_module(module): global server try: server = corenlp.CoreNLPServer(port=9000) except LookupError: ...
57,196
38.803062
222
py
nltk-develop
nltk-develop/nltk/test/unit/test_aline.py
""" Test Aline algorithm for aligning phonetic sequences """ from nltk.metrics import aline def test_aline(): result = aline.align("θin", "tenwis") expected = [[("θ", "t"), ("i", "e"), ("n", "n")]] assert result == expected result = aline.align("jo", "ʒə") expected = [[("j", "ʒ"), ("o", "ə")]] ...
1,074
20.938776
65
py
nltk-develop
nltk-develop/nltk/test/unit/test_corpora.py
import unittest import pytest from nltk.corpus import ( # mwa_ppdb cess_cat, cess_esp, conll2007, floresta, indian, ptb, sinica_treebank, udhr, ) from nltk.tree import Tree class TestUdhr(unittest.TestCase): def test_words(self): for name in udhr.fileids(): w...
9,535
33.676364
114
py
nltk-develop
nltk-develop/nltk/test/unit/test_downloader.py
from nltk import download def test_downloader_using_existing_parent_download_dir(tmp_path): """Test that download works properly when the parent folder of the download_dir exists""" download_dir = str(tmp_path.joinpath("another_dir")) download_status = download("mwa_ppdb", download_dir) assert downlo...
722
35.15
101
py
nltk-develop
nltk-develop/nltk/test/unit/test_rte_classify.py
import pytest from nltk import config_megam from nltk.classify.rte_classify import RTEFeatureExtractor, rte_classifier, rte_features from nltk.corpus import rte as rte_corpus expected_from_rte_feature_extration = """ alwayson => True ne_hyp_extra => 0 ne_overlap => 1 neg_hyp => 0 neg_txt ...
2,671
27.126316
88
py
nltk-develop
nltk-develop/nltk/test/unit/test_classify.py
""" Unit tests for nltk.classify. See also: nltk/test/classify.doctest """ import pytest from nltk import classify TRAIN = [ (dict(a=1, b=1, c=1), "y"), (dict(a=1, b=1, c=1), "x"), (dict(a=1, b=1, c=0), "y"), (dict(a=0, b=1, c=1), "x"), (dict(a=0, b=1, c=1), "y"), (dict(a=0, b=0, c=1), "y"), ...
1,288
24.78
70
py
nltk-develop
nltk-develop/nltk/test/unit/test_chunk.py
import unittest from nltk import RegexpParser class TestChunkRule(unittest.TestCase): def test_tag_pattern2re_pattern_quantifier(self): """Test for bug https://github.com/nltk/nltk/issues/1597 Ensures that curly bracket quantifiers can be used inside a chunk rule. This type of quantifier...
2,134
23.825581
79
py
nltk-develop
nltk-develop/nltk/test/unit/__init__.py
0
0
0
py
nltk-develop
nltk-develop/nltk/test/unit/test_metrics.py
import unittest from nltk.metrics import ( BigramAssocMeasures, QuadgramAssocMeasures, TrigramAssocMeasures, ) ## Test the likelihood ratio metric _DELTA = 1e-8 class TestLikelihoodRatio(unittest.TestCase): def test_lr_bigram(self): self.assertAlmostEqual( BigramAssocMeasures.li...
1,883
27.119403
81
py
nltk-develop
nltk-develop/nltk/test/unit/test_tokenize.py
""" Unit tests for nltk.tokenize. See also nltk/test/tokenize.doctest """ from typing import List, Tuple import pytest from nltk.tokenize import ( LegalitySyllableTokenizer, StanfordSegmenter, SyllableTokenizer, TreebankWordTokenizer, TweetTokenizer, punkt, sent_tokenize, word_tokenize...
27,969
30.533258
341
py
nltk-develop
nltk-develop/nltk/test/unit/test_disagreement.py
import unittest from nltk.metrics.agreement import AnnotationTask class TestDisagreement(unittest.TestCase): """ Class containing unit tests for nltk.metrics.agreement.Disagreement. """ def test_easy(self): """ Simple test, based on https://github.com/foolswood/krippendorffs...
4,317
28.77931
85
py
nltk-develop
nltk-develop/nltk/test/unit/test_twitter_auth.py
""" Tests for static parts of Twitter package """ import os import pytest pytest.importorskip("twython") from nltk.twitter import Authenticate @pytest.fixture def auth(): return Authenticate() class TestCredentials: """ Tests that Twitter credentials from a file are handled correctly. """ @...
2,432
30.192308
94
py
nltk-develop
nltk-develop/nltk/test/unit/test_wordnet.py
""" Unit tests for nltk.corpus.wordnet See also nltk/test/wordnet.doctest """ import unittest from nltk.corpus import wordnet as wn from nltk.corpus import wordnet_ic as wnic wn.ensure_loaded() S = wn.synset L = wn.lemma class WordnNetDemo(unittest.TestCase): def test_retrieve_synset(self): move_synset ...
9,018
36.423237
88
py
nltk-develop
nltk-develop/nltk/test/unit/test_json2csv_corpus.py
# Natural Language Toolkit: Twitter client # # Copyright (C) 2001-2023 NLTK Project # Author: Lorenzo Rubio <lrnzcig@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Regression tests for `json2csv()` and `json2csv_entities()` in Twitter package. """ from pathlib import Path imp...
5,678
25.914692
84
py
nltk-develop
nltk-develop/nltk/test/unit/test_naivebayes.py
import unittest from nltk.classify.naivebayes import NaiveBayesClassifier class NaiveBayesClassifierTest(unittest.TestCase): def test_simple(self): training_features = [ ({"nice": True, "good": True}, "positive"), ({"bad": True, "mean": True}, "negative"), ] class...
743
32.818182
74
py
nltk-develop
nltk-develop/nltk/test/unit/lm/test_vocabulary.py
# Natural Language Toolkit: Language Model Unit Tests # # Copyright (C) 2001-2023 NLTK Project # Author: Ilia Kurenkov <ilia.kurenkov@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT import unittest from collections import Counter from timeit import timeit from nltk.lm import Vocab...
5,761
35.700637
87
py
nltk-develop
nltk-develop/nltk/test/unit/lm/test_models.py
# Natural Language Toolkit: Language Model Unit Tests # # Copyright (C) 2001-2023 NLTK Project # Author: Ilia Kurenkov <ilia.kurenkov@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT import math from operator import itemgetter import pytest from nltk.lm import ( MLE, Absolu...
19,546
30.991817
88
py
nltk-develop
nltk-develop/nltk/test/unit/lm/test_counter.py
# Natural Language Toolkit: Language Model Unit Tests # # Copyright (C) 2001-2023 NLTK Project # Author: Ilia Kurenkov <ilia.kurenkov@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT import unittest import pytest from nltk import FreqDist from nltk.lm import NgramCounter from nltk...
3,775
31.273504
88
py
nltk-develop
nltk-develop/nltk/test/unit/lm/test_preprocessing.py
# Natural Language Toolkit: Language Model Unit Tests # # Copyright (C) 2001-2023 NLTK Project # Author: Ilia Kurenkov <ilia.kurenkov@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT import unittest from nltk.lm.preprocessing import padded_everygram_pipeline class TestPreprocessin...
969
30.290323
80
py
nltk-develop
nltk-develop/nltk/test/unit/lm/__init__.py
0
0
0
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_nist.py
""" Tests for NIST translation evaluation metric """ import io import unittest from nltk.data import find from nltk.translate.nist_score import corpus_nist class TestNIST(unittest.TestCase): def test_sentence_nist(self): ref_file = find("models/wmt15_eval/ref.ru") hyp_file = find("models/wmt15_e...
1,609
42.513514
85
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_ibm_model.py
""" Tests for common methods of IBM translation models """ import unittest from collections import defaultdict from nltk.translate import AlignedSent, IBMModel from nltk.translate.ibm_model import AlignmentInfo class TestIBMModel(unittest.TestCase): __TEST_SRC_SENTENCE = ["j'", "aime", "bien", "jambon"] __T...
9,403
33.82963
88
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_gdfa.py
""" Tests GDFA alignments """ import unittest from nltk.translate.gdfa import grow_diag_final_and class TestGDFA(unittest.TestCase): def test_from_eflomal_outputs(self): """ Testing GDFA with first 10 eflomal outputs from issue #1829 https://github.com/nltk/nltk/issues/1829 """ ...
4,616
28.787097
181
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_ibm4.py
""" Tests for IBM Model 4 training methods """ import unittest from collections import defaultdict from nltk.translate import AlignedSent, IBMModel, IBMModel4 from nltk.translate.ibm_model import AlignmentInfo class TestIBMModel4(unittest.TestCase): def test_set_uniform_distortion_probabilities_of_max_displacem...
5,084
41.024793
85
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_ibm2.py
""" Tests for IBM Model 2 training methods """ import unittest from collections import defaultdict from nltk.translate import AlignedSent, IBMModel, IBMModel2 from nltk.translate.ibm_model import AlignmentInfo class TestIBMModel2(unittest.TestCase): def test_set_uniform_alignment_probabilities(self): # ...
3,286
36.781609
80
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_ibm3.py
""" Tests for IBM Model 3 training methods """ import unittest from collections import defaultdict from nltk.translate import AlignedSent, IBMModel, IBMModel3 from nltk.translate.ibm_model import AlignmentInfo class TestIBMModel3(unittest.TestCase): def test_set_uniform_distortion_probabilities(self): #...
4,078
37.481132
80
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_meteor.py
import unittest from nltk.translate.meteor_score import meteor_score class TestMETEOR(unittest.TestCase): reference = [["this", "is", "a", "test"], ["this", "is" "test"]] candidate = ["THIS", "Is", "a", "tEST"] def test_meteor(self): score = meteor_score(self.reference, self.candidate, preproces...
730
33.809524
82
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_ibm5.py
""" Tests for IBM Model 5 training methods """ import unittest from collections import defaultdict from nltk.translate import AlignedSent, IBMModel, IBMModel4, IBMModel5 from nltk.translate.ibm_model import AlignmentInfo class TestIBMModel5(unittest.TestCase): def test_set_uniform_vacancy_probabilities_of_max_d...
6,594
39.962733
85
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_bleu.py
""" Tests for BLEU translation evaluation metric """ import io import unittest from nltk.data import find from nltk.translate.bleu_score import ( SmoothingFunction, brevity_penalty, closest_ref_length, corpus_bleu, modified_precision, sentence_bleu, ) class TestBLEU(unittest.TestCase): d...
15,469
37.103448
99
py
nltk-develop
nltk-develop/nltk/test/unit/translate/__init__.py
0
0
0
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_ibm1.py
""" Tests for IBM Model 1 training methods """ import unittest from collections import defaultdict from nltk.translate import AlignedSent, IBMModel, IBMModel1 from nltk.translate.ibm_model import AlignmentInfo class TestIBMModel1(unittest.TestCase): def test_set_uniform_translation_probabilities(self): ...
2,593
34.054054
87
py
nltk-develop
nltk-develop/nltk/test/unit/translate/test_stack_decoder.py
# Natural Language Toolkit: Stack decoder # # Copyright (C) 2001-2023 NLTK Project # Author: Tah Wei Hoon <hoon.tw@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Tests for stack decoder """ import unittest from collections import defaultdict from math import log from nltk.tr...
9,706
31.905085
84
py
nltk-develop
nltk-develop/nltk/sentiment/sentiment_analyzer.py
# # Natural Language Toolkit: Sentiment Analyzer # # Copyright (C) 2001-2023 NLTK Project # Author: Pierpaolo Pantone <24alsecondo@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ A SentimentAnalyzer is a tool to implement and facilitate Sentiment Analysis tasks using NLTK featu...
10,177
38.757813
89
py
nltk-develop
nltk-develop/nltk/sentiment/util.py
# # Natural Language Toolkit: Sentiment Analyzer # # Copyright (C) 2001-2023 NLTK Project # Author: Pierpaolo Pantone <24alsecondo@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Utility methods for Sentiment Analysis. """ import codecs import csv import json import pickle imp...
30,388
33.221847
112
py
nltk-develop
nltk-develop/nltk/sentiment/vader.py
# Natural Language Toolkit: vader # # Copyright (C) 2001-2023 NLTK Project # Author: C.J. Hutto <Clayton.Hutto@gtri.gatech.edu> # Ewan Klein <ewan@inf.ed.ac.uk> (modifications) # Pierpaolo Pantone <24alsecondo@gmail.com> (modifications) # George Berry <geb97@cornell.edu> (modifications) # ...
21,131
32.33123
88
py
nltk-develop
nltk-develop/nltk/sentiment/__init__.py
# Natural Language Toolkit: Sentiment Analysis # # Copyright (C) 2001-2023 NLTK Project # Author: Ewan Klein <ewan@inf.ed.ac.uk> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ NLTK Sentiment Analysis Package """ from nltk.sentiment.sentiment_analyzer import SentimentAnalyzer from nltk.s...
369
25.428571
63
py
nltk-develop
nltk-develop/nltk/metrics/paice.py
# Natural Language Toolkit: Agreement Metrics # # Copyright (C) 2001-2023 NLTK Project # Author: Lauri Hallila <laurihallila@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT # """Counts Paice's performance statistics for evaluating stemming algorithms. What is required: - A dictio...
14,350
35.797436
123
py
nltk-develop
nltk-develop/nltk/metrics/association.py
# Natural Language Toolkit: Ngram Association Measures # # Copyright (C) 2001-2023 NLTK Project # Author: Joel Nothman <jnothman@student.usyd.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Provides scoring functions for a number of association measures through a generic, abstract...
16,093
32.740042
116
py
nltk-develop
nltk-develop/nltk/metrics/aline.py
# Natural Language Toolkit: ALINE # # Copyright (C) 2001-2023 NLTK Project # Author: Greg Kondrak <gkondrak@ualberta.ca> # Geoff Bacon <bacon@berkeley.edu> (Python port) # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ ALINE https://webdocs.cs.ualberta.ca/~kondrak/ Copyright 2002 b...
31,348
22.135793
88
py
nltk-develop
nltk-develop/nltk/metrics/spearman.py
# Natural Language Toolkit: Spearman Rank Correlation # # Copyright (C) 2001-2023 NLTK Project # Author: Joel Nothman <jnothman@student.usyd.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Tools for comparing ranked lists. """ def _rank_dists(ranks1, ranks2): """Finds the di...
2,129
29.869565
78
py
nltk-develop
nltk-develop/nltk/metrics/segmentation.py
# Natural Language Toolkit: Text Segmentation Metrics # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # David Doukhan <david.doukhan@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Text S...
6,999
30.390135
87
py
nltk-develop
nltk-develop/nltk/metrics/scores.py
# Natural Language Toolkit: Evaluation # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT import operator from functools import reduce from math import fabs from rand...
7,694
32.60262
88
py
nltk-develop
nltk-develop/nltk/metrics/agreement.py
# Natural Language Toolkit: Agreement Metrics # # Copyright (C) 2001-2023 NLTK Project # Author: Tom Lippincott <tom@cs.columbia.edu> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT # """ Implementations of inter-annotator agreement coefficients surveyed by Artstein and Poesio (2007), Inter-C...
15,956
33.242489
130
py
nltk-develop
nltk-develop/nltk/metrics/confusionmatrix.py
# Natural Language Toolkit: Confusion Matrices # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # Tom Aarsen <> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT from nltk.probability import FreqDist clas...
12,682
34.827684
86
py
nltk-develop
nltk-develop/nltk/metrics/__init__.py
# Natural Language Toolkit: Metrics # # Copyright (C) 2001-2023 NLTK Project # Author: Steven Bird <stevenbird1@gmail.com> # Edward Loper <edloper@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT # """ NLTK Metrics Classes and methods for scoring processing modules. """ fr...
1,192
21.942308
57
py
nltk-develop
nltk-develop/nltk/metrics/distance.py
# Natural Language Toolkit: Distance Metrics # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # Tom Lippincott <tom@cs.columbia.edu> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT # """ Distance Metrics....
17,153
32.701375
107
py
nltk-develop
nltk-develop/nltk/app/concordance_app.py
# Natural Language Toolkit: Concordance Application # # Copyright (C) 2001-2023 NLTK Project # Author: Sumukh Ghodke <sghodke@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT import queue as q import re import threading from tkinter import ( END, LEFT, SUNKEN, ...
24,173
33.047887
104
py
nltk-develop
nltk-develop/nltk/app/collocations_app.py
# Natural Language Toolkit: Collocations Application # Much of the GUI code is imported from concordance.py; We intend to merge these tools together # Copyright (C) 2001-2023 NLTK Project # Author: Sumukh Ghodke <sghodke@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT # ...
14,226
31.407745
104
py
nltk-develop
nltk-develop/nltk/app/chunkparser_app.py
# Natural Language Toolkit: Regexp Chunk Parser Application # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ A graphical tool for exploring the regular expression based chunk parser ``nltk.chunk.RegexpChunk...
56,822
36.856762
88
py
nltk-develop
nltk-develop/nltk/app/chartparser_app.py
# Natural Language Toolkit: Chart Parser Application # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Jean Mark Gawron <gawron@mail.sdsu.edu> # Steven Bird <stevenbird1@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ A graphi...
85,626
32.317899
88
py
nltk-develop
nltk-develop/nltk/app/wordfreq_app.py
# Natural Language Toolkit: Wordfreq Application # # Copyright (C) 2001-2023 NLTK Project # Author: Sumukh Ghodke <sghodke@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT from matplotlib import pylab from nltk.corpus import gutenberg from nltk.text import Text def plot...
921
23.918919
80
py
nltk-develop
nltk-develop/nltk/app/srparser_app.py
# Natural Language Toolkit: Shift-Reduce Parser Application # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ A graphical tool for exploring the shift-reduce parser. The shift-reduce parser maintains a stac...
33,464
34.676972
89
py
nltk-develop
nltk-develop/nltk/app/wordnet_app.py
# Natural Language Toolkit: WordNet Browser Application # # Copyright (C) 2001-2023 NLTK Project # Author: Jussi Salmela <jtsalmela@users.sourceforge.net> # Paul Bone <pbone@students.csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ A WordNet Browser application...
34,569
33.363817
481
py
nltk-develop
nltk-develop/nltk/app/__init__.py
# Natural Language Toolkit: Applications package # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Interactive NLTK Applications: chartparser: Chart Parser chu...
1,531
30.916667
88
py
nltk-develop
nltk-develop/nltk/app/rdparser_app.py
# Natural Language Toolkit: Recursive Descent Parser Application # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ A graphical tool for exploring the recursive descent parser. The recursive descent parser m...
36,729
33.881292
88
py
nltk-develop
nltk-develop/nltk/app/nemo_app.py
# Finding (and Replacing) Nemo, Version 1.1, Aristide Grange 2006/06/06 # https://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496783 """ Finding (and Replacing) Nemo Instant Regular Expressions Created by Aristide Grange """ import itertools import re from tkinter import SEL_FIRST, SEL_LAST, Frame, Label, PhotoI...
12,142
73.042683
2,379
py
nltk-develop
nltk-develop/nltk/ccg/lexicon.py
# Natural Language Toolkit: Combinatory Categorial Grammar # # Copyright (C) 2001-2023 NLTK Project # Author: Graeme Gange <ggange@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ CCG Lexicons """ import re from collections import defaultdict from nltk.ccg.api import ...
9,525
27.100295
96
py
nltk-develop
nltk-develop/nltk/ccg/api.py
# Natural Language Toolkit: CCG Categories # # Copyright (C) 2001-2023 NLTK Project # Author: Graeme Gange <ggange@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT from abc import ABCMeta, abstractmethod from functools import total_ordering from nltk.internals import rais...
10,002
26.86351
83
py
nltk-develop
nltk-develop/nltk/ccg/__init__.py
# Natural Language Toolkit: Combinatory Categorial Grammar # # Copyright (C) 2001-2023 NLTK Project # Author: Graeme Gange <ggange@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Combinatory Categorial Grammar. For more information see nltk/doc/contrib/ccg/ccg.pdf ""...
881
24.2
73
py
nltk-develop
nltk-develop/nltk/ccg/combinator.py
# Natural Language Toolkit: Combinatory Categorial Grammar # # Copyright (C) 2001-2023 NLTK Project # Author: Graeme Gange <ggange@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ CCG Combinators """ from abc import ABCMeta, abstractmethod from nltk.ccg.api import Fun...
10,294
29.279412
87
py
nltk-develop
nltk-develop/nltk/ccg/logic.py
# Natural Language Toolkit: Combinatory Categorial Grammar # # Copyright (C) 2001-2023 NLTK Project # Author: Tanin Na Nakorn (@tanin) # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Helper functions for CCG semantics computation """ from nltk.sem.logic import * def compute_type_raised_...
1,811
28.704918
84
py
nltk-develop
nltk-develop/nltk/ccg/chart.py
# Natural Language Toolkit: Combinatory Categorial Grammar # # Copyright (C) 2001-2023 NLTK Project # Author: Graeme Gange <ggange@csse.unimelb.edu.au> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ The lexicon is constructed by calling ``lexicon.fromstring(<lexicon string>)``. In order...
13,667
27.4158
88
py
nltk-develop
nltk-develop/nltk/tokenize/sonority_sequencing.py
# Natural Language Toolkit: Tokenizers # # Copyright (C) 2001-2023 NLTK Project # Author: Christopher Hench <chris.l.hench@gmail.com> # Alex Estes # URL: <https://www.nltk.org> # For license information, see LICENSE.TXT """ The Sonority Sequencing Principle (SSP) is a language agnostic algorithm proposed by Ot...
7,545
37.697436
95
py
nltk-develop
nltk-develop/nltk/tokenize/toktok.py
# Natural Language Toolkit: Python port of the tok-tok.pl tokenizer. # # Copyright (C) 2001-2015 NLTK Project # Author: Jon Dehdari # Contributors: Liling Tan, Selcuk Ayguney, ikegami, Martijn Pieters # # URL: <https://www.nltk.org> # For license information, see LICENSE.TXT """ The tok-tok tokenizer is a simple, gene...
7,448
40.383333
172
py
nltk-develop
nltk-develop/nltk/tokenize/legality_principle.py
# Natural Language Toolkit: Tokenizers # # Copyright (C) 2001-2023 NLTK Project # Author: Christopher Hench <chris.l.hench@gmail.com> # Alex Estes # URL: <https://www.nltk.org> # For license information, see LICENSE.TXT """ The Legality Principle is a language agnostic principle maintaining that syllable onset...
6,087
40.135135
134
py
nltk-develop
nltk-develop/nltk/tokenize/simple.py
# Natural Language Toolkit: Simple Tokenizers # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # URL: <https://www.nltk.org> # For license information, see LICENSE.TXT r""" Simple Tokenizers These tokenizers divide strings into substring...
5,262
36.592857
95
py
nltk-develop
nltk-develop/nltk/tokenize/regexp.py
# Natural Language Toolkit: Tokenizers # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # Trevor Cohn <tacohn@csse.unimelb.edu.au> # URL: <https://www.nltk.org> # For license information, see LICENSE.TXT r""" Regular-Expression To...
8,111
35.705882
95
py
nltk-develop
nltk-develop/nltk/tokenize/api.py
# Natural Language Toolkit: Tokenizer Interface # # Copyright (C) 2001-2023 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Tokenizer Interface """ from abc import ABC, abstractmethod fr...
2,274
26.083333
77
py
nltk-develop
nltk-develop/nltk/tokenize/mwe.py
# Multi-Word Expression tokenizer # # Copyright (C) 2001-2023 NLTK Project # Author: Rob Malouf <rmalouf@mail.sdsu.edu> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT """ Multi-Word Expression Tokenizer A ``MWETokenizer`` takes a string which has already been divided into tokens and retoken...
4,057
31.464
89
py