@Test public void test() throws Exception { URL url = RutaEngine.class.getClassLoader().getResource("BasicEngine.xml"); if (url == null) { url = RutaTestUtils.class.getClassLoader() .getResource("org/apache/uima/ruta/engine/BasicEngine.xml"); } XMLInputSource in = new XMLInputSource(url); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier); CAS cas = ae.newCAS(); String text = "Different kinds of tokens like ApacheUIMA % &amp; <nomarkup !?.;:," + " and also <FONT CLASS=\"western\" ALIGN=JUSTIFY " + "STYLE=\"margin-bottom: 0cm\">html <b>markup</b></FONT>" + "<br/>\n"; cas.setDocumentText(text); DefaultSeeder seeder = new DefaultSeeder(); Type type = seeder.seed(text, cas); assertEquals("org.apache.uima.ruta.type.TokenSeed", type.getName()); AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex(type); assertEquals(40, annotationIndex.size()); FSIterator<AnnotationFS> iterator = annotationIndex.iterator(); assertEquals("CW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("CW", iterator.next().getType().getShortName()); assertEquals("CAP", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SPECIAL", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("AMP", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SPECIAL", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("EXCLAMATION", iterator.next().getType().getShortName()); assertEquals("QUESTION", iterator.next().getType().getShortName()); assertEquals("PERIOD", iterator.next().getType().getShortName()); assertEquals("SEMICOLON", iterator.next().getType().getShortName()); assertEquals("COLON", iterator.next().getType().getShortName()); assertEquals("COMMA", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("MARKUP", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("SPACE", iterator.next().getType().getShortName()); assertEquals("MARKUP", iterator.next().getType().getShortName()); assertEquals("SW", iterator.next().getType().getShortName()); assertEquals("MARKUP", iterator.next().getType().getShortName()); assertEquals("MARKUP", iterator.next().getType().getShortName()); assertEquals("MARKUP", iterator.next().getType().getShortName()); assertEquals("BREAK", iterator.next().getType().getShortName()); cas.release(); }
public Type seed(String text, CAS cas) { Type result = super.seed(text, cas); JCas jCas = null; try { jCas = cas.getJCas(); } catch (CASException e) { throw new RuntimeException(e); } if (text != null) { Matcher matcher = markupPattern.matcher(text); Collection<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); while (matcher.find()) { int begin = matcher.start(); int end = matcher.end(); MARKUP markup = new MARKUP(jCas, begin, end); markup.addToIndexes(); List<AnnotationFS> selectCovered = CasUtil.selectCovered(result, markup); toRemove.addAll(selectCovered); } for (AnnotationFS each : toRemove) { cas.removeFsFromIndexes(each); } } return result; }
DefaultSeeder extends TextSeeder { public Type seed(String text, CAS cas) { Type result = super.seed(text, cas); JCas jCas = null; try { jCas = cas.getJCas(); } catch (CASException e) { throw new RuntimeException(e); } if (text != null) { Matcher matcher = markupPattern.matcher(text); Collection<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); while (matcher.find()) { int begin = matcher.start(); int end = matcher.end(); MARKUP markup = new MARKUP(jCas, begin, end); markup.addToIndexes(); List<AnnotationFS> selectCovered = CasUtil.selectCovered(result, markup); toRemove.addAll(selectCovered); } for (AnnotationFS each : toRemove) { cas.removeFsFromIndexes(each); } } return result; } }
DefaultSeeder extends TextSeeder { public Type seed(String text, CAS cas) { Type result = super.seed(text, cas); JCas jCas = null; try { jCas = cas.getJCas(); } catch (CASException e) { throw new RuntimeException(e); } if (text != null) { Matcher matcher = markupPattern.matcher(text); Collection<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); while (matcher.find()) { int begin = matcher.start(); int end = matcher.end(); MARKUP markup = new MARKUP(jCas, begin, end); markup.addToIndexes(); List<AnnotationFS> selectCovered = CasUtil.selectCovered(result, markup); toRemove.addAll(selectCovered); } for (AnnotationFS each : toRemove) { cas.removeFsFromIndexes(each); } } return result; }  }
DefaultSeeder extends TextSeeder { public Type seed(String text, CAS cas) { Type result = super.seed(text, cas); JCas jCas = null; try { jCas = cas.getJCas(); } catch (CASException e) { throw new RuntimeException(e); } if (text != null) { Matcher matcher = markupPattern.matcher(text); Collection<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); while (matcher.find()) { int begin = matcher.start(); int end = matcher.end(); MARKUP markup = new MARKUP(jCas, begin, end); markup.addToIndexes(); List<AnnotationFS> selectCovered = CasUtil.selectCovered(result, markup); toRemove.addAll(selectCovered); } for (AnnotationFS each : toRemove) { cas.removeFsFromIndexes(each); } } return result; }  Type seed(String text, CAS cas); }
DefaultSeeder extends TextSeeder { public Type seed(String text, CAS cas) { Type result = super.seed(text, cas); JCas jCas = null; try { jCas = cas.getJCas(); } catch (CASException e) { throw new RuntimeException(e); } if (text != null) { Matcher matcher = markupPattern.matcher(text); Collection<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); while (matcher.find()) { int begin = matcher.start(); int end = matcher.end(); MARKUP markup = new MARKUP(jCas, begin, end); markup.addToIndexes(); List<AnnotationFS> selectCovered = CasUtil.selectCovered(result, markup); toRemove.addAll(selectCovered); } for (AnnotationFS each : toRemove) { cas.removeFsFromIndexes(each); } } return result; }  Type seed(String text, CAS cas); static final String seedType; }