Hi,

you can access these annotations like any other annotation in UIMA.

... with plain UIMA:

Type yearType = cas.getTypeSystem().getType("uima.ruta.example.Year");
AnnotationIndex<AnnotationFS> annotationIndex =
cas.getAnnotationIndex(yearType);
for (AnnotationFS each : annotationIndex) {
  System.out.println(each.getCoveredText());
}

... with JCas cover classes and uimaFIT:

for (Year year : JCasUtil.select(jCas, Year.class)) {
   System.out.println(year.getCoveredText());
}

If you are familiar with maven, you should take a look at the new
example project "ruta-maven-example".

Best,

Peter


Am 17.10.2015 um 12:52 schrieb Olivier Austina:
> Hi,
> I am learning UIMA ruta. How to get annotations from a java program? I
> follow this code in the UIMA ruta document:
>
> File specFile = new File("pathToMyWorkspace/MyProject/descriptor/"+
>     "my/package/MyScriptEngine.xml");
> XMLInputSource in = new XMLInputSource(specFile);
> ResourceSpecifier specifier = UIMAFramework.getXMLParser().
>     parseResourceSpecifier(in);
> // for import by name... set the datapath in the ResourceManager
> AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
> CAS cas = ae.newCAS();
> cas.setDocumentText("This is my document.");
> ae.process(cas);
>
> How to print for example the type Year for the ExampleProject in UIMA
> ruta source release ? Thank you.
>
> Regards
> Olivier
>

Reply via email to