public SpRole(IntPair span, SpRoleTypes spRoleType, Sentence sentence) { this.span = span; this.sentence = sentence.getSentenceConstituent(); this.spRoleType = spRoleType; }
/** * Gets the index of the sentence that contains the token, indexed by tokenPosition. If no * sentence contains the token, then this function throws an IllegalArgumentException. The * sentence index can further be used to get the Sentence itself by calling * {@link edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation#getSentence(int)} * . * * @param tokenId The index of the token whose sentenceId is needed * @return The index of the sentence that contains this token * @throws IllegalArgumentException if no sentence contains the {@code tokenId} */ public int getSentenceId(int tokenId) { for (int i = 0; i < this.getNumberOfSentences(); i++) { if (this.sentences.get(i).getSentenceConstituent().doesConstituentCover(tokenId)) return i; } throw new IllegalArgumentException("No sentence contains token id " + tokenId); }
/** * Gets the index of the sentence that contains the token, indexed by tokenPosition. If no * sentence contains the token, then this function throws an IllegalArgumentException. The * sentence index can further be used to get the Sentence itself by calling * {@link edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation#getSentence(int)} * . * * @param tokenId The index of the token whose sentenceId is needed * @return The index of the sentence that contains this token * @throws IllegalArgumentException if no sentence contains the {@code tokenId} */ public int getSentenceId(int tokenId) { for (int i = 0; i < this.getNumberOfSentences(); i++) { if (this.sentences.get(i).getSentenceConstituent().doesConstituentCover(tokenId)) return i; } throw new IllegalArgumentException("No sentence contains token id " + tokenId); }
public List<Sentence> getSentenceFromTokens(Set<Integer> tokens) { List<Sentence> mySentences = new ArrayList<>(); Set<Integer> sentencesSeen = new HashSet<>(); for (Sentence s : sentences()) { for (int token : tokens) { if (s.getSentenceConstituent().doesConstituentCover(token)) { if (!sentencesSeen.contains(s.getStartSpan())) { mySentences.add(s); sentencesSeen.add(s.getStartSpan()); } break; } } } return mySentences; }
public List<Sentence> getSentenceFromTokens(Set<Integer> tokens) { List<Sentence> mySentences = new ArrayList<>(); Set<Integer> sentencesSeen = new HashSet<>(); for (Sentence s : sentences()) { for (int token : tokens) { if (s.getSentenceConstituent().doesConstituentCover(token)) { if (!sentencesSeen.contains(s.getStartSpan())) { mySentences.add(s); sentencesSeen.add(s.getStartSpan()); } break; } } } return mySentences; }
public TextAnnotation getTextAnnotation() { return getSentence().getSentenceConstituent().getTextAnnotation(); }
/** * Get the root constituent of the tree that covers a sentence */ public Constituent getTreeRoot(Sentence s) { Constituent root = null; Constituent sentenceConstituent = s.getSentenceConstituent(); IQueryable<Constituent> queryable = this.where(Queries.containedInConstituent(sentenceConstituent)); for (Constituent c : queryable) { if (c.getIncomingRelations().size() == 0) { root = c; break; } } return root; }
/** * Get the root constituent of the tree that covers a sentence */ public Constituent getTreeRoot(Sentence s) { Constituent root = null; Constituent sentenceConstituent = s.getSentenceConstituent(); IQueryable<Constituent> queryable = this.where(Queries.containedInConstituent(sentenceConstituent)); for (Constituent c : queryable) { if (c.getIncomingRelations().size() == 0) { root = c; break; } } return root; }
/** * Get the parse tree of a sentence. This code assumes that the view called * {@code parseViewName} exists in the text annotation. * * @param parseViewName The name of the parse view * @param s The sentence * @return The parse tree of the sentence */ public static Tree<String> getParseTree(String parseViewName, Sentence s) { return getParseTree(parseViewName, s.getSentenceConstituent().getTextAnnotation(), s.getSentenceId()); }
/** * Get the parse tree of a sentence. This code assumes that the view called * {@code parseViewName} exists in the text annotation. * * @param parseViewName The name of the parse view * @param s The sentence * @return The parse tree of the sentence */ public static Tree<String> getParseTree(String parseViewName, Sentence s) { return getParseTree(parseViewName, s.getSentenceConstituent().getTextAnnotation(), s.getSentenceId()); }
/** * Get the parse tree of a sentence. This code assumes that the view called * {@code parseViewName} exists in the text annotation. * * @param parseViewName The name of the parse view * @param s The sentence * @return The parse tree of the sentence */ public static Tree<String> getParseTree(String parseViewName, Sentence s) { return getParseTree(parseViewName, s.getSentenceConstituent().getTextAnnotation(), s.getSentenceId()); }
/** * Get the parse tree of a sentence. This code assumes that the view called * {@code parseViewName} exists in the text annotation. * * @param parseViewName The name of the parse view * @param s The sentence * @return The parse tree of the sentence */ public static Tree<String> getParseTree(String parseViewName, Sentence s) { return getParseTree(parseViewName, s.getSentenceConstituent().getTextAnnotation(), s.getSentenceId()); }
/** * 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())); }
IntPair sentenceSpan = currSentence.getSentenceConstituent().getSpan(); View PosView = ta.getView("POS"); List<Constituent> sentenceConstituents = PosView.getConstituents();
IntPair sentenceSpan = currSentence.getSentenceConstituent().getSpan(); View PosView = ta.getView("POS"); List<Constituent> sentenceConstituents = PosView.getConstituents();
Sentence sentence = ta.getSentence(i); System.out.println(i+") "+sentence+"@"+sentence.getStartSpan()); List<Constituent> nerlabels = slv.getConstituentsCovering(sentence.getSentenceConstituent()); for (Constituent c : nerlabels) { System.out.println(" "+c.getTokenizedSurfaceForm()+"-"+c.getLabel());
Sentence sentence = ta.getSentence(i); System.out.println(i+") "+sentence+"@"+sentence.getStartSpan()); List<Constituent> nerlabels = slv.getConstituentsCovering(sentence.getSentenceConstituent()); for (Constituent c : nerlabels) { System.out.println(" "+c.getTokenizedSurfaceForm()+"-"+c.getLabel());