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))$'");
}
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:%'");
}
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:%'");
}
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));
}
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));
}
Aggregations