Exemplo n.º 1
0
 def test_if_result_is_equal_a_document_base(self):
     text_handler = TextHandler([
         "Falar é fácil. Mostre-me o código.",
         "É fácil escrever código. Difícil é escrever código que funcione.",
     ])
     assert text_handler.sw_frequency_distribution() == {
         "text1": [1, 1, 1, 1, 0, 0, 0],
         "text2": [0, 1, 0, 2, 2, 1, 1],
     }
Exemplo n.º 2
0
    def get(self):
        list_of_texts = [
            text
            for text, in db.session.query(Text.text).order_by(Text.id).all()
        ]
        text_handler = TextHandler(list_of_texts)

        frequency = {"frequency": text_handler.sw_frequency_distribution()}
        schema = FrequenceDistributionSchema()

        return schema.load(frequency), 200
Exemplo n.º 3
0
    def test_if_return_list_the_frequence_of_multiples_text(self):
        text_handler = TextHandler([
            "bernardo GOMES; Abreu. gomes abreu",
            "YASMINE",
            "Melo",
            "Costa",
            "gomes abreu Leonardo Gomes Abreu 1teste",
        ])
        bernardo = 1
        gomes = 2
        abreu = 2
        yasmine = 1
        melo = 1
        costa = 1
        leonardo = 1

        assert text_handler.sw_frequency_distribution() == {
            "text1": [bernardo, gomes, abreu, 0, 0, 0, 0],
            "text2": [0, 0, 0, yasmine, 0, 0, 0],
            "text3": [0, 0, 0, 0, melo, 0, 0],
            "text4": [0, 0, 0, 0, 0, costa, 0],
            "text5": [0, gomes, abreu, 0, 0, 0, leonardo],
        }
Exemplo n.º 4
0
 def test_if_return_list_the_frequence_of_text_empty(self):
     text_handler = TextHandler([""])
     assert text_handler.sw_frequency_distribution() == {"text1": []}
Exemplo n.º 5
0
    def test_if_return_list_the_frequence_of_list_with_unique_word(self):
        text_handler = TextHandler(["bufalo"])
        assert text_handler.sw_frequency_distribution() == {"text1": [1]}

        text_handler = TextHandler(["bufalo bufalo bufalo"])
        assert text_handler.sw_frequency_distribution() == {"text1": [3]}