Download tests/test_goldenset_quality.py from legexbenchmark/code: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/datasets/legexbenchmark/code/resolve/main/tests/test_goldenset_quality.py
- Command line
-
hf download hf://datasets/legexbenchmark/code/tests/test_goldenset_quality.py
-
curl -L -o test_goldenset_quality.py https://huggingface.co/datasets/legexbenchmark/code/resolve/main/tests/test_goldenset_quality.py
2.46 kB
| from legex.analysis.goldenset_quality import classify_cell | |
| def test_empty_variants(): | |
| for v in (None, "", "None", "none", "nan"): | |
| assert classify_cell("court_cost_awarded_nominal", v) == "empty" | |
| def test_money_valid_and_invalid(): | |
| assert classify_cell("court_cost_awarded_nominal", "4000") == "valid" | |
| assert classify_cell("court_cost_awarded_nominal", "4000.50") == "valid" | |
| assert classify_cell("court_cost_awarded_nominal", 4000) == "valid" | |
| # Text where a number is expected -> invalid. | |
| assert classify_cell("court_cost_awarded_nominal", "keine Angabe") == "invalid" | |
| assert classify_cell("court_cost_awarded_nominal", "CHF 4000") == "invalid" | |
| def test_dispute_allows_nonpecuniary(): | |
| assert classify_cell("dispute_value_nominal", "nonpecuniary") == "valid" | |
| assert classify_cell("dispute_value_nominal", "150000.00") == "valid" | |
| assert classify_cell("dispute_value_nominal", "two million") == "invalid" | |
| def test_ratio_range(): | |
| assert classify_cell("plaintiff_loosing_share", "0.6") == "valid" | |
| assert classify_cell("plaintiff_loosing_share", "0") == "valid" | |
| assert classify_cell("plaintiff_loosing_share", "1") == "valid" | |
| assert classify_cell("plaintiff_loosing_share", "1.5") == "invalid" | |
| assert classify_cell("plaintiff_loosing_share", "60%") == "invalid" | |
| def test_counts_integer_nonnegative(): | |
| assert classify_cell("plaintiffs_all_count", "2") == "valid" | |
| assert classify_cell("plaintiffs_all_count", 3) == "valid" | |
| assert classify_cell("plaintiffs_all_count", "2.5") == "invalid" | |
| assert classify_cell("defendants_all_count", "two") == "invalid" | |
| def test_dates_iso(): | |
| assert classify_cell("trial_end_date", "2023-01-23") == "valid" | |
| assert classify_cell("trial_end_date", "23.01.2023") == "invalid" | |
| assert classify_cell("trial_start_date", "sometime in 2022") == "invalid" | |
| def test_isic_vocabulary(): | |
| assert classify_cell("plaintiff_no1_ISIC1_industry_category", "l_financial_insurance") == "valid" | |
| assert classify_cell("defendant_no1_ISIC1_industry_category", "no_allocation_possible") == "valid" | |
| assert classify_cell("plaintiff_no1_ISIC1_industry_category", "banking") == "invalid" | |
| def test_legal_subject_free_text(): | |
| assert classify_cell("legal_subject_judgement", "Contract_for_Work") == "valid" | |
| # A bare number is a coding slip for a translated subject. | |
| assert classify_cell("legal_subject_judgement", "12345") == "invalid" | |