def __init__(self, node, children, origin=None): """ Note, you should use `SimpleRSTTree.from_RSTTree(tree)` to create this tree instead """ SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin)
def __init__(self, node, children, origin=None, verbose=False): """ See `educe.rst_dt.parse` to build trees from strings """ SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin) # WIP 2016-11-10 store num of head in node if len(children) == 1 and isinstance(children[0], EDU): # pre-terminal: head is num of terminal (EDU) node.head = children[0].num else: # internal node kids_nuclei = [ i for i, kid in enumerate(children) if kid.label().nuclearity == NUC_N ] if len(kids_nuclei) == 1: # 1 nucleus, 1-n satellites: n mono-nuc relations pass elif len(kids_nuclei) == len(children): # all children are nuclei: 1 multi-nuc relation kid_rels = [kid.label().rel for kid in children] if len(set(kid_rels)) > 1: if verbose: err_msg = ('W: More than one label in multi-nuclear' ' relation {}'.format(children)) print(err_msg) else: # corner case, should not happen err_msg = 'E: Unknown pattern in children' print(err_msg) # its head is the head of its leftmost nucleus child lnuc = children[kids_nuclei[0]] node.head = lnuc.label().head
def __init__(self, node, children, origin=None, verbose=False): """ See `educe.rst_dt.parse` to build trees from strings """ SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin) # WIP 2016-11-10 store num of head in node if len(children) == 1 and isinstance(children[0], EDU): # pre-terminal: head is num of terminal (EDU) node.head = children[0].num else: # internal node kids_nuclei = [i for i, kid in enumerate(children) if kid.label().nuclearity == NUC_N] if len(kids_nuclei) == 1: # 1 nucleus, 1-n satellites: n mono-nuc relations pass elif len(kids_nuclei) == len(children): # all children are nuclei: 1 multi-nuc relation kid_rels = [kid.label().rel for kid in children] if len(set(kid_rels)) > 1: if verbose: err_msg = ('W: More than one label in multi-nuclear' ' relation {}'.format(children)) print(err_msg) else: # corner case, should not happen err_msg = 'E: Unknown pattern in children' print(err_msg) # its head is the head of its leftmost nucleus child lnuc = children[kids_nuclei[0]] node.head = lnuc.label().head
def __init__(self,node,children,origin=None): """ Note, you should use `RSTTree.build(str)` to create this tree instead """ SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin)
def __init__(self, node, children, origin=None): """ See `educe.rst_dt.parse` to build trees from strings """ SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin)
def __init__(self, node, children, origin=None): SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin) if not children: raise Exception("Can't create a tree with no children") self.children = children start = min(x.span.char_start for x in children) end = max(x.span.char_end for x in children) self.span = Span(start, end)
def __init__(self, node, children, link, origin=None): SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin) nodes = children if not self.is_root(): nodes.append(self.label()) start = min(x.span.char_start for x in nodes) end = max(x.span.char_end for x in nodes) self.link = link self.span = Span(start, end) self.origin = origin
def __init__(self, tokens, trees, deptrees, chains): Standoff.__init__(self, None) self.tokens = tokens "list of `CoreNlpToken`" self.trees = trees "constituency trees" self.deptrees = deptrees "dependency trees" self.chains = chains "coreference chains"
def __init__(self, node, children, origin=None): """ Note, you should use `SimpleRSTTree.from_RSTTree(tree)` to create this tree instead """ SearchableTree.__init__(self, node, children) Standoff.__init__(self, origin) # WIP 2016-11-10 store num of head in node if len(children) == 1 and isinstance(children[0], EDU): node.head = children[0].num else: # head is head of the leftmost nucleus child lnuc_idx = node.nuclearity.index('N') node.head = children[lnuc_idx].label().head
def __init__(self, descr, start=0, origin=None): s = descr.strip() if s.startswith("<s>"): self._sentstart = True s = s[3:] else: self._sentstart = False if s.endswith("</s>"): self._sentend = True s = s[:-4] else: self._sentend = False if s.startswith("<EDU>") and s.endswith("</EDU>"): self.text = s[5:-6] # remove <EDU></EDU> mark elif s.startswith("_!") and s.endswith("_!"): self.text = s[2:-2] else: self.text = s end = start + len(self.text) self.span = Span(start, end) # text-span (not the same as EDU span) Standoff.__init__(self, origin)
def __init__(self, tokens, trees, deptrees, chains): Standoff.__init__(self, None) self.tokens = tokens self.trees = trees self.deptrees = deptrees self.chains = chains
def __init__(self, tok, span): RawToken.__init__(self, tok.word, tok.tag) Standoff.__init__(self) self.span = span
def __init__(self, mentions): Standoff.__init__(self) self.mentions = mentions
def __init__(self, tokens, head, most_representative=False): Standoff.__init__(self) self.tokens = tokens self.head = head self.most_representative = most_representative