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.
Projectmiso-belica/sumy
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
| 75 | 75 | denominator_sentences = frozenset(denominator_sentences) | |
| 76 | 76 | numerator_sentences = frozenset(numerator_sentences) | |
| 77 | 77 | ||
| 78 | + | if len(numerator_sentences) == 0 or len(denominator_sentences) == 0: | |
| 79 | + | raise ValueError("Both collections have to contain at least 1 sentence.") | |
| 80 | + | ||
| 78 | 81 | common_count = len(denominator_sentences & numerator_sentences) | |
| 79 | 82 | choosen_count = len(denominator_sentences) | |
| 80 | 83 | ||
| 81 | - | return 0.0 if choosen_count == 0 else common_count / choosen_count | |
| 84 | + | assert choosen_count != 0 | |
| 85 | + | return common_count / choosen_count | |
| 82 | 86 |
The check that tells the two apart
fail→pass·tests/test_evaluation.py::TestEvaluation::test_basic_f_score_empty_evaluated
fail→pass·tests/test_evaluation.py::TestEvaluation::test_basic_f_score_empty_reference
fail→pass·tests/test_evaluation.py::TestEvaluation::test_precision_empty_evaluated
fail→pass·tests/test_evaluation.py::TestEvaluation::test_precision_empty_reference
fail→pass·tests/test_evaluation.py::TestEvaluation::test_recall_empty_evaluated
fail→pass·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.