/** * * @param aJCas * the source JCas * @param aFile * the file to write to * @throws IOException * if there is a problem writing the file * @deprecated Use {@link CasIOUtils#save(CAS, OutputStream, org.apache.uima.cas.SerialFormat)} * with {@link SerialFormat#XCAS} instead. */ @Deprecated public static void writeXCas(JCas aJCas, File aFile) throws IOException { CasIOUtil.writeXCas(aJCas.getCas(), aFile); } }
private static void annotate(final File[] pdfs, final File outputFolder, final boolean force) { Annotator annotator = new Annotator(); for (final File pdf : pdfs) { System.out.println("Processing file " + pdf.getAbsolutePath()); try { // Make sure the output file is not overridden unless this is // explicitly wanted final File outputFile = new File(outputFolder, pdf.getName().replace(".pdf", ".xml")); if (outputFile.exists()) { if (!force) { System.out.println("Ignoring file because output file " + outputFile.getAbsolutePath() + " already exists!"); continue; } else { outputFile.delete(); } } // Perform the actual annotation CasIOUtil.writeXCas(annotator.annotateInputFile(pdf, true), outputFile); } catch (UIMAException | IOException ex) { System.err.println("The file could not be processed because of " + "an exception during parsing:"); ex.printStackTrace(System.err); } } }
CasIOUtil.writeXCas(annotator.annotateInputFile(inFile, type.equals("PDF")), outFile); System.out.println("DONE " + outputToken);