reckart commented on issue #168: URL: https://github.com/apache/uima-ruta/issues/168#issuecomment-2278050915
I am unable to reproduce the issue on the 3.3.x branch ``` package org.apache.uima.ruta; import static java.util.Arrays.asList; import org.apache.uima.cas.CAS; import org.apache.uima.cas.Type; import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.fit.factory.TypeSystemDescriptionFactory; import org.apache.uima.resource.metadata.TypeSystemDescription; import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl; import org.apache.uima.ruta.engine.Ruta; import org.apache.uima.util.CasCreationUtils; public class RutaScriptExample { private static final String DOCUMENT = "org.apache.uima.ruta.type.Document"; public static void main(String[] args) { try { // Create a TypeSystemDescription with a type x.y.z.Document TypeSystemDescription tsDesc = new TypeSystemDescription_impl(); tsDesc.addType(DOCUMENT, "", "uima.tcas.Annotation"); TypeSystemDescription tsDefault = TypeSystemDescriptionFactory.createTypeSystemDescription(); TypeSystemDescription tsAll = CasCreationUtils.mergeTypeSystems(asList(tsDesc, tsDefault)); // Create a CAS with the type system CAS cas = CasCreationUtils.createCas(tsAll, null, null); // Add some text to the CAS cas.setDocumentText("This is a sample document."); // Create an annotation of type Document Type documentType = cas.getTypeSystem().getType(DOCUMENT); AnnotationFS documentAnnotation = cas.createAnnotation(documentType, 0, cas.getDocumentText().length()); cas.addFsToIndexes(documentAnnotation); // Define a Ruta script that uses the rule Document{-> ...} String rutaScript = "Document{-> NUM};"; // Apply the Ruta script to the CAS Ruta.apply(cas, rutaScript); } catch (Exception e) { // Catch and handle any exceptions that occur System.err.println("An error occurred while applying the Ruta script:"); e.printStackTrace(); } } } ``` @viorell91 suggested on the mailing list to try disambiguating the type in the scripts: ``` TYPE Document1 = org.apache.uima.ruta.type.Document; TYPE Document2 = uima.tcas.DocumentAnnotation; Document1{ -> CREATE(MyAnnotation)}; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@uima.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org