use of org.corpus_tools.salt.common.SPointingRelation in project ANNIS by korpling.
the class SaltAnnotateExtractorTest method testRelationType.
@Test
public void testRelationType() throws SQLException {
SaltProject project = instance.extractData(resultSetProviderSingleText.getResultSet());
assertNotNull(project);
SDocumentGraph g = project.getCorpusGraphs().get(0).getDocuments().get(0).getDocumentGraph();
for (SRelation<? extends SNode, ? extends SNode> r : g.getRelations()) {
if (!(r instanceof STextualRelation)) {
assertEquals(1, r.getLayers().size());
String layerName = r.getLayers().iterator().next().getName();
if ("exmaralda".equals(layerName) || "urml".equals(layerName) || "mmax".equals(layerName)) {
assertTrue("instance of SSpanningRelation", r instanceof SSpanningRelation);
} else if ("dep".equals(layerName)) {
assertTrue("instance of SPointingRelation", r instanceof SPointingRelation);
} else if ("tiger".equals(layerName)) {
assertTrue("instance of SDominanceRelation", r instanceof SDominanceRelation);
}
}
}
}
use of org.corpus_tools.salt.common.SPointingRelation in project ANNIS by korpling.
the class TimelineReconstructor method moveRelations.
private void moveRelations(SStructuredNode oldSpan, SToken newToken, Set<String> validSpanAnnos, String orderName) {
final List<SRelation> inRels = new LinkedList<>(oldSpan.getInRelations());
final List<SRelation> outRels = new LinkedList<>(oldSpan.getOutRelations());
final List<SToken> coveredByOldSpan = new LinkedList<>();
for (SRelation rel : outRels) {
if (rel instanceof SPointingRelation || rel instanceof SDominanceRelation) {
rel.setSource(newToken);
} else if (rel instanceof SSpanningRelation) {
coveredByOldSpan.add(((SSpanningRelation) rel).getTarget());
}
}
for (SRelation rel : inRels) {
if (rel instanceof SPointingRelation || rel instanceof SDominanceRelation) {
rel.setTarget(newToken);
}
}
// find the connected spans and connect them with the new token instead
for (SToken tok : coveredByOldSpan) {
if (tok.getInRelations() != null) {
for (SRelation<?, ?> rel : tok.getInRelations()) {
if (rel instanceof SSpanningRelation) {
boolean valid = false;
SSpan spanToMap = ((SSpanningRelation) rel).getSource();
if (virtualTokenizationFromNamespace) {
for (SAnnotation anno : spanToMap.getAnnotations()) {
if (anno.getNamespace() != null && anno.getNamespace().equals(orderName)) {
valid = true;
break;
}
}
} else {
for (String validAnno : validSpanAnnos) {
if (spanToMap.getAnnotation(validAnno) != null) {
valid = true;
break;
}
}
}
if (valid) {
graph.createRelation(spanToMap, newToken, SALT_TYPE.SSPANNING_RELATION, null);
}
}
}
}
}
}
Aggregations