Skip to content

Commit 1e4debd

Browse files
committed
So far, the validator was missing some of the function words when checking that they are leaves.
1 parent c16aa24 commit 1e4debd

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

validate.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,18 +1669,16 @@ def validate_functional_leaves(id, tree):
16691669
"""
16701670
Most of the time, function-word nodes should be leaves. This function
16711671
checks for known exceptions and warns in the other cases.
1672+
(https://universaldependencies.org/u/overview/syntax.html#function-word-modifiers)
16721673
"""
16731674
testlevel = 3
16741675
testclass = 'Syntax'
16751676
# This is a level 3 test, we will check only the universal part of the relation.
16761677
deprel = lspec2ud(tree['nodes'][id][DEPREL])
1677-
if re.match(r"^(case|mark|cc|aux|cop|det|fixed|goeswith|punct)$", deprel):
1678+
if re.match(r"^(case|mark|cc|aux|cop|det|clf|fixed|goeswith|punct)$", deprel):
16781679
idparent = id
1680+
pdeprel = deprel
16791681
for idchild in tree['children'][id]:
1680-
# This is a level 3 test, we will check only the universal part of the relation.
1681-
pdeprel = lspec2ud(tree['nodes'][idparent][DEPREL])
1682-
###!!! We should also check that 'det' does not have children except for a limited set of exceptions!
1683-
###!!! (see https://universaldependencies.org/u/overview/syntax.html#function-word-modifiers)
16841682
cdeprel = lspec2ud(tree['nodes'][idchild][DEPREL])
16851683
# The guidelines explicitly say that negation can modify any function word
16861684
# (see https://universaldependencies.org/u/overview/syntax.html#function-word-modifiers).
@@ -1729,14 +1727,14 @@ def validate_functional_leaves(id, tree):
17291727
testid = 'leaf-mark-case'
17301728
testmessage = "'%s' not expected to have children (%s:%s:%s --> %s:%s:%s)" % (pdeprel, idparent, tree['nodes'][idparent][FORM], pdeprel, idchild, tree['nodes'][idchild][FORM], cdeprel)
17311729
warn(testmessage, testclass, testlevel, testid, nodeid=id, lineno=tree['linenos'][idchild])
1732-
###!!! The pdeprel regex in the following test should probably include "det".
1733-
###!!! I forgot to add it well in advance of release 2.4, so I am leaving it
1734-
###!!! out for now, so that people don't have to deal with additional load
1735-
###!!! of errors.
17361730
if re.match(r"^(aux|cop)$", pdeprel) and not re.match(r"^(goeswith|fixed|reparandum|conj|cc|punct)$", cdeprel):
17371731
testid = 'leaf-aux-cop'
17381732
testmessage = "'%s' not expected to have children (%s:%s:%s --> %s:%s:%s)" % (pdeprel, idparent, tree['nodes'][idparent][FORM], pdeprel, idchild, tree['nodes'][idchild][FORM], cdeprel)
17391733
warn(testmessage, testclass, testlevel, testid, nodeid=id, lineno=tree['linenos'][idchild])
1734+
if re.match(r"^(det|clf)$", pdeprel) and not re.match(r"^(goeswith|fixed|reparandum|conj|cc|punct)$", cdeprel):
1735+
testid = 'leaf-det-clf'
1736+
testmessage = "'%s' not expected to have children (%s:%s:%s --> %s:%s:%s)" % (pdeprel, idparent, tree['nodes'][idparent][FORM], pdeprel, idchild, tree['nodes'][idchild][FORM], cdeprel)
1737+
warn(testmessage, testclass, testlevel, testid, nodeid=id, lineno=tree['linenos'][idchild])
17401738
if re.match(r"^(cc)$", pdeprel) and not re.match(r"^(goeswith|fixed|reparandum|conj|punct)$", cdeprel):
17411739
testid = 'leaf-cc'
17421740
testmessage = "'%s' not expected to have children (%s:%s:%s --> %s:%s:%s)" % (pdeprel, idparent, tree['nodes'][idparent][FORM], pdeprel, idchild, tree['nodes'][idchild][FORM], cdeprel)

0 commit comments

Comments
 (0)