def test_f_score_2():
    sentences = (("s1", "s3", "s6"), ("s1", "s2", "s3", "s4", "s5"))
    result = f_score(*sentences, weight=0.5)

    p = 2/3
    r = 2/5
    # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
    expected = (1.25 * p * r) / (0.25 * p + r)

    assert result == approx(expected)
Esempio n. 2
0
    def test_f_score_2(self):
        sentences = (("s1", "s3", "s6"), ("s1", "s2", "s3", "s4", "s5"))
        result = f_score(*sentences, weight=0.5)

        p = 2/3
        r = 2/5
        # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
        expected = (1.25 * p * r) / (0.25 * p + r)

        self.assertAlmostEqual(result, expected)
Esempio n. 3
0
    def test_f_score_1(self):
        sentences = (("s1",), ("s1", "s2", "s3", "s4", "s5"))
        result = f_score(*sentences, weight=2.0)

        p = 1/1
        r = 1/5
        # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
        expected = (5 * p * r) / (4 * p + r)

        self.assertAlmostEqual(result, expected)
Esempio n. 4
0
    def test_f_score_1(self):
        sentences = (("s1", ), ("s1", "s2", "s3", "s4", "s5"))
        result = f_score(*sentences, weight=2.0)

        p = 1 / 1
        r = 1 / 5
        # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
        expected = (5 * p * r) / (4 * p + r)

        self.assertAlmostEqual(result, expected)
Esempio n. 5
0
    def test_f_score_2(self):
        sentences = (("s1", "s3", "s6"), ("s1", "s2", "s3", "s4", "s5"))
        result = f_score(*sentences, weight=0.5)

        p = 2 / 3
        r = 2 / 5
        # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
        expected = (1.25 * p * r) / (0.25 * p + r)

        self.assertAlmostEqual(result, expected)
def test_f_score_1():
    sentences = (("s1", ), ("s1", "s2", "s3", "s4", "s5"))
    result = f_score(*sentences, weight=2.0)

    p = 1 / 1
    r = 1 / 5
    # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
    expected = (5 * p * r) / (4 * p + r)

    assert result == approx(expected)
def test_f_score_1():
    sentences = (("s1",), ("s1", "s2", "s3", "s4", "s5"))
    result = f_score(*sentences, weight=2.0)

    p = 1/1
    r = 1/5
    # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
    expected = (5 * p * r) / (4 * p + r)

    assert result == approx(expected)
def test_f_score_2():
    sentences = (("s1", "s3", "s6"), ("s1", "s2", "s3", "s4", "s5"))
    result = f_score(*sentences, weight=0.5)

    p = 2 / 3
    r = 2 / 5
    # ( (W^2 + 1) * P * R ) / ( W^2 * P + R )
    expected = (1.25 * p * r) / (0.25 * p + r)

    assert result == approx(expected)
Esempio n. 9
0
def evaluate(summary, sumref, debug=False):
    sumstring = sumtostr(summary)
    sumtuple = sumtotup(summary)
    refstring = sumtostr(sumref)
    reftuple = sumtotup(sumref)
    summodel = TfDocumentModel(sumstring, Tokenizer("english"))
    refmodel = TfDocumentModel(refstring, Tokenizer("english"))

    if debug:
        print(reftuple)
        print(sumtuple)

    cos_val = cosine_similarity(summodel, refmodel)
    unit_val = unit_overlap(summodel, refmodel)

    precision_val = precision(sumtuple, reftuple)
    recall_val = recall(sumtuple, reftuple)
    f_val = f_score(sumtuple, reftuple)

    return cos_val, unit_val, precision_val, recall_val, f_val
def test_basic_f_score_empty_reference():
    with pytest.raises(ValueError):
        f_score(("s1", "s2", "s3", "s4", "s5"), ())
def test_basic_f_score_equals():
    sentences = ("s1", "s2", "s3", "s4", "s5")
    result = f_score(sentences, sentences)

    assert result == approx(1.0)
Esempio n. 12
0
    def test_basic_f_score_no_match(self):
        result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s6", "s7", "s8"))

        self.assertEqual(result, 0.0)
Esempio n. 13
0
    def test_basic_f_score_equals(self):
        sentences = ("s1", "s2", "s3", "s4", "s5")
        result = f_score(sentences, sentences)

        self.assertAlmostEqual(result, 1.0)
def test_basic_f_score_evaluated_smaller():
    result = f_score(("s1", ), ("s1", "s2", "s3", "s4", "s5"))

    assert result == approx(1 / 3)
Esempio n. 15
0
    def test_basic_f_score_reference_smaller(self):
        result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s1", ))

        self.assertAlmostEqual(result, 1 / 3)
Esempio n. 16
0
    def test_basic_f_score_evaluated_smaller(self):
        result = f_score(("s1", ), ("s1", "s2", "s3", "s4", "s5"))

        self.assertAlmostEqual(result, 1 / 3)
Esempio n. 17
0
    def test_basic_f_score_reference_smaller(self):
        result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s1",))

        self.assertAlmostEqual(result, 1/3)
Esempio n. 18
0
    def test_basic_f_score_no_match(self):
        result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s6", "s7", "s8"))

        self.assertEqual(result, 0.0)
Esempio n. 19
0
    def test_basic_f_score_equals(self):
        sentences = ("s1", "s2", "s3", "s4", "s5")
        result = f_score(sentences, sentences)

        self.assertAlmostEqual(result, 1.0)
Esempio n. 20
0
    def test_basic_f_score_evaluated_smaller(self):
        result = f_score(("s1",), ("s1", "s2", "s3", "s4", "s5"))

        self.assertAlmostEqual(result, 1/3)
def test_basic_f_score_no_match():
    result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s6", "s7", "s8"))

    assert result == 0.0
def test_basic_f_score_empty_evaluated():
    with pytest.raises(ValueError):
        f_score((), ("s1", "s2", "s3", "s4", "s5"))
def test_basic_f_score_empty_evaluated():
    with pytest.raises(ValueError):
        f_score((), ("s1", "s2", "s3", "s4", "s5"))
def test_basic_f_score_evaluated_smaller():
    result = f_score(("s1",), ("s1", "s2", "s3", "s4", "s5"))

    assert result == approx(1/3)
def test_basic_f_score_equals():
    sentences = ("s1", "s2", "s3", "s4", "s5")
    result = f_score(sentences, sentences)

    assert result == approx(1.0)
def test_basic_f_score_empty_reference():
    with pytest.raises(ValueError):
        f_score(("s1", "s2", "s3", "s4", "s5"), ())
def test_basic_f_score_no_match():
    result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s6", "s7", "s8"))

    assert result == 0.0
def test_basic_f_score_reference_smaller():
    result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s1", ))

    assert result == approx(1 / 3)
def test_basic_f_score_reference_smaller():
    result = f_score(("s1", "s2", "s3", "s4", "s5"), ("s1",))

    assert result == approx(1/3)