Пример #1
0
 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)
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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
Пример #10
0
 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
Пример #11
0
    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"
Пример #12
0
    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"
Пример #13
0
 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
Пример #14
0
 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
Пример #15
0
    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)
Пример #16
0
 def __init__(self, tokens, trees, deptrees, chains):
     Standoff.__init__(self, None)
     self.tokens   = tokens
     self.trees    = trees
     self.deptrees = deptrees
     self.chains   = chains
Пример #17
0
 def __init__(self, tok, span):
     RawToken.__init__(self, tok.word, tok.tag)
     Standoff.__init__(self)
     self.span = span
Пример #18
0
 def __init__(self, mentions):
     Standoff.__init__(self)
     self.mentions = mentions
Пример #19
0
 def __init__(self, tokens, head, most_representative=False):
     Standoff.__init__(self)
     self.tokens = tokens
     self.head = head
     self.most_representative = most_representative
Пример #20
0
 def __init__(self, tok, span):
     RawToken.__init__(self, tok.word, tok.tag)
     Standoff.__init__(self)
     self.span = span
Пример #21
0
 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)