Codota Logo
TextAnnotation.getSentenceFromToken
Code IndexAdd Codota to your IDE (free)

How to use
getSentenceFromToken
method
in
edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation

Best Java code snippets using edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation.getSentenceFromToken (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: CogComp/cogcomp-nlp

@Override
public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException {
  Sentence sentence = ta.getSentenceFromToken(wordPosition);
  int sentenceStart = sentence.getStartSpan();
  int predicatePosition = wordPosition - sentenceStart;
  Tree<String> tree = ParseHelper.getParseTree(parseViewName, sentence);
  Tree<Pair<String, IntPair>> spanLabeledTree = ParseUtils.getSpanLabeledTree(tree);
  Tree<Pair<String, IntPair>> currentNode =
      spanLabeledTree.getYield().get(predicatePosition).getParent();
  String f = getVoice(currentNode);
  return new LinkedHashSet<Feature>(Collections.singletonList(DiscreteFeature.create(f)));
}
origin: edu.illinois.cs.cogcomp/illinois-edison

@Override
public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException {
  Sentence sentence = ta.getSentenceFromToken(wordPosition);
  int sentenceStart = sentence.getStartSpan();
  int predicatePosition = wordPosition - sentenceStart;
  Tree<String> tree = ParseHelper.getParseTree(parseViewName, sentence);
  Tree<Pair<String, IntPair>> spanLabeledTree = ParseUtils.getSpanLabeledTree(tree);
  Tree<Pair<String, IntPair>> currentNode =
      spanLabeledTree.getYield().get(predicatePosition).getParent();
  String f = getVoice(currentNode);
  return new LinkedHashSet<Feature>(Collections.singletonList(DiscreteFeature.create(f)));
}
origin: CogComp/cogcomp-nlp

Sentence currSentence = ta.getSentenceFromToken(currSpan.getFirst());
IntPair sentenceSpan = currSentence.getSentenceConstituent().getSpan();
View PosView = ta.getView("POS");
origin: CogComp/cogcomp-nlp

/**
 * Check if the Constituent is a start of a sentence
 * The size of the Constituent should be 1
 */
public static String isSentenceStart (Constituent c){
  Sentence sentence = c.getTextAnnotation().getSentenceFromToken(c.getStartSpan());
  int sentenceStart = sentence.getStartSpan();
  if (c.getStartSpan() == sentenceStart){
    return "1";
  }
  return "0";
}
origin: edu.illinois.cs.cogcomp/md

/**
 * Check if the Constituent is a start of a sentence
 * The size of the Constituent should be 1
 */
public static String isSentenceStart (Constituent c){
  Sentence sentence = c.getTextAnnotation().getSentenceFromToken(c.getStartSpan());
  int sentenceStart = sentence.getStartSpan();
  if (c.getStartSpan() == sentenceStart){
    return "1";
  }
  return "0";
}
origin: edu.illinois.cs.cogcomp/illinois-md

/**
 * Check if the Constituent is a start of a sentence
 * The size of the Constituent should be 1
 */
public static String isSentenceStart (Constituent c){
  Sentence sentence = c.getTextAnnotation().getSentenceFromToken(c.getStartSpan());
  int sentenceStart = sentence.getStartSpan();
  if (c.getStartSpan() == sentenceStart){
    return "1";
  }
  return "0";
}
origin: edu.illinois.cs.cogcomp/illinois-time

Sentence currSentence = ta.getSentenceFromToken(currSpan.getFirst());
IntPair sentenceSpan = currSentence.getSentenceConstituent().getSpan();
View PosView = ta.getView("POS");
origin: edu.illinois.cs.cogcomp/illinois-relation-extraction

/**
 * Helper function for print essential information of a relation
 * @param r Input Relation
 */
public static void printRelation (Relation r){
  TextAnnotation ta = r.getSource().getTextAnnotation();
  Constituent source = r.getSource();
  Constituent target = r.getTarget();
  Constituent source_head = RelationFeatureExtractor.getEntityHeadForConstituent(source, ta, "");
  Constituent target_head = RelationFeatureExtractor.getEntityHeadForConstituent(target, ta, "");
  System.out.println(ta.getSentenceFromToken(source.getStartSpan()));
  System.out.println(r.getRelationName());
  System.out.println(r.getAttribute("RelationType") + ":" + r.getAttribute("RelationSubtype"));
  System.out.println(source.toString() + " || " + target.toString());
  System.out.println(source_head.toString() + " || " + target_head.toString());
}
origin: CogComp/cogcomp-nlp

System.out.println(goldMention.getTextAnnotation().getSentenceFromToken(goldMention.getStartSpan()).toString());
System.out.println(goldMention.toString() + " " + goldMention.getAttribute("EntityType") + " " + predictMention.getAttribute("EntityType"));
System.out.println();
origin: edu.illinois.cs.cogcomp/md

System.out.println(goldMention.getTextAnnotation().getSentenceFromToken(goldMention.getStartSpan()).toString());
System.out.println(goldMention.toString() + " " + goldMention.getAttribute("EntityType") + " " + predictMention.getAttribute("EntityType"));
System.out.println();
origin: edu.illinois.cs.cogcomp/illinois-md

System.out.println(goldMention.getTextAnnotation().getSentenceFromToken(goldMention.getStartSpan()).toString());
System.out.println(goldMention.toString() + " " + goldMention.getAttribute("EntityType") + " " + predictMention.getAttribute("EntityType"));
System.out.println();
origin: CogComp/cogcomp-nlp

/**
 * Get the form/lemma features of a given Constituent.
 * The size of the Constituent should be 1
 */
public static List<Pair<Integer, String>> getWordFormFeatures (Constituent c){
  List<Pair<Integer, String>> ret_features = new ArrayList<>();
  TextAnnotation ta = c.getTextAnnotation();
  Sentence sentence = ta.getSentenceFromToken(c.getStartSpan());
  int sentenceStart = sentence.getStartSpan();
  int sentenceEnd = sentence.getEndSpan();
  if (c.getStartSpan() > sentenceStart){
    ret_features.add(new Pair<>(-1, ta.getToken(c.getStartSpan() - 1)));
    ret_features.add(new Pair<>(-1, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() - 1))));
  }
  ret_features.add(new Pair<>(0, ta.getToken(c.getStartSpan())));
  ret_features.add(new Pair<>(0, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan()))));
  if (c.getEndSpan() < sentenceEnd){
    ret_features.add(new Pair<>(1, ta.getToken(c.getStartSpan() + 1)));
    ret_features.add(new Pair<>(1, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() + 1))));
  }
  if (c.getEndSpan() < sentenceEnd - 1){
    ret_features.add(new Pair<>(2, ta.getToken(c.getStartSpan() + 2)));
    ret_features.add(new Pair<>(2, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() + 2))));
  }
  return ret_features;
}
origin: edu.illinois.cs.cogcomp/md

/**
 * Get the form/lemma features of a given Constituent.
 * The size of the Constituent should be 1
 */
public static List<Pair<Integer, String>> getWordFormFeatures (Constituent c){
  List<Pair<Integer, String>> ret_features = new ArrayList<>();
  TextAnnotation ta = c.getTextAnnotation();
  Sentence sentence = ta.getSentenceFromToken(c.getStartSpan());
  int sentenceStart = sentence.getStartSpan();
  int sentenceEnd = sentence.getEndSpan();
  if (c.getStartSpan() > sentenceStart){
    ret_features.add(new Pair<>(-1, ta.getToken(c.getStartSpan() - 1)));
    ret_features.add(new Pair<>(-1, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() - 1))));
  }
  ret_features.add(new Pair<>(0, ta.getToken(c.getStartSpan())));
  ret_features.add(new Pair<>(0, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan()))));
  if (c.getEndSpan() < sentenceEnd){
    ret_features.add(new Pair<>(1, ta.getToken(c.getStartSpan() + 1)));
    ret_features.add(new Pair<>(1, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() + 1))));
  }
  if (c.getEndSpan() < sentenceEnd - 1){
    ret_features.add(new Pair<>(2, ta.getToken(c.getStartSpan() + 2)));
    ret_features.add(new Pair<>(2, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() + 2))));
  }
  return ret_features;
}
origin: edu.illinois.cs.cogcomp/illinois-md

/**
 * Get the form/lemma features of a given Constituent.
 * The size of the Constituent should be 1
 */
public static List<Pair<Integer, String>> getWordFormFeatures (Constituent c){
  List<Pair<Integer, String>> ret_features = new ArrayList<>();
  TextAnnotation ta = c.getTextAnnotation();
  Sentence sentence = ta.getSentenceFromToken(c.getStartSpan());
  int sentenceStart = sentence.getStartSpan();
  int sentenceEnd = sentence.getEndSpan();
  if (c.getStartSpan() > sentenceStart){
    ret_features.add(new Pair<>(-1, ta.getToken(c.getStartSpan() - 1)));
    ret_features.add(new Pair<>(-1, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() - 1))));
  }
  ret_features.add(new Pair<>(0, ta.getToken(c.getStartSpan())));
  ret_features.add(new Pair<>(0, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan()))));
  if (c.getEndSpan() < sentenceEnd){
    ret_features.add(new Pair<>(1, ta.getToken(c.getStartSpan() + 1)));
    ret_features.add(new Pair<>(1, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() + 1))));
  }
  if (c.getEndSpan() < sentenceEnd - 1){
    ret_features.add(new Pair<>(2, ta.getToken(c.getStartSpan() + 2)));
    ret_features.add(new Pair<>(2, MyString.normalizeDigitsForFeatureExtraction(ta.getToken(c.getStartSpan() + 2))));
  }
  return ret_features;
}
edu.illinois.cs.cogcomp.core.datastructures.textannotationTextAnnotationgetSentenceFromToken

Javadoc

Gets the sentence containing the specified token

Popular methods of TextAnnotation

  • addView
  • getView
  • hasView
  • getText
  • getId
  • getSentence
  • getTokens
  • getToken
  • getNumberOfSentences
  • size
  • getTokenIdFromCharacterOffset
    Get the position of token that corresponds to the character offset that is passed as a parameter. Th
  • getAvailableViews
  • getTokenIdFromCharacterOffset,
  • getAvailableViews,
  • <init>,
  • getSentenceId,
  • getTokenizedText,
  • getCorpusId,
  • getTokensInSpan,
  • sentences,
  • addAttribute

Popular in Java

  • Finding current android device location
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • getContentResolver (Context)
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now