Search in sources :

Example 6 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForNodeDirectDominance.

/**
 * WHERE conditions for direct dominance operator (>).
 */
@Theory
public void shouldGenerateWhereConditionsForNodeDirectDominance(String componentPredicate) {
    // given
    node23.addOutgoingJoin(new Dominance(node42, 1));
    // then
    checkEdgeConditions(componentPredicate, "d", null, false, join("=", "_rank23.id", "_rank42.parent"));
}
Also used : RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) Theory(org.junit.experimental.theories.Theory)

Example 7 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForIndirectDominance.

/**
 * WHERE conditions for indirect dominance (>*).
 */
@Theory
public void shouldGenerateWhereConditionsForIndirectDominance(String componentPredicate) {
    // given
    node23.addOutgoingJoin(new Dominance(node42));
    // then
    checkEdgeConditions(componentPredicate, "d", null, true, join("<", "_rank23.pre", "_rank42.pre"), join("<", "_rank42.pre", "_rank23.post"));
}
Also used : RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) Theory(org.junit.experimental.theories.Theory)

Example 8 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForRangedDominance.

/**
 * WHERE conditions for ranged dominance (>n,m).
 */
@Theory
public void shouldGenerateWhereConditionsForRangedDominance(String componentPredicate) {
    // given
    int min = uniqueInt(1, 10);
    int max = min + uniqueInt(1, 10);
    node23.addOutgoingJoin(new Dominance(node42, min, max));
    // then
    checkEdgeConditions(componentPredicate, "d", null, true, join("<", "_rank23.pre", "_rank42.pre"), join("<", "_rank42.pre", "_rank23.post"), between("_rank23.level", "_rank42.level", -min, -max));
}
Also used : RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) Theory(org.junit.experimental.theories.Theory)

Example 9 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForExactDominance.

/**
 * WHERE conditions for exact dominance (>n).
 */
@Theory
public void shouldGenerateWhereConditionsForExactDominance(String componentPredicate) {
    // given
    int distance = uniqueInt();
    node23.addOutgoingJoin(new Dominance(node42, distance));
    // then
    checkEdgeConditions(componentPredicate, "d", null, true, join("<", "_rank23.pre", "_rank42.pre"), join("<", "_rank42.pre", "_rank23.post"), numberJoin("=", "_rank23.level", "_rank42.level", -distance));
}
Also used : RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) Theory(org.junit.experimental.theories.Theory)

Example 10 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method whereClauseForNodeEdgeAnnotation.

// WHERE condition for node annotation
@Test
public void whereClauseForNodeEdgeAnnotation() {
    Dominance j = new Dominance(node23);
    j.addEdgeAnnotation(new QueryAnnotation("namespace1", "name1"));
    j.addEdgeAnnotation(new QueryAnnotation("namespace2", "name2", "value2", TextMatching.EXACT_EQUAL));
    j.addEdgeAnnotation(new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_EQUAL));
    node42.addOutgoingJoin(j);
    checkWhereConditions("_rank_annotation23_1.qannotext LIKE 'namespace1:name1:%'", "_rank_annotation23_2.qannotext LIKE 'namespace2:name2:value2'", "_rank_annotation23_3.qannotext ~ '^(namespace3:name3:(value3))$'");
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) Test(org.junit.Test)

Aggregations

Dominance (annis.sqlgen.model.Dominance)13 LeftDominance (annis.sqlgen.model.LeftDominance)12 RightDominance (annis.sqlgen.model.RightDominance)12 Theory (org.junit.experimental.theories.Theory)6 QueryAnnotation (annis.model.QueryAnnotation)5 QueryNode (annis.model.QueryNode)5 Join (annis.model.Join)4 SqlConstraints.sqlString (annis.sqlgen.SqlConstraints.sqlString)2 PointingRelation (annis.sqlgen.model.PointingRelation)2 TestUtils.uniqueString (annis.test.TestUtils.uniqueString)2 Test (org.junit.Test)2 AnnisQLSemanticsException (annis.exceptions.AnnisQLSemanticsException)1 SqlConstraints.numberJoin (annis.sqlgen.SqlConstraints.numberJoin)1 CommonAncestor (annis.sqlgen.model.CommonAncestor)1 EqualValue (annis.sqlgen.model.EqualValue)1 Identical (annis.sqlgen.model.Identical)1 Inclusion (annis.sqlgen.model.Inclusion)1 LeftAlignment (annis.sqlgen.model.LeftAlignment)1 LeftOverlap (annis.sqlgen.model.LeftOverlap)1 Near (annis.sqlgen.model.Near)1