private JCas createJas() throws ResourceInitializationException { try { return JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()); } catch (UIMAException e) { throw new ResourceInitializationException(e); } }
/** * Constructor * * <p>Type system provided by {@link JCasFactory} * * @param includedTypeNames The (full) class names of the types to convert (eg * Person.class.getName()) * @throws UIMAException if type system can not be created */ public TaxonomyFactory(String[] includedTypeNames) throws UIMAException { this(JCasFactory.createJCas().getTypeSystem(), includedTypeNames); }
@Before public void setUp() throws Exception { jCas = JCasFactory.createJCas(); outputDirectory = folder.newFolder("output"); outputDirectoryName = outputDirectory.getPath(); } }
private JCas readCas(Reader reader) throws UIMAException, IOException, SAXException { JCas jcas = JCasFactory .createJCas(annotationSchemaService.getFullProjectTypeSystem(project)); String xmi = IOUtils.toString(reader); // Get the annotations from the XMI are back in the CAS. XmiCasDeserializer.deserialize(new ByteArrayInputStream(xmi.getBytes()), jcas.getCas()); return jcas; }
public ToIOBConverter() throws Exception { jtbd = AnalysisEngineFactory.createEngine("de.julielab.jcore.ae.jtbd.desc.jcore-jtbd-ae-biomedical-english"); pennbioIEPosTagger = AnalysisEngineFactory .createEngine("de.julielab.jcore.ae.opennlp.postag.desc.jcore-opennlp-postag-ae-biomedical-english"); jCas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-morpho-syntax-types"); }
public static JCas newCasFromFile(String filePath, String docId) throws UIMAException { JCas jCas = JCasFactory.createJCas(); Header header = new Header(jCas); header.setDocId(docId); header.setSource(filePath); header.addToIndexes(); return jCas; }
public static void main(String[] args) throws UIMAException, IOException { String sampleSentence = "He still is not able to work because of severe pain involving his wrists."; JCas jCas = JCasFactory.createJCas(); jCas.setDocumentText(sampleSentence); AnalysisEngine relationExtractor = AnalysisEngineFactory.createEngineFromPath( "desc/analysis_engine/RelationExtractorAggregate.xml"); AnalysisEngine relationConsumer = AnalysisEngineFactory.createEngine( RelationExtractorConsumer.class); SimplePipeline.runPipeline(jCas, relationExtractor, relationConsumer); } }
@Test public void testClearJCasWithoutDocumentMetadata() throws Exception { JCas jcas = JCasFactory.createJCas(); BratAnnotatorUtility.clearJcasAnnotations(jcas); } }
@Before public void setUp() throws UIMAException { JCas jCas = JCasFactory.createJCas(); typeSystem = jCas.getTypeSystem(); }
public static JCas getJCasInstance() throws UIMAException { if (jCas == null) { jCas = JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()); } else { jCas.reset(); } return jCas; } }
@BeforeClass public static void setupClass() throws UIMAException { typeSystemDescription = TypeSystemSingleton.getTypeSystemDescriptionInstance(); jCas = JCasFactory.createJCas(typeSystemDescription); }
@Test public void testAnalyze() throws Exception { JCas jcas = JCasFactory.createJCas(); TsvSchema schema = Tsv3XCasSchemaAnalyzer.analyze(jcas.getTypeSystem()); for (TsvColumn col : schema.getColumns()) { System.out.println(col); } } }
public static JCas read(String aPath) throws UIMAException, IOException { CollectionReader reader = createReader(Conll2006Reader.class, Conll2006Reader.PARAM_SOURCE_LOCATION, "src/test/resources/" + aPath); JCas jcas = JCasFactory.createJCas(); reader.getNext(jcas.getCas()); return jcas; }
@Before public void before() throws UIMAException { noTextJCas = JCasFactory.createJCas(); noTextJCas.setDocumentText("This is text and more text"); textJCas = JCasFactory.createJCas(); textJCas.setDocumentText("This is text and more text"); final Text text = new Text(textJCas, 8, 12); text.addToIndexes(); final Text moreText = new Text(textJCas, 17, 26); moreText.addToIndexes(); }
private static JCas makeJCas() throws UIMAException { TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription(); TypeSystemDescription local = TypeSystemDescriptionFactory .createTypeSystemDescriptionFromPath( "src/test/resources/desc/type/webannoTestTypes.xml"); TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local)); JCas jcas = JCasFactory.createJCas(merged); DocumentMetaData.create(jcas).setDocumentId("doc"); return jcas; }
@Before public void setUp() throws UIMAException { JCas jCas = JCasFactory.createJCas(); addMetadata(jCas, KEY1, VALUE1); addMetadata(jCas, KEY2, VALUE2); addMetadata(jCas, KEY2, VALUE3); metadata = new JCasMetadata(jCas); }
@Test public void docHash() throws Exception { JCas jcas = JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()); jcas.setDocumentText("There is the mention of some entity in this sentence."); DocumentAnnotation doc = (DocumentAnnotation) jcas.getDocumentAnnotationFs(); assertEquals("87cebccde680225b7640878d334b4cbb1c048ba1c8e66763f72cca5396a37807", doc.getHash()); } }
@Test public void testRecordable() throws UIMAException { JCas jCas = JCasFactory.createJCas(); FakeRecordable fakeRecordable = new FakeRecordable(jCas); assertEquals(new Annotation(jCas).getType().getName(), fakeRecordable.getTypeName()); }
@Test public void testDocumentGraphMetadataHasContentFromJCas() throws UIMAException { DocumentGraphOptions options = DocumentGraphOptions.builder().withContent(true).build(); DocumentGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); Variables variables = graph.variables(); assertEquals(JCasTestGraphUtil.CONTENT, variables.get(FIELD_CONTENT).orElse("")); }
@Test public void testGetOffsetText() throws UIMAException { JCas jCas = JCasFactory.createJCas(); jCas.setDocumentText("This is a test."); assertEquals("", OffsetUtil.getText(jCas, new Offset(0, 0))); assertEquals("This", OffsetUtil.getText(jCas, new Offset(0, 4))); assertEquals(" is a ", OffsetUtil.getText(jCas, new Offset(4, 10))); assertEquals("This is a test.", OffsetUtil.getText(jCas, new Offset(0, 15))); }