@Override public synchronized CAS newCAS() throws ResourceInitializationException { return this.ae.newCAS(); }
public CAS retrieve() { CAS ret = casPool.getCas(); try { return ret == null ? analysisEngine.newCAS() : ret; } catch (ResourceInitializationException e) { throw new RuntimeException(e); } }
public CAS retrieve() { CAS ret = casPool.getCas(); try { return ret == null ? analysisEngine.newCAS() : ret; } catch (ResourceInitializationException e) { throw new RuntimeException(e); } }
public CAS retrieve() { CAS ret = casPool.getCas(); try { return ret == null ? analysisEngine.newCAS() : ret; } catch (ResourceInitializationException e) { throw new RuntimeException(e); } }
/** * Creates a new fresh CAS instance which can be used for testing. * @return a new fresh CAS instance which can be used for testing * @throws Exception passthru */ public CAS createCAS() throws Exception { try { return ae.newCAS(); } catch (Exception ex) { JUnitExtension.handleException(ex); return null; } }
/** * Creates a new fresh CAS instance which can be used for testing. * @return a new fresh CAS instance which can be used for testing * @throws Exception passthru */ public CAS createCAS() throws Exception { try { return ae.newCAS(); } catch (Exception ex) { JUnitExtension.handleException(ex); return null; } }
public void doFullValidation(ResourceManager aResourceManager) throws ResourceInitializationException { // attempt to instantiate AE in "verification mode" Map<String, Object> m = new HashMap<String, Object>(); m.put(AnalysisEngineImplBase.PARAM_VERIFICATION_MODE, Boolean.TRUE); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(this, aResourceManager, m); validateSofaMappings(); ae.newCAS(); }
public void doFullValidation() throws ResourceInitializationException { // attempt to instantiate AE in "verification mode" Map<String, Object> m = new HashMap<String, Object>(); m.put(AnalysisEngineImplBase.PARAM_VERIFICATION_MODE, Boolean.TRUE); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(this, m); validateSofaMappings(); ae.newCAS(); }
public void initCPM() throws DictionaryLoaderException { try { ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); String dp = System.getProperty("uima.datapath"); if (null != dp) { resMgr.setDataPath(dp); } ae = UIMAFramework.produceAnalysisEngine(aeSpecifier); cas = ae.newCAS(); } catch (ResourceInitializationException e) { throw new DictionaryLoaderException(e); } catch (MalformedURLException e) { throw new DictionaryLoaderException(e); } }
System.out.println("analysis engine created."); CAS cas = ae.newCAS();
System.out.println("analysis engine created."); CAS cas = ae.newCAS();
public static void main(String[] args) throws Exception { URL url = TextMarkerEngine.class.getClassLoader().getResource("PlainTextAnnotator.xml"); if (url == null) { url = PlainTextAnnotator.class.getClassLoader().getResource( "org/apache/uima/textmarker/engine/PlainTextAnnotator.xml"); } XMLInputSource in = new XMLInputSource(url); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier); CAS cas = ae.newCAS(); cas.setDocumentText(FileUtils.file2String(new File( "D:/work/workspace-textmarker/Test/input/list1.txt"), "UTF-8")); ae.process(cas); AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex(); for (AnnotationFS annotationFS : annotationIndex) { System.out.println(annotationFS.getType().getShortName() + " : " + annotationFS.getCoveredText()); } }
protected void newCAS(PackageBrowser instPear, ResourceManager rsrcMgr) { // Create analysis engine from the installed PEAR package using // the created PEAR specifier XMLInputSource in = null; try { in = new XMLInputSource(instPear.getComponentPearDescPath()); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in); tae = UIMAFramework.produceAnalysisEngine(specifier, rsrcMgr, null); cas = tae.newCAS(); } catch (Exception e) { throw new RuntimeException(e); } finally { if(in != null) { try { in.close(); } catch (IOException e) { LOG.error("Exception while trying to close resource", e); } } } }
public PosUimaTokenizer(String tokens, AnalysisEngine engine, Collection<String> allowedPosTags) { if (engine == null) PosUimaTokenizer.engine = engine; this.allowedPosTags = allowedPosTags; this.tokens = new ArrayList<>(); try { if (cas == null) cas = engine.newCAS(); cas.reset(); cas.setDocumentText(tokens); PosUimaTokenizer.engine.process(cas); for (Sentence s : JCasUtil.select(cas.getJCas(), Sentence.class)) { for (Token t : JCasUtil.selectCovered(Token.class, s)) { //add NONE for each invalid token if (valid(t)) if (t.getLemma() != null) this.tokens.add(t.getLemma()); else if (t.getStem() != null) this.tokens.add(t.getStem()); else this.tokens.add(t.getCoveredText()); else this.tokens.add("NONE"); } } } catch (Exception e) { throw new RuntimeException(e); } }
public PosUimaTokenizer(String tokens,AnalysisEngine engine,Collection<String> allowedPosTags) { if(engine == null) PosUimaTokenizer.engine = engine; this.allowedPosTags = allowedPosTags; this.tokens = new ArrayList<>(); try { if(cas == null) cas = engine.newCAS(); cas.reset(); cas.setDocumentText(tokens); PosUimaTokenizer.engine.process(cas); for(Sentence s : JCasUtil.select(cas.getJCas(), Sentence.class)) { for(Token t : JCasUtil.selectCovered(Token.class,s)) { //add NONE for each invalid token if(valid(t)) if(t.getLemma() != null) this.tokens.add(t.getLemma()); else if(t.getStem() != null) this.tokens.add(t.getStem()); else this.tokens.add(t.getCoveredText()); else this.tokens.add("NONE"); } } } catch (Exception e) { throw new RuntimeException(e); } }
/** * performs a test on the initialized annotator. The specified document is * processed with the given language. * * @param text * a document text * @param language * the document text language * @return CAS - results of the analysis * @throws Exception passthru */ public CAS performTest(String text, String language) throws Exception { try { // Create a new CAS. CAS cas = this.ae.newCAS(); // Set the document text on the CAS. cas.setDocumentText(text); cas.setDocumentLanguage(language); // Process the sample document. this.ae.process(cas); return cas; } catch (Exception ex) { JUnitExtension.handleException(ex); } return null; }
/** * performs a test on the initialized annotator. The specified document is * processed with the given language. * * @param text * a document text * @param language * the document text language * @return CAS - results of the analysis * @throws Exception passthru */ public CAS performTest(String text, String language) throws Exception { try { // Create a new CAS. CAS cas = this.ae.newCAS(); // Set the document text on the CAS. cas.setDocumentText(text); cas.setDocumentLanguage(language); // Process the sample document. this.ae.process(cas); return cas; } catch (Exception ex) { JUnitExtension.handleException(ex); } return null; }
public static void main(String[] args) throws Exception { parseCmdLineArgs(args); ResourceManager resourceManager = null; if (classPath != null) { String[] split = classPath.split(File.pathSeparator); ClassLoader classLoader = getClassLoader(Arrays.asList(split)); resourceManager = new ResourceManager_impl(classLoader); } AnalysisEngine ae = Ruta.wrapAnalysisEngine(descriptor.toURI().toURL(), view, true, inputEncoding, resourceManager); configure(ae); CAS cas = ae.newCAS(); List<File> inputFiles = getFiles(inputFolder, inputRecursive); for (File file : inputFiles) { processFile(file, ae, cas); } ae.batchProcessComplete(new ProcessTrace_impl()); ae.collectionProcessComplete(new ProcessTrace_impl()); cas.release(); ae.destroy(); }
/** * analyzes the tokenizer input using the given analysis engine * <p> * {@link #cas} will be filled with extracted metadata (UIMA annotations, feature structures) * * @throws IOException If there is a low-level I/O error. */ protected void analyzeInput() throws ResourceInitializationException, AnalysisEngineProcessException, IOException { if (ae == null) { ae = AEProviderFactory.getInstance().getAEProvider(null, descriptorPath, configurationParameters).getAE(); } if (cas == null) { cas = ae.newCAS(); } else { cas.reset(); } cas.setDocumentText(toString(input)); ae.process(cas); }
CAS cas = ae.newCAS();