@Test public void test1() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/1.rules")); Parse p = parser.Parse(); }
@Test public void test3() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/3.rules")); Parse p = parser.Parse(); }
@Test public void test4() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/4.rules")); Parse p = parser.Parse(); }
@Test public void test7() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/7.rules")); Parse p = parser.Parse(); }
@Test public void test2() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/2.rules")); Parse p = parser.Parse(); }
@Test public void test6() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/6.rules")); Parse p = parser.Parse(); }
@Test public void test8() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/8.rules")); Parse p = parser.Parse(); }
@Test public void test5() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/5.rules")); Parse p = parser.Parse(); }
@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); } }
@Test public void test() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/6.rules")); Parse p = parser.Parse(); List<Rule> rules = new ArrayList<>(); p.accept(new RuleVisitor(), rules); for (Rule rule : rules) { System.out.printf("%s %n", rule); } }
@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); }
@Test public void test() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/6.rules")); Parse p = parser.Parse(); List<Restriction> restrictions = new ArrayList<>(); p.accept(new RestrictionVisitor(), restrictions); for (Restriction res : restrictions) { System.out.printf("%s %n", res); } } }
@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")); } }
@Test public void test() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/6.rules")); Parse p = parser.Parse(); List<Condition> conditions = new ArrayList<>(); p.accept(new ConditionVisitor(), conditions); for (Condition cond : conditions) { System.out.printf("%s %n", cond); } } }
Parse p = parser.Parse();
@Test public void testSimpleSymbolicRules() throws Exception { ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream( "src/test/resources/rules/symbolic1.rules")); Parse p = parser.Parse(); ParsedConstraints constraints = p.accept(new ParserVisitor()); JCas jcas = JCasFactory.createJCas(); CollectionReader reader = createReader(Conll2006Reader.class, Conll2006Reader.PARAM_SOURCE_LOCATION, "src/test/resources/text/1.conll"); reader.getNext(jcas.getCas()); POS pos = new POS(jcas, 8, 9); pos.setPosValue("pronoun"); pos.addToIndexes(); Evaluator constraintsEvaluator = new ValuesGenerator(); Lemma lemma = select(jcas, Lemma.class).iterator().next(); List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(lemma, "value", constraints); List<PossibleValue> expectedOutput = new ArrayList<>(); expectedOutput.add(new PossibleValue("good", true)); assertEquals(expectedOutput, possibleValues); }
@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); }
Parse p = parser.Parse(); ParsedConstraints constraints = p.accept(new ParserVisitor());
Parse p = parser.Parse(); ParsedConstraints constraints = p.accept(new ParserVisitor());
Parse p = parser.Parse();