@Override public void process(JCas jcas) throws AnalysisEngineProcessException { String sent = jcas.getDocumentText(); StringBuffer buff = new StringBuffer(); Parse parse = null; try{ parse = ParserTool.parseLine(sent, parser, 1)[0]; parse.show(buff); }catch(NullPointerException e){ System.err.println("Parser error... no parse found... check POS tags of missed sentence (immediately above)"); } if(parse == null){ buff.append("(S null)"); } TopTreebankNode ttn = new TopTreebankNode(jcas); ttn.setTreebankParse(buff.toString()); ttn.addToIndexes(); }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { String sent = jcas.getDocumentText(); StringBuffer buff = new StringBuffer(); Parse parse = null; try{ parse = ParserTool.parseLine(sent, parser, 1)[0]; parse.show(buff); }catch(NullPointerException e){ System.err.println("Parser error... no parse found... check POS tags of missed sentence (immediately above)"); } if(parse == null){ buff.append("(S null)"); } TopTreebankNode ttn = new TopTreebankNode(jcas); ttn.setTreebankParse(buff.toString()); ttn.addToIndexes(); }
/** * @param jcas ye olde ... * @param parse opennlp parse * @param terminalArray [token] terminals in the sentence * @param sentence - * @return a top treebank node for the sentence * @throws AnalysisEngineProcessException thrown by {@link #recursivelyCreateStructure} */ public static TopTreebankNode buildAlignedTree( final JCas jcas, final Parse parse, final FSArray terminalArray, final Sentence sentence ) throws AnalysisEngineProcessException { final StringBuffer parseBuffer = new StringBuffer(); if ( parse != null ) { parse.show( parseBuffer ); } final TopTreebankNode top = new TopTreebankNode( jcas, sentence.getBegin(), sentence.getEnd() ); top.setTreebankParse( parseBuffer.toString() ); top.setTerminals( terminalArray ); top.setParent( null ); if ( parse != null ) { recursivelyCreateStructure( jcas, top, parse, top ); } return top; }
/** * @param jcas ye olde ... * @param parse opennlp parse * @param terminalArray [token] terminals in the sentence * @param sentence - * @return a top treebank node for the sentence * @throws AnalysisEngineProcessException thrown by {@link #recursivelyCreateStructure} */ public static TopTreebankNode buildAlignedTree( final JCas jcas, final Parse parse, final FSArray terminalArray, final Sentence sentence ) throws AnalysisEngineProcessException { final StringBuffer parseBuffer = new StringBuffer(); if ( parse != null ) { parse.show( parseBuffer ); } final TopTreebankNode top = new TopTreebankNode( jcas, sentence.getBegin(), sentence.getEnd() ); top.setTreebankParse( parseBuffer.toString() ); top.setTerminals( terminalArray ); top.setParent( null ); if ( parse != null ) { recursivelyCreateStructure( jcas, top, parse, top ); } return top; }
public static TopTreebankNode getTreeCopy(JCas jcas, TopTreebankNode orig){ if(orig == null) return null; TopTreebankNode copy = new TopTreebankNode(jcas); copy.setNodeType(orig.getNodeType()); copy.setBegin(orig.getBegin()); copy.setEnd(orig.getEnd()); copy.setParent(null); copy.setChildren(new FSArray(jcas,1)); copy.setTreebankParse(orig.getTreebankParse()); if(orig.getChildren() == null || orig.getChildren().size() == 0){ System.err.println("WHAT?"); } copy.setChildren(0, getTreeCopy(jcas, orig.getChildren(0))); copy.getChildren(0).setParent(copy); return copy; }
public static TopTreebankNode getTreeCopy(JCas jcas, TopTreebankNode orig){ if(orig == null) return null; TopTreebankNode copy = new TopTreebankNode(jcas); copy.setNodeType(orig.getNodeType()); copy.setBegin(orig.getBegin()); copy.setEnd(orig.getEnd()); copy.setParent(null); copy.setChildren(new FSArray(jcas,1)); copy.setTreebankParse(orig.getTreebankParse()); if(orig.getChildren() == null || orig.getChildren().size() == 0){ System.err.println("WHAT?"); } copy.setChildren(0, getTreeCopy(jcas, orig.getChildren(0))); copy.getChildren(0).setParent(copy); return copy; }