Search code examples
uimaruta

Type "Sentence" not defined in this script/block in UIMA Ruta


I am getting a

Type "Sentence" not defined in this script/block!

error when writing a "Sentence" block in "main.ruta".

Here is my uima ruta script:

PACKAGE com.example.test;
DECLARE ApplyBusinessCardKeyword;
WORDLIST ApplicationKeywordList = 'application.txt';
Sentence{->MARKFAST(ApplyBusinessCardKeyword, ApplicationKeywordList)};

This also happens with the "Paragraph" annotation. Other annotations like "Document" work fine.

Any ideas of what I could be doing wrong?

I am using the latest UIMA Workbench (2.6.1) and Runtime (2.10.2).

Here is the full error stack:

Dec 13, 2017 5:02:25 PM org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl callAnalysisComponentProcess(434)
SEVERE: Exception occurred
org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator processing failed.    
    at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:563)
    at org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:401)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:318)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:269)
    at org.apache.uima.ruta.ide.launching.RutaLauncher.processFile(RutaLauncher.java:242)
    at org.apache.uima.ruta.ide.launching.RutaLauncher.main(RutaLauncher.java:191)
Caused by: java.lang.IllegalArgumentException: Not able to resolve annotation/type expression: Sentence
    at org.apache.uima.ruta.expression.MatchReference.resolve(MatchReference.java:132)
    at org.apache.uima.ruta.expression.MatchReference.getAnnotationExpression(MatchReference.java:173)
    at org.apache.uima.ruta.expression.AnnotationTypeExpression.initialize(AnnotationTypeExpression.java:59)
    at org.apache.uima.ruta.expression.AnnotationTypeExpression.getType(AnnotationTypeExpression.java:152)
    at org.apache.uima.ruta.rule.RutaAnnotationTypeMatcher.getMatchingAnnotations(RutaAnnotationTypeMatcher.java:55)
    at org.apache.uima.ruta.rule.RutaRuleElement.getAnchors(RutaRuleElement.java:51)
    at org.apache.uima.ruta.rule.RutaRuleElement.startMatch(RutaRuleElement.java:59)
    at org.apache.uima.ruta.rule.ComposedRuleElement.startMatch(ComposedRuleElement.java:76)
    at org.apache.uima.ruta.rule.RutaRule.apply(RutaRule.java:63)
    at org.apache.uima.ruta.rule.RutaRule.apply(RutaRule.java:54)
    at org.apache.uima.ruta.rule.RutaRule.apply(RutaRule.java:36)
    at org.apache.uima.ruta.block.RutaScriptBlock.apply(RutaScriptBlock.java:67)
    at org.apache.uima.ruta.RutaModule.apply(RutaModule.java:56)
    at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:561)
    ... 6 more

Solution

  • As far as I know, you need to create your own rules to annotate sentences and paragraphs, and from your example you're not doing this.

    Check this link from the documentation https://uima.apache.org/d/ruta-current/tools.ruta.book.html#ugr.tools.ruta.language.seeding it contains the basic annotations of a RUTA engine

    This example that create sentences is taken from the documentation

    DECLARE Sentence; PERIOD #{-> MARK(Sentence)} PERIOD;

    For paragraphs it's a bit trickier, and if you checked the documentation you'll notice that they use some properties to check it (bold, for example), you'll need to create your own rules to find annotate them