edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation.toString()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(62)

本文整理了Java中edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation.toString()方法的一些代码示例,展示了TextAnnotation.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextAnnotation.toString()方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation
类名称:TextAnnotation
方法名:toString

TextAnnotation.toString介绍

暂无

代码示例

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

public static void main(String[] args) throws EdisonException, AnnotatorException {
  gazetteersInstance.ignoreGazetteer("Weapons.gz");
  gazetteersInstance.ignoreGazetteer("Weapons.Missile.gz");
  List<String[]> sentences =
      Arrays.asList("I live in Chicago , Illinois .".split("\\s+"),
          "I met George Bush .".split("\\s+"));
  TextAnnotation ta = BasicTextAnnotationBuilder.createTextAnnotationFromTokens(sentences);
  gazetteersInstance.addView(ta);
  System.out.println(ta.toString());
  System.out.println(ta.getView(gazetteersInstance.getViewName()).toString());
}

代码示例来源:origin: CogComp/cogcomp-nlp

public static void main(String[] args) throws EdisonException, AnnotatorException {
  gazetteersInstance.ignoreGazetteer("Weapons.gz");
  gazetteersInstance.ignoreGazetteer("Weapons.Missile.gz");
  List<String[]> sentences =
      Arrays.asList("I live in Chicago , Illinois .".split("\\s+"),
          "I met George Bush .".split("\\s+"));
  TextAnnotation ta = BasicTextAnnotationBuilder.createTextAnnotationFromTokens(sentences);
  gazetteersInstance.addView(ta);
  System.out.println(ta.toString());
  System.out.println(ta.getView(gazetteersInstance.getViewName()).toString());
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-nlp-pipeline

TextAnnotation ta = rp.RunPipelineOnFile(inFileName);
SerializationHelper.serializeTextAnnotationToFile(ta, outFileName, true, true);
System.out.println("Processed file.  TextAnnotation.toString(): " + ta.toString());

代码示例来源:origin: CogComp/cogcomp-nlp

TextAnnotation ta = rp.RunPipelineOnFile(inFileName);
SerializationHelper.serializeTextAnnotationToFile(ta, outFileName, true, true);
System.out.println("Processed file.  TextAnnotation.toString(): " + ta.toString());

代码示例来源:origin: CogComp/cogcomp-nlp

protected void addDependencyTree(Tree<Pair<String, Integer>> depTree, int sentStart,
    Constituent parent) {
  String word = depTree.getLabel().getFirst();
  String token = this.getTextAnnotation().getToken(parent.getStartSpan());
  word = treebankTokenHacks(word);
  token = treebankTokenHacks(token);
  assert word.trim().length() > 0;
  assert token.trim().length() > 0;
  if (!word.equals(token)) {
    logger.error(parent.getTextAnnotation().toString());
    logger.error(depTree.toString());
    throw new IllegalStateException("Expecting " + token + ", found " + word
        + " instead while constructing the dependency tree");
  }
  for (int i = 0; i < depTree.getNumberOfChildren(); i++) {
    String relationLabel = depTree.getEdgeLabel(i).getFirst();
    Tree<Pair<String, Integer>> child = depTree.getChild(i);
    Constituent childConstituent =
        getConstituentRelativeToSentenceStart(child, 1.0, sentStart, relationLabel);
    this.addConstituent(childConstituent, true);
    this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0));
    addDependencyTree(child, sentStart, childConstituent);
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

protected void addDependencyTreeWithHack(Tree<Pair<String, Integer>> depTree,
    Constituent parent, int sentenceStart) {
  String word = depTree.getLabel().getFirst();
  String token = this.getTextAnnotation().getToken(parent.getStartSpan());
  word = treebankTokenHacks(word);
  token = treebankTokenHacks(token);
  assert word.trim().length() > 0;
  assert token.trim().length() > 0;
  if (!word.equals(token)) {
    logger.info(parent.getTextAnnotation().toString());
    logger.info(depTree.toString());
    throw new IllegalStateException("Expecting " + token + ", found " + word
        + " instead while constructing the dependency tree");
  }
  for (int i = 0; i < depTree.getNumberOfChildren(); i++) {
    String relationLabel = depTree.getEdgeLabel(i).getFirst();
    Tree<Pair<String, Integer>> child = depTree.getChild(i);
    Constituent childConstituent =
        getConstituentRelativeToSentenceStart(child, 1.0, sentenceStart, relationLabel);
    this.addConstituent(childConstituent, true);
    this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0));
    addDependencyTreeWithHack(child, childConstituent, sentenceStart);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities

protected void addDependencyTreeWithHack(Tree<Pair<String, Integer>> depTree,
    Constituent parent, int sentenceStart) {
  String word = depTree.getLabel().getFirst();
  String token = this.getTextAnnotation().getToken(parent.getStartSpan());
  word = treebankTokenHacks(word);
  token = treebankTokenHacks(token);
  assert word.trim().length() > 0;
  assert token.trim().length() > 0;
  if (!word.equals(token)) {
    logger.info(parent.getTextAnnotation().toString());
    logger.info(depTree.toString());
    throw new IllegalStateException("Expecting " + token + ", found " + word
        + " instead while constructing the dependency tree");
  }
  for (int i = 0; i < depTree.getNumberOfChildren(); i++) {
    String relationLabel = depTree.getEdgeLabel(i).getFirst();
    Tree<Pair<String, Integer>> child = depTree.getChild(i);
    Constituent childConstituent =
        getConstituentRelativeToSentenceStart(child, 1.0, sentenceStart, relationLabel);
    this.addConstituent(childConstituent);
    this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0));
    addDependencyTreeWithHack(child, childConstituent, sentenceStart);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities

protected void addDependencyTree(Tree<Pair<String, Integer>> depTree, int sentStart,
    Constituent parent) {
  String word = depTree.getLabel().getFirst();
  String token = this.getTextAnnotation().getToken(parent.getStartSpan());
  word = treebankTokenHacks(word);
  token = treebankTokenHacks(token);
  assert word.trim().length() > 0;
  assert token.trim().length() > 0;
  if (!word.equals(token)) {
    logger.error(parent.getTextAnnotation().toString());
    logger.error(depTree.toString());
    throw new IllegalStateException("Expecting " + token + ", found " + word
        + " instead while constructing the dependency tree");
  }
  for (int i = 0; i < depTree.getNumberOfChildren(); i++) {
    String relationLabel = depTree.getEdgeLabel(i).getFirst();
    Tree<Pair<String, Integer>> child = depTree.getChild(i);
    Constituent childConstituent =
        getConstituentRelativeToSentenceStart(child, 1.0, sentStart, relationLabel);
    this.addConstituent(childConstituent);
    this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0));
    addDependencyTree(child, sentStart, childConstituent);
  }
}

相关文章