Download latest PDF - Read the Docs

Transcript
educe Documentation, Release 0.1
(VP
(VBZ <educe.external.postag.Token object at 0x10e41efd0>)
(VP
(VP
(VBN <educe.external.postag.Token object at 0x10e41ef90>)
(NP
(JJ <educe.external.postag.
The result of this alignment is an educe ConstituencyTree, the leaves of which are educe Token objects. We’ll
say a little bit more about these below.
# show what's beneath these educe tokens
def str_tree(tree):
if isinstance(tree, Tree):
return Tree(str(tree.label()), map(str_tree, tree))
else:
return str(tree)
print(str_tree(ex0_ptb_tree).pprint()[:400])
(S
(NP-SBJ
(DT The/DT
(0,3))
(NNP Justice/NNP
(4,11))
(NNP Department/NNP
(12,22)))
(VP
(VBZ has/VBZ
(23,26))
(VP
(VP
(VBN revised/VBN
(27,34))
(NP
(JJ certain/JJ
(35,42))
(JJ internal/JJ
(43,51))
(NNS guidelines/NNS
(52,62))))
(CC and/CC
(63,66))
(VP (VBN clarified/VBN
(67,76)) (NP (NNS others/NNS
(77,83))))
2.2.6 Combining annotations
We now have several types of annotation at our disposal:
• EDUs and RST trees
• raw text paragraph/sentences (not terribly reliable)
• PTB trees
The next question that arises is how we can use these annotations in conjuction with each other.
Span enclosure and overlapping
The simplest way to reason about annotations (particularly since they tend to be sloppy and to overlap). Suppose for
example, we wanted to find all of the edus in a tree that are in the same sentence as an given edu.
from itertools import chain
# pick an EDU, any edu
2.2. RST-DT
19