Search in sources :

Example 6 with QueryAnnotation

use of annis.model.QueryAnnotation in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForNamedAndAnnotatedDirectDominance.

/**
 * WHERE conditions for annotated named direct dominance (> name
 * [annotation]).
 */
@Theory
public void shouldGenerateWhereConditionsForNamedAndAnnotatedDirectDominance(String componentPredicate) {
    // given
    String componentName = uniqueString();
    Join j = new Dominance(node42, componentName, 1);
    node23.addOutgoingJoin(j);
    j.addEdgeAnnotation(new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_EQUAL));
    // then
    checkEdgeConditions(componentPredicate, "d", componentName, false, join("=", "_rank23.id", "_rank42.parent"));
    checkWhereConditions(node42, "_rank_annotation42.qannotext ~ '^(namespace3:name3:(value3))$'");
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) SqlConstraints.numberJoin(annis.sqlgen.SqlConstraints.numberJoin) Join(annis.model.Join) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) TestUtils.uniqueString(annis.test.TestUtils.uniqueString) SqlConstraints.sqlString(annis.sqlgen.SqlConstraints.sqlString) Theory(org.junit.experimental.theories.Theory)

Example 7 with QueryAnnotation

use of annis.model.QueryAnnotation in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method whereClauseForNodeAnnotation2Nodes.

@Test
public void whereClauseForNodeAnnotation2Nodes() {
    node23.addNodeAnnotation(new QueryAnnotation("namespace1", "name1"));
    node23.addNodeAnnotation(new QueryAnnotation("namespace2", "name2"));
    node42.addNodeAnnotation(new QueryAnnotation("namespace3", "name3"));
    node42.addNodeAnnotation(new QueryAnnotation("namespace4", "name4"));
    node23.addOutgoingJoin(new Precedence(node42, 1));
    checkWhereConditions(node23, "_annotation23_1.qannotext LIKE 'namespace1:name1:%'", "_annotation23_2.qannotext LIKE 'namespace2:name2:%'", "_node23.right_token = _node42.left_token - 1", "_node23.text_ref = _node42.text_ref");
    checkWhereConditions(node42, "_annotation42_1.qannotext LIKE 'namespace3:name3:%'", "_annotation42_2.qannotext LIKE 'namespace4:name4:%'");
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) Precedence(annis.sqlgen.model.Precedence) Test(org.junit.Test)

Example 8 with QueryAnnotation

use of annis.model.QueryAnnotation in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method whereClauseForNodeAnnotationNot.

@Test
public void whereClauseForNodeAnnotationNot() {
    node23.addNodeAnnotation(new QueryAnnotation("namespace2", "name2", "value2", TextMatching.EXACT_NOT_EQUAL));
    node23.addNodeAnnotation(new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_NOT_EQUAL));
    checkWhereConditions("_annotation23_1.qannotext NOT LIKE 'namespace2:name2:value2'", "_annotation23_1.qannotext LIKE 'namespace2:name2:%'", "_annotation23_2.qannotext !~ '^(namespace3:name3:(value3))$'", "_annotation23_2.qannotext LIKE 'namespace3:name3:%'");
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) Test(org.junit.Test)

Example 9 with QueryAnnotation

use of annis.model.QueryAnnotation in project ANNIS by korpling.

the class TestSubQueryCorpusSelectionStrategy method corpusConstraintEmptyCorpusListAnnotation.

@Test
public void corpusConstraintEmptyCorpusListAnnotation() {
    String expected = "" + "SELECT DISTINCT c1.id " + "FROM corpus AS c1, corpus_annotation AS corpus_annotation1, corpus_annotation AS corpus_annotation2, corpus_annotation AS corpus_annotation3 " + "WHERE corpus_annotation1.namespace = 'namespace1' " + "AND corpus_annotation1.name = 'name1' " + "AND corpus_annotation1.corpus_ref = c1.id " + "AND corpus_annotation2.namespace = 'namespace2' " + "AND corpus_annotation2.name = 'name2' " + "AND corpus_annotation2.value = 'value2' " + "AND corpus_annotation2.corpus_ref = c1.id " + "AND corpus_annotation3.namespace = 'namespace3' " + "AND corpus_annotation3.name = 'name3' " + "AND corpus_annotation3.value ~ '^value3$' " + "AND corpus_annotation3.corpus_ref = c1.id";
    QueryAnnotation annotation1 = new QueryAnnotation("namespace1", "name1");
    QueryAnnotation annotation2 = new QueryAnnotation("namespace2", "name2", "value2", TextMatching.EXACT_EQUAL);
    QueryAnnotation annotation3 = new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_EQUAL);
    metaData = Arrays.asList(annotation1, annotation2, annotation3);
    assertEquals(expected, strategy.buildSubQuery(corpusList, metaData));
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) Test(org.junit.Test)

Example 10 with QueryAnnotation

use of annis.model.QueryAnnotation in project ANNIS by korpling.

the class TestSubQueryCorpusSelectionStrategy method corpusConstraintCorpusListAndAnnotation.

@Test
public void corpusConstraintCorpusListAndAnnotation() {
    String expected = "" + "SELECT DISTINCT c1.id " + "FROM corpus AS c1, corpus AS c2, corpus_annotation AS corpus_annotation1, corpus_annotation AS corpus_annotation2, corpus_annotation AS corpus_annotation3 " + "WHERE c1.pre >= c2.pre " + "AND c1.post <= c2.post " + "AND c2.id IN ( 23, 42, 69 ) " + "AND corpus_annotation1.namespace = 'namespace1' " + "AND corpus_annotation1.name = 'name1' " + "AND corpus_annotation1.corpus_ref = c1.id " + "AND corpus_annotation2.namespace = 'namespace2' " + "AND corpus_annotation2.name = 'name2' " + "AND corpus_annotation2.value = 'value2' " + "AND corpus_annotation2.corpus_ref = c1.id " + "AND corpus_annotation3.namespace = 'namespace3' " + "AND corpus_annotation3.name = 'name3' " + "AND corpus_annotation3.value ~ '^value3$' " + "AND corpus_annotation3.corpus_ref = c1.id";
    QueryAnnotation annotation1 = new QueryAnnotation("namespace1", "name1");
    QueryAnnotation annotation2 = new QueryAnnotation("namespace2", "name2", "value2", TextMatching.EXACT_EQUAL);
    QueryAnnotation annotation3 = new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_EQUAL);
    corpusList = Arrays.asList(23L, 42L, 69L);
    metaData = Arrays.asList(annotation1, annotation2, annotation3);
    assertEquals(expected, strategy.buildSubQuery(corpusList, metaData));
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) Test(org.junit.Test)

Aggregations

QueryAnnotation (annis.model.QueryAnnotation)20 QueryNode (annis.model.QueryNode)9 Test (org.junit.Test)7 Dominance (annis.sqlgen.model.Dominance)5 LeftDominance (annis.sqlgen.model.LeftDominance)5 RightDominance (annis.sqlgen.model.RightDominance)5 Join (annis.model.Join)4 PointingRelation (annis.sqlgen.model.PointingRelation)2 Precedence (annis.sqlgen.model.Precedence)2 TestUtils.uniqueString (annis.test.TestUtils.uniqueString)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 AnnisQLSemanticsException (annis.exceptions.AnnisQLSemanticsException)1 AqlParseError (annis.model.AqlParseError)1 AqlParser (annis.ql.AqlParser)1 AnnisAttribute (annis.service.objects.AnnisAttribute)1 SqlConstraints.numberJoin (annis.sqlgen.SqlConstraints.numberJoin)1 SqlConstraints.sqlString (annis.sqlgen.SqlConstraints.sqlString)1 CommonAncestor (annis.sqlgen.model.CommonAncestor)1