Skip to content

Commit 110a2df

Browse files
committed
node.upostag -> node.upos, node.xpostag
Let's follow the agreed names used in udapi-java and udapi-perl. Note that node.upos is used also in https://github.com/UniversalDependencies/tools/blob/master/v2-conversion/depgraph_utils.py The CoNLL-U specification uses UPOSTAG and XPOSTAG as column names, but it uses also ID and HEAD, which are not used (cannot be used) in Udapi.
1 parent 3d5ad50 commit 110a2df

13 files changed

Lines changed: 23 additions & 24 deletions

File tree

udapi/block/demo/rehangprepositions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class RehangPrepositions(Block):
55

66
def process_node(self, node):
7-
if node.upostag == "ADP":
7+
if node.upos == "ADP":
88
origparent = node.parent
99
node.parent = origparent.parent
1010
origparent.parent = node

udapi/block/read/conllu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, strict=False, **kwargs):
1616
super().__init__(**kwargs)
1717

1818
# A list of Conllu columns.
19-
self.node_attributes = ["ord", "form", "lemma", "upostag", "xpostag",
19+
self.node_attributes = ["ord", "form", "lemma", "upos", "xpos",
2020
"feats", "head", "deprel", "deps", "misc"]
2121

2222
# TODO: this should be invoked from the parent class

udapi/block/read/reducedconllu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ def __init__(self, args=None):
1212

1313
# Here is the reduced list of the data fields as appear in the Conllu
1414
# reduced format.
15-
self.node_attributes = ["ord", "form", "upostag", "head", "deprel"]
15+
self.node_attributes = ["ord", "form", "upos", "head", "deprel"]

udapi/block/write/conllu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, print_sent_id=True, print_text=True, print_empty_trees=True,
1111
self.print_empty_trees = print_empty_trees
1212

1313
# A list of Conllu columns.
14-
self.node_attributes = ["ord", "form", "lemma", "upostag", "xpostag",
14+
self.node_attributes = ["ord", "form", "lemma", "upos", "xpos",
1515
"raw_feats", "parent", "deprel", "raw_deps", "misc"]
1616

1717
def process_tree(self, tree):

udapi/block/write/textmodetrees.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
COLOR_OF = {
99
'form': 'yellow',
1010
'lemma': 'cyan',
11-
'upostag': 'red',
11+
'upos': 'red',
1212
'deprel': 'blue',
1313
'ord': 'yellow',
1414
}
@@ -60,7 +60,7 @@ class TextModeTrees(BaseWriter):
6060
"""
6161

6262
def __init__(self, print_sent_id=False, print_sentence=False, add_empty_line=True, indent=1,
63-
minimize_cross=True, color='auto', attributes='form,upostag,deprel',
63+
minimize_cross=True, color='auto', attributes='form,upos,deprel',
6464
print_undef_as='', **kwargs):
6565
'''Create new TextModeTrees block object.
6666
@@ -79,16 +79,16 @@ def __init__(self, print_sent_id=False, print_sentence=False, add_empty_line=Tru
7979
If you plan to pipe the output (e.g. to "less -R") and you want the colors,
8080
you need to set explicitly color=1, see the example in Synopsis.
8181
attributes: A comma-separated list of node attributes which should be printed. Possible
82-
values are ord, form, lemma, upostag, xpostag, feats, deprel, deps, misc.
82+
values are ord, form, lemma, upos, xpos, feats, deprel, deps, misc.
8383
print_undef_as: What should be printed instead of undefined attribute values (if any)?
8484
'''
8585
super().__init__(**kwargs)
8686
self.print_sent_id = print_sent_id
8787
self.print_sentence = print_sentence
8888
self.add_empty_line = add_empty_line
89-
self.indent = indent
89+
self.indent = indent
9090
self.minimize_cross = minimize_cross
91-
self.color = color
91+
self.color = color
9292
self.attributes = attributes
9393
self.print_undef_as = print_undef_as
9494

@@ -118,7 +118,7 @@ def _compute_gaps(self, node):
118118
lm, rm, de = self._compute_gaps(child)
119119
lmost = min(lm, lmost)
120120
rmost = max(rm, rmost)
121-
descs += de;
121+
descs += de
122122
self._gaps[node.ord] = rmost - lmost - descs
123123
return lmost, rmost, descs + 1
124124

udapi/block/zellig_harris/baseline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def process_node(self, node):
122122
123123
"""
124124
# We want to extract contexts only for verbs.
125-
if str(node.upostag) not in self.pos:
125+
if str(node.upos) not in self.pos:
126126
return
127127

128128
# Process node's parent.

udapi/block/zellig_harris/csnouns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def process_node(self, node):
3434
3535
"""
3636
# We want to extract contexts only for the .
37-
if str(node.upostag) not in self.pos:
37+
if str(node.upos) not in self.pos:
3838
return
3939

4040
if self.verbose:

udapi/block/zellig_harris/csverbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def process_node(self, node):
3434
3535
"""
3636
# We want to extract contexts only for verbs.
37-
if str(node.upostag) not in self.pos:
37+
if str(node.upos) not in self.pos:
3838
return
3939

4040
if self.verbose:

udapi/block/zellig_harris/ennouns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def process_node(self, node):
3434
3535
"""
3636
# We want to extract contexts only for verbs.
37-
if str(node.upostag) not in self.pos:
37+
if str(node.upos) not in self.pos:
3838
return
3939

4040
if self.verbose:

udapi/block/zellig_harris/enverbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def process_node(self, node):
3434
3535
"""
3636
# We want to extract contexts only for verbs.
37-
if str(node.upostag) not in self.pos:
37+
if str(node.upos) not in self.pos:
3838
return
3939

4040
if self.verbose:

0 commit comments

Comments
 (0)