### Question:
AnnotationAddressExpression extends AbstractAnnotationExpression { public String getAddress() { return address; } AnnotationAddressExpression(String address); @Override AnnotationFS getAnnotation(MatchContext context, RutaStream stream); @Override FeatureStructure getFeatureStructure(MatchContext context, RutaStream stream); String getAddress();  }### Answer:
@Test public void testMatching() { String document = "Some text."; CAS cas = null; try { cas = RutaTestUtils.getCAS(document); } catch (Exception e) { e.printStackTrace(); } Type t1 = RutaTestUtils.getTestType(cas, 1); AnnotationFS a1 = cas.createAnnotation(t1, 5, 9); cas.addFsToIndexes(a1); int ref = 0; if (a1 instanceof AnnotationImpl) { AnnotationImpl aImpl = (AnnotationImpl) a1; ref = aImpl.getAddress(); } String script = ""; script += "$" + ref + "{REGEXP(\".*ex.*\")-> T2};"; script += "W $" + ref + "{REGEXP(\".*ex.*\")-> T3};"; try { Ruta.apply(cas, script); } catch (Exception e) { e.printStackTrace(); } RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "text"); RutaTestUtils.assertAnnotationsEquals(cas, 3, 1, "text"); if (cas != null) { cas.release(); } }
@Test public void testFeatureAssignment() { String document = "Some text."; Map<String, String> typeMap = new TreeMap<String, String>(); String typeName = "Struct"; typeMap.put(typeName, "uima.tcas.Annotation"); Map<String, List<TestFeature>> featureMap = new TreeMap<String, List<TestFeature>>(); List<TestFeature> list = new ArrayList<RutaTestUtils.TestFeature>(); featureMap.put(typeName, list); String fn = "a"; list.add(new TestFeature(fn, "", "uima.tcas.Annotation")); CAS cas = null; try { cas = RutaTestUtils.getCAS(document, typeMap, featureMap); } catch (Exception e) { e.printStackTrace(); } Type t1 = RutaTestUtils.getTestType(cas, 1); AnnotationFS a1 = cas.createAnnotation(t1, 5, 9); cas.addFsToIndexes(a1); int ref = 0; if (a1 instanceof AnnotationImpl) { AnnotationImpl aImpl = (AnnotationImpl) a1; ref = aImpl.getAddress(); } String script = ""; script += "CREATE(Struct, \"a\" = $"+ref+");"; try { Ruta.apply(cas, script); } catch (Exception e) { e.printStackTrace(); } Type t = null; AnnotationIndex<AnnotationFS> ai = null; FSIterator<AnnotationFS> iterator = null; t = cas.getTypeSystem().getType(typeName); Feature f1 = t.getFeatureByBaseName(fn); ai = cas.getAnnotationIndex(t); assertEquals(1, ai.size()); iterator = ai.iterator(); AnnotationFS next = iterator.next(); assertEquals("Some text.", next.getCoveredText()); AnnotationFS a = (AnnotationFS) next.getFeatureValue(f1); assertNotNull("Feature value is null!", a); assertEquals("text", a.getCoveredText()); if (cas != null) { cas.release(); } }