private static String getTokenDescPath(AnalysisEngineDescription tokenDesc) throws IOException, ResourceInitializationException, SAXException { if (tokenDescrPath != null) return tokenDescrPath.getAbsolutePath(); tokenDescrPath = File.createTempFile("tmp", "TokenizerAnnotator.xml"); tokenDesc.toXML(new FileWriter(tokenDescrPath)); return tokenDescrPath.getAbsolutePath(); }
private static void writeDesc(File descDir, String name, AnalysisEngineDescription desc) throws SAXException, IOException { // set the name (not done by uimaFIT) desc.getMetaData().setName(name); File descFile = new File(descDir, name + ".xml"); System.err.println("Writing description to " + descFile); FileOutputStream output = new FileOutputStream(descFile); desc.toXML(output); output.close(); } }
private static void writeDesc(File descDir, String name, AnalysisEngineDescription desc) throws SAXException, IOException { // set the name (not done by uimaFIT) desc.getMetaData().setName(name); File descFile = new File(descDir, name + ".xml"); System.err.println("Writing description to " + descFile); FileOutputStream output = new FileOutputStream(descFile); desc.toXML(output); output.close(); } }
private static void writeAggregateDescriptions( AggregateBuilder preprocessing, AnalysisEngineDescription ClearNLPDepParserDesc, AnalysisEngineDescription ClearNLPSRLDesc, File outputRoot, String aggregateSuffix) throws ResourceInitializationException, FileNotFoundException, SAXException, IOException { // Append Dependency Parser into aggregate and write description file preprocessing.add(ClearNLPDepParserDesc); preprocessing.createAggregateDescription().toXML(new FileOutputStream(new File(outputRoot, DEP_NAME + aggregateSuffix))); // Append SRL Parser into aggregate and write description file preprocessing.add(ClearNLPSRLDesc); preprocessing.createAggregateDescription().toXML(new FileOutputStream(new File(outputRoot, SRL_NAME + aggregateSuffix))); }
private static void writeAggregateDescriptions( AggregateBuilder preprocessing, AnalysisEngineDescription ClearNLPDepParserDesc, AnalysisEngineDescription ClearNLPSRLDesc, File outputRoot, String aggregateSuffix) throws ResourceInitializationException, FileNotFoundException, SAXException, IOException { // Append Dependency Parser into aggregate and write description file preprocessing.add(ClearNLPDepParserDesc); preprocessing.createAggregateDescription().toXML(new FileOutputStream(new File(outputRoot, DEP_NAME + aggregateSuffix))); // Append SRL Parser into aggregate and write description file preprocessing.add(ClearNLPSRLDesc); preprocessing.createAggregateDescription().toXML(new FileOutputStream(new File(outputRoot, SRL_NAME + aggregateSuffix))); }
/** * Saves a given UIMA aggregate component desciption in a specified XML descriptor file. * * @param aggDescription * The given UIMA aggregate component desciption. * @param aggDescFile * The given XML descriptor file. * @throws IOException * If an I/O exception occurrs. */ static void saveAggregateDescription(AnalysisEngineDescription aggDescription, File aggDescFile) throws IOException { FileWriter fWriter = null; try { fWriter = new FileWriter(aggDescFile); aggDescription.toXML(fWriter); } catch (SAXException exc) { throw new IOException(exc.toString()); } finally { if (fWriter != null) { try { fWriter.close(); } catch (Exception e) { } } } }
public void createZonerMayoDescriptor() throws Exception { AggregateBuilder builder = new AggregateBuilder(); String generalSectionRegexFileUri = "org/mitre/medfacts/uima/mayo_sections.xml"; AnalysisEngineDescription zonerAnnotator = AnalysisEngineFactory.createEngineDescription(ZoneAnnotator.class, ZoneAnnotator.PARAM_SECTION_REGEX_FILE_URI, generalSectionRegexFileUri ); builder.add(zonerAnnotator); File outputFile = new File("desc/analysis_engine/assertion_zoner__mayo.xml"); FileOutputStream outputStream = new FileOutputStream(outputFile); String outputFilePath = outputFile.getAbsolutePath(); System.out.println("output descriptor file: " + outputFilePath); zonerAnnotator.toXML(outputStream); }
public void createZonerNormalDescriptor() throws Exception { AggregateBuilder builder = new AggregateBuilder(); String generalSectionRegexFileUri = "org/mitre/medfacts/zoner/section_regex.xml"; AnalysisEngineDescription zonerAnnotator = AnalysisEngineFactory.createEngineDescription(ZoneAnnotator.class, ZoneAnnotator.PARAM_SECTION_REGEX_FILE_URI, generalSectionRegexFileUri ); builder.add(zonerAnnotator); File outputFile = new File("desc/analysis_engine/assertion_zoner__normal.xml"); FileOutputStream outputStream = new FileOutputStream(outputFile); String outputFilePath = outputFile.getAbsolutePath(); System.out.println("output descriptor file: " + outputFilePath); zonerAnnotator.toXML(outputStream); }
public void createZonerMayoDescriptor() throws Exception { AggregateBuilder builder = new AggregateBuilder(); String generalSectionRegexFileUri = "org/mitre/medfacts/uima/mayo_sections.xml"; AnalysisEngineDescription zonerAnnotator = AnalysisEngineFactory.createEngineDescription(ZoneAnnotator.class, ZoneAnnotator.PARAM_SECTION_REGEX_FILE_URI, generalSectionRegexFileUri ); builder.add(zonerAnnotator); File outputFile = new File("desc/analysis_engine/assertion_zoner__mayo.xml"); FileOutputStream outputStream = new FileOutputStream(outputFile); String outputFilePath = outputFile.getAbsolutePath(); System.out.println("output descriptor file: " + outputFilePath); zonerAnnotator.toXML(outputStream); }
public void createZonerNormalDescriptor() throws Exception { AggregateBuilder builder = new AggregateBuilder(); String generalSectionRegexFileUri = "org/mitre/medfacts/zoner/section_regex.xml"; AnalysisEngineDescription zonerAnnotator = AnalysisEngineFactory.createEngineDescription(ZoneAnnotator.class, ZoneAnnotator.PARAM_SECTION_REGEX_FILE_URI, generalSectionRegexFileUri ); builder.add(zonerAnnotator); File outputFile = new File("desc/analysis_engine/assertion_zoner__normal.xml"); FileOutputStream outputStream = new FileOutputStream(outputFile); String outputFilePath = outputFile.getAbsolutePath(); System.out.println("output descriptor file: " + outputFilePath); zonerAnnotator.toXML(outputStream); }
public static void main(String[] args) throws ResourceInitializationException, SAXException, IOException { AggregateBuilder aggregateBuilder = new AggregateBuilder(); aggregateBuilder.add(SimpleSegmentAnnotator.createAnnotatorDescription()); aggregateBuilder.add(SentenceDetectorAnnotatorBIO.getDescription(sentModelPath)); aggregateBuilder.createAggregateDescription().toXML(new FileWriter("desc/analysis_engine/SentenceAnnotatorBIOAggregate.xml")); SentenceDetectorAnnotatorBIO.getDescription(sentModelPath).toXML(new FileWriter("desc/analysis_engine/SentenceDetectorAnnotatorBIO.xml")); }
public static void main(String[] args) throws ResourceInitializationException, SAXException, IOException { AggregateBuilder aggregateBuilder = new AggregateBuilder(); aggregateBuilder.add(SimpleSegmentAnnotator.createAnnotatorDescription()); aggregateBuilder.add(SentenceDetectorAnnotatorBIO.getDescription(sentModelPath)); aggregateBuilder.createAggregateDescription().toXML(new FileWriter("desc/analysis_engine/SentenceAnnotatorBIOAggregate.xml")); SentenceDetectorAnnotatorBIO.getDescription(sentModelPath).toXML(new FileWriter("desc/analysis_engine/SentenceDetectorAnnotatorBIO.xml")); }
@Override public void write(OutputStream aStream) throws Exception { AnalysisEngineDescription analysisDesc = getAnalysisEngineDescription(aContext); // FIXME should use the same resource manager here // as the engine uses! analysisDesc.resolveImports(UIMAFramework.newDefaultResourceManager()); analysisDesc.toXML(aStream); } });
@Override public void write(OutputStream aStream) throws Exception { AnalysisEngineDescription analysisDesc = getAnalysisEngineDescription(aContext); // FIXME should use the same resource manager here // as the engine uses! analysisDesc.resolveImports(UIMAFramework.newDefaultResourceManager()); analysisDesc.toXML(aStream); } });
description.toXML(outputStream);
description.toXML(outputStream);
description.toXML(outputStream);
private static void setImportsByLocation(File dir, String descName) { FileOutputStream fos = null; try { File file = new File(dir, descName); AnalysisEngineDescription description = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(file)); Import[] imports = description.getAnalysisEngineMetaData().getTypeSystem().getImports(); for (Import each : imports) { String name = each.getName(); String[] split = name.split("[.]"); String location = split[split.length - 1] + ".xml"; each.setName(null); each.setLocation(location); } fos = new FileOutputStream(file); description.toXML(fos); } catch (InvalidXMLException | IOException | SAXException e) { RutaIdeUIPlugin.error(e); } finally { IOUtils.closeQuietly(fos); } }
public static void main( String[] args ) throws Exception { String note = "Hello World!"; JCas jcas = JCasFactory.createJCas(); jcas.setDocumentText( note ); AggregateBuilder builder = new AggregateBuilder(); // Get a simple pre-defined existing pipeline for Tokenization // You can consider using ClinicalPipelineFactory.getDefaultPipeline(); // Which will include the UMLS Lookup, but you'll need to set your // -Dctakes.umlsuser and -Dctakes.umlspw in your environment builder.add( ClinicalPipelineFactory.getTokenProcessingPipeline() ); //Add the new HelloWorld Example: builder.add( ExampleHelloWorldAnnotator.createAnnotatorDescription() ); //Run the Aggregate Pipeline SimplePipeline.runPipeline( jcas, builder.createAggregateDescription() ); //Print out the IdentifiedAnnotation objects for ( IdentifiedAnnotation entity : JCasUtil.select( jcas, IdentifiedAnnotation.class ) ) { System.out.println( "Entity: " + entity.getCoveredText() + " === Polarity: " + entity.getPolarity() ); } //Example to save the Aggregate descriptor to an xml file for external //use such as the UIMA CVD/CPE if ( args.length > 0 ) { builder.createAggregateDescription().toXML( new FileWriter( args[ 0 ] ) ); } }
public static void main(String[] args) throws UIMAException, IOException, SAXException { AggregateBuilder builder = new AggregateBuilder(); builder.add(AnalysisEngineFactory.createEngineDescription(SimpleSegmentAnnotator.class)); builder.add(AnalysisEngineFactory.createEngineDescription( SentenceDetector.class, SentenceDetector.SD_MODEL_FILE_PARAM, "org/apache/ctakes/core/sentdetect/sd-med-model.zip")); builder.add(AnalysisEngineFactory.createEngineDescription(TokenizerAnnotatorPTB.class)); builder.add(AnalysisEngineFactory.createEngineDescription(ConstituencyParser.class)); AnalysisEngineDescription defaultDescriptor = builder.createAggregateDescription(); defaultDescriptor.toXML(new FileWriter("desc/analysis_engine/DefaultAggregateParsingProcessor.xml")); builder = new AggregateBuilder(); builder.add(SimpleSegmentAnnotator.createAnnotatorDescription()); builder.add(SentenceDetectorAnnotatorBIO.getDescription()); builder.add(TokenizerAnnotatorPTB.createAnnotatorDescription()); builder.add(ConstituencyParser.createAnnotatorDescription()); AnalysisEngineDescription mimicDescriptor = builder.createAggregateDescription(); mimicDescriptor.toXML(new FileWriter("desc/analysis_engine/MimicAggregateParsingProcessor.xml")); } }