use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer in project webanno by webanno.
the class LegacyProjectInitializer method createDepLayer.
private void createDepLayer(Project aProject, TagSet aTagset) throws IOException {
// Dependency Layer
AnnotationLayer depLayer = new AnnotationLayer(Dependency.class.getName(), "Dependency", RELATION_TYPE, aProject, true);
AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject);
List<AnnotationFeature> tokenFeatures = annotationSchemaService.listAnnotationFeature(tokenLayer);
AnnotationFeature tokenPosFeature = null;
for (AnnotationFeature feature : tokenFeatures) {
if (feature.getName().equals("pos")) {
tokenPosFeature = feature;
break;
}
}
depLayer.setAttachType(tokenLayer);
depLayer.setAttachFeature(tokenPosFeature);
annotationSchemaService.createLayer(depLayer);
annotationSchemaService.createFeature(new AnnotationFeature(aProject, depLayer, "DependencyType", "Relation", CAS.TYPE_NAME_STRING, "Dependency relation", aTagset));
String[] flavors = { DependencyFlavor.BASIC, DependencyFlavor.ENHANCED };
String[] flavorDesc = { DependencyFlavor.BASIC, DependencyFlavor.ENHANCED };
TagSet flavorsTagset = annotationSchemaService.createTagSet("Dependency flavors", "Dependency flavors", "mul", flavors, flavorDesc, aProject);
annotationSchemaService.createFeature(new AnnotationFeature(aProject, depLayer, "flavor", "Flavor", CAS.TYPE_NAME_STRING, "Dependency relation", flavorsTagset));
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer in project webanno by webanno.
the class LegacyProjectInitializer method createPOSLayer.
private void createPOSLayer(Project aProject, TagSet aPosTagset) throws IOException {
AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject);
AnnotationLayer posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, aProject, true);
AnnotationFeature tokenPosFeature = new AnnotationFeature(aProject, tokenLayer, "pos", "pos", POS.class.getName());
annotationSchemaService.createFeature(tokenPosFeature);
posLayer.setAttachType(tokenLayer);
posLayer.setAttachFeature(tokenPosFeature);
annotationSchemaService.createLayer(posLayer);
annotationSchemaService.createFeature(new AnnotationFeature(aProject, posLayer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING, "Part-of-speech tag", aPosTagset));
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer in project webanno by webanno.
the class LegacyProjectInitializer method createChunkLayer.
private void createChunkLayer(Project aProject) throws IOException {
AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true);
chunkLayer.setAllowStacking(false);
chunkLayer.setMultipleTokens(true);
chunkLayer.setLockToTokenOffset(false);
annotationSchemaService.createLayer(chunkLayer);
AnnotationFeature chunkValueFeature = new AnnotationFeature();
chunkValueFeature.setDescription("Chunk tag");
chunkValueFeature.setName("chunkValue");
chunkValueFeature.setType(CAS.TYPE_NAME_STRING);
chunkValueFeature.setProject(aProject);
chunkValueFeature.setUiName("Tag");
chunkValueFeature.setLayer(chunkLayer);
annotationSchemaService.createFeature(chunkValueFeature);
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer in project webanno by webanno.
the class LegacyProjectInitializer method createCorefLayer.
private AnnotationLayer createCorefLayer(Project aProject, TagSet aCorefTypeTags, TagSet aCorefRelTags) throws IOException {
AnnotationLayer base = new AnnotationLayer("de.tudarmstadt.ukp.dkpro.core.api.coref.type.Coreference", "Coreference", CHAIN_TYPE, aProject, true);
base.setCrossSentence(true);
base.setAllowStacking(true);
base.setMultipleTokens(true);
base.setLockToTokenOffset(false);
annotationSchemaService.createLayer(base);
annotationSchemaService.createFeature(new AnnotationFeature(aProject, base, "referenceType", "referenceType", CAS.TYPE_NAME_STRING, "Coreference type", aCorefTypeTags));
annotationSchemaService.createFeature(new AnnotationFeature(aProject, base, "referenceRelation", "referenceRelation", CAS.TYPE_NAME_STRING, "Coreference relation", aCorefRelTags));
return base;
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer in project webanno by webanno.
the class ReindexFeatureAttachedSpanAnnotationsRepair method repair.
@Override
public void repair(Project aProject, CAS aCas, List<LogMessage> aMessages) {
Map<FeatureStructure, FeatureStructure> nonIndexed = getNonIndexedFSesWithOwner(aCas);
for (AnnotationLayer layer : annotationService.listAnnotationLayer(aProject)) {
if (!(WebAnnoConst.SPAN_TYPE.equals(layer.getType()) && layer.getAttachFeature() != null)) {
continue;
}
int count = 0;
// anno -> e.g. Lemma
for (AnnotationFS attach : select(aCas, getType(aCas, layer.getAttachType().getName()))) {
AnnotationFS anno = getFeature(attach, layer.getAttachFeature().getName(), AnnotationFS.class);
if (anno != null && nonIndexed.containsKey(anno)) {
aCas.addFsToIndexes(anno);
count++;
}
}
if (count > 0) {
aMessages.add(new LogMessage(this, LogLevel.INFO, "Reindexed [%d] unindexed spans in layer [" + layer.getName() + "].", count));
}
}
}
Aggregations