コード例 #1
0
    def test_report_on_word_not_in_tfidf(self):
        """Check report_on none tf_idf"""
        clean_texts = [
            ['this', 'is', 'an', 'example', 'of', 'test', 'text', 'it', 'contains', 'two', 'sentences'],
            ['das', 'ist', 'ein', 'testtext', 'es', 'ist', 'auf', 'deutsch', 'geschrieben']
        ]
        tf_instance = TfIdfCalculator(clean_texts)
        tf_instance.tf_idf_values = None

        tf_instance.calculate()

        res = tf_instance.report_on('wtf', 0)
        exp_res = ()
        self.assertEqual(res, exp_res)
コード例 #2
0
    def test_report_on_index_bigger(self):
        """Check report_on invalid doc index"""
        clean_texts = [
            ['this', 'is', 'an', 'example', 'of', 'test', 'text', 'it', 'contains', 'two', 'sentences'],
            ['das', 'ist', 'ein', 'testtext', 'es', 'ist', 'auf', 'deutsch', 'geschrieben']
        ]
        tf_instance = TfIdfCalculator(clean_texts)
        tf_instance.tf_idf_values = [
            {
                'this': 10,
                'that': 9,
                'another': 5
            }
        ]

        tf_instance.calculate()

        res = tf_instance.report_on('this', 2)
        exp_res = ()
        self.assertEqual(res, exp_res)
コード例 #3
0
ファイル: test.py プロジェクト: katyanemzer/2018-2-level-labs
from lab_4.main import TfIdfCalculator

clean_texts = [[
    'this', 'is', 'an', 'example', 'of', 'test', 'text', 'it', 'contains',
    'two', 'sentences'
],
               [
                   'das', 'ist', 'ein', 'testtext', 'es', 'ist', 'auf',
                   'deutsch', 'geschrieben'
               ]]
tf_instance = TfIdfCalculator(clean_texts)
tf_instance.tf_idf_values = [{'this': 10, 'that': 9, 'another': 5}]

tf_instance.calculate()

res = tf_instance.report_on('this', 0)
print(res)