Search in sources :

Example 36 with Annotation

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

the class TimeHelper method getNextEndTime.

private String getNextEndTime(AnnisNode rightNode) {
    int offset = getOffset(rightNode);
    String time = null;
    for (long i = offset + 1; i < token.size(); i++) {
        for (Annotation anno : token.get((int) i).getNodeAnnotations()) {
            if ("time".equals(anno.getName())) {
                time = anno.getValue();
                break;
            }
        }
        String startTime = getStartTime(time);
        String endTime = getEndTime(time);
        if (startTime != null && !"undefined".equals(startTime)) {
            return startTime;
        }
        if (endTime != null && !"undefined".equals(endTime)) {
            return endTime;
        }
    }
    return "undefined";
}
Also used : Annotation(annis.model.Annotation)

Example 37 with Annotation

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

the class AomAnnotateSqlGeneratorTest method shouldMapEmptyAnnotation.

@Test
public void shouldMapEmptyAnnotation() throws SQLException {
    // given
    String table = uniqueString();
    stubDefaultAnnotation(table);
    given(resultSet.wasNull()).willReturn(true);
    // when
    Annotation actual = generator.mapAnnotation(resultSet, tableAccessStrategy, table);
    // then
    assertThat(actual, is(nullValue()));
}
Also used : TestUtils.uniqueString(annis.test.TestUtils.uniqueString) Annotation(annis.model.Annotation) Test(org.junit.Test)

Example 38 with Annotation

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

the class ListCorpusAnnotationsSqlHelper method mapRow.

@Override
public Annotation mapRow(ResultSet rs, int rowNum) throws SQLException {
    String namespace = rs.getString("namespace");
    String name = rs.getString("name");
    String value = rs.getString("value");
    String type = rs.getString("type");
    String corpusName = rs.getString("corpus_name");
    int pre = rs.getInt("corpus_pre");
    return new Annotation(namespace, name, value, type, corpusName, pre);
}
Also used : SqlConstraints.sqlString(annis.sqlgen.SqlConstraints.sqlString) Annotation(annis.model.Annotation)

Example 39 with Annotation

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

the class ListDocumentsAnnotationsSqlHelper method mapRow.

@Override
public Annotation mapRow(ResultSet rs, int rowNum) throws SQLException {
    Integer pre = rs.getInt("pre");
    String corpusName = rs.getString("corpus_name");
    String type = rs.getString("type");
    String namespace = rs.getString("namespace");
    String name = rs.getString("name");
    String value = rs.getString("value");
    Array annotationPathArray = rs.getArray("path_name");
    List<String> annotationPath = new LinkedList<>();
    if (annotationPathArray.getBaseType() == Types.VARCHAR) {
        annotationPath = Arrays.asList((String[]) annotationPathArray.getArray());
    }
    return new Annotation(namespace, name, value, type, corpusName, pre, annotationPath);
}
Also used : Array(java.sql.Array) SqlConstraints.sqlString(annis.sqlgen.SqlConstraints.sqlString) LinkedList(java.util.LinkedList) Annotation(annis.model.Annotation)

Example 40 with Annotation

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

the class TestQueryDaoImpl method listCorpusAnnotations.

@SuppressWarnings("unchecked")
@Test
public void listCorpusAnnotations() {
    // stub JdbcTemplate to return a list of Annotation
    final List<Annotation> ANNOTATIONS = mock(List.class);
    when(jdbcTemplate.query(anyString(), any(RowMapper.class))).thenReturn(ANNOTATIONS);
    // stub SQL query
    final String ID = "toplevelcorpus";
    when(listCorpusAnnotationsHelper.createSqlQuery(anyString(), anyString(), anyBoolean())).thenReturn(SQL);
    // call and test
    assertThat(queryDao.listCorpusAnnotations(ID), is(ANNOTATIONS));
    verify(listCorpusAnnotationsHelper).createSqlQuery(ID, ID, true);
    verify(jdbcTemplate).query(SQL, listCorpusAnnotationsHelper);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Annotation(annis.model.Annotation) ParameterizedSingleColumnRowMapper(org.springframework.jdbc.core.simple.ParameterizedSingleColumnRowMapper) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.Test)

Aggregations

Annotation (annis.model.Annotation)43 ArrayList (java.util.ArrayList)13 LinkedList (java.util.LinkedList)12 HashMap (java.util.HashMap)11 AnnisNode (annis.model.AnnisNode)10 AnnotatedSpan (annis.dao.objects.AnnotatedSpan)6 Test (org.junit.Test)6 AnnotatedMatch (annis.dao.objects.AnnotatedMatch)5 List (java.util.List)5 Map (java.util.Map)5 TreeMap (java.util.TreeMap)5 SAnnotation (org.corpus_tools.salt.core.SAnnotation)5 AnnisResult (annis.service.ifaces.AnnisResult)4 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)4 WebResource (com.sun.jersey.api.client.WebResource)4 Array (java.sql.Array)4 SNode (org.corpus_tools.salt.core.SNode)4 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)3 SToken (org.corpus_tools.salt.common.SToken)3 AnnotationGraph (annis.model.AnnotationGraph)2