use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.syntaxtree.Parse in project webanno by webanno.
the class ComplexTypeTest method testProfType.
@Test
public void testProfType() throws Exception {
TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription("desc.types.TestTypeSystemDescriptor");
CAS cas = CasCreationUtils.createCas(tsd, null, null);
cas.setDocumentText("I listen to lectures by Prof. Gurevych sometimes.");
TypeSystem ts = cas.getTypeSystem();
Type profType = ts.getType("de.tud.Prof");
Feature profNameFeature = profType.getFeatureByBaseName("fullName");
Feature profBossFeature = profType.getFeatureByBaseName("boss");
AnnotationFS proemel = cas.createAnnotation(profType, 0, 0);
proemel.setStringValue(profNameFeature, "Hans Juergen Proeml");
cas.addFsToIndexes(proemel);
AnnotationFS gurevych = cas.createAnnotation(profType, 24, 38);
gurevych.setStringValue(profNameFeature, "Iryna Gurevych");
gurevych.setFeatureValue(profBossFeature, proemel);
cas.addFsToIndexes(gurevych);
/*
* for (String feature : Arrays.asList("fullName", "boss")) { Feature someFeature =
* gurevych.getType().getFeatureByBaseName(feature); if
* (someFeature.getRange().isPrimitive()) { String value =
* gurevych.getFeatureValueAsString(someFeature); System.out.println(value); } else {
* FeatureStructure value = gurevych.getFeatureValue(someFeature);
* System.out.printf("%s (%s)%n", value.getFeatureValueAsString(profNameFeature),
* value.getType()); } }
*/
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/prof.rules"));
Parse p = parser.Parse();
ParsedConstraints constraints = p.accept(new ParserVisitor());
Evaluator constraintsEvaluator = new ValuesGenerator();
List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(gurevych, "professorName", constraints);
List<PossibleValue> exValues = new LinkedList<>();
exValues.add(new PossibleValue("Iryna Gurevych", false));
assertEquals(possibleValues, exValues);
}
use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.syntaxtree.Parse in project webanno by webanno.
the class ScopeVisitorTest method test.
@Test
public void test() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/6.rules"));
Parse p = parser.Parse();
List<Scope> scopes = new ArrayList<>();
p.accept(new ScopeVisitor(), scopes);
for (Scope scope : scopes) {
System.out.printf("%s %n", scope);
}
}
use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.syntaxtree.Parse in project webanno by webanno.
the class ConstraintsParserTest method test5.
@Test
public void test5() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/5.rules"));
Parse p = parser.Parse();
}
use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.syntaxtree.Parse in project webanno by webanno.
the class ConstraintsParserTest method test2.
@Test
public void test2() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/2.rules"));
Parse p = parser.Parse();
}
use of de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.syntaxtree.Parse in project webanno by webanno.
the class ConstraintsParserTest method test6.
@Test
public void test6() throws Exception {
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream("src/test/resources/rules/6.rules"));
Parse p = parser.Parse();
}
Aggregations