Closed giuliabaldini closed 1 year ago
I think the problem may be that cas.select("NamedEntity")
returns a "live view" of the data, so when you remove stuff from the CAS, that loop gets confused. I think you can write something like list(cas.select("NamedEntity"))
to avoid the problem.
I think the problem may be that
cas.select("NamedEntity")
returns a "live view" of the data, so when you remove stuff from the CAS, that loop gets confused. I think you can write something likelist(cas.select("NamedEntity"))
to avoid the problem.
Hey, thank you very much for your answer!
cas.select("NamedEntity")
is already a list, I have checked that with print(type(cas.select("NamedEntity")))
. I have also now run it as you suggested, but the result is the same.
I have also tried doing the following:
to_remove = []
for entity in list(cas.select("NamedEntity")):
if entity.source != "user":
found_entities += 1
to_remove.append(entity)
for e in to_remove:
cas.remove(e)
which also results in the same output.
Found the bug. Annotations were considered equal when their positions were equal which cause the undesired behavior. In fact, I wonder why any annotations remained in the index. That said, I think I have a fix - PR is already there.
@giuliabaldini you can try running your code against the main branch
@reckart thank you very much, it was super fast! From a quick test, everything seems to be alright, I'll get back to you if I have any other problems. Have a nice weekend!
Describe the bug Hey there, thank you for the great package! I am currently using it for my annotations, and I have noticed something weird when trying to remove multiple entities.
To Reproduce Steps to reproduce the behavior:
Output:
Expected behavior I would expect the
remove
function to remove all the entities wheresource
is notuser
. Also, since it removes 50 entities, it also removes annotations that do haveuser
assource
.Please complete the following information:
Thank you very much in advance! Best, Giulia