use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.ConstraintsGrammar in project webanno by webanno.
the class ConstraintsGeneratorTest method testSimpleFeature.
@Test
public void testSimpleFeature() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/9.rules"));
Parse p = parser.Parse();
ParsedConstraints constraints = p.accept(new ParserVisitor());
JCas jcas = JCasFactory.createJCas();
jcas.setDocumentText("is");
Lemma lemma = new Lemma(jcas, 0, 2);
lemma.setValue("be");
lemma.addToIndexes();
Evaluator constraintsEvaluator = new ValuesGenerator();
List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(lemma, "value", constraints);
List<PossibleValue> expectedOutput = new LinkedList<>();
expectedOutput.add(new PossibleValue("be", true));
assertEquals(expectedOutput, possibleValues);
}
use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.ConstraintsGrammar in project webanno by webanno.
the class ImportVisitorTest method test.
@Test
public void test() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/6.rules"));
Parse p = parser.Parse();
Map<String, String> imports = new LinkedHashMap<>();
p.accept(new ImportVisitor(), imports);
for (Entry<String, String> e : imports.entrySet()) {
System.out.printf("[%s] is short for [%s]%n", e.getKey(), e.getValue());
}
assertEquals("de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma", imports.get("Lemma"));
}
use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.ConstraintsGrammar in project webanno by webanno.
the class ParserVisitorTest 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());
System.out.printf("%s %n", constraints);
}
Aggregations