public static <I extends Info, S extends AbstractNode<I,S>> Set<String> lemmasLowerCaseOfNodes(Iterable<S> nodes) { Set<String> ret = new LinkedHashSet<>(); for (S node : nodes) { ret.add(InfoGetFields.getLemma(node.getInfo()).toLowerCase()); } return ret; }
public String getEdgeStringRepresentation() { return InfoGetFields.getRelation(node.getInfo()); }
public String getEdgeStringRepresentation() { return InfoGetFields.getRelation(node.getInfo()); }
private void addLemmasOfTextFromTree(S tree) { for (S node : TreeIterator.iterableTree(tree)) { lemmasOfText_lowerCase.add(InfoGetFields.getLemma(node.getInfo()).toLowerCase()); } }
@Override public boolean areMatch() { String wordInTree = InfoGetFields.getWord(lhs.getInfo()); String wordInArkref = rhs.getWord(); return wordInTree.equals(wordInArkref); } private S lhs;
/** * @param root * @throws CompilationException */ private static <I extends Info, N extends AbstractNode<I,N>> void checkPos(N root) throws CompilationException { String pos = ExtendedInfoGetFields.getPartOfSpeech(root.getInfo(), null); if (pos == null || pos.isEmpty()) throw new CompilationException("This node has no POS: " + root); }
private Set<String> allLemmasOfArgument_lowerCase(TypedArgument<I, S> argument) { Set<String> ret = new LinkedHashSet<>(); for (S node : argument.getArgument().getNodes()) { ret.add(InfoGetFields.getLemma(node.getInfo()).toLowerCase()); } return ret; }
/** * @return A string id that, hopefully, uniquely identifies a certain subtree. This is useful, for example, for differentiating between assignments to variables, etc. * @note id is not enough, because ids are not guaranteed to be unique. */ public static <T extends Info,S extends AbstractNode<T,S>> String uniqueSubtreeId(S parseTree) { return parseTree==null? null: parseTree.getInfo().getId()+" "+toEnglishSentence(parseTree); }
public static <T extends Info, S extends AbstractNode<T,S>> Map<String,S> mapIdToNode(S tree) throws TeEngineMlException { Map<String,S> ret = new LinkedHashMap<String, S>(); for (S node : TreeIterator.iterableTree(tree)) { String id = node.getInfo().getId(); if (null==id) throw new TeEngineMlException("Null id"); ret.put(id,node); } return ret; }
private Set<String> matchingLemmasOfArguments(Set<PredicateAndArgument<I, S>> textMatchingArguments) { Set<String> ret = new LinkedHashSet<>(); for (PredicateAndArgument<I, S> argument : textMatchingArguments) { for (S node : argument.getArgument().getArgument().getNodes()) { ret.add(InfoGetFields.getLemma(node.getInfo())); } } return ret; }
private boolean argumentsSameHead(TypedArgument<I, S> argument1, TypedArgument<I, S> argument2) { String lemma1 = InfoGetFields.getLemma(argument1.getArgument().getSemanticHead().getInfo()); String lemma2 = InfoGetFields.getLemma(argument2.getArgument().getSemanticHead().getInfo()); if (lemma1.equalsIgnoreCase(lemma2)) return true; else return false; }
/** * 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 ExtendedConstructionNode newEmptyNode(List<? extends AbstractNode<ExtendedInfo, ?>> children) { ExtendedConstructionNode ret = newEmptyNode(); for (AbstractNode<ExtendedInfo, ?> node : children) { ret.addChild(new ExtendedConstructionNode(node.getInfo())); } return ret; }
public ExtendedConstructionNode newNode(ExtendedInfo info, List<? extends AbstractNode<ExtendedInfo, ?>> children) { ExtendedConstructionNode ret = newNode(info); for (AbstractNode<ExtendedInfo, ?> node : children) { ret.addChild(new ExtendedConstructionNode(node.getInfo())); } return ret; }
public ExtendedNode newNode(ExtendedInfo info, List<? extends AbstractNode<ExtendedInfo, ?>> children) { ExtendedNode ret = new ExtendedNode(info); if (children != null) { for (AbstractNode<ExtendedInfo, ?> node : children) { ret.addChild(newNode(node.getInfo(),node.getChildren())); } } return ret; }
@Override public Bag<String> transform(AbstractNode<? extends Info,? extends AbstractNode> parseTree) { Bag<String> words = new HashBag<String> (); if (parseTree.getChildren()==null) { words.add(InfoGetFields.getWord(parseTree.getInfo())); } else { for (AbstractNode child: parseTree.getChildren()) { words.addAll(mapNodeToBagOfWords.get(child)); } } return words; } }