File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1529,11 +1529,18 @@ def _init_deps(self, value):
15291529 value = value .split ("|" )
15301530 if all (isinstance (x , str ) for x in value ):
15311531 value = [x .split (":" , maxsplit = 1 ) for x in value ]
1532+ word_id = self .id
1533+ add_edge = graph .add_edge
15321534 for parent , dep in value :
1533- parent = tuple (map (int , parent .split ("." , maxsplit = 1 )))
1534- if len (parent ) == 1 :
1535- parent = parent [0 ]
1536- graph .add_edge (parent , self .id , dep )
1535+ # only an empty node has a . in its id, and those are rare, so the
1536+ # common case skips building a tuple just to unpack it again
1537+ if "." in parent :
1538+ parent = tuple (map (int , parent .split ("." , maxsplit = 1 )))
1539+ if len (parent ) == 1 :
1540+ parent = parent [0 ]
1541+ else :
1542+ parent = int (parent )
1543+ add_edge (parent , word_id , dep )
15371544
15381545 @property
15391546 def manual_expansion (self ):
You can’t perform that action at this time.
0 commit comments