Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Possible fix for issues #380 and #372
After fighting with the debugger for two full days, I think I might have found the problem behind these two issues.
In
de.unistuttgart.ims.coref.annotator.document.CoreferenceModel
, when a newFeatureStructure
(e.g. aMention
orEntity
) is created, it is explicitly passed the respectiveorg.apache.uima.jcas.JCas
instance for the document:See the call to
documentModel.getJcas()
above (which could be replaced by justgetJCas()
, but that's another issue). Later in that code,e.addToIndexes()
is called, a method oforg.apache.uima.cas.impl.FeatureStructureImplC
:Here, the instance variable
_casView
seems to be the correct object reference. Adding theFeatureStructure
to the indices works as expected. This is not the case for when e.g. aMention
(orEntity
or anything else) is deleted, renamed, moved, whatever!Here is an example: When deleting a
Mention
, the respective event is passed around and eventually this happens (m
is the object reference to theMention
that is to be deleted):In
FeatureStructureImplC
, this method acts just like theaddToIndexes()
we saw above: It assumes that the instance variable_casView
ofm
holds the correctJCas
reference. I am very far from understanding UIMA and its internal workings, but for me, this looks like it should work. But it doesn't. In fact, the_casView
object used insidem.removeFromIndexes()
is not the same as the one that's used when saving the project or exporting to CSV. I double-checked.Now if we replace every call to
addToIndexes()
andremoveFromIndexes()
insideCoreferenceModel
byaddToIndexes(getJCas())
andremoveFromIndexes(getJCas())
, respectively (so we explicitly pass theJCas
object used for the document), it all starts to work as intended:Important question
Is there any case where a project/document uses multiple
JCas
instances? My solution assumes that the one returned bydocumentModel.getJcas()
is the one true instance. I don't understand the project well enough, so that'd be important to check. If it's okay to just use this reference and pass it around, this PR solves those problems.closes #380
closes #372