File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Delete coreference annotation (Entity|Bridge|SplitAnte) and optionally also empty nodes."""
2+
3+ from udapi .core .block import Block
4+ import udapi .core .coref
5+ import logging
6+
7+ class Delete (Block ):
8+
9+ def __init__ (self , empty = False , ** kwargs ):
10+ super ().__init__ (** kwargs )
11+ self .empty = empty
12+
13+ def process_document (self , doc ):
14+ # This block should work both with coreference loaded (deserialized) and not.
15+ doc ._eid_to_entity = None
16+ for root in doc .trees :
17+ if self .empty :
18+ root .empty_nodes = []
19+ for node in root .descendants :
20+ if node .raw_deps != '_' :
21+ node .raw_deps = '|' .join (d for d in node .raw_deps .split ('|' ) if not '.' in d )
22+ if node .raw_deps == '' :
23+ node .raw_deps = '0:root'
24+ if '.' in node .misc ['Functor' ]:
25+ del node .misc ['Functor' ]
26+
27+ for node in root .descendants + root .empty_nodes :
28+ node ._mentions = []
29+ for attr in ('Entity' , 'Bridge' , 'SplitAnte' ):
30+ del node .misc [attr ]
You can’t perform that action at this time.
0 commit comments