/** * Return a String that represent that NP-parts array (it may filter some of the word if not needed) * @param nodes * @return * @throws InitException - if {@link ClassUtils} was not initialized. */ protected String getFinalStringRepresentation(List<NodeInfo> nodes, NodeInfo NPsourceNode) throws InitException{ NodeInfo[] sortedNodes = sortNodes(nodes); String stringRep = new String(); LinkedList<NodeInfo> filteredNodes = new LinkedList<NodeInfo>(); filteredNodes = filterNodesArray(sortedNodes,NPsourceNode); filteredNodes = filterFirstLastNodes(filteredNodes); if (filteredNodes.size() <= m_maxNPSize) //only save that NP if less then 7 words length { //Write array to string for (int i = 0; i < filteredNodes.size(); i++) { if (!(stringRep.isEmpty())) //if it's not the first word { stringRep = stringRep + " "; } stringRep = stringRep + filteredNodes.get(i).getWordLemma(); } } return stringRep; }
/** * Return a String that represent that NP-parts array (it may filter some of the word if not neeeded) * @param nodes * @return * @throws InitException */ protected String getFinalStringRepresentation(List<NodeInfo> nodes, NodeInfo NPsourceNode) throws InitException{ NodeInfo[] sortedNodes = sortNodes(nodes); String stringRep = new String(); LinkedList<NodeInfo> filteredNodes = new LinkedList<NodeInfo>(); filteredNodes = filterNodesArray(sortedNodes,NPsourceNode); filteredNodes = filterFirstLastNodes(filteredNodes); if (filteredNodes.size() <= m_maxNPSize) //only save that NP if less then 7 words length { //Write array to string for (int i = 0; i < filteredNodes.size(); i++) { if (!(stringRep.isEmpty())) //if it's not the first word { stringRep = stringRep + " "; } stringRep = stringRep + filteredNodes.get(i).getWordLemma(); } } return stringRep; }
/** * return true iff the node is negated * @param node * @return */ public static <T extends Info, S extends AbstractNode<T,S>> boolean isNegated(S node) { if (node.getChildren() != null) for( S child : node.getChildren()) if (NEG_WORDS.contains(child.getInfo().getNodeInfo().getWordLemma())) return true; return false; }
public static boolean isArtificialRoot(AbstractNode<? extends Info, ?> node) { boolean ret = false; try { if (node.getInfo().getId().equals(AbstractBasicParser.ROOT_NODE_ID)) if (node.getInfo().getNodeInfo().getWordLemma()==null) ret = true; } catch(NullPointerException e) {} return ret; }
word = node.getInfo().getNodeInfo().getWordLemma();
word = node.getInfo().getNodeInfo().getWordLemma();
BasicNode parentNode = entry.getValue(); if (relevantNode(childNode) && relevantNode(parentNode)) { LemmaPosTextUnit child = new LemmaPosTextUnit(childNode.getInfo().getNodeInfo().getWordLemma(),childNode.getInfo().getNodeInfo().getSyntacticInfo().getPartOfSpeech().getCanonicalPosTag()); LemmaPosTextUnit parent = new LemmaPosTextUnit(parentNode.getInfo().getNodeInfo().getWordLemma(),parentNode.getInfo().getNodeInfo().getSyntacticInfo().getPartOfSpeech().getCanonicalPosTag());
String word_lemma = current_tree.getInfo().getNodeInfo().getWordLemma(); PartOfSpeech word_pos = current_tree.getInfo().getNodeInfo().getSyntacticInfo().getPartOfSpeech();
String word_lemma = current_tree.getInfo().getNodeInfo().getWordLemma(); PartOfSpeech word_pos = current_tree.getInfo().getNodeInfo().getSyntacticInfo().getPartOfSpeech();
lemma.setValue(nodeInfo.getWordLemma()); lemma.addToIndexes(); tokenAnno.setLemma(lemma);
public void makeOperation() { NodeInfo nodeInfo = null; try{nodeInfo = node.getInfo().getNodeInfo();}catch(Exception e){} String word = null; String lemma = null; int serial = 0; NamedEntity namedEntity = null; SyntacticInfo syntacticInfo = null; if (nodeInfo != null) { word = nodeInfo.getWord(); lemma = nodeInfo.getWordLemma(); serial = nodeInfo.getSerial(); syntacticInfo = nodeInfo.getSyntacticInfo(); } namedEntity = neWord.getNamedEntity(); Info oldInfo = node.getInfo(); node.setInfo(new DefaultInfo(oldInfo.getId(),new DefaultNodeInfo(word,lemma,serial,namedEntity,syntacticInfo),oldInfo.getEdgeInfo())); }
@Override public Info supplementRightInfoWithLeftInfo(Info leftInfo, Info rightInfo) throws EntailmentCompilationException { if (leftInfo == null) throw new EntailmentCompilationException("got null left info"); if (rightInfo == null) throw new EntailmentCompilationException("got null right info"); Info alphaAnnotatedInfo = rightInfo; Info betaAnnotatedInfo = leftInfo; // choose args: alphaObj != null ? alphaObj : betaObj String lemma = (String) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getNodeInfo().getWordLemma(), betaAnnotatedInfo.getNodeInfo().getWordLemma()); EdgeInfo newEdgeAnnotatedInfo = new DefaultEdgeInfo( (DependencyRelation) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getEdgeInfo().getDependencyRelation(), betaAnnotatedInfo.getEdgeInfo().getDependencyRelation())); SyntacticInfo syntacticInfo = (SyntacticInfo) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getNodeInfo().getSyntacticInfo(), betaAnnotatedInfo.getNodeInfo().getSyntacticInfo()); // decide if to construct a NodeInfo or a VariableNodeAnnotatedInfo by the type of the betaNode? NodeInfo newAnnotatedNodeInfo; if (betaAnnotatedInfo.getNodeInfo().isVariable()) // copied variable nodes get the word and lemma of their lhs originals newAnnotatedNodeInfo = DefaultNodeInfo.newVariableDefaultNodeInfo (betaAnnotatedInfo.getNodeInfo().getVariableId(), null, -1, null, syntacticInfo); else { String word = (String) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getNodeInfo().getWord(), betaAnnotatedInfo.getNodeInfo().getWord()); newAnnotatedNodeInfo = new DefaultNodeInfo(word, lemma, -1, null, syntacticInfo); } Info newAnnotatedInfo = new DefaultInfo(betaAnnotatedInfo.getId(), newAnnotatedNodeInfo, newEdgeAnnotatedInfo); return newAnnotatedInfo; }
/** * If rhsInfo has a POS (not {@link WildcardPartOfSpeech}), copy it to treeInfo. Return treeInfo * @param treeInfo * @param rhsInfo * @return */ public static NodeInfo combineNodeInfo(Info treeInfo, Info rhsInfo) { NodeInfo treeNodeInfo = treeInfo.getNodeInfo(); if (rhsInfo != null && rhsInfo.getNodeInfo() != null && rhsInfo.getNodeInfo().getSyntacticInfo() != null && rhsInfo.getNodeInfo().getSyntacticInfo().getPartOfSpeech() != null && !WildcardPartOfSpeech.isWildCardPOS(rhsInfo.getNodeInfo().getSyntacticInfo().getPartOfSpeech())) { // treeInfo with rhsInfo's syntactic info return new DefaultNodeInfo(treeNodeInfo.getWord(), treeNodeInfo.getWordLemma(), treeNodeInfo.getSerial(), treeNodeInfo.getNamedEntityAnnotation(), rhsInfo.getNodeInfo().getSyntacticInfo()); } else return treeNodeInfo; } }
String lemma = node.getInfo().getNodeInfo().getWordLemma(); if (lemma.contains(" "))
private static void addNeToAntecedents(BasicConstructionNode mutableParseTree) { for (BasicConstructionNode mutableNode : TreeIterator.iterableTree(mutableParseTree)) { if (mutableNode.getAntecedent()!=null) { BasicConstructionNode antecedent = AbstractNodeUtils.getDeepAntecedentOf(mutableNode); if (antecedent.getInfo().getNodeInfo().getNamedEntityAnnotation()!=null) { NamedEntity ne = antecedent.getInfo().getNodeInfo().getNamedEntityAnnotation(); Info newInfo = new DefaultInfo(mutableNode.getInfo().getId(), new DefaultNodeInfo(mutableNode.getInfo().getNodeInfo().getWord(), mutableNode.getInfo().getNodeInfo().getWordLemma(), mutableNode.getInfo().getNodeInfo().getSerial(), ne, mutableNode.getInfo().getNodeInfo().getSyntacticInfo()), mutableNode.getInfo().getEdgeInfo()); mutableNode.setInfo(newInfo); } } } }
case LOOKUP_PREDTYPE_OF_LEMMA: PredicateSignature predType = lemmaToPredTypeMap.get(lhs.getInfo().getNodeInfo().getWordLemma()); annotations.setSig(predType); break;
if (leftInfo.getNodeInfo().isVariable()) throw new EntailmentCompilationException("A \""+ AlignmentType.COPY_LEMMA.name() + "\" cannot come out of a variable node"); lemma = leftInfo.getNodeInfo().getWordLemma();