Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea33c78

Browse files
committed
corefud.Delete misc=1
parameters (coref|empty|misc) turn on/off the deletionof the respective parts of CoNLL-U.
1 parentf2987e6 commitea33c78

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

‎udapi/block/corefud/delete.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66

77
classDelete(Block):
88

9-
def__init__(self,empty=False,**kwargs):
9+
def__init__(self,coref=True,empty=False,misc=False,**kwargs):
10+
"""Args:
11+
coref: delete coreference attributes in MISC, i.e (Entity|Bridge|SplitAnte)
12+
empty: delete all empty nodes and references to them (from DEPS and MISC[Functor])
13+
misc: delete all attributes in MISC except for SpaceAfter
14+
"""
1015
super().__init__(**kwargs)
16+
self.coref=coref
1117
self.empty=empty
18+
self.misc=misc
1219

1320
defis_root_reachable_by_deps(self,node,parents_to_ignore=None):
1421
""" Check if the root node is reachable from node, possibly after deleting the parents_to_ignore nodes.
@@ -54,7 +61,8 @@ def _deps_ignore_nodes(self, node, parents_to_ignore):
5461

5562
defprocess_document(self,doc):
5663
# This block should work both with coreference loaded (deserialized) and not.
57-
doc._eid_to_entity=None
64+
ifself.coref:
65+
doc._eid_to_entity=None
5866
forrootindoc.trees:
5967
ifself.empty:
6068
fornodeinroot.descendants:
@@ -74,7 +82,12 @@ def process_document(self, doc):
7482
delnode.misc['Functor']
7583
root.empty_nodes= []
7684

77-
fornodeinroot.descendants+root.empty_nodes:
78-
node._mentions= []
79-
forattrin ('Entity','Bridge','SplitAnte'):
80-
delnode.misc[attr]
85+
ifself.coreforself.misc:
86+
fornodeinroot.descendants+root.empty_nodes:
87+
ifself.misc:
88+
node.misc='SpaceAfter=No'ifnode.no_space_afterelseNone
89+
ifself.coref:
90+
node._mentions= []
91+
ifnotself.misc:
92+
forattrin ('Entity','Bridge','SplitAnte'):
93+
delnode.misc[attr]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp