cogcomp-nlp
cogcomp-nlp copied to clipboard
ServerClientAnnotator causes side-effects
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.
Truuu. Could you clarify more on "discrepancies"? (Like give example)
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.
Ah I see. What's your suggestion on this?
How about using annotate function inside ServerClientAnnotator? Does it have this issue too?