コード例 #1
0
ファイル: annotation.py プロジェクト: chloebt/educe
 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
ファイル: annotation.py プロジェクト: moreymat/educe
 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
ファイル: annotation.py プロジェクト: irit-melodi/educe
 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
ファイル: parse.py プロジェクト: arne-cl/educe
 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
ファイル: annotation.py プロジェクト: chloebt/educe
 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
ファイル: parser.py プロジェクト: irit-melodi/educe
 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
ファイル: parser.py プロジェクト: irit-melodi/educe
 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
ファイル: corenlp.py プロジェクト: eipiplusun/educe
    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
ファイル: corenlp.py プロジェクト: moreymat/educe
    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
ファイル: annotation.py プロジェクト: moreymat/educe
 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
ファイル: annotation.py プロジェクト: irit-melodi/educe
 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
ファイル: parse.py プロジェクト: arne-cl/educe
    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
ファイル: corenlp.py プロジェクト: arne-cl/educe
 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
ファイル: postag.py プロジェクト: arne-cl/educe
 def __init__(self, tok, span):
     RawToken.__init__(self, tok.word, tok.tag)
     Standoff.__init__(self)
     self.span = span
コード例 #18
0
ファイル: coref.py プロジェクト: tjane/educe
 def __init__(self, mentions):
     Standoff.__init__(self)
     self.mentions = mentions
コード例 #19
0
ファイル: coref.py プロジェクト: tjane/educe
 def __init__(self, tokens, head, most_representative=False):
     Standoff.__init__(self)
     self.tokens = tokens
     self.head = head
     self.most_representative = most_representative
コード例 #20
0
ファイル: postag.py プロジェクト: Sablayrolles/debates
 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)