/** Initializes this node as an artificial root node. */ public void initRoot() { init(DEPLib.ROOT_ID, DEPLib.ROOT_TAG, DEPLib.ROOT_TAG, DEPLib.ROOT_TAG, new DEPFeat()); }
public DEPNode(int id, String form) { init(id, form, null, null, new DEPFeat()); }
public DEPNode(int id, POSNode node) { init(id, node.form, node.lemma, node.pos, new DEPFeat()); }
/** Initializes the dependency head of a constituent. */ public C2DInfo(CTNode head) { s_label = null; b_head = false; if (head.c2d == null) // for terminals: head = itself { d_head = head; p_head = null; d_feats = new DEPFeat(); } else // for phrases: head = child { d_head = head.c2d.getDependencyHead(); p_head = head; } }
void evalSubPOS(String inputFile) throws Exception { BufferedReader reader = UTInput.createBufferedFileReader(inputFile); Pattern delim = Pattern.compile("\t"); int correct = 0, total = 0; DEPFeat p, g; String[] ls; String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (!line.isEmpty()) { ls = delim.split(line); g = new DEPFeat(ls[6]); p = new DEPFeat(ls[7]); if (g.get("SubPOS").equals(p.get("SubPOS"))) correct++; total++; } } System.out.printf("%5.2f (%d/%d)\n", 100d*correct/total, correct, total); }
/** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */ private DEPNode getNode(DEPNode head, String form, String lemma, String pos, String deprel, String label) { DEPNode aux = new DEPNode(0, form, lemma, pos, new DEPFeat()); aux.initXHeads(); aux.initSHeads(); aux.setHead(head, deprel); if (label != null) aux.addSHead(head, label); return aux; }
public DEPTree getNullTree() { DEPTree tree = new DEPTree(); DEPNode dummy = new DEPNode(1, "NULL", "NULL", "NULL", new DEPFeat()); dummy.setHead(tree.get(0), "NULL"); tree.add(dummy); tree.initXHeads(); tree.initSHeads(); return tree; }
private DEPTree getNullTree() { DEPTree tree = new DEPTree(); DEPNode dummy = new DEPNode(1, "NULL", "NULL", "NULL", new DEPFeat()); dummy.setHead(tree.get(0), "NULL"); tree.add(dummy); tree.initXHeads(); tree.initSHeads(); return tree; }
lemma = tmp[i_lemma]; pos = tmp[i_pos]; feats = new DEPFeat(tmp[i_feats]);
feat = new DEPFeat(l[6]); roleset = feat.get(DEPLib.FEAT_PB); vncls = feat.get(DEPLib.FEAT_VN);
@Override public synchronized void process( JCas jCas ) throws AnalysisEngineProcessException { LOGGER.info( "Dependency parser starting with thread:" + Thread.currentThread().getName() ); for ( Sentence sentence : JCasUtil.select( jCas, Sentence.class ) ) { List<BaseToken> printableTokens = new ArrayList<>(); for ( BaseToken token : JCasUtil.selectCovered( jCas, BaseToken.class, sentence ) ) { if ( token instanceof NewlineToken ) continue; printableTokens.add( token ); } if ( printableTokens.isEmpty() ) { // If there are no printable tokens then #convert fails continue; } DEPTree tree = new DEPTree(); // Convert CAS data into structures usable by ClearNLP for ( int i = 0; i < printableTokens.size(); i++ ) { BaseToken token = printableTokens.get( i ); String lemma = useLemmatizer ? lemmatizer.getLemma( token.getCoveredText(), token.getPartOfSpeech() ) : token.getNormalizedForm(); DEPNode node = new DEPNode( i + 1, token.getCoveredText(), lemma, token.getPartOfSpeech(), new DEPFeat() ); tree.add( node ); } // Run parser and convert output back to CAS friendly data types synchronized(LOCK){ parser.process( tree ); ArrayList<ConllDependencyNode> nodes = ClearDependencyUtility.convert( jCas, tree, sentence, printableTokens ); DependencyUtility.addToIndexes( jCas, nodes ); } } LOGGER.info( "Dependency parser ending with thread:" + Thread.currentThread().getName() ); }
lemma = tmp[i_lemma]; pos = tmp[i_pos]; feats = new DEPFeat(tmp[i_feats]);
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (Sentence sentence : JCasUtil.select(jCas, Sentence.class)) { List<BaseToken> printableTokens = new ArrayList<>(); for(BaseToken token : JCasUtil.selectCovered(jCas, BaseToken.class, sentence)){ if(token instanceof NewlineToken) continue; printableTokens.add(token); } if ( printableTokens.isEmpty() ) { // If there are no printable tokens then #convert fails continue; } DEPTree tree = new DEPTree(); // Convert CAS data into structures usable by ClearNLP for (int i = 0; i < printableTokens.size(); i++) { BaseToken token = printableTokens.get(i); String lemma = useLemmatizer ? lemmatizer.getLemma(token.getCoveredText(), token.getPartOfSpeech()) : token.getNormalizedForm(); DEPNode node = new DEPNode(i+1, token.getCoveredText(), lemma, token.getPartOfSpeech(), new DEPFeat()); tree.add(node); } // Run parser and convert output back to CAS friendly data types parser.process(tree); ArrayList<ConllDependencyNode> nodes = ClearDependencyUtility.convert( jCas, tree, sentence, printableTokens ); DependencyUtility.addToIndexes( jCas, nodes ); } }
String lemma = casDepNode.getLemma(); DEPNode node = new DEPNode( id, form, lemma, pos, new DEPFeat() ); tree.add( node ); idIter++;
String lemma = casDepNode.getLemma(); DEPNode node = new DEPNode( id, form, lemma, pos, new DEPFeat() ); tree.add( node ); idIter++;
node.init(id, form, lemma, pos, new DEPFeat(feats)); node.nament = nament;