private void createNeLayer(Project aProject, TagSet aTagSet) throws IOException { AnnotationLayer neLayer = new AnnotationLayer(NamedEntity.class.getName(), "Named entity", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); neLayer.setAllowStacking(true); annotationSchemaService.createLayer(neLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, neLayer, "value", "value", CAS.TYPE_NAME_STRING, "Named entity type", aTagSet)); }
private void createNeLayer(Project aProject, TagSet aTagSet) throws IOException { AnnotationLayer neLayer = new AnnotationLayer(NamedEntity.class.getName(), "Named entity", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); neLayer.setAllowStacking(true); annotationSchemaService.createLayer(neLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, neLayer, "value", "value", CAS.TYPE_NAME_STRING, "Named entity type", aTagSet)); }
@Override public void configure(Project aProject) throws IOException { TagSet nerTagSet = JsonImportUtil.importTagSetFromJson(aProject, new ClassPathResource("/tagsets/de-ne-webanno.json").getInputStream(), annotationSchemaService); AnnotationLayer neLayer = new AnnotationLayer(NamedEntity.class.getName(), "Named entity", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); neLayer.setAllowStacking(true); annotationSchemaService.createLayer(neLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, neLayer, "value", "value", CAS.TYPE_NAME_STRING, "Named entity type", nerTagSet)); } }
@Override public void configure(Project aProject) throws IOException { TagSet nerTagSet = JsonImportUtil.importTagSetFromJson(aProject, new ClassPathResource("/tagsets/de-ne-webanno.json").getInputStream(), annotationSchemaService); AnnotationLayer neLayer = new AnnotationLayer(NamedEntity.class.getName(), "Named entity", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); neLayer.setAllowStacking(true); annotationSchemaService.createLayer(neLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, neLayer, "value", "value", CAS.TYPE_NAME_STRING, "Named entity type", nerTagSet)); } }
private void createChunkLayer(Project aProject) throws IOException { AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); chunkLayer.setAllowStacking(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); }
@Override public void configure(Project aProject) throws IOException { AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); chunkLayer.setAllowStacking(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); } }
@Override public void configure(Project aProject) throws IOException { TagSet corefTypeTagSet = JsonImportUtil.importTagSetFromJson(aProject, new ClassPathResource("/tagsets/de-coref-type-bart.json").getInputStream(), annotationSchemaService); TagSet corefRelTagSet = JsonImportUtil.importTagSetFromJson(aProject, new ClassPathResource("/tagsets/de-coref-rel-tuebadz.json").getInputStream(), annotationSchemaService); AnnotationLayer base = new AnnotationLayer( "de.tudarmstadt.ukp.dkpro.core.api.coref.type.Coreference", "Coreference", CHAIN_TYPE, aProject, true, AnchoringMode.TOKENS); base.setCrossSentence(true); base.setAllowStacking(true); annotationSchemaService.createLayer(base); annotationSchemaService.createFeature(new AnnotationFeature(aProject, base, "referenceType", "referenceType", CAS.TYPE_NAME_STRING, "Coreference type", corefTypeTagSet)); annotationSchemaService.createFeature( new AnnotationFeature(aProject, base, "referenceRelation", "referenceRelation", CAS.TYPE_NAME_STRING, "Coreference relation", corefRelTagSet)); } }
private void createChunkLayer(Project aProject) throws IOException { AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); chunkLayer.setAllowStacking(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); }
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, AnchoringMode.TOKENS); base.setCrossSentence(true); base.setAllowStacking(true); 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; }
@Override public void configure(Project aProject) throws IOException { AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); chunkLayer.setAllowStacking(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); } }
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, AnchoringMode.TOKENS); base.setCrossSentence(true); base.setAllowStacking(true); 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; }
@Override public void configure(Project aProject) throws IOException { // The surface form must be locked to tokens for CoNLL-U writer to work properly AnnotationLayer surfaceFormLayer = new AnnotationLayer(SurfaceForm.class.getName(), "Surface form", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); surfaceFormLayer.setAllowStacking(false); annotationSchemaService.createLayer(surfaceFormLayer); AnnotationFeature surfaceFormValueFeature = new AnnotationFeature(); surfaceFormValueFeature.setDescription("Original surface text"); surfaceFormValueFeature.setName("value"); surfaceFormValueFeature.setType(CAS.TYPE_NAME_STRING); surfaceFormValueFeature.setProject(aProject); surfaceFormValueFeature.setUiName("Form"); surfaceFormValueFeature.setLayer(surfaceFormLayer); annotationSchemaService.createFeature(surfaceFormValueFeature); } }
@Override public void configure(Project aProject) throws IOException { // The surface form must be locked to tokens for CoNLL-U writer to work properly AnnotationLayer surfaceFormLayer = new AnnotationLayer(SurfaceForm.class.getName(), "Surface form", SPAN_TYPE, aProject, true, AnchoringMode.TOKENS); surfaceFormLayer.setAllowStacking(false); annotationSchemaService.createLayer(surfaceFormLayer); AnnotationFeature surfaceFormValueFeature = new AnnotationFeature(); surfaceFormValueFeature.setDescription("Original surface text"); surfaceFormValueFeature.setName("value"); surfaceFormValueFeature.setType(CAS.TYPE_NAME_STRING); surfaceFormValueFeature.setProject(aProject); surfaceFormValueFeature.setUiName("Form"); surfaceFormValueFeature.setLayer(surfaceFormLayer); annotationSchemaService.createFeature(surfaceFormValueFeature); } }
@Test public void thatSpanStackingBehaviorOnValidateGeneratesErrors() throws AnnotationException { TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class); builder.buildTokens(jcas, "This is a test ."); SpanAdapter sut = new SpanAdapter(featureSupportRegistry, null, neLayer, asList(), behaviors); // Add two annotations neLayer.setAllowStacking(true); sut.add(document, username, jcas, 0, 1); sut.add(document, username, jcas, 0, 1); //Validation fails neLayer.setAllowStacking(false); assertThat(sut.validate(jcas)) .extracting(Pair::getLeft) .usingElementComparatorIgnoringFields("source", "message") .containsExactly(LogMessage.error(null, "")); }
@Test public void thatSpanStackingBehaviorOnCreateThrowsException() throws AnnotationException { neLayer.setAllowStacking(false); TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class); builder.buildTokens(jcas, "This is a test ."); SpanAdapter sut = new SpanAdapter(featureSupportRegistry, null, neLayer, asList(), behaviors); // First time should work sut.add(document, username, jcas, 0, 1); // Second time not assertThatExceptionOfType(AnnotationException.class) .isThrownBy(() -> sut.add(document, username, jcas, 0, 1)) .withMessageContaining("stacking is not enabled"); }
@Override public void configure(Project aProject) throws IOException { AnnotationLayer factLayer = new AnnotationLayer(FactLinkingConstants.FACT_LAYER, "Fact", SPAN_TYPE, aProject, false, AnchoringMode.TOKENS); factLayer.setAllowStacking(true); factLayer.setCrossSentence(false); annotationSchemaService.createFeature( new AnnotationFeature(aProject, factLayer, "predicate", "1) Predicate", PropertyFeatureSupport.PREFIX, "Predicate of a fact", null)); AnnotationFeature subjectFeature = createLinkedFeature("subject", "2) Subject", "The subject of a fact.", FactLinkingConstants.SUBJECT_LINK, factLayer, aProject); annotationSchemaService.createFeature(subjectFeature); annotationSchemaService.createLayer(factLayer); AnnotationFeature objectFeature = createLinkedFeature("object", "3) Object", "The object of a fact.", FactLinkingConstants.OBJECT_LINK, factLayer, aProject); annotationSchemaService.createFeature(objectFeature); annotationSchemaService.createLayer(factLayer); AnnotationFeature qualifierFeature = createLinkedFeature("qualifiers", "4) Qualifiers", "The qualifier of a fact.", FactLinkingConstants.QUALIFIER_LINK, factLayer, aProject); annotationSchemaService.createFeature(qualifierFeature); annotationSchemaService.createLayer(factLayer); }
@Test public void simpleCopyToDiffExistingAnnoWithStackingTest() throws Exception { AnnotatorState state = new AnnotatorStateImpl(CURATION); state.setUser(new User()); neLayer.setAllowStacking(true); JCas jcas = createJCas(); Type type = jcas.getTypeSystem().getType(NamedEntity.class.getTypeName()); AnnotationFS clickedFs = createNEAnno(jcas, "NN", 0, 0); JCas mergeCAs = createJCas(); createTokenAnno(mergeCAs, 0, 0); AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0); Feature posValue = type.getFeatureByBaseName("value"); existingFs.setStringValue(posValue, "NE"); mergeCAs.addFsToIndexes(existingFs); MergeCas.addSpanAnnotation(state, annotationSchemaService, neLayer, mergeCAs, clickedFs, true); assertEquals(2, selectCovered(mergeCAs.getCas(), type, 0, 0).size()); }
public static void setLayer(AnnotationService aAnnotationService, AnnotationLayer aLayer, de.tudarmstadt.ukp.clarin.webanno.model.export.AnnotationLayer aExLayer, Project aProject, User aUser) throws IOException { aLayer.setAllowStacking(aExLayer.isAllowStacking()); aLayer.setBuiltIn(aExLayer.isBuiltIn()); aLayer.setCrossSentence(aExLayer.isCrossSentence()); aLayer.setDescription(aExLayer.getDescription()); aLayer.setEnabled(aExLayer.isEnabled()); aLayer.setLockToTokenOffset(aExLayer.isLockToTokenOffset()); aLayer.setMultipleTokens(aExLayer.isMultipleTokens()); aLayer.setLinkedListBehavior(aExLayer.isLinkedListBehavior()); aLayer.setUiName(aExLayer.getUiName()); aLayer.setName(aExLayer.getName()); aLayer.setProject(aProject); aLayer.setType(aExLayer.getType()); aAnnotationService.createLayer(aLayer, aUser); }
@Test public void copySpanWithSlotNoStackingTest() throws Exception { slotLayer.setAllowStacking(false); JCas jcasA = createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1")); Type type = jcasA.getTypeSystem().getType(DiffUtils.HOST_TYPE); Feature feature = type.getFeatureByBaseName("f1"); AnnotationFS clickedFs = DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0)); JCas mergeCAs = JCasFactory .createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1")); DiffUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", DiffUtils.makeLinkFS(mergeCAs, "slot1", 0, 0)); MergeCas.addSpanAnnotation(new AnnotatorStateImpl(CURATION), annotationSchemaService, slotLayer, mergeCAs, clickedFs, false); assertEquals(1, selectCovered(mergeCAs.getCas(), type, 0, 0).size()); }
@Test public void copySpanWithSlotWithStackingTest() throws Exception { AnnotatorState state = new AnnotatorStateImpl(CURATION); state.setUser(new User()); slotLayer.setAnchoringMode(TOKENS); slotLayer.setAllowStacking(true); JCas jcasA = createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1")); Type type = jcasA.getTypeSystem().getType(DiffUtils.HOST_TYPE); Feature feature = type.getFeatureByBaseName("f1"); AnnotationFS clickedFs = DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0)); JCas mergeCAs = JCasFactory .createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1")); DiffUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", DiffUtils.makeLinkFS(mergeCAs, "slot1", 0, 0)); MergeCas.addSpanAnnotation(state, annotationSchemaService, slotLayer, mergeCAs, clickedFs, true); assertEquals(2, selectCovered(mergeCAs.getCas(), type, 0, 0).size()); }