You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.IllegalArgumentException: Document is ambiguous, use one of the following instead : org.apache.uima.ruta.type.Document uima.tcas.DocumentAnnotation
The text was updated successfully, but these errors were encountered:
@pkluegl Could you please help out what is going wrong and mostly its occurring when it runs in batch.
I don't have any multiple versions too.
and why Ruta thinks that "Document" should be a valid name for "Document" annotation.
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)};
I am using below versions:
versions used:
[uimaj-3.4.1]
[uimafit-3.4.0]
[ruta-3.3.0]
[cleartk-3.0.0]
java.lang.IllegalArgumentException: Document is ambiguous, use one of the following instead : org.apache.uima.ruta.type.Document uima.tcas.DocumentAnnotation
The text was updated successfully, but these errors were encountered: