<commit_before><commit_msg>Started a unit-tests module for nltk.probability<commit_after># Natural Language Toolkit: Test Code for Probability and Statistics
#
# Copyright (C) 2001 University of Pennsylvania
# Author: <NAME> <<EMAIL>>
# URL: <http://nltk.sf.net>
# For license information, see LICENSE.TXT
#
# $Id$


from nltk.set import *

##//////////////////////////////////////////////////////
##  Test code
##//////////////////////////////////////////////////////

import unittest

class SampleEventTestCase(unittest.TestCase):
    """
    Unit test cases for C{probability.SampleEvent}
    """
    def testConstructor(self):
        "nltk.probability.SampleEvent: constructor tests"
        x = SampleEvent(1)
        y = SampleEvent('a')
        z = SampleEvent( (1,2,3, (4,5)) )

        self.failUnless(1 in x)
        self.failUnless('a' in y)
        self.failUnless( (1,2,3, (4,5)) in z)

        self.failf(0 in x)
        self.failf(0 in x)
        self.failf('A' in y)
        self.failf('z' in y)
        self.failf('a' in z)
        self.failf(1 in z)


def testsuite():
    """
    Return a PyUnit testsuite for the probability module.
    """
    
    tests = unittest.TestSuite()

    eventtests = unittest.makeSuite(SampleEventTestCase, 'test')
    tests = unittest.TestSuite( (tests, eventtests) )

    return tests

def test():
    import unittest
    runner = unittest.TextTestRunner()
    runner.run(testsuite())

if __name__ == '__main__':
    test()


{'fraction_non_alphanumeric': 0.19215155615696888, 'fraction_numerical': 0.012855209742895805, 'mean_word_length': 2.1806451612903226, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1755660', 'n_tokens_mistral': 471, 'n_tokens_neox': 455, 'n_words': 120}