예제 #1
0
    def test_undefined_token(self):
        analyzer = MorphologicalSentenceAnalyzer('Mia asdiosdsds')
        analyzer.analyze()

        assert analyzer.simple_results() == [['Mia', 'Pronoun'],
                                             ['asdiosdsds', 'Undefined']]
        assert analyzer.simple_results()[1][1] == 'Undefined'
예제 #2
0
    def test_format_table_data_without_formating(self):
        analyzer = MorphologicalSentenceAnalyzer(self.TEST_SENTENCE)
        analyzer.analyze()

        expected = [['Mi', 'Pronoun'], ['loĝas', 'Verb'],
                    ['en', 'Preposition'], ['Brazilo', 'Noun']]

        assert CLI.format_table_data(analyzer.simple_results(),
                                     colorize=False) == expected
예제 #3
0
    def test_format_table_data_with_formating(self):
        analyzer = MorphologicalSentenceAnalyzer(self.TEST_SENTENCE)
        analyzer.analyze()

        expected = [['\x1b[96mMi \x1b[0m', '\x1b[96mPronoun \x1b[0m'],
                    ['\x1b[31mloĝas \x1b[0m', '\x1b[31mVerb \x1b[0m'],
                    ['\x1b[36men \x1b[0m', '\x1b[36mPreposition \x1b[0m'],
                    ['\x1b[34mBrazilo \x1b[0m', '\x1b[34mNoun \x1b[0m']]

        assert CLI.format_table_data(analyzer.simple_results()) == expected
예제 #4
0
    def test_print_results(self):
        analyzer = MorphologicalSentenceAnalyzer(self.TEST_SENTENCE)
        analyzer.analyze()

        output = StringIO()

        # Execute the method that will write to `output`
        CLI.print_results(analyzer.simple_results(), output=output)

        assert output.getvalue() == self.EXPECT_OUTPUT_TEST_SENTENCE