Beispiel #1
0
 def setUp(self):
     self.object = Filters.URLFilter()
import unittest

from TextProcessingTools.TextTools.Filtration import Filters
from TextProcessingTools.TextTools.Replacement import Modifiers
from TextProcessingTools.StatisticalTools import Counters as C

filters = [
    Filters.UsernameFilter(),
    Filters.PunctuationFilter(),
    Filters.URLFilter(),
    Filters.NumeralFilter()
]

modifiers = [Modifiers.WierdBPrefixConverter(), Modifiers.CaseConverter()]


class SelectedCounterTests(unittest.TestCase):
    def setUp(self):
        self.obj = C.SelectedWordCounter()
        self.obj.add_filters(filters)
        self.obj.add_modifiers(modifiers)

    def test_process_count(self):
        test = "My cat eats food of cat"
        self.obj.set_words_to_count(['my', 'cat', 'eats'])
        expected = {'my': 1, 'cat': 2, 'eats': 1}
        self.obj.process(test)

        # check
        for k in expected.keys():
            self.assertEqual(self.obj.counts[k], expected[k])