Whole file

miso-belica/sumy

The author described this change as Raise exception if evaluated document is empty. It counts as a record because the checks below fail on the code as it stood at 7dccc6872 and pass on 9b2c3cbc7, with nothing else changed between the two runs.

Fix saved2013-03-17
Sharing licenceApache-2.0 · LICENSE.md
Change size+5 1

What the code was meant to do, written into the code itself as a save note

Raise exception if evaluated document is empty

The change

7575 denominator_sentences = frozenset(denominator_sentences)
7676 numerator_sentences = frozenset(numerator_sentences)
7777
78+ if len(numerator_sentences) == 0 or len(denominator_sentences) == 0:
79+ raise ValueError("Both collections have to contain at least 1 sentence.")
80+
7881 common_count = len(denominator_sentences & numerator_sentences)
7982 choosen_count = len(denominator_sentences)
8083
81- return 0.0 if choosen_count == 0 else common_count / choosen_count
84+ assert choosen_count != 0
85+ return common_count / choosen_count
8286

The check that tells the two apart

failpass·tests/test_evaluation.py::TestEvaluation::test_basic_f_score_empty_evaluated
failpass·tests/test_evaluation.py::TestEvaluation::test_basic_f_score_empty_reference
failpass·tests/test_evaluation.py::TestEvaluation::test_precision_empty_evaluated
failpass·tests/test_evaluation.py::TestEvaluation::test_precision_empty_reference
failpass·tests/test_evaluation.py::TestEvaluation::test_recall_empty_evaluated
failpass·tests/test_evaluation.py::TestEvaluation::test_recall_empty_reference

Check file tests/test_evaluation.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it7dccc6872e6df67bb96ea63335226b7deb1982e9
Broken version dated2013-03-17
Modulesumy.evaluation.coselection
Units changed_divide_evaluation
Fingerprintd22113e5f6184891
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in miso-belica/sumy