Java Reference
In-Depth Information
The showCodeTree method can be used instead to display parent-child relationships:
parse.showCodeTree();
The output for the first parse is shown here. The first part of each line shows the element
levels enclosed in brackets. The tag is displayed next followed by two hash values separ-
ated by -> . The first number is for the element and the second number is its parent. For
example, in the third line, it shows the proper noun, The , to have a parent of the noun
phrase, The cow :
[0] S -929208263 -> -929208263 TOP The cow jumped over the
moon
[0.0] NP -929237012 -> -929208263 S The cow
[0.0.0] DT -929242488 -> -929237012 NP The
[0.0.0.0] TK -929242488 -> -929242488 DT The
[0.0.1] NN -929034400 -> -929237012 NP cow
[0.0.1.0] TK -929034400 -> -929034400 NN cow
[0.1] VP -928803039 -> -929208263 S jumped over the moon
[0.1.0] VBD -928822205 -> -928803039 VP jumped
[0.1.0.0] TK -928822205 -> -928822205 VBD jumped
[0.1.1] PP -928448468 -> -928803039 VP over the moon
[0.1.1.0] IN -928460789 -> -928448468 PP over
[0.1.1.0.0] TK -928460789 -> -928460789 IN over
[0.1.1.1] NP -928195203 -> -928448468 PP the moon
[0.1.1.1.0] DT -928202048 -> -928195203 NP the
[0.1.1.1.0.0] TK -928202048 -> -928202048 DT the
[0.1.1.1.1] NN -927992591 -> -928195203 NP moon
[0.1.1.1.1.0] TK -927992591 -> -927992591 NN moon
Another way of accessing the elements of the parse is through the getChildren meth-
od. This method returns an array of the Parse objects each representing an element of
the parse. Using various Parse methods, we can get each element's text, tag, and labels.
This is illustrated here:
Parse children[] = parse.getChildren();
for (Parse parseElement : children) {
System.out.println(parseElement.getText());
System.out.println(parseElement.getType());
Parse tags[] = parseElement.getTagNodes();
Search WWH ::




Custom Search