Skip to content

Commit

Permalink
#334 quick fix: try to keep entities in order of their appearance and…
Browse files Browse the repository at this point in the history
… skip those one which intersects with the prior
  • Loading branch information
nicolay-r committed Jun 15, 2022
1 parent a4df945 commit f506fd3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion arekit/contrib/source/brat/sentence.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ def add_local_entity(self, entity):
assert(isinstance(entity, BratEntity))
self.__entities.append(entity)

def iter_entity_with_local_bounds(self):
def iter_entity_with_local_bounds(self, avoid_intersection=True):
last_position = -1

for entity in self.__entities:
start = entity.CharIndexBegin - self.__begin
end = entity.CharIndexEnd - self.__begin

if start <= last_position and avoid_intersection:
# intersected with the previous one.
continue

yield entity, Bound(pos=start, length=end - start)
last_position = end

def is_entity_goes_after(self, entity):
assert(isinstance(entity, BratEntity))
Expand Down

0 comments on commit f506fd3

Please sign in to comment.