Codota Logo
TextAnnotation.<init>
Code IndexAdd Codota to your IDE (free)

How to use
edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation
constructor

Best Java code snippets using edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation.<init> (Showing top 20 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

/**
 * The default way to create a {@link TextAnnotation} from pre-tokenized text.
 * 
 * @param tokenizedSentences A list of sentences, each one being a list of tokens
 * @return A {@link TextAnnotation} containing the SENTENCE and TOKENS views.
 */
public static TextAnnotation createTextAnnotationFromTokens(String corpusId, String textId,
    List<String[]> tokenizedSentences) {
  Tokenization tokenization = tokenizeTextSpan(tokenizedSentences);
  StringBuilder text = new StringBuilder();
  for (String[] sentenceTokens : tokenizedSentences)
    text.append(StringUtils.join(sentenceTokens, ' '))
        .append(System.lineSeparator());
  return new TextAnnotation(corpusId, textId, text.toString(), tokenization.getCharacterOffsets(),
      tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}
origin: edu.illinois.cs.cogcomp/illinois-core-utilities

/**
 * The default way to create a {@link TextAnnotation} from pre-tokenized text.
 * 
 * @param tokenizedSentences A list of sentences, each one being a list of tokens
 * @return A {@link TextAnnotation} containing the SENTENCE and TOKENS views.
 */
public static TextAnnotation createTextAnnotationFromTokens(String corpusId, String textId,
    List<String[]> tokenizedSentences) {
  Tokenization tokenization = tokenizeTextSpan(tokenizedSentences);
  StringBuilder text = new StringBuilder();
  for (String[] sentenceTokens : tokenizedSentences)
    text.append(StringUtils.join(sentenceTokens, ' '))
        .append(System.lineSeparator());
  return new TextAnnotation(corpusId, textId, text.toString(), tokenization.getCharacterOffsets(),
      tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}
origin: edu.illinois.cs.cogcomp/wikipediaAPI-multilingual

TextAnnotation ta = new TextAnnotation("", "", text, offs,
    surfs, ends);
return ta;
origin: CogComp/cogcomp-nlp

TextAnnotation ta = new TextAnnotation("", "", text, offs,
    surfs, ends);
return ta;
origin: CogComp/cogcomp-nlp

@Override
public TextAnnotation createTextAnnotation(String corpusId, String textId, String text,
    Tokenizer.Tokenization tokenization) throws IllegalArgumentException {
  return new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
      tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}
origin: CogComp/cogcomp-nlp

@Override
public TextAnnotation createTextAnnotation(String corpusId, String textId, String text,
    Tokenization tokenization) throws IllegalArgumentException {
  return new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
      tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}
origin: edu.illinois.cs.cogcomp/illinois-curator

@Override
public TextAnnotation createTextAnnotation(String corpusId, String textId, String text,
    Tokenizer.Tokenization tokenization) throws IllegalArgumentException {
  return new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
      tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}
origin: edu.illinois.cs.cogcomp/illinois-core-utilities

@Override
public TextAnnotation createTextAnnotation(String corpusId, String textId, String text,
    Tokenization tokenization) throws IllegalArgumentException {
  return new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
      tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
}
origin: CogComp/cogcomp-nlp

  public TextAnnotation getTextAnnotation(String text){
    Annotation document = new Annotation(text);
    pipeline.annotate(document);

    List<CoreLabel> tokens = new ArrayList<>();
    List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
    int[] sen_ends = new int[sentences.size()];
    int sen_idx = 0;
    for (CoreMap sentence : sentences) {
      for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {

        tokens.add(token);
      }
      sen_ends[sen_idx++] = tokens.size();
    }
    String[] surfaces = new String[tokens.size()];
    IntPair[] tokenCharOffsets = new IntPair[tokens.size()];
    for(int i = 0; i < tokens.size(); i++){

      surfaces[i] = tokens.get(i).originalText();
      tokenCharOffsets[i] = new IntPair(tokens.get(i).beginPosition(), tokens.get(i).endPosition());
//            System.out.println(surfaces[i]);
//            System.out.println(tokenCharOffsets[i]);
    }
//        System.out.println(sen_ends[0]);
    TextAnnotation ta = new TextAnnotation("", "", text, tokenCharOffsets,
        surfaces, sen_ends);
    return ta;
  }

origin: edu.illinois.cs.cogcomp/wikipediaAPI-multilingual

  public TextAnnotation getTextAnnotation(String text){
    Annotation document = new Annotation(text);
    pipeline.annotate(document);

    List<CoreLabel> tokens = new ArrayList<>();
    List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
    int[] sen_ends = new int[sentences.size()];
    int sen_idx = 0;
    for (CoreMap sentence : sentences) {
      for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {

        tokens.add(token);
      }
      sen_ends[sen_idx++] = tokens.size();
    }
    String[] surfaces = new String[tokens.size()];
    IntPair[] tokenCharOffsets = new IntPair[tokens.size()];
    for(int i = 0; i < tokens.size(); i++){

      surfaces[i] = tokens.get(i).originalText();
      tokenCharOffsets[i] = new IntPair(tokens.get(i).beginPosition(), tokens.get(i).endPosition());
//            System.out.println(surfaces[i]);
//            System.out.println(tokenCharOffsets[i]);
    }
//        System.out.println(sen_ends[0]);
    TextAnnotation ta = new TextAnnotation("", "", text, tokenCharOffsets,
        surfaces, sen_ends);
    return ta;
  }

origin: CogComp/cogcomp-nlp

assert tokensPairs.size() == tokenSize;
String text = ta.getText().substring(tokensPairs.get(0).getFirst() + firstCharOffset, tokensPairs.get(tokensPairs.size()-1).getSecond() + firstCharOffset);
TextAnnotation newTA = new TextAnnotation(ta.corpusId, ta.id, text,
    tokensPairs.toArray(new IntPair[tokenSize]), tokens.toArray(new String[tokenSize]), new int[]{tokenSize});
origin: edu.illinois.cs.cogcomp/illinois-core-utilities

assert tokensPairs.size() == tokenSize;
String text = ta.getText().substring(tokensPairs.get(0).getFirst() + firstCharOffset, tokensPairs.get(tokensPairs.size()-1).getSecond() + firstCharOffset);
TextAnnotation newTA = new TextAnnotation(ta.corpusId, ta.id, text,
    tokensPairs.toArray(new IntPair[tokenSize]), tokens.toArray(new String[tokenSize]), new int[]{tokenSize});
origin: CogComp/cogcomp-nlp

new TextAnnotation(corpusId, id, text, offsets, tokens, sentences.getSecond());
origin: edu.illinois.cs.cogcomp/illinois-core-utilities

new TextAnnotation(corpusId, id, text, offsets, tokens, sentences.getSecond());
origin: CogComp/cogcomp-nlp

public static TextAnnotation readTextAnnotation(TextAnnotationProto taImpl) throws Exception {
  String corpusId = taImpl.getCorpusId();
  String id = taImpl.getId();
  String text = taImpl.getText();
  String[] tokens = taImpl.getTokensList().toArray(new String[0]);
  Pair<Pair<String, Double>, int[]> sentences = readSentences(taImpl.getSentences());
  IntPair[] offsets = TokenUtils.getTokenOffsets(text, tokens);
  TextAnnotation ta =
      new TextAnnotation(corpusId, id, text, offsets, tokens, sentences.getSecond());
  for (ViewProto view : taImpl.getViewsList()) {
    String viewName = view.getViewName();
    List<View> topKViews = new ArrayList<>();
    for (ViewDataProto viewData : view.getViewDataList()) {
      topKViews.add(readViewData(viewData, ta));
    }
    if (viewName.equals(ViewNames.SENTENCE))
      ta.removeView(viewName);
    ta.addTopKView(viewName, topKViews);
    if (viewName.equals(ViewNames.SENTENCE))
      ta.setSentences();
  }
  for (Map.Entry<String, String> entry: taImpl.getPropertiesMap().entrySet()) {
    ta.addAttribute(entry.getKey(), entry.getValue());
  }
  return ta;
}
origin: edu.illinois.cs.cogcomp/illinois-core-utilities

public static TextAnnotation readTextAnnotation(TextAnnotationProto taImpl) throws Exception {
  String corpusId = taImpl.getCorpusId();
  String id = taImpl.getId();
  String text = taImpl.getText();
  String[] tokens = taImpl.getTokensList().toArray(new String[0]);
  Pair<Pair<String, Double>, int[]> sentences = readSentences(taImpl.getSentences());
  IntPair[] offsets = TokenUtils.getTokenOffsets(text, tokens);
  TextAnnotation ta =
      new TextAnnotation(corpusId, id, text, offsets, tokens, sentences.getSecond());
  for (ViewProto view : taImpl.getViewsList()) {
    String viewName = view.getViewName();
    List<View> topKViews = new ArrayList<>();
    for (ViewDataProto viewData : view.getViewDataList()) {
      topKViews.add(readViewData(viewData, ta));
    }
    if (viewName.equals(ViewNames.SENTENCE))
      ta.removeView(viewName);
    ta.addTopKView(viewName, topKViews);
    if (viewName.equals(ViewNames.SENTENCE))
      ta.setSentences();
  }
  for (Map.Entry<String, String> entry: taImpl.getPropertiesMap().entrySet()) {
    ta.addAttribute(entry.getKey(), entry.getValue());
  }
  return ta;
}
origin: edu.illinois.cs.cogcomp/illinois-tokenizer

new TextAnnotation(corpusId, textId, text, offsets, tokens, sentenceEndPositions);
origin: CogComp/cogcomp-nlp

new TextAnnotation(corpusId, textId, text, offsets, tokens, sentenceEndPositions);
origin: CogComp/cogcomp-nlp

  throws IllegalArgumentException {
Tokenizer.Tokenization tokenization = tokenizer.tokenizeTextSpan(text);
TextAnnotation ta = new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
    tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
SpanLabelView view =
origin: edu.illinois.cs.cogcomp/illinois-tokenizer

  throws IllegalArgumentException {
Tokenizer.Tokenization tokenization = tokenizer.tokenizeTextSpan(text);
TextAnnotation ta = new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
    tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
SpanLabelView view =
edu.illinois.cs.cogcomp.core.datastructures.textannotationTextAnnotation<init>

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,
  • getSentenceId,
  • getTokenizedText,
  • getCorpusId,
  • getSentenceFromToken,
  • getTokensInSpan,
  • sentences,
  • addAttribute

Popular in Java

  • Updating database using SQL prepared statement
  • runOnUiThread (Activity)
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
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