Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in BratWriter #1170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Changes in BratWriter #1170

wants to merge 1 commit into from

Conversation

joancf
Copy link

@joancf joancf commented Dec 18, 2017

refactoring of #1169

It adds some parameters to allow:

  • indicate where the html template is located
  • define the sorting order of the annotations above each span
  • define the Feature to be shown for each annotation type

It adds some parameters to allow: 
- indicate where the html template is located
- define the sorting order of the annotations above each span
- define the Feature to be shown for each annotation type
@ukp-svc-jenkins
Copy link

Can one of the admins verify this patch?

@joancf joancf mentioned this pull request Dec 18, 2017
Copy link
Member

@reckart reckart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using Eclipse? If yes, could you please apply the code style available on our contribution website (http://dkpro.github.io/contributing/) to the changed portions of the code?

Some of the changes in this PR seem to particularly have a nicer visualization in mind, but it seems this happens at the sacrifice of being able to do a round trip UIMA<->brat. I think it is a good idea to improve the support for cleaner visualization, but I also believe this should be controlled via options, in particular if the changes create round-trip problems.

What do you think?

{
this("T" + aId, aType, aBegin, aEnd, aText);
{
this("T" + String.format("%04d", aId), aType, aBegin, aEnd, aText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joancf You mentioned in the previous PR this change is done to permit sorting in the JS (btw. the change to the sorting in the JS code is not included in the present PR anymore). But using the padded numbers is kind of brittle as one needs to pre-suppose the number of annotations. How about instead changing the sorting code so that it strips the annotation type letter and then compares the rest of the ID numerically?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we could have an ID of the form "layer-id" for sorting, so it will sort by layer (the layer can be a two digits padded number, more than 100 layers would be crazy)
for example 01-1 01-2 01-3 02-4 02-05 ....

for (String currentType: spanTypes.keySet()){
for (FeatureStructure fs : selectAll(aJCas)) {
String typeName=fs.getType().getName();
String superType = fs.getCAS().getTypeSystem().getParent(fs.getType()).getName();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code seems to take into account only the type and the direct supertype of the FS. When taking into account the direct supertype, it seems sensible to actually check the entire inheritance hierarchy, no? org.apache.uima.cas.TypeSystem.subsumes(Type, Type) should be useful here.

Comment applies also to other changes further down.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used the same way it was used somewhere else in the module. I understood that it was a method to specify the parent type instead of the all the subsumed types.

relationFS.add(fs);
}
else if (hasNonPrimitiveFeatures(fs) && (fs instanceof AnnotationFS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joancf why did you entirely drop the support for annotations with multiple non-primitive features?

BratEventAnnotation event = writeEventAnnotation(doc, (AnnotationFS) fs);
eventFS.put(event, fs);
}
else if (fs instanceof AnnotationFS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you drop the fall-back handling for other types of annotations and the warning if an annotation could not be handled?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the same way as before: why should the component export elements the user hasn't ask for?

@@ -562,7 +598,9 @@ private boolean isSlotFeature(FeatureStructure aFS, Feature aFeature)
private void writeRelationAnnotation(BratAnnotationDocument aDoc, FeatureStructure aFS)
{
RelationParam rel = parsedRelationTypes.get(aFS.getType().getName());

if (rel== null ) {// then is the parent type
rel=parsedRelationTypes.get(aFS.getCAS().getTypeSystem().getParent(aFS.getType()).getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it the parent type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we reach this function the type or his parent is in parsdRelationTypes
if the first one fails then is the parent.
There are soo many relation types that using the parent simplifies the definition.


aDoc.addAnnotation(anno);

// writeAttributes(anno, aFS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you disable the ability to write attributes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not displayed, and I could not see any advantage of having them

@reckart
Copy link
Member

reckart commented Dec 18, 2017

Jenkins, can you test this please?

@reckart
Copy link
Member

reckart commented Jan 19, 2018

@joancf Your changes rather target using the BratWriter to visualize annotations, not doing a lossless round trip CAS -> brat-format -> CAS, right? How about copying the BratWriter class into e.g. BratVisualizationWriter and focussing there on the kind of changes you made? That is probably easier for the moment than trying to handle the two use cases in the same component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants