-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4064 - Support for agreement calculation on document-level annotations
- Added a diff adapter for document-level annotations - Allow document-level layers in coding agreements
- Loading branch information
Showing
7 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
.../tudarmstadt/ukp/clarin/webanno/curation/casdiff/docmeta/DocumentMetadataDiffAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Licensed to the Technische Universität Darmstadt under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The Technische Universität Darmstadt | ||
* licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.docmeta; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.apache.uima.cas.CAS; | ||
import org.apache.uima.cas.FeatureStructure; | ||
import org.apache.uima.fit.util.FSUtil; | ||
import org.apache.uima.jcas.cas.AnnotationBase; | ||
|
||
import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.LinkCompareBehavior; | ||
import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase; | ||
import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.Position; | ||
import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanRenderer; | ||
import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; | ||
|
||
public class DocumentMetadataDiffAdapter | ||
extends DiffAdapter_ImplBase | ||
{ | ||
public DocumentMetadataDiffAdapter(String aType, String... aLabelFeatures) | ||
{ | ||
this(aType, new HashSet<>(asList(aLabelFeatures))); | ||
} | ||
|
||
public DocumentMetadataDiffAdapter(String aType, Set<String> aLabelFeatures) | ||
{ | ||
super(aType, aLabelFeatures); | ||
} | ||
|
||
/** | ||
* @see SpanRenderer#selectAnnotationsInWindow | ||
*/ | ||
@Override | ||
public List<AnnotationBase> selectAnnotationsInWindow(CAS aCas, int aWindowBegin, | ||
int aWindowEnd) | ||
{ | ||
return aCas.<AnnotationBase> select(getType()).asList(); | ||
} | ||
|
||
@Override | ||
public Position getPosition(FeatureStructure aFS, String aFeature, String aRole, | ||
int aLinkTargetBegin, int aLinkTargetEnd, LinkCompareBehavior aLinkCompareBehavior) | ||
{ | ||
String collectionId = null; | ||
String documentId = null; | ||
try { | ||
var dmd = WebAnnoCasUtil.getDocumentMetadata(aFS.getCAS()); | ||
collectionId = FSUtil.getFeature(dmd, "collectionId", String.class); | ||
documentId = FSUtil.getFeature(dmd, "documentId", String.class); | ||
} | ||
catch (IllegalArgumentException e) { | ||
// We use this information only for debugging - so we can ignore if the information | ||
// is missing. | ||
} | ||
|
||
String linkTargetText = null; | ||
if (aLinkTargetBegin != -1 && aFS.getCAS().getDocumentText() != null) { | ||
linkTargetText = aFS.getCAS().getDocumentText().substring(aLinkTargetBegin, | ||
aLinkTargetEnd); | ||
} | ||
|
||
return new DocumentPosition(collectionId, documentId, getType(), aFeature, aRole, | ||
aLinkTargetBegin, aLinkTargetEnd, linkTargetText, aLinkCompareBehavior); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...ain/java/de/tudarmstadt/ukp/clarin/webanno/curation/casdiff/docmeta/DocumentPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to the Technische Universität Darmstadt under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The Technische Universität Darmstadt | ||
* licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.docmeta; | ||
|
||
import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.LinkCompareBehavior; | ||
import de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.Position_ImplBase; | ||
|
||
/** | ||
* Represents a document position. | ||
*/ | ||
public class DocumentPosition | ||
extends Position_ImplBase | ||
{ | ||
private static final long serialVersionUID = -1020728944030217843L; | ||
|
||
public DocumentPosition(String aCollectionId, String aDocumentId, String aType, String aFeature, | ||
String aRole, int aLinkTargetBegin, int aLinkTargetEnd, String aLinkTargetText, | ||
LinkCompareBehavior aLinkCompareBehavior) | ||
{ | ||
super(aCollectionId, aDocumentId, aType, aFeature, aRole, aLinkTargetBegin, aLinkTargetEnd, | ||
aLinkTargetText, aLinkCompareBehavior); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("Document ["); | ||
toStringFragment(builder); | ||
builder.append(']'); | ||
return builder.toString(); | ||
} | ||
|
||
@Override | ||
public String toMinimalString() | ||
{ | ||
return "Document"; | ||
} | ||
} |