/** * Resets the CAS (Common Analysis System), emptying it of all content. * * @param jcas JCas object */ public static void resetCAS(JCas jcas) { if (jcas != null) { jcas.reset(); } }
/** * Resets the CAS (Common Analysis System), emptying it of all content. * * @param jcas JCas object */ public static void resetCAS(JCas jcas) { if (jcas != null) { jcas.reset(); } }
/** * Resets the CAS (Common Analysis System), emptying it of all content. * * @param jcas JCas object */ public static void resetCAS(JCas jcas) { if (jcas != null) { jcas.reset(); } }
public JCas borrowJCas() throws ResourceInitializationException { synchronized (this) { if (!mJCasList.isEmpty()) { int last = mJCasList.size() - 1; JCas res = mJCasList.get(last); mJCasList.remove(last); res.reset(); return res; } return mEngine.newJCas(); } }
@Override public void reset() throws CASAdminException { testLiveness(); delegate.reset(); }
@Override public void processRow(ResultSet rs) throws SQLException { // InputStream in = lobHandler.getBlobAsBinaryStream(rs, "xcas"); // Work with sqlite jdbc driver InputStream in = new ByteArrayInputStream(lobHandler.getBlobAsBytes(rs, "xcas")); try { nextCas.reset(); BasePhase.deserializeCAS(nextCas.getCas(), in); processedCas = true; } catch (Exception e) { throw new SQLException(e); } }
@Before public void beforeTest() { jCas.reset(); }
@Before public void beforeTest() { jCas.reset(); }
@Before public void setup() { jCas.reset(); }
private void processDocument(JCas jCas) throws IOException, CollectionException { LOGGER.debug("Beginning processing of document on {} {}", getType(), name); // Get next document from Collection Reader collectionReader.getNext(jCas.getCas()); // Process JCas with each annotator in turn for (AnalysisEngine ae : annotators) { processAnalysisEngine(jCas, ae, "annotator"); } // Process JCas with each consumer in turn for (AnalysisEngine ae : consumers) { processAnalysisEngine(jCas, ae, "consumer"); } // Prepare the JCas for the next document jCas.reset(); }
@After public void tearDown() throws IOException { // clearElasticsearchIndex(); jCas.reset(); elasticsearch.close(); }
protected JobSettings execute(AnalysisEngine... analysisEngines) throws AnalysisEngineProcessException { jCas.reset(); for (AnalysisEngine ae : analysisEngines) { ae.process(jCas); } return new JobSettings(jCas); }
private void assertNotFoundMoney(String text) throws Exception { jCas.reset(); jCas.setDocumentText(text); processJCas(); assertEquals(0, JCasUtil.select(jCas, Money.class).size()); } }
public static JCas getJCasInstance() throws UIMAException { if (jCas == null) { jCas = JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()); } else { jCas.reset(); } return jCas; } }
@Test public void testBad() throws Exception { jCas.setDocumentText("This test was written at 301137Z FEB 13"); processJCas(); assertEquals(0, JCasUtil.select(jCas, Temporal.class).size()); jCas.reset(); jCas.setDocumentText("This test was written at 901137Z FEB 13"); processJCas(); assertEquals(0, JCasUtil.select(jCas, Temporal.class).size()); } }
@Test public void testNoTearline() throws Exception { JCas jCas = JCasSingleton.getJCasInstance(); BaleenContentExtractor contentExtractor = new TearlineContentExtractor(); contentExtractor.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); File f = new File(getClass().getResource("tearline/notearline.docx").getPath()); try (InputStream is = new FileInputStream(f); ) { contentExtractor.processStream(is, f.getPath(), jCas); assertEquals("This document has no tearline.", jCas.getDocumentText()); jCas.reset(); } contentExtractor.destroy(); }
private String assertFoundMoney(String text, Double amount, String currency) throws Exception { jCas.reset(); jCas.setDocumentText(text); processJCas(); assertEquals(1, JCasUtil.select(jCas, Money.class).size()); Money m = JCasUtil.selectByIndex(jCas, Money.class, 0); assertEquals(amount, m.getAmount(), 0.00000001); assertEquals(currency, m.getCurrency()); return m.getValue(); }
private void assertNextSourceNotNull(BaleenCollectionReader bcr) throws Exception { assertTrue(bcr.doHasNext()); bcr.getNext(jCas.getCas()); assertNotNull(getSource(jCas)); jCas.reset(); }
protected void createEntitiesDocument2() { jCas.reset(); jCas.setDocumentText( "Paula went to London on 12th February 2017. In Paris, she met a UID male."); Annotations.createPerson(jCas, 0, 5, "Paula"); Annotations.createLocation(jCas, 47, 53, "Paris", null); Temporal d = Annotations.createTemporal(jCas, 24, 42, ""); d.setConfidence(1.0); Entity e = new Entity(jCas); e.setBegin(14); e.setEnd(20); e.setValue("London"); e.addToIndexes(); }
protected void createMetadataDocument() { jCas.reset(); jCas.setDocumentText("Hello World"); PublishedId pid1 = new PublishedId(jCas); pid1.setValue("id_1"); pid1.addToIndexes(); PublishedId pid2 = new PublishedId(jCas); pid2.setValue("id_2"); pid2.addToIndexes(); Annotations.createMetadata(jCas, "sourceAndInformationGrading", "D3"); Annotations.createMetadata(jCas, "countryInfo", "ENG|WAL|SCO"); Annotations.createMetadata(jCas, "documentTitle", "Test Title"); Annotations.createMetadata(jCas, "test_key", "test_value"); }