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()); }
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()); }
TextAnnotation ta = rp.RunPipelineOnFile(inFileName); SerializationHelper.serializeTextAnnotationToFile(ta, outFileName, true, true); System.out.println("Processed file. TextAnnotation.toString(): " + ta.toString());
TextAnnotation ta = rp.RunPipelineOnFile(inFileName); SerializationHelper.serializeTextAnnotationToFile(ta, outFileName, true, true); System.out.println("Processed file. TextAnnotation.toString(): " + ta.toString());
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); } }
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); } }
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); } }
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); } }