asymgram 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: asymgram
3
+ Version: 0.1.0
4
+ Summary: Utilities for CoNLL-U dependency tree objects, manipulation, evaluation, and error checking.
5
+ Author-email: Tsy Yih <yihtsy@outlook.com>
6
+ Project-URL: Homepage, https://github.com/Yihtsy/asymgram
7
+ Project-URL: Repository, https://github.com/Yihtsy/asymgram
8
+ Project-URL: Issues, https://github.com/Yihtsy/asymgram/issues
9
+ Keywords: CoNLL-U,Universal Dependencies,dependency grammar,dependency parsing,corpus linguistics,treebank
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
22
+ Classifier: Topic :: Text Processing :: Linguistic
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: conllu>=6.0
26
+ Provides-Extra: nlp
27
+ Requires-Dist: spacy>=3.0; extra == "nlp"
28
+ Requires-Dist: spacy-stanza>=1.0; extra == "nlp"
29
+ Requires-Dist: stanza>=1.0; extra == "nlp"
30
+
31
+ # asymgram
32
+
33
+ `asymgram` is a small Python toolkit for working with CoNLL-U dependency treebanks. It wraps parsed CoNLL-U tokens and sentences with convenient object references, provides tree manipulation helpers, evaluates dependency parses, and includes diagnostics for common annotation and format errors.
34
+
35
+ The package is designed for corpus linguistics, dependency grammar research, Universal Dependencies style treebank work, and quick inspection of parser output.
36
+
37
+ ## Features
38
+
39
+ - Enhanced CoNLL-U objects: `Token`, `TokenList`, `SentenceList`, and `SentenceLists`.
40
+ - Context-aware token navigation, including head lookup, dependent lookup, subtree span extraction, and node depth.
41
+ - Sentence and token manipulation helpers for merging tokens, splitting tokens, removing leaf nodes, merging sentences, and splitting sentences at marginal subtrees.
42
+ - Basic dependency evaluation metrics: UAS and LAS.
43
+ - CoNLL-U readers, writers, text reconstruction, and simple conversion helpers.
44
+ - Error checking for common CoNLL-U and dependency treebank issues, including invalid IDs, malformed HEAD values, self-loops, cycles, missing roots, multiple roots, invalid UPOS/DEPREL labels, malformed FEATS/DEPS, punctuation mismatches, and suspicious UPOS-DEPREL combinations.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install asymgram
50
+ ```
51
+
52
+ For local development:
53
+
54
+ ```bash
55
+ git clone https://github.com/Yihtsy/asymgram.git
56
+ cd asymgram
57
+ pip install -e .
58
+ ```
59
+
60
+ Optional NLP-related dependencies can be installed with:
61
+
62
+ ```bash
63
+ pip install "asymgram[nlp]"
64
+ ```
65
+
66
+ ## Quick Start
67
+
68
+ ```python
69
+ import asymgram as ag
70
+
71
+ text = """
72
+ # sent_id = demo-1
73
+ # text = I saw her.
74
+ 1 I _ PRON _ _ 2 nsubj 2:nsubj _
75
+ 2 saw _ VERB _ _ 0 root 0:root _
76
+ 3 her _ PRON _ _ 2 obj 2:obj SpaceAfter=No
77
+ 4 . _ PUNCT _ _ 2 punct 2:punct _
78
+ """
79
+
80
+ sentences = ag.parse(text)
81
+ sentence = sentences[0]
82
+ root = sentence.get_roottoken()
83
+
84
+ print(root.form)
85
+ print([tok.form for tok in root.get_deptokens(include_punct=True)])
86
+ print(sentences.to_tokenized_text())
87
+ ```
88
+
89
+ ## Error Checking
90
+
91
+ `asymgram.error_checker` can inspect raw CoNLL-U text, files, parsed sentences, or sentence lists.
92
+
93
+ ```python
94
+ from asymgram.error_checker import check_conllu_text, check_file
95
+
96
+ diagnostics = check_conllu_text(text)
97
+
98
+ for diagnostic in diagnostics:
99
+ print(diagnostic.level, diagnostic.code, diagnostic.sent_id, diagnostic.token_id, diagnostic.message)
100
+
101
+ file_diagnostics = check_file("treebank.conllu")
102
+ ```
103
+
104
+ Each diagnostic is represented by a `Diagnostic` object:
105
+
106
+ ```python
107
+ Diagnostic(
108
+ code="SELF_LOOP",
109
+ level="ERROR",
110
+ message="token cannot take itself as HEAD",
111
+ sent_id="demo-1",
112
+ token_id=3,
113
+ )
114
+ ```
115
+
116
+ Diagnostic levels are:
117
+
118
+ - `ERROR`: structural or format problems that are usually automatically decidable.
119
+ - `WARNING`: strong annotation warnings that should be manually checked.
120
+ - `INFO`: low-frequency or linguistically atypical patterns that may still be valid.
121
+
122
+ ## Common APIs
123
+
124
+ ```python
125
+ import asymgram as ag
126
+
127
+ sentences = ag.read_conllu("sample.conllu")
128
+ sentences.to_conllu("copy.conllu")
129
+
130
+ root = sentences[0].get_roottoken()
131
+ children = root.get_deptokens()
132
+ span = root.get_subtree_span()
133
+
134
+ uas = ag.uas(gold_sentences, predicted_sentences)
135
+ las = ag.las(gold_sentences, predicted_sentences)
136
+ ```
137
+
138
+ ## Notes
139
+
140
+ `asymgram` follows the CoNLL-U conventions used by Universal Dependencies, but it is not limited to official UD treebanks. Some diagnostics intentionally return warnings or info-level messages because many unusual UPOS-DEPREL combinations can be valid in ellipsis, multiword expressions, headless constructions, dates, measurements, names, and language-specific analyses.
141
+
142
+ ## License
143
+
144
+ License information has not yet been specified.
@@ -0,0 +1,114 @@
1
+ # asymgram
2
+
3
+ `asymgram` is a small Python toolkit for working with CoNLL-U dependency treebanks. It wraps parsed CoNLL-U tokens and sentences with convenient object references, provides tree manipulation helpers, evaluates dependency parses, and includes diagnostics for common annotation and format errors.
4
+
5
+ The package is designed for corpus linguistics, dependency grammar research, Universal Dependencies style treebank work, and quick inspection of parser output.
6
+
7
+ ## Features
8
+
9
+ - Enhanced CoNLL-U objects: `Token`, `TokenList`, `SentenceList`, and `SentenceLists`.
10
+ - Context-aware token navigation, including head lookup, dependent lookup, subtree span extraction, and node depth.
11
+ - Sentence and token manipulation helpers for merging tokens, splitting tokens, removing leaf nodes, merging sentences, and splitting sentences at marginal subtrees.
12
+ - Basic dependency evaluation metrics: UAS and LAS.
13
+ - CoNLL-U readers, writers, text reconstruction, and simple conversion helpers.
14
+ - Error checking for common CoNLL-U and dependency treebank issues, including invalid IDs, malformed HEAD values, self-loops, cycles, missing roots, multiple roots, invalid UPOS/DEPREL labels, malformed FEATS/DEPS, punctuation mismatches, and suspicious UPOS-DEPREL combinations.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install asymgram
20
+ ```
21
+
22
+ For local development:
23
+
24
+ ```bash
25
+ git clone https://github.com/Yihtsy/asymgram.git
26
+ cd asymgram
27
+ pip install -e .
28
+ ```
29
+
30
+ Optional NLP-related dependencies can be installed with:
31
+
32
+ ```bash
33
+ pip install "asymgram[nlp]"
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```python
39
+ import asymgram as ag
40
+
41
+ text = """
42
+ # sent_id = demo-1
43
+ # text = I saw her.
44
+ 1 I _ PRON _ _ 2 nsubj 2:nsubj _
45
+ 2 saw _ VERB _ _ 0 root 0:root _
46
+ 3 her _ PRON _ _ 2 obj 2:obj SpaceAfter=No
47
+ 4 . _ PUNCT _ _ 2 punct 2:punct _
48
+ """
49
+
50
+ sentences = ag.parse(text)
51
+ sentence = sentences[0]
52
+ root = sentence.get_roottoken()
53
+
54
+ print(root.form)
55
+ print([tok.form for tok in root.get_deptokens(include_punct=True)])
56
+ print(sentences.to_tokenized_text())
57
+ ```
58
+
59
+ ## Error Checking
60
+
61
+ `asymgram.error_checker` can inspect raw CoNLL-U text, files, parsed sentences, or sentence lists.
62
+
63
+ ```python
64
+ from asymgram.error_checker import check_conllu_text, check_file
65
+
66
+ diagnostics = check_conllu_text(text)
67
+
68
+ for diagnostic in diagnostics:
69
+ print(diagnostic.level, diagnostic.code, diagnostic.sent_id, diagnostic.token_id, diagnostic.message)
70
+
71
+ file_diagnostics = check_file("treebank.conllu")
72
+ ```
73
+
74
+ Each diagnostic is represented by a `Diagnostic` object:
75
+
76
+ ```python
77
+ Diagnostic(
78
+ code="SELF_LOOP",
79
+ level="ERROR",
80
+ message="token cannot take itself as HEAD",
81
+ sent_id="demo-1",
82
+ token_id=3,
83
+ )
84
+ ```
85
+
86
+ Diagnostic levels are:
87
+
88
+ - `ERROR`: structural or format problems that are usually automatically decidable.
89
+ - `WARNING`: strong annotation warnings that should be manually checked.
90
+ - `INFO`: low-frequency or linguistically atypical patterns that may still be valid.
91
+
92
+ ## Common APIs
93
+
94
+ ```python
95
+ import asymgram as ag
96
+
97
+ sentences = ag.read_conllu("sample.conllu")
98
+ sentences.to_conllu("copy.conllu")
99
+
100
+ root = sentences[0].get_roottoken()
101
+ children = root.get_deptokens()
102
+ span = root.get_subtree_span()
103
+
104
+ uas = ag.uas(gold_sentences, predicted_sentences)
105
+ las = ag.las(gold_sentences, predicted_sentences)
106
+ ```
107
+
108
+ ## Notes
109
+
110
+ `asymgram` follows the CoNLL-U conventions used by Universal Dependencies, but it is not limited to official UD treebanks. Some diagnostics intentionally return warnings or info-level messages because many unusual UPOS-DEPREL combinations can be valid in ellipsis, multiword expressions, headless constructions, dates, measurements, names, and language-specific analyses.
111
+
112
+ ## License
113
+
114
+ License information has not yet been specified.
@@ -0,0 +1,57 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "asymgram"
7
+ version = "0.1.0"
8
+ description = "Utilities for CoNLL-U dependency tree objects, manipulation, evaluation, and error checking."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ authors = [
12
+ { name = "Tsy Yih", email = "yihtsy@outlook.com" }
13
+ ]
14
+ keywords = [
15
+ "CoNLL-U",
16
+ "Universal Dependencies",
17
+ "dependency grammar",
18
+ "dependency parsing",
19
+ "corpus linguistics",
20
+ "treebank"
21
+ ]
22
+ classifiers = [
23
+ "Development Status :: 3 - Alpha",
24
+ "Intended Audience :: Science/Research",
25
+ "Intended Audience :: Developers",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3.14",
34
+ "Topic :: Scientific/Engineering :: Information Analysis",
35
+ "Topic :: Text Processing :: Linguistic"
36
+ ]
37
+ dependencies = [
38
+ "conllu>=6.0"
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ nlp = [
43
+ "spacy>=3.0",
44
+ "spacy-stanza>=1.0",
45
+ "stanza>=1.0"
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/Yihtsy/asymgram"
50
+ Repository = "https://github.com/Yihtsy/asymgram"
51
+ Issues = "https://github.com/Yihtsy/asymgram/issues"
52
+
53
+ [tool.setuptools.packages.find]
54
+ where = ["src"]
55
+
56
+ [tool.setuptools.package-data]
57
+ asymgram = ["sample/*.conllu"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,56 @@
1
+ __title__ = 'asymmetrencygrammar'
2
+ __author__ = 'Tsy Yih'
3
+ __email__ = 'yihtsy@outlook.com'
4
+ __version__ = '0.1.0'
5
+
6
+ from .format_changer import (
7
+ read_conllu,
8
+ write_conllu,
9
+ extract_all_deprels,
10
+ load_sentence_lists,
11
+ stanza_doc2conllu_style_text,
12
+ conllu_to_latex_standalone
13
+ )
14
+
15
+ from .conllu import (
16
+ Token,
17
+ TokenList,
18
+ SentenceList,
19
+ SentenceLists,
20
+ parse,
21
+ parse_incr,
22
+ to_sentencelist
23
+ )
24
+
25
+ from .tree_manipulation import (
26
+ merge_tokens,
27
+ split_token,
28
+ is_marginal_subtree,
29
+ merge_sentences,
30
+ remove_leaf_node,
31
+ split_sentence_at_node,
32
+ postprocess_stanza_depparse
33
+ )
34
+
35
+ from .metrics import (
36
+ uas,
37
+ las
38
+ )
39
+
40
+ from .error_checker import (
41
+ Diagnostic,
42
+ check_conllu_text,
43
+ check_file,
44
+ check_sentence,
45
+ check_sentence_list,
46
+ exists_error,
47
+ find_id_equals_head_errors
48
+ )
49
+
50
+ __all__ = [
51
+ "read_conllu", "write_conllu", "extract_all_deprels", "load_sentence_lists", "stanza_doc2conllu_style_text", "conllu_to_latex_standalone",
52
+ "Token", "TokenList", "SentenceList", "SentenceLists", "parse", "parse_incr", "to_sentencelist",
53
+ "merge_tokens", "split_token", "is_marginal_subtree", "merge_sentences", "remove_leaf_node", "split_sentence_at_node", "postprocess_stanza_depparse",
54
+ "uas", "las",
55
+ "Diagnostic", "check_conllu_text", "check_file", "check_sentence", "check_sentence_list", "exists_error", "find_id_equals_head_errors"
56
+ ]