cogcomp-nlp icon indicating copy to clipboard operation
cogcomp-nlp copied to clipboard

ServerClientAnnotator causes side-effects

Open bhargav opened this issue 8 years ago • 4 comments

Line 156 causes some un-intended side-effects. Since the ServerClientAnnotator creates a temporary TextAnnotation (from the server response), the new view that is added still refers to newTA.

Consider the following scenario:

TextAnnotation ta1  = ... // With views ViewNames.POS, ViewNames.TOKENS, ViewNames.SENTENCE only

ServerClientAnnotator annotator = new ServerClientAnnotator()
annotator.setViews(ViewNames.NER_CONLL)

annotator.addView(ta1) // This creates an instance of newTA on line 151.

ta.getView(ViewNames.POS).getTextAnnotation != ta.getView(ViewNames.NER_CONLL).getTextAnnotation

ta.getView(ViewNames.POS).getTextAnnotation holds a reference to ta1, while ta.getView(ViewNames.NER_CONLL).getTextAnnotation is a reference to newTA. This causes discrepancies while using the generated view's getTextAnnotation method downstream.

bhargav avatar Jul 09 '17 17:07 bhargav

Truuu. Could you clarify more on "discrepancies"? (Like give example)

danyaljj avatar Jul 09 '17 17:07 danyaljj

In Saul, one issue I had was that I was adding text annotations as keys to a HashMap for some evaluation and when I try to access the HashMap using the ta.getView().getTextAnnotation from views added using ServerClientAnnotation, the HashMap says key not found. The newTA created intermediate has empty getId, getCorpusId and empty set of attributes. So hashcode and equals are different than the original document. Not sure if this affects lots of people.

bhargav avatar Jul 09 '17 22:07 bhargav

Ah I see. What's your suggestion on this?

danyaljj avatar Jul 09 '17 22:07 danyaljj

How about using annotate function inside ServerClientAnnotator? Does it have this issue too?

danyaljj avatar Jul 09 '17 22:07 danyaljj