Java Code Examples for org.apache.uima.cas.impl.CASImpl#getJCas()
The following examples show how to use
org.apache.uima.cas.impl.CASImpl#getJCas() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonCasSerializerTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
private void setupTypeSystem(String tsdName) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { File tsdFile = JUnitExtension.getFile("CasSerialization/desc/" + tsdName); tsd = parser.parseTypeSystemDescription(new XMLInputSource(tsdFile)); cas = (CASImpl) CasCreationUtils.createCas(tsd, null, null); // cas.getSofaRef(); // creates the default sofa jcas = cas.getJCas(); tsi = cas.getTypeSystemImpl(); topType = (TypeImpl) tsi.getTopType(); annotationType = (TypeImpl) tsi.getType("uima.tcas.Annotation"); allTypesType = (TypeImpl) tsi.getType("org.apache.uima.test.AllTypes"); tokenType = (TypeImpl) tsi.getType("org.apache.uima.test.Token"); emptyIntListType = (TypeImpl) tsi.getType("uima.cas.EmptyIntegerList"); // nonEmptyIntListType = (TypeImpl) tsi.getType("uima.cas.NonEmptyIntegerList"); // emptyFSListType = (TypeImpl) tsi.getType("uima.cas.EmptyFSList"); // nonEmptyFSListType = (TypeImpl) tsi.getType("uima.cas.NonEmptyFSList"); }
Example 2
Source File: AnnotationIndexTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
protected void setUp() throws Exception { long startTime = System.nanoTime(); TypeSystemDescription typeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(typeSystemFile1)); System.out.format("time to parse ts: %,d%n", (System.nanoTime() - startTime)/ 1000000); startTime = System.nanoTime(); cas = (CASImpl) CasCreationUtils.createCas(typeSystemDescription, new TypePriorities_impl(), null); jcas = cas.getJCas(); ir = (FSIndexRepositoryImpl) cas.getIndexRepository(); ai = cas.getAnnotationIndex(); tsi = cas.getTypeSystemImpl(); topType = tsi.getTopType(); System.out.format("time to create CAS: %,d%n", (System.nanoTime() - startTime)/ 1000000); startTime = System.nanoTime(); //prefill int[] ttt = new int[SZp2]; for (int i = 0; i < SZp2; i++) { ttt[i] = i;} ttt = shuffle(ttt); for (int i = 0; i < SZp2; i++) { as[ttt[i]] = new Annotation(jcas, i, i + 200); ir.addFS(as[ttt[i]]); } System.out.format("time to create Annotations, add to indexes: %,d%n", (System.nanoTime() - startTime)/ 1000000); startTime = System.nanoTime(); }
Example 3
Source File: JsonCasSerializerTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
private FeatureStructure setAllValues(int v) throws CASException { cas = (CASImpl) cas.getView(CAS.NAME_DEFAULT_SOFA); // create the default initial view sofa. JCas jcas = cas.getJCas(); boolean s1 = v == 0; boolean s2 = v == 1; FeatureStructure fs = cas.createFS(allTypesType); cas.addFsToIndexes(fs); FeatureStructure fs2 = cas.createFS(allTypesType); fs.setBooleanValue(allTypesType.getFeatureByBaseName("aBoolean"), s1 ? true : false); fs.setByteValue (allTypesType.getFeatureByBaseName("aByte"), s1 ? (byte) -117 : (byte) 0); fs.setShortValue (allTypesType.getFeatureByBaseName("aShort"), s1 ? (short) -112 : (short) 0); fs.setIntValue (allTypesType.getFeatureByBaseName("aInteger"), s1 ? 0 : 1); fs.setLongValue (allTypesType.getFeatureByBaseName("aLong"), s2 ? 4321 : 1234); fs.setFloatValue (allTypesType.getFeatureByBaseName("aFloat"), s1 ? 1.3F : Float.NaN); fs.setDoubleValue (allTypesType.getFeatureByBaseName("aDouble"), s2 ? Float.NEGATIVE_INFINITY : 2.6); fs.setStringValue (allTypesType.getFeatureByBaseName("aString"), "some \"String\""); fs.setFeatureValue(allTypesType.getFeatureByBaseName("aFS"), fs2); FeatureStructure fsAboolean = cas.createBooleanArrayFS(s1 ? 1 : 0); ByteArray fsAbyte = new ByteArray(jcas, s1 ? 2 : 0); if (s1) { fsAbyte.set(0, (byte) 15); fsAbyte.set(1, (byte) 0xee); } FeatureStructure fsAshort = cas.createShortArrayFS(s2 ? 2 : 0); FeatureStructure fsAstring = cas.createStringArrayFS(s1 ? 1 : 0); fsa1 = cas.createFS(allTypesType); fsa2 = cas.createFS(allTypesType); fsa3 = cas.createFS(allTypesType); fsaa = new FSArray(jcas, 3); fsaa.set(0, fsa1); fsaa.set(1, fsa2); fsaa.set(2, fsa3);; FeatureStructure fsMrAboolean = cas.createBooleanArrayFS(1); FeatureStructure fsMrAbyte = cas.createByteArrayFS(2); FeatureStructure fsMrAshort = cas.createShortArrayFS(0); FeatureStructure fsMrAstring = cas.createStringArrayFS(1); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayBoolean"), fsAboolean); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayByte"), fsAbyte); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayShort"), fsAshort); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayString"), fsAstring); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayMrBoolean"), fsMrAboolean); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayMrByte"), fsMrAbyte); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayMrShort"), fsMrAshort); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aArrayMrString"), fsMrAstring); FeatureStructure fsLinteger0 = cas.createFS(tsi.getType(CAS.TYPE_NAME_EMPTY_INTEGER_LIST)); FeatureStructure fsLstring0 = cas.createFS(tsi.getType(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST)); FeatureStructure fsLstring1 = cas.createFS(tsi.getType(CAS.TYPE_NAME_EMPTY_STRING_LIST)); fsLstring0.setStringValue (tsi.getFeatureByFullName(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST + ":head"), "testStr"); fsLstring0.setFeatureValue (tsi.getFeatureByFullName(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST + ":tail"), fsLstring1); FeatureStructure fsLfs0 = cas.createFS(tsi.getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST)); FeatureStructure fsLfs1 = cas.createFS(tsi.getType(CAS.TYPE_NAME_EMPTY_FS_LIST)); fsLfs0.setFeatureValue (tsi.getFeatureByFullName(CAS.TYPE_NAME_NON_EMPTY_FS_LIST + ":tail"), fsLfs1); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aListInteger"), fsLinteger0); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aListString"), fsLstring0); fs.setFeatureValue (allTypesType.getFeatureByBaseName("aListFs"), fsLfs0); cas.addFsToIndexes(fs); return fs; }