Parse implements Cloneable, Comparable<Parse> { public Parse[] getTagNodes() { List<Parse> tags = new LinkedList<Parse>(); List<Parse> nodes = new LinkedList<Parse>(); nodes.addAll(this.parts); while(nodes.size() != 0) { Parse p = nodes.remove(0); if (p.isPosTag()) { tags.add(p); } else { nodes.addAll(0,p.parts); } } return tags.toArray(new Parse[tags.size()]); } Parse(String text, Span span, String type, double p, int index);  Parse(String text, Span span, String type, double p, Parse h); @Override Object clone(); Parse clone(Parse node); Parse cloneRoot(Parse node, int parseIndex); static void useFunctionTags(boolean uft); void setType(String type); String getType(); Collection<Parse> getPreviousPunctuationSet(); void addPreviousPunctuation(Parse punct); Collection<Parse> getNextPunctuationSet(); void addNextPunctuation(Parse punct); void setNextPunctuation(Collection<Parse> punctSet); void setPrevPunctuation(Collection<Parse> punctSet); void insert(final Parse constituent); void show(StringBuffer sb); void show(); double getTagSequenceProb(); boolean complete(); String getCoveredText(); @Override String toString(); String getText(); Span getSpan(); double getProb(); void addProb(double logProb); Parse[] getChildren(); void setChild(int index, String label); void add(Parse daughter, HeadRules rules); void remove(int index); Parse adjoinRoot(Parse node, HeadRules rules, int parseIndex); Parse adjoin(Parse sister, HeadRules rules); void expandTopNode(Parse root); int getChildCount(); int indexOf(Parse child); Parse getHead(); int getHeadIndex(); String getLabel(); void setLabel(String label); void updateHeads(HeadRules rules); void updateSpan(); static void pruneParse(Parse parse); static void fixPossesives(Parse parse); static Parse parseParse(String parse); static Parse parseParse(String parse, GapLabeler gl); Parse getParent(); void setParent(Parse parent); boolean isPosTag(); boolean isFlat(); void isChunk(boolean ic); boolean isChunk(); Parse[] getTagNodes(); Parse getCommonParent(Parse node); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(Parse p); StringBuffer getDerivation(); void setDerivation(StringBuffer derivation); void showCodeTree(); static void addNames(String tag, Span[] names, Parse[] tokens); @Deprecated static void main(String[] args); static final String BRACKET_LRB; static final String BRACKET_RRB; static final String BRACKET_LCB; static final String BRACKET_RCB; }
@Test public void testGetTagNodes() { Parse p = Parse.parseParse(PARSE_STRING); Parse tags[] = p.getTagNodes(); for (Parse node : tags) { assertTrue(node.isPosTag()); } assertEquals("PRP", tags[0].getType()); assertEquals("VBD", tags[1].getType()); assertEquals("RB", tags[2].getType()); assertEquals("DT", tags[3].getType()); assertEquals("NN", tags[4].getType()); assertEquals("IN", tags[5].getType()); assertEquals("DT", tags[6].getType()); assertEquals("NNPS", tags[7].getType()); assertEquals(",", tags[8].getType()); assertEquals("CC", tags[9].getType()); assertEquals("PRP", tags[10].getType()); assertEquals("VBD", tags[11].getType()); assertEquals("RB", tags[12].getType()); assertEquals("JJ", tags[13].getType()); assertEquals("IN", tags[14].getType()); assertEquals("PRP$", tags[15].getType()); assertEquals("NN", tags[16].getType()); assertEquals(".", tags[17].getType()); }