/** * Gets the sentence containing the specified token */ public Sentence getSentenceFromToken(int tokenId) { return this.getSentence(this.getSentenceId(tokenId)); }
/** * Gets the sentence containing the specified token */ public Sentence getSentenceFromToken(int tokenId) { return this.getSentence(this.getSentenceId(tokenId)); }
public int getSentenceId(Constituent constituent) { return getSentenceId(constituent.getStartSpan()); }
public int getSentenceId(Constituent constituent) { return getSentenceId(constituent.getStartSpan()); }
public int getSentenceId() { return this.textAnnotation.getSentenceId(this.getStartSpan()); }
public int getSentenceId() { return this.textAnnotation.getSentenceId(this.getStartSpan()); }
/** * Return the identifier of the sentence that contains this constituent. No sentence contains * this constituent (that is, if this constituent is an implicit one), then return -1. */ public int getSentenceId() { try { return this.getTextAnnotation().getSentenceId(this.getStartSpan()); } catch (Exception e) { return -1; } }
/** * Return the identifier of the sentence that contains this constituent. No sentence contains * this constituent (that is, if this constituent is an implicit one), then return -1. */ public int getSentenceId() { try { return this.getTextAnnotation().getSentenceId(this.getStartSpan()); } catch (Exception e) { return -1; } }
/** * Gets the root constituent of the tree for the given sentence */ public Constituent getRootConstituent(Sentence sentence) { if (this.roots == null) { findRoots(); } return this.roots.get(this.getTextAnnotation().getSentenceId( sentence.getSentenceConstituent())); }
/** * Gets the root constituent of the tree for the given sentence */ public Constituent getRootConstituent(Sentence sentence) { if (this.roots == null) { findRoots(); } return this.roots.get(this.getTextAnnotation().getSentenceId( sentence.getSentenceConstituent())); }
private static Tree<Pair<String, IntPair>> getTokenIndexedTreeCovering(Constituent predicate, String parseViewName) { TextAnnotation ta = predicate.getTextAnnotation(); int sentenceId = ta.getSentenceId(predicate); Tree<String> tree = getParseTree(parseViewName, ta, sentenceId); int sentenceStartSpan = ta.getSentence(sentenceId).getStartSpan(); int start = predicate.getStartSpan() - sentenceStartSpan; int end = predicate.getEndSpan() - sentenceStartSpan; return getTokenIndexedTreeCovering(tree, start, end); }
private static Tree<Pair<String, IntPair>> getTokenIndexedTreeCovering(Constituent predicate, String parseViewName) { TextAnnotation ta = predicate.getTextAnnotation(); int sentenceId = ta.getSentenceId(predicate); Tree<String> tree = ParseHelper.getParseTree(parseViewName, ta, sentenceId); int sentenceStartSpan = ta.getSentence(sentenceId).getStartSpan(); int start = predicate.getStartSpan() - sentenceStartSpan; int end = predicate.getEndSpan() - sentenceStartSpan; return ParseHelper.getTokenIndexedTreeCovering(tree, start, end); }
private static Tree<Pair<String, IntPair>> getTokenIndexedTreeCovering(Constituent predicate, String parseViewName) { TextAnnotation ta = predicate.getTextAnnotation(); int sentenceId = ta.getSentenceId(predicate); Tree<String> tree = ParseHelper.getParseTree(parseViewName, ta, sentenceId); int sentenceStartSpan = ta.getSentence(sentenceId).getStartSpan(); int start = predicate.getStartSpan() - sentenceStartSpan; int end = predicate.getEndSpan() - sentenceStartSpan; return ParseHelper.getTokenIndexedTreeCovering(tree, start, end); }
private static Tree<Pair<String, IntPair>> getTokenIndexedTreeCovering(Constituent predicate, String parseViewName) { TextAnnotation ta = predicate.getTextAnnotation(); int sentenceId = ta.getSentenceId(predicate); Tree<String> tree = getParseTree(parseViewName, ta, sentenceId); int sentenceStartSpan = ta.getSentence(sentenceId).getStartSpan(); int start = predicate.getStartSpan() - sentenceStartSpan; int end = predicate.getEndSpan() - sentenceStartSpan; return getTokenIndexedTreeCovering(tree, start, end); }
public static Tree<Pair<String, IntPair>> getTokenIndexedCleanedParseTreeNodeCovering( Constituent c, String parseViewName) { TextAnnotation ta = c.getTextAnnotation(); Tree<String> tree = getParseTree(parseViewName, ta, ta.getSentenceId(c)); int start = c.getStartSpan(); int end = c.getEndSpan(); tree = ParseUtils.snipNullNodes(tree); tree = ParseUtils.stripFunctionTags(tree); tree = ParseUtils.stripIndexReferences(tree); return getTokenIndexedTreeCovering(tree, start, end); }
public static Tree<Pair<String, IntPair>> getTokenIndexedCleanedParseTreeNodeCovering( Constituent c, String parseViewName) { TextAnnotation ta = c.getTextAnnotation(); Tree<String> tree = getParseTree(parseViewName, ta, ta.getSentenceId(c)); int start = c.getStartSpan(); int end = c.getEndSpan(); tree = ParseUtils.snipNullNodes(tree); tree = ParseUtils.stripFunctionTags(tree); tree = ParseUtils.stripIndexReferences(tree); return getTokenIndexedTreeCovering(tree, start, end); }
public static Tree<Pair<String, IntPair>> getTokenIndexedCleanedParseTreeNodeCovering( Constituent c, String parseViewName) { TextAnnotation ta = c.getTextAnnotation(); Tree<String> tree = getParseTree(parseViewName, ta, ta.getSentenceId(c)); int start = c.getStartSpan(); int end = c.getEndSpan(); tree = ParseUtils.snipNullNodes(tree); tree = ParseUtils.stripFunctionTags(tree); tree = ParseUtils.stripIndexReferences(tree); return getTokenIndexedTreeCovering(tree, start, end); }
public static Tree<Pair<String, IntPair>> getTokenIndexedCleanedParseTreeNodeCovering( Constituent c, String parseViewName) { TextAnnotation ta = c.getTextAnnotation(); Tree<String> tree = getParseTree(parseViewName, ta, ta.getSentenceId(c)); int start = c.getStartSpan(); int end = c.getEndSpan(); tree = ParseUtils.snipNullNodes(tree); tree = ParseUtils.stripFunctionTags(tree); tree = ParseUtils.stripIndexReferences(tree); return getTokenIndexedTreeCovering(tree, start, end); }
public static TreeView alignForestToDependencyView(String viewName, TextAnnotation ta, Forest dep) { TreeView view = new TreeView(viewName, dep.getSource(), ta, 0.0d); for (edu.illinois.cs.cogcomp.thrift.base.Tree tree : dep.getTrees()) { int topId = tree.getTop(); List<Node> nodes = tree.getNodes(); int topTokenStart = nodes.get(topId).getSpan().getStart(); int topTokenId = ta.getTokenIdFromCharacterOffset(topTokenStart); int sentenceId = ta.getSentenceId(topTokenId); Tree<Pair<String, Integer>> dependencyTree = makeDependencyTree(ta, tree); double score = tree.getScore(); view.setDependencyTree(sentenceId, dependencyTree, score); } return view; }
public static TreeView alignForestToDependencyView(String viewName, TextAnnotation ta, Forest dep) { TreeView view = new TreeView(viewName, dep.getSource(), ta, 0.0d); for (edu.illinois.cs.cogcomp.thrift.base.Tree tree : dep.getTrees()) { int topId = tree.getTop(); List<Node> nodes = tree.getNodes(); int topTokenStart = nodes.get(topId).getSpan().getStart(); int topTokenId = ta.getTokenIdFromCharacterOffset(topTokenStart); int sentenceId = ta.getSentenceId(topTokenId); Tree<Pair<String, Integer>> dependencyTree = makeDependencyTree(ta, tree); double score = tree.getScore(); view.setDependencyTree(sentenceId, dependencyTree, score); } return view; }