use of de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.Verifiable in project webanno by webanno.
the class ConstraintsVerifierTest method test.
@Test
public void test() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/6.rules"));
Parse p = parser.Parse();
ParsedConstraints constraints = p.accept(new ParserVisitor());
// Get imports
Map<String, String> imports = new LinkedHashMap<>();
imports = constraints.getImports();
// Get rules
// List<Rule> rules = new ArrayList<>();
JCas jcas = JCasFactory.createJCas();
jcas.setDocumentText("Just some text.");
Lemma lemma1 = new Lemma(jcas, 0, 1);
lemma1.setValue("good");
lemma1.addToIndexes();
Lemma lemma2 = new Lemma(jcas, 1, 2);
lemma2.setValue("bad");
lemma2.addToIndexes();
Verifiable cVerifier = new ConstraintsVerifier();
for (Lemma lemma : select(jcas, Lemma.class)) {
if (lemma == lemma1) {
assertEquals(true, cVerifier.verify(lemma, constraints));
}
if (lemma == lemma2) {
assertEquals(false, cVerifier.verify(lemma, constraints));
}
}
}
Aggregations