public String getCommaID() { return commaPosition + " " + s.goldTa.getId(); }
public String getCommaID() { return commaPosition + " " + s.goldTa.getId(); }
public String getId() { return commas.get(0).getTextAnnotation(true).getId(); }
public String getId() { return commas.get(0).getTextAnnotation(true).getId(); }
public void RunPipelineWithCorpusReader(AnnotationReader reader) { Iterator<TextAnnotation> iter = reader.iterator(); boolean replaceExistingViews = false; while (iter.hasNext()) { TextAnnotation ta = iter.next(); try { ta = pipeline.annotateTextAnnotation(ta, replaceExistingViews); } catch (AnnotatorException e) { e.printStackTrace(); logger.error("failed to preprocess ta with id '" + ta.getId() + "'."); } logger.debug("processed file (assumed this is TextAnnotation docid): '" + ta.getId() + "'"); } }
@Override public final TextAnnotation next() { TextAnnotation ta; if (wsjIterator == null) ta = super.next(); else ta = wsjIterator.next(); assert ta != null; if (this.goldFields.containsKey(ta.getId())) addAnnotation(ta); return ta; }
@Override public final TextAnnotation next() { TextAnnotation ta; if (wsjIterator == null) ta = super.next(); else ta = wsjIterator.next(); assert ta != null; if (this.goldFields.containsKey(ta.getId())) addAnnotation(ta); return ta; }
public void RunPipelineWithCorpusReader(AnnotationReader reader) { Iterator<TextAnnotation> iter = reader.iterator(); boolean replaceExistingViews = false; while (iter.hasNext()) { TextAnnotation ta = iter.next(); try { ta = pipeline.annotateTextAnnotation(ta, replaceExistingViews); } catch (AnnotatorException e) { e.printStackTrace(); logger.error("failed to preprocess ta with id '" + ta.getId() + "'."); } logger.debug("processed file (assumed this is TextAnnotation docid): '" + ta.getId() + "'"); } }
@Override public final TextAnnotation next() { TextAnnotation ta; if (wsjIterator == null) ta = super.next(); else ta = wsjIterator.next(); assert ta != null; if (this.goldFields.containsKey(ta.getId())) addAnnotation(ta); return ta; }
@Override public final TextAnnotation next() { TextAnnotation ta; if (wsjIterator == null) ta = super.next(); else ta = wsjIterator.next(); assert ta != null; if (this.goldFields.containsKey(ta.getId())) addAnnotation(ta); return ta; }
static public void printTextAnnotation(PrintStream out, TextAnnotation ta) { out.println("TextAnnotation with id: " + ta.getId()); String rawText = ta.getText(); out.println("Raw Text: " + rawText); out.println(getLineFill()); out.println("TextAnnotation Views:"); for (String name : ta.getAvailableViews()) { out.println("View Name: " + name); out.println(ta.getView(name).toString()); out.println(getLineFill()); } }
static public void printTextAnnotation(PrintStream out, TextAnnotation ta) { out.println("TextAnnotation with id: " + ta.getId()); String rawText = ta.getText(); out.println("Raw Text: " + rawText); out.println(getLineFill()); out.println("TextAnnotation Views:"); for (String name : ta.getAvailableViews()) { out.println("View Name: " + name); out.println(ta.getView(name).toString()); out.println(getLineFill()); } }
public static void main(String[] args) throws Exception { String corpusDirectory = "/shared/corpora/corporaWeb/written/eng/MASC-3.0.0/xces"; String outputDirectory = "/shared/corpora/corporaWeb/written/eng/MASC-3.0.0/json"; if (args.length >= 2) { corpusDirectory = args[0]; outputDirectory = args[1]; } MascXCESReader reader = new MascXCESReader("MASC-3.0.0", corpusDirectory, ".xml"); for (TextAnnotation ta : reader) { String outputFile = Paths.get(outputDirectory, ta.getId() + ".json").toAbsolutePath().toString(); new File(outputFile).getParentFile().mkdirs(); SerializationHelper.serializeTextAnnotationToFile(ta, outputFile, true, true); logger.info("Serialized TextAnnotation to [" + outputFile + "]"); } System.out.print(reader.generateReport()); } }
/** * A little convenience function. * * @param sent * @return */ public static String getSentId(Constituent sent) { return sent.getTextAnnotation().getId() + ":" + sent.getSentenceId(); }
public static String getHTMLfromTA(TextAnnotation ta, Dictionary dict, boolean showdefs) { return getHTMLfromTA(ta, new IntPair(-1, -1), ta.getId(), "", dict, showdefs, false, false); }
public static String getHTMLfromTA(TextAnnotation ta, String query, Dictionary dict, boolean showdefs) { return getHTMLfromTA(ta, new IntPair(-1, -1), ta.getId(), query, dict, showdefs, false, false); }
public static String getHTMLfromTA(TextAnnotation ta, Dictionary dict, boolean showdefs, boolean showroman, boolean allowcopy) { return getHTMLfromTA(ta, new IntPair(-1, -1), ta.getId(), "", dict, showdefs, showroman, allowcopy); }
public static String getHTMLfromTA(TextAnnotation ta, Dictionary dict, boolean showdefs, boolean showroman) { return getHTMLfromTA(ta, new IntPair(-1, -1), ta.getId(), "", dict, showdefs, showroman, false); }
static void checkLength(TextAnnotation textAnnotation, boolean throwExceptionOnSentenceLengthCheck, int maxParseSentenceLength) throws AnnotatorException { if (throwExceptionOnSentenceLengthCheck) { Constituent c = HandlerUtils.checkTextAnnotationRespectsSentenceLengthLimit(textAnnotation, maxParseSentenceLength); if (null != c) { String msg = HandlerUtils.getSentenceLengthError(textAnnotation.getId(), c.getSurfaceForm(), maxParseSentenceLength); logger.error(msg); throw new AnnotatorException(msg); } } }
static void checkLength(TextAnnotation textAnnotation, boolean throwExceptionOnSentenceLengthCheck, int maxParseSentenceLength) throws AnnotatorException { if (throwExceptionOnSentenceLengthCheck) { Constituent c = HandlerUtils.checkTextAnnotationRespectsSentenceLengthLimit(textAnnotation, maxParseSentenceLength); if (null != c) { String msg = HandlerUtils.getSentenceLengthError(textAnnotation.getId(), c.getSurfaceForm(), maxParseSentenceLength); logger.error(msg); throw new AnnotatorException(msg); } } }