Datasets:
Tasks:
Text Classification
Formats:
parquet
Languages:
Ancient Greek (to 1453)
Size:
100K - 1M
ArXiv:
License:
Download tests/test_syntax_normalization.py from Urdatorn/sphragis: direct link, hf CLI and curl.
- Browser
- Download file 2.64 kB
-
https://huggingface.co/datasets/Urdatorn/sphragis/resolve/main/tests/test_syntax_normalization.py
- Command line
-
hf download hf://datasets/Urdatorn/sphragis/tests/test_syntax_normalization.py
-
curl -L -o test_syntax_normalization.py https://huggingface.co/datasets/Urdatorn/sphragis/resolve/main/tests/test_syntax_normalization.py
2.64 kB
| from scripts.syntax_normalization import ( | |
| canonical_stoicheia_deprel, | |
| is_universal_deprel, | |
| punctuationless_lemma, | |
| punctuationless_tokens, | |
| syntax_text_normalize, | |
| ) | |
| def test_parser_input_removes_attached_punctuation_and_splits_hidden_words(): | |
| assert punctuationless_tokens("Ἀστάσπης,") == ["Ἀστάσπης"] | |
| assert punctuationless_tokens("Φαρανδάκης θʼ,") == ["Φαρανδάκης", "θ"] | |
| assert punctuationless_tokens("ͅ") == [] | |
| def test_editorial_symbols_are_stripped_like_punctuation(): | |
| assert punctuationless_tokens("<ἄλαστ>") == ["ἄλαστ"] | |
| assert punctuationless_tokens("<ἔστ") == ["ἔστ"] | |
| assert punctuationless_lemma("δι~ος") == "διος" | |
| assert punctuationless_lemma("῎ἴλιος") == "ἴλιος" | |
| assert punctuationless_lemma("??") == "_" | |
| assert punctuationless_lemma("λέγω3") == "λέγω" | |
| assert punctuationless_tokens("ἔλλαχες1") == ["ἔλλαχες"] | |
| assert punctuationless_tokens("20") == [] | |
| def test_punctuated_lemmas_are_cleaned_without_removing_diacritics(): | |
| assert punctuationless_lemma("Σοσθάνης.") == "Σοσθάνης" | |
| assert syntax_text_normalize("θʼ,") == syntax_text_normalize("θ") | |
| def test_auxp_and_unknown_legacy_relations_cannot_survive_ud_normalization(): | |
| assert canonical_stoicheia_deprel("AuxP", "ADP", 2) == "case" | |
| assert canonical_stoicheia_deprel("nsubj", "NOUN", 2) == "nsubj" | |
| assert canonical_stoicheia_deprel("made_up", "NOUN", 2) == "dep" | |
| assert all(is_universal_deprel(value) for value in ("case", "nsubj", "dep")) | |
| def test_coordinators_attach_to_the_following_conjunct_whatever_the_project_did() -> None: | |
| from scripts.syntax_normalization import normalize_cc_heads | |
| # A καὶ B καὶ C, with UD Perseus' convention: both καί on the first conjunct. | |
| ids = [1, 2, 3, 4, 5] | |
| deprels = ["nsubj", "cc", "conj", "cc", "conj"] | |
| assert normalize_cc_heads(ids, [0, 1, 1, 1, 1], deprels) == [0, 3, 1, 5, 1] | |
| # PROIEL's convention is already the guideline and is left alone. | |
| assert normalize_cc_heads(ids, [0, 3, 1, 5, 1], deprels) == [0, 3, 1, 5, 1] | |
| # A conjunction with no following conjunct stays on the last member, and a | |
| # sentence-opening καί with no coordination at all stays where it was. | |
| assert normalize_cc_heads([1, 2, 3], [0, 1, 1], ["root", "conj", "cc"]) == [0, 1, 2] | |
| assert normalize_cc_heads([1, 2], [2, 0], ["cc", "root"]) == [2, 0] | |
| # A subtype is still a coordinator. | |
| assert normalize_cc_heads([1, 2, 3], [0, 1, 1], ["root", "cc:preconj", "conj"]) == [0, 3, 1] | |