@Override public void entityProcessComplete(CAS cas) { try { CasIOUtil.writeXmi(cas, file); } catch (IOException e) { e.printStackTrace(); } }
/** * This method loads the contents of an XMI or XCAS file into the given CAS. The file type is * detected by the extension. * * @param aCas * the target CAS * @param aFile * the file to read from * @throws IOException * if there is a problem reading the file * @deprecated Use {@link CasIOUtils#load(java.net.URL, CAS)} instead. */ @Deprecated public static void readCas(CAS aCas, File aFile) throws IOException { String lowerCaseFileName = aFile.getName().toLowerCase(); if (lowerCaseFileName.endsWith(".xmi")) { CasIOUtil.readXmi(aCas, aFile); } else if (lowerCaseFileName.endsWith(".xcas")) { CasIOUtil.readXCas(aCas, aFile); } else { throw new IllegalArgumentException("Unknown file extension: [" + aFile + "] "); } }
/** * * @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); } }
/** * * @param aJCas * the target JCas * @param aFile * the file to read from * @throws IOException * if there is a problem reading the file * @deprecated Use {@link CasIOUtils#load(java.net.URL, CAS)} instead. */ @Deprecated public static void readXCas(JCas aJCas, File aFile) throws IOException { CasIOUtil.readXCas(aJCas.getCas(), aFile); }
/** * This method loads the contents of an XMI or XCAS file into the given CAS. The file type is * detected by the extension. * * @param aJCas * the target JCas * @param aFile * the file to read from * @throws IOException * if there is a problem reading the file * @deprecated Use {@link CasIOUtils#load(java.net.URL, CAS)} instead. */ @Deprecated public static void readJCas(JCas aJCas, File aFile) throws IOException { CasIOUtil.readCas(aJCas.getCas(), aFile); }
/** * This method creates a new JCas and loads the contents of an XMI or XCAS file into it. * * @param fileName * a file name for the serialized CAS data * @param typeSystemDescription * a type system description to initialize the JCas * @return a new JCas * @throws UIMAException * if the JCas could not be initialized * @throws IOException * if there is a problem reading the file */ public static JCas createJCas(String fileName, TypeSystemDescription typeSystemDescription) throws UIMAException, IOException { JCas jCas = createJCas(typeSystemDescription); CasIOUtil.readJCas(jCas, new File(fileName)); return jCas; } }
entry[0] = xcas.getName(); jcas = Typesystem.getJCas(TYPESYSTEM); CasIOUtil.readXCas(jcas, xcas); Collection<Error> errors = JCasUtil.select(jcas, Error.class); for (Error error : errors) {
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { File xmiFile = getXmiFile(jCas); CasIOUtil.writeXmi(jCas, xmiFile); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
CasIOUtil.readXCas(jcas, XCASFile); input.add(new XCASRelationTuple(jcas, readRawRelations, relFile.getName().replace(".rel", "")));
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); } } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { try { File xmiFile = getXmiFile(jCas); CasIOUtil.writeXmi(jCas, xmiFile); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
CasIOUtil.writeXCas(annotator.annotateInputFile(inFile, type.equals("PDF")), outFile); System.out.println("DONE " + outputToken);
/** * * @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#XMI} instead. */ @Deprecated public static void writeXmi(JCas aJCas, File aFile) throws IOException { CasIOUtil.writeXmi(aJCas.getCas(), aFile); }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { SourceDocumentInformation sourceDocInfo = null; FSIndex annoIndex = jCas.getAnnotationIndex(SourceDocumentInformation.type); Iterator annoIter = annoIndex.iterator(); if (annoIter.hasNext()) { sourceDocInfo = (SourceDocumentInformation) annoIter.next(); } String FileName = new File(sourceDocInfo.getUri()).getName(); try { CasIOUtil.writeXmi(jCas, new File(outputDirectory, FileName + ".xmi")); } catch (IOException e) { e.printStackTrace(); } } }
public static void main(String[] args) throws Exception { System.out.println("Started " + ClinicalPipelineWithUmls.class.getCanonicalName() + " at " + new Date()); //String documentText = "Text of document to test goes here, such as the following. No edema, some soreness, denies pain."; //InputStream inStream = InputStreamCollectionReader.convertToByteArrayInputStream(documentText); //CollectionReader collectionReader = InputStreamCollectionReader.getCollectionReader(inStream); CollectionReaderDescription collectionReader = FilesCollectionReader.getDescription(AssertionConst.CORPUS_WO_GOLD_STD_TO_RUN_THROUGH_CTAKES); System.out.println("Reading from directory: " + AssertionConst.CORPUS_WO_GOLD_STD_TO_RUN_THROUGH_CTAKES); System.out.println("Outputting to directory: " + AssertionConst.evalOutputDir); AnalysisEngineDescription pipelineIncludingUmlsDictionaries = AnalysisEngineFactory.createEngineDescription( "desc/analysis_engine/AggregatePlaintextUMLSProcessor"); for(JCas jCas : SimplePipeline.iteratePipeline(collectionReader, pipelineIncludingUmlsDictionaries)){ CasIOUtil.writeXmi(jCas, new File(AssertionConst.evalOutputDir, DocumentIDAnnotationUtil.getDocumentID(jCas) + ".xmi")); } System.out.println("Done at " + new Date()); }
public static void main(String[] args) throws Exception { System.out.println("Started " + ClinicalPipelineWithUmls.class.getCanonicalName() + " at " + new Date()); //String documentText = "Text of document to test goes here, such as the following. No edema, some soreness, denies pain."; //InputStream inStream = InputStreamCollectionReader.convertToByteArrayInputStream(documentText); //CollectionReader collectionReader = InputStreamCollectionReader.getCollectionReader(inStream); CollectionReaderDescription collectionReader = FilesCollectionReader.getDescription(AssertionConst.CORPUS_WO_GOLD_STD_TO_RUN_THROUGH_CTAKES); System.out.println("Reading from directory: " + AssertionConst.CORPUS_WO_GOLD_STD_TO_RUN_THROUGH_CTAKES); System.out.println("Outputting to directory: " + AssertionConst.evalOutputDir); AnalysisEngineDescription pipelineIncludingUmlsDictionaries = AnalysisEngineFactory.createEngineDescription( "desc/analysis_engine/AggregatePlaintextUMLSProcessor"); for(JCas jCas : SimplePipeline.iteratePipeline(collectionReader, pipelineIncludingUmlsDictionaries)){ CasIOUtil.writeXmi(jCas, new File(AssertionConst.evalOutputDir, DocumentIDAnnotationUtil.getDocumentID(jCas) + ".xmi")); } System.out.println("Done at " + new Date()); }
public static void main(String[] args) throws UIMAException, IOException, CmdLineException { Options options = new Options(); CmdLineParser parser = new CmdLineParser(options); parser.parseArgument(args); CollectionReaderDescription collectionReader = CollectionReaderFactory.createReaderDescriptionFromPath( "../ctakes-core/desc/collection_reader/FilesInDirectoryCollectionReader.xml", ConfigParameterConstants.PARAM_INPUTDIR, options.inputDirectory ); // make sure the model parameters match those used for training AnalysisEngineDescription relationExtractor = AnalysisEngineFactory.createEngineDescriptionFromPath( "desc/analysis_engine/RelationExtractorAggregate.xml"); int fileNum = 0; for(JCas jcas : SimplePipeline.iteratePipeline(collectionReader, relationExtractor)){ CasIOUtil.writeXmi(jcas, new File(options.outputDirectory, String.format("%d.txt", fileNum++))); } } }
public static void main(String[] args) throws UIMAException, IOException, CmdLineException { Options options = new Options(); CmdLineParser parser = new CmdLineParser(options); parser.parseArgument(args); CollectionReaderDescription collectionReader = CollectionReaderFactory.createReaderDescriptionFromPath( "../ctakes-core/desc/collection_reader/FilesInDirectoryCollectionReader.xml", ConfigParameterConstants.PARAM_INPUTDIR, options.inputDirectory ); // make sure the model parameters match those used for training AnalysisEngineDescription relationExtractor = AnalysisEngineFactory.createEngineDescriptionFromPath( "desc/analysis_engine/RelationExtractorAggregate.xml"); int fileNum = 0; for(JCas jcas : SimplePipeline.iteratePipeline(collectionReader, relationExtractor)){ CasIOUtil.writeXmi(jcas, new File(options.outputDirectory, String.format("%d.txt", fileNum++))); } } }
engine.process(jCas); documentID.setDocumentID(textFile.getName()); CasIOUtil.writeXmi(jCas, new File("/tmp", textFile.toURI().toString()));
engine.process(jCas); documentID.setDocumentID(textFile.getName()); CasIOUtil.writeXmi(jCas, new File("/tmp", textFile.toURI().toString()));