@Test public void test() { String document = "some text 1 some text 2 some text"; String script = ""; script += "BLOCK(B) NUM{REGEXP(\"1\")}{\n"; script += "Document{-> T1};\n"; script += "DOCUMENTBLOCK SW{REGEXP(\"text\")}{\n"; script += "Document{-> T2};\n"; script += "}"; script += "}"; Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(RutaEngine.PARAM_ADDITIONAL_EXTENSIONS, new String[] { DocumentBlockExtension.class.getName() }); CAS cas = null; try { cas = RutaTestUtils.getCAS(document); Ruta.apply(cas, script, parameters); } catch (Exception e) { e.printStackTrace(); } RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "1"); RutaTestUtils.assertAnnotationsEquals(cas, 2, 3, "text", "text", "text"); if (cas != null) { cas.release(); } }
@Override public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) { CAS cas = stream.getCas(); AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType()); ScriptApply result = super.apply(completeStream, crowd); return result; }
DocumentBlock extends RutaScriptBlock { @Override public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) { CAS cas = stream.getCas(); AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType()); ScriptApply result = super.apply(completeStream, crowd); return result; } }
DocumentBlock extends RutaScriptBlock { @Override public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) { CAS cas = stream.getCas(); AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType()); ScriptApply result = super.apply(completeStream, crowd); return result; } DocumentBlock(RutaBlock parent, String defaultNamespace); }
DocumentBlock extends RutaScriptBlock { @Override public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) { CAS cas = stream.getCas(); AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType()); ScriptApply result = super.apply(completeStream, crowd); return result; } DocumentBlock(RutaBlock parent, String defaultNamespace); @Override ScriptApply apply(RutaStream stream, InferenceCrowd crowd); }
DocumentBlock extends RutaScriptBlock { @Override public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) { CAS cas = stream.getCas(); AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType()); ScriptApply result = super.apply(completeStream, crowd); return result; } DocumentBlock(RutaBlock parent, String defaultNamespace); @Override ScriptApply apply(RutaStream stream, InferenceCrowd crowd);  }