diff --git a/alvisnlp-core/src/main/java/fr/inra/maiage/bibliome/alvisnlp/core/corpus/Layer.java b/alvisnlp-core/src/main/java/fr/inra/maiage/bibliome/alvisnlp/core/corpus/Layer.java index 56bc8a1d..cb20cfdc 100644 --- a/alvisnlp-core/src/main/java/fr/inra/maiage/bibliome/alvisnlp/core/corpus/Layer.java +++ b/alvisnlp-core/src/main/java/fr/inra/maiage/bibliome/alvisnlp/core/corpus/Layer.java @@ -325,16 +325,27 @@ public Layer overlapping(int from, int to) { List list; if (hasOverlaps()) { list = new ArrayList(); - for (Annotation annot : annotations.subList(0, fromi)) - if (annot.getEnd() > from) + for (Annotation annot : annotations.subList(0, fromi)) { + if (annot.getEnd() > from) { list.add(annot); - for (Annotation annot : annotations.subList(fromi, toi)) - list.add(annot); + } + } + if (toi > fromi) { + for (Annotation annot : annotations.subList(fromi, toi - 1)) { + list.add(annot); + } + } } else { - if ((fromi > 0) && (annotations.get(fromi - 1).getEnd() > from)) + if ((fromi > 0) && (annotations.get(fromi - 1).getEnd() > from)) { fromi--; - list = annotations.subList(fromi, toi); + } + if (toi > fromi) { + list = annotations.subList(fromi, toi - 1); + } + else { + list = Collections.emptyList(); + } } return subLayer(list); }