import pprint
from patterny.nlp.ne import extract_entities, pre_process, NOUN, VERB, NOUN_VERB
from nose.tools import assert_not_equal, assert_equal


class TestTxt(object):
    """
        This is a dummy test. It only checks whether the output is None
        To see how the output looks like, run the test on the root folder like this:
            nosetests --nocapture tests/test_nlp_txt.py > out/pre_process.txt
        Then, check the pre_process.txt output file
    """

    def setup(self):
        self.pp = pprint.PrettyPrinter(indent=2)

    def teardown(self):
        pass

    def test_extract_entities(self):
        lookup_tags = [NOUN, VERB, NOUN_VERB]

        # This is a cluster with different analysis
        clustered_documents = [
            """\nIf you are navigating through the list of open tabs inside the All+Tabs panel and you wanna filter by a term you have to select the search text field first.\n
                    It would be nice if any entered character is automatically routed to the search field and the filter gets applied.\n
                """,
            """\n                In maximized mode there is something like 3 pixels padding on the right side of \"All tabs\" panel.
               \n                It doesn't exist on the left side of panel and in not maximized mode.\n
            """,
            """
                \n                When you have the All+Tabs panel open it would be great if you can press Cmd/Ctrl+F to focus the search text field. Right now the panel gets hidden and the Find toolbar is shown without focus.\n
            """
        ]
        ngrams = 2
        documents = [pre_process(clustered_documents)]
        result = extract_entities(lookup_tags, documents, ngram_range=ngrams)
        assert_not_equal(result, None)

        assert_equal(NOUN in result, True)
        assert_equal(VERB in result, True)
        assert_equal(NOUN_VERB in result, True)

        for n in xrange(1, ngrams + 1):
            assert_equal(n in result[NOUN], True)
            assert_equal(n in result[VERB], True)
            assert_equal(n in result[NOUN_VERB], True)


