private CAS getEmptyCas() throws ResourceInitializationException { CAS cas = null; while(cas == null) { // Use class level locking to serialize access to CasCreationUtils // Only one thread at the time can create a CAS. UIMA uses lazy // initialization approach which can cause NPE when two threads // attempt to initialize a CAS. synchronized( CasCreationUtils.class) { cas = CasCreationUtils.createCas(cr_tsd, cr_tp, cr_fid, cr_properties); } } return cas; }
/** * Create a new JCas for the given type system description. No auto-detection type priorities, or * indexes is performed. * * @param typeSystemDescription * a type system description to initialize the JCas * @return a new JCas * @throws UIMAException * if the JCas could not be initialized */ public static JCas createJCas(TypeSystemDescription typeSystemDescription) throws UIMAException { return CasCreationUtils.createCas(typeSystemDescription, null, null).getJCas(); }
public DynamicTypeGenerator(TypeSystemDescription typeSystemDescription) { try { JCas jCas = CasCreationUtils.createCas(typeSystemDescription, null, null).getJCas(); this.typeSystemDescription = typeSystemDescription; customTypes = new HashSet<>(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
public DynamicTypeGenerator(ArrayList<TypeSystemDescription> typeSystemDescriptions) { try { TypeSystemDescription mergedTypeSystem = CasCreationUtils.mergeTypeSystems(typeSystemDescriptions); this.typeSystemDescription = mergedTypeSystem; JCas jCas = CasCreationUtils.createCas(mergedTypeSystem, null, null).getJCas(); customTypes = new HashSet<>(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
@Override public JCas createJCas() throws CASException, ResourceInitializationException { return CasCreationUtils.createCas(casManager.getCasDefinition(), null).getJCas(); } }
public CASWritable() { try { cas = CasCreationUtils.createCas(createTypeSystemDescription(), null, null); } catch (ResourceInitializationException e) { e.printStackTrace(); } }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
@Override public CAS prepareCasForExport(CAS aCas, SourceDocument aSourceDocument) throws ResourceInitializationException, UIMAException, IOException { CAS exportCas = CasCreationUtils.createCas((TypeSystemDescription) null, null, null); upgradeCas(aCas, exportCas, getFullProjectTypeSystem(aSourceDocument.getProject(), false)); return exportCas; }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
@Override public CAS prepareCasForExport(CAS aCas, SourceDocument aSourceDocument) throws ResourceInitializationException, UIMAException, IOException { CAS exportCas = CasCreationUtils.createCas((TypeSystemDescription) null, null, null); upgradeCas(aCas, exportCas, getFullProjectTypeSystem(aSourceDocument.getProject(), false)); return exportCas; }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
/** * @see org.apache.uima.analysis_engine.AnalysisEngine#newCAS() */ public synchronized CAS newCAS() throws ResourceInitializationException { CasDefinition casDef = getCasManager().getCasDefinition(); return CasCreationUtils.createCas(casDef, getPerformanceTuningSettings()); }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
private void analyzeTypeSystem(TypeSystemDescription aTSD) throws ResourceInitializationException { // We create a CAS from which we can obtain an instantiated type system. With that, it // is easier to check type inheritance. CAS cas = CasCreationUtils.createCas(aTSD, null, null); TypeSystem ts = cas.getTypeSystem(); for (TypeDescription td : aTSD.getTypes()) { analyzeType(ts, aTSD, td); } log.debug("Recognized {} of {} types as layers ({}%)", getLayers().size(), aTSD.getTypes().length, getLayers().size() * 100 / aTSD.getTypes().length); }
private void analyzeTypeSystem(TypeSystemDescription aTSD) throws ResourceInitializationException { // We create a CAS from which we can obtain an instantiated type system. With that, it // is easier to check type inheritance. CAS cas = CasCreationUtils.createCas(aTSD, null, null); TypeSystem ts = cas.getTypeSystem(); for (TypeDescription td : aTSD.getTypes()) { analyzeType(ts, aTSD, td); } log.debug("Recognized {} of {} types as layers ({}%)", getLayers().size(), aTSD.getTypes().length, getLayers().size() * 100 / aTSD.getTypes().length); }
public JCas initJCas() { JCas jCas = null; try { jCas = CasCreationUtils.createCas(dynamicTypeGenerator.getTypeSystemDescription(), null, null).getJCas(); } catch (CASException e) { e.printStackTrace(); } catch (ResourceInitializationException e) { e.printStackTrace(); } return jCas; }
public JCas initJCas() { JCas jCas = null; try { jCas = CasCreationUtils.createCas(dynamicTypeGenerator.getTypeSystemDescription(), null, null).getJCas(); } catch (CASException e) { e.printStackTrace(); } catch (ResourceInitializationException e) { e.printStackTrace(); } return jCas; }
public JCas initJCas() { JCas jCas = null; try { jCas = CasCreationUtils.createCas(dynamicTypeGenerator.getTypeSystemDescription(), null, null).getJCas(); } catch (CASException e) { e.printStackTrace(); } catch (ResourceInitializationException e) { e.printStackTrace(); } return jCas; }
@Override public JCas readInitialCas(TrainingDocument aDocument) throws CASException, ResourceInitializationException, IOException { JCas jcas = CasCreationUtils.createCas((TypeSystemDescription) null, null, null).getJCas(); CasPersistenceUtils.readSerializedCas(jcas, getCasFile(aDocument)); automationCasStorageService.analyzeAndRepair(aDocument, jcas.getCas()); return jcas; }
public void read() throws Exception { CollectionReader xmiReader = CollectionReaderFactory.createReader(XmiReader.class, ResourceCollectionReaderBase.PARAM_SOURCE_LOCATION, testFolder.getRoot().getPath(), ResourceCollectionReaderBase.PARAM_PATTERNS, new String[] { ResourceCollectionReaderBase.INCLUDE_PREFIX + "*.xmi" }); CAS cas = CasCreationUtils.createCas(createTypeSystemDescription(), null, null); xmiReader.getNext(cas); String refText = readFileToString(new File("src/test/resources/texts/latin.txt")); assertEquals(refText, cas.getDocumentText()); assertEquals("latin", cas.getDocumentLanguage()); }