Exemple #1
0
    def test_complex_case(self):
        positives = {u"Page 1": {u"A": 0.2, u"B": 0.2, u"C": 0.3}, u"Page 2": {u"B": 0.2, u"C": 0.2, u"D": 0.2}}
        negatives = {u"Page 3": {u"A": 0.2, u"E": 0.1}}

        expected = [u"C", u"B", u"D", u"A", u"E"]
        actual = search.evaluate(positives, negatives).keys()
        self.assertEqual(expected, actual)
Exemple #2
0
    def test_should_not_contain_self(self):
        positives = {u"A": {u"A": 0.2, u"B": 0.2, u"C": 0.3}, u"B": {u"B": 0.2, u"C": 0.2, u"D": 0.2}}
        negatives = {u"C": {u"A": 0.2, u"E": 0.1}}

        expected = [u"D", u"E"]
        actual = search.evaluate(positives, negatives).keys()
        self.assertEqual(expected, actual)
Exemple #3
0
    def search(cls, expression):
        # parse
        parsed = search.parse_expression(expression)

        # evaluate
        pos, neg = parsed['pos'], parsed['neg']
        pos_pages = [cls.get_by_title(t, True) for t in pos]
        neg_pages = [cls.get_by_title(t, True) for t in neg]
        scoretable = search.evaluate(
            dict((page.title, page.link_scoretable) for page in pos_pages),
            dict((page.title, page.link_scoretable) for page in neg_pages)
        )
        return scoretable
Exemple #4
0
    def test_complex_case(self):
        positives = {
            u'Page 1': {
                u'A': 0.2,
                u'B': 0.2,
                u'C': 0.3,
            },
            u'Page 2': {
                u'B': 0.2,
                u'C': 0.2,
                u'D': 0.2,
            }
        }
        negatives = {
            u'Page 3': {
                u'A': 0.2,
                u'E': 0.1,
            }
        }

        expected = [u'C', u'B', u'D', u'A', u'E']
        actual = search.evaluate(positives, negatives).keys()
        self.assertEqual(expected, actual)
Exemple #5
0
    def test_should_not_contain_self(self):
        positives = {
            u'A': {
                u'A': 0.2,
                u'B': 0.2,
                u'C': 0.3,
            },
            u'B': {
                u'B': 0.2,
                u'C': 0.2,
                u'D': 0.2,
            }
        }
        negatives = {
            u'C': {
                u'A': 0.2,
                u'E': 0.1,
            }
        }

        expected = [u'D', u'E']
        actual = search.evaluate(positives, negatives).keys()
        self.assertEqual(expected, actual)