use of annis.model.AnnisNode in project ANNIS by korpling.
the class TestAnnisResultImpl method setup.
@Before
public void setup() {
initMocks(this);
// sanity check: IDS are different
assertThat(ID1, is(not(ID2)));
assertThat(ID2, is(not(ID3)));
assertThat(ID3, is(not(ID1)));
// set up underlying graph
token1 = newToken(ID1, TEXT1, TOKEN_INDEX1);
token2 = newToken(ID2, TEXT2, TOKEN_INDEX2);
token3 = newToken(ID3, TEXT3, TOKEN_INDEX3);
node4 = new AnnisNode(ID4);
node5 = new AnnisNode(ID5);
when(graph.getNodes()).thenReturn(Arrays.asList(token1, token2, token3, node4, node5));
when(graph.getTokens()).thenReturn(Arrays.asList(token1, token2, token3));
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class AomAnnotateSqlGeneratorTest method createDefaultEdge.
private Edge createDefaultEdge() {
Edge expected = new Edge();
expected.setPre(PRE);
expected.setEdgeType(EDGETYPE);
expected.setNamespace(EDGE_NAMESPACE);
expected.setName(EDGE_NAME);
expected.setSource(new AnnisNode(PARENT));
expected.setDestination(new AnnisNode(NODE_REF));
return expected;
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class AomAnnotateSqlGeneratorTest method shouldMapNodeWithToken.
@Test
public void shouldMapNodeWithToken() throws SQLException {
// given
stubNodeResultSet();
given(resultSet.wasNull()).willReturn(true);
// when
AnnisNode node = generator.mapNode(resultSet, tableAccessStrategy, null);
// then
assertThat(node.isToken(), is(false));
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class LegacyGraphConverterTest method testConvertToAOM.
/**
* Test of convertToAOM method, of class LegacyGraphConverter.
*/
@Test
public void testConvertToAOM() throws SQLException {
SaltAnnotateExtractor saltExtractor = new SaltAnnotateExtractor() {
@Override
protected SolutionKey<?> createSolutionKey() {
PostgreSqlArraySolutionKey<Long> key = new PostgreSqlArraySolutionKey<>();
key.setKeyColumnName("key");
key.setIdColumnName("id");
return key;
}
};
CorpusPathExtractor corpusPathExtractor = new ArrayCorpusPathExtractor();
saltExtractor.setCorpusPathExtractor(corpusPathExtractor);
TestAnnotateSqlGenerator.setupOuterQueryFactsTableColumnAliases(saltExtractor);
List<Match> matches = new ArrayList<>();
matches.add(Match.parseFromString("salt:/pcc2/4282/#tok_155 tiger::pos::salt:/pcc2/4282#tok_156"));
MatchGroup matchGroup = new MatchGroup(matches);
SaltProject p = saltExtractor.extractData(new CsvResultSetProvider(annis.sqlgen.SaltAnnotateExtractorTest.class.getResourceAsStream("SampleAnnotateResult.csv")).getResultSet());
SaltAnnotateExtractor.addMatchInformation(p, matchGroup);
List<AnnotationGraph> expected = aomSqlGen.extractData(new CsvResultSetProvider(annis.sqlgen.SaltAnnotateExtractorTest.class.getResourceAsStream("SampleAnnotateResult.csv")).getResultSet());
List<AnnotationGraph> result = LegacyGraphConverter.convertToAOM(p);
assertEquals(expected.size(), result.size());
Iterator<AnnotationGraph> itGraphExpected = expected.iterator();
Iterator<AnnotationGraph> itGraphResult = result.iterator();
while (itGraphExpected.hasNext() && itGraphResult.hasNext()) {
AnnotationGraph graphExpected = itGraphExpected.next();
AnnotationGraph graphResult = itGraphResult.next();
List<AnnisNode> nodeListExpected = graphExpected.getNodes();
List<AnnisNode> nodeListResult = graphResult.getNodes();
assertEquals(nodeListExpected.size(), nodeListResult.size());
Collections.sort(nodeListExpected, new Comparator<AnnisNode>() {
@Override
public int compare(AnnisNode arg0, AnnisNode arg1) {
return Long.valueOf(arg0.getId()).compareTo(Long.valueOf(arg1.getId()));
}
});
Collections.sort(nodeListResult, new Comparator<AnnisNode>() {
@Override
public int compare(AnnisNode arg0, AnnisNode arg1) {
return Long.valueOf(arg0.getId()).compareTo(Long.valueOf(arg1.getId()));
}
});
Iterator<AnnisNode> itNodeExpected = nodeListExpected.iterator();
Iterator<AnnisNode> itNodeResult = nodeListResult.iterator();
while (itNodeExpected.hasNext() && itNodeResult.hasNext()) {
checkAnnisNodeEqual(itNodeExpected.next(), itNodeResult.next());
}
}
}
use of annis.model.AnnisNode in project ANNIS by korpling.
the class AomAnnotateExtractor method mapEdge.
public Edge mapEdge(ResultSet resultSet, TableAccessStrategy tableAccessStrategy) throws SQLException {
Edge edge = new Edge();
edge.setPre(longValue(resultSet, RANK_TABLE, "pre", tableAccessStrategy));
edge.setComponentID(longValue(resultSet, RANK_TABLE, "component_id", tableAccessStrategy));
edge.setEdgeType(EdgeType.parseEdgeType(stringValue(resultSet, RANK_TABLE, "edge_type", tableAccessStrategy)));
edge.setNamespace(stringValue(resultSet, COMPONENT_TABLE, "namespace", tableAccessStrategy));
edge.setName(stringValue(resultSet, COMPONENT_TABLE, "name", tableAccessStrategy));
edge.setDestination(new AnnisNode(longValue(resultSet, RANK_TABLE, "node_ref", tableAccessStrategy)));
edge.setComponentID(longValue(resultSet, COMPONENT_TABLE, "id", tableAccessStrategy));
edge.setId(longValue(resultSet, RANK_TABLE, "id", tableAccessStrategy));
// create nodes for src with rank value (parent) as id.
// this must later be fixed by AnnotationGraphDaoHelper.fixSourceNodeIds().
// this is simpler than chaining the edgeByPre map in AnnisResultSetBuilder
// and making the EdgeRowMapper thread-safe.
// FIXME: use custum mapRow(resultSet, edgeByPre) function, throw Exception here
// also, no need to implement Spring RowMapper
long parent = longValue(resultSet, RANK_TABLE, "parent", tableAccessStrategy);
if (!resultSet.wasNull())
edge.setSource(new AnnisNode(parent));
return edge;
}
Aggregations