Esempio n. 1
0
    def test_add_multiple_sentences_no_punctuation(self):
        """
        Tests whether multiple sentences can be properly added to a lexicon with no punctuation.
        """
        test_sentence = "Hello! Welcome to my paragraph. This is the greatest literary work of our generation. Your eyes cannot handle the debonair stylings of my sumptuous, florid, and resplendent locution!"

        expected_lexicon = {
            'PRON': ['my', 'our', 'your'],
            'PRT': ['to'],
            'DET': ['this', 'the'],
            'ADJ':
            ['greatest', 'literary', 'sumptuous', 'florid', 'resplendent'],
            'NOUN': [
                'hello', 'welcome', 'paragraph', 'work', 'generation', 'eyes',
                'debonair', 'stylings', 'locution'
            ],
            'VERB': ['is', 'cannot', 'handle'],
            'CONJ': ['and'],
            'ADP': ['of']
        }
        lexicon = {}

        nltktest.add_paragraph_no_punctuation(test_sentence, lexicon)

        self.assertEqual(expected_lexicon, lexicon)
Esempio n. 2
0
    def test_single_sentence_no_punctuation_easy(self):
        """
        Tests whether a single sentence achieves the expected output while stripping away punctuation.
        """
        test_sentence = "Hello here is sentence."

        expected_lexicon = {'NOUN': ['hello', 'sentence'], 'ADV': ['here'], 'VERB': ['is']}
        lexicon = {}
        nltktest.add_paragraph_no_punctuation(test_sentence, lexicon)

        self.assertEqual(expected_lexicon, lexicon)
Esempio n. 3
0
    def test_add_multiple_sentences_no_punctuation(self):
        """
        Tests whether multiple sentences can be properly added to a lexicon with no punctuation.
        """
        test_sentence = "Hello! Welcome to my paragraph. This is the greatest literary work of our generation. Your eyes cannot handle the debonair stylings of my sumptuous, florid, and resplendent locution!"

        expected_lexicon ={'PRON': ['my', 'our', 'your'], 'PRT': ['to'], 'DET': ['this', 'the'], 'ADJ': ['greatest', 'literary', 'sumptuous', 'florid', 'resplendent'], 'NOUN': ['hello', 'welcome', 'paragraph', 'work', 'generation', 'eyes', 'debonair', 'stylings', 'locution'], 'VERB': ['is', 'cannot', 'handle'], 'CONJ': ['and'], 'ADP': ['of']}
        lexicon = {}

        nltktest.add_paragraph_no_punctuation(test_sentence, lexicon)

        self.assertEqual(expected_lexicon, lexicon)
Esempio n. 4
0
    def test_single_sentence_no_punctuation_easy(self):
        """
        Tests whether a single sentence achieves the expected output while stripping away punctuation.
        """
        test_sentence = "Hello here is sentence."

        expected_lexicon = {
            'NOUN': ['hello', 'sentence'],
            'ADV': ['here'],
            'VERB': ['is']
        }
        lexicon = {}
        nltktest.add_paragraph_no_punctuation(test_sentence, lexicon)

        self.assertEqual(expected_lexicon, lexicon)