nltk.test.unit.lm package

Submodules

nltk.test.unit.lm.test_counter module

class nltk.test.unit.lm.test_counter.NgramCounterTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for NgramCounter that only involve lookup, no modification.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test_N()[source]
test_bigram_counts_seen_ngrams()[source]
test_bigram_counts_unseen_ngrams()[source]
test_counter_len_changes_with_lookup()[source]
test_ngram_conditional_freqdist()[source]
test_ngram_order_access_unigrams()[source]
test_unigram_counts_completely_unseen_words()[source]
test_unigram_counts_seen_words()[source]
class nltk.test.unit.lm.test_counter.NgramCounterTrainingTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_None()[source]
test_empty_list()[source]
test_empty_string()[source]
test_train_on_bigrams()[source]
test_train_on_illegal_sentences()[source]
test_train_on_mix()[source]
test_train_on_unigrams()[source]

nltk.test.unit.lm.test_models module

class nltk.test.unit.lm.test_models.KneserNeyInterpolatedTrigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

score_tests = [('c', None, 0.125), ('z', None, 0.125), ('y', None, 0.125), ('c', ['b'], 0.4625), ('c', ['a', 'b'], 0.94625)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_score_4()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()
class nltk.test.unit.lm.test_models.LaplaceBigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

unit tests for Laplace class

score_tests = [('d', ['c'], 0.2222222222222222), ('a', None, 0.13636363636363635), ('z', None, 0.045454545454545456), ('y', None, 0.18181818181818182)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_entropy_perplexity()[source]
test_gamma()[source]
test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()
class nltk.test.unit.lm.test_models.LidstoneBigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

unit tests for Lidstone class

score_tests = [('d', ['c'], 0.6111111111111112), ('a', None, 0.14189189189189189), ('z', None, 0.006756756756756757), ('y', None, 0.20945945945945946)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_entropy_perplexity()[source]
test_gamma()[source]
test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()
class nltk.test.unit.lm.test_models.LidstoneTrigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

score_tests = [('d', ['c'], 0.6111111111111112), ('e', ['c'], 0.05555555555555556), ('d', ['b', 'c'], 0.6111111111111112), ('e', ['b', 'c'], 0.05555555555555556)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()
class nltk.test.unit.lm.test_models.MleBigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

unit tests for MLENgramModel class

score_tests = [('d', ['c'], 1), ('d', ['e'], 0), ('z', None, 0), ('a', None, 0.14285714285714285), ('y', None, 0.21428571428571427)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_entropy_perplexity_seen()[source]
test_entropy_perplexity_unigrams()[source]
test_entropy_perplexity_unseen()[source]
test_logscore_zero_score()[source]
test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_score_4()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()
class nltk.test.unit.lm.test_models.MleTrigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

MLE trigram model tests

score_tests = [('d', ('b', 'c'), 1), ('d', ['c'], 1), ('a', None, 0.1111111111111111), ('z', None, 0), ('y', None, 0.16666666666666666)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_score_4()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()
class nltk.test.unit.lm.test_models.NgramModelTextGenerationTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

Using MLE estimator, generate some text.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_generate_None_text_seed()[source]
test_generate_no_seed_unigrams()[source]
test_generate_one_limiting_context()[source]
test_generate_one_no_context()[source]
test_generate_one_varied_context()[source]
test_generate_oov_text_seed()[source]
test_generate_with_text_seed()[source]
class nltk.test.unit.lm.test_models.ParametrizeTestsMeta[source]

Bases: type

Metaclass for generating parametrized tests.

classmethod add_score_test(word, context, expected_score)[source]
classmethod add_sum_to_1_test(context)[source]
class nltk.test.unit.lm.test_models.WittenBellInterpolatedTrigramTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

score_tests = [('c', None, 0.05555555555555555), ('z', None, 0.0), ('y', None, 0.16666666666666666), ('c', ['b'], 0.45062222222222226), ('c', ['a', 'b'], 0.9633565022222222)]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_score_0()
test_score_1()
test_score_2()
test_score_3()
test_score_4()
test_sumto1_0()
test_sumto1_1()
test_sumto1_2()
test_sumto1_3()
test_sumto1_4()
test_sumto1_5()
test_sumto1_6()
test_sumto1_7()
test_sumto1_8()

nltk.test.unit.lm.test_preprocessing module

class nltk.test.unit.lm.test_preprocessing.TestPreprocessing(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_padded_everygram_pipeline()[source]

nltk.test.unit.lm.test_vocabulary module

class nltk.test.unit.lm.test_vocabulary.NgramModelVocabularyTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

tests Vocabulary Class

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test_counts_set_correctly()[source]
test_creation_with_counter()[source]
test_cutoff_setter_checks_value()[source]
test_cutoff_value_set_correctly()[source]
test_eqality()[source]
test_lookup()[source]
test_lookup_None()[source]
test_lookup_empty_iterables()[source]
test_lookup_empty_str()[source]
test_lookup_int()[source]
test_lookup_iterables()[source]
test_lookup_recursive()[source]
test_membership_check_respects_cutoff()[source]
test_str()[source]
test_truthiness()[source]
test_unable_to_change_cutoff()[source]
test_update_empty_vocab()[source]
test_vocab_iter_respects_cutoff()[source]
test_vocab_len_respects_cutoff()[source]

Module contents