Ejemplo n.º 1
0
    def test_was_produced_by_action(self):
        """Tests the WordExtraction produced method."""

        test_content = {
            AbstractAction.ACTION: WordExtraction.__name__,
            AbstractAction.RESULT: ['One', 'Two']
        }

        assert WordExtraction.produced(test_content)

        test_content[AbstractAction.ACTION] = ''

        assert not WordExtraction.produced(test_content)
Ejemplo n.º 2
0
    def test_apply(self):
        """Tests the ContentReversal apply method."""

        test_content = Consolidation().apply(WordPosTagging().apply(
            WordExtraction().apply(self.TEXT)))

        reversed_content = ContentReversal().apply(test_content)

        assert reversed_content is not None

        assert len(reversed_content[AbstractAction.RESULT]) > 0

        assert len(reversed_content[AbstractAction.RESULT]) == 25
Ejemplo n.º 3
0
    def test_apply(self):
        """Tests the FrequencyCalculation apply method."""

        freqs = FrequencyCalculation().apply(WordExtraction().apply(self.TEXT))

        assert freqs is not None

        assert None not in freqs[AbstractAction.RESULT]

        assert len(freqs[AbstractAction.RESULT]) > 0

        assert len(freqs[AbstractAction.RESULT]) == 120

        assert isinstance(freqs[AbstractAction.RESULT], dict)
Ejemplo n.º 4
0
    def test_apply(self):
        """Tests the UniqueFiltering apply method."""

        unique_items = UniqueFiltering().apply(WordExtraction().apply(
            self.TEXT))

        assert unique_items is not None

        assert None not in unique_items

        assert len(unique_items[AbstractAction.RESULT]) > 0

        assert len(unique_items[AbstractAction.RESULT]) == 120

        assert isinstance(unique_items[AbstractAction.RESULT], list)
Ejemplo n.º 5
0
    def test_apply(self):
        """Tests the PhraseExtraction apply method."""

        phrases = PhraseExtraction().apply(WordPosTagging().apply(
            WordExtraction().apply(self.TEXT)))

        assert phrases is not None

        assert None not in phrases

        assert len(phrases) > 0

        assert len(phrases[AbstractAction.RESULT]) == 42

        assert isinstance(phrases[AbstractAction.RESULT], list)

        assert isinstance(phrases[AbstractAction.RESULT][0], str)
Ejemplo n.º 6
0
    def test_apply(self):
        """Tests the NamedEntityExtraction apply method."""

        named_entities = NamedEntityExtraction().apply(WordPosTagging().apply(
            WordExtraction().apply(self.TEXT)))

        assert named_entities is not None

        assert None not in named_entities[AbstractAction.RESULT]

        assert len(named_entities[AbstractAction.RESULT]) > 0

        assert len(named_entities[AbstractAction.RESULT]) == 1

        assert isinstance(named_entities[AbstractAction.RESULT], list)

        assert isinstance(named_entities[AbstractAction.RESULT][0], tuple)

        assert isinstance(named_entities[AbstractAction.RESULT][0][0], str)
Ejemplo n.º 7
0
    def test_apply(self):
        """Tests the WordPosTagging apply method."""

        tagged_words = WordPosTagging().apply(WordExtraction().apply(
            self.TEXT))

        assert tagged_words is not None

        assert None not in tagged_words[AbstractAction.RESULT]

        assert len(tagged_words[AbstractAction.RESULT]) > 0

        assert len(tagged_words[AbstractAction.RESULT]) == 167

        assert isinstance(tagged_words[AbstractAction.RESULT], list)

        assert isinstance(tagged_words[AbstractAction.RESULT][0], tuple)

        assert isinstance(tagged_words[AbstractAction.RESULT][0][0], str)
Ejemplo n.º 8
0
    def test_apply(self):
        """Tests the WordExtraction apply method."""

        words = WordExtraction().apply(self.TEXT)

        assert words is not None

        assert None not in words[AbstractAction.RESULT]

        assert len(words[AbstractAction.RESULT]) > 0

        assert 167 == len(words[AbstractAction.RESULT])

        assert isinstance(words[AbstractAction.RESULT], list)

        assert isinstance(words[AbstractAction.RESULT][0], str)

        assert len(
            [word for word in words[AbstractAction.RESULT] if ' ' in word]) == 0