void add(Annotation ann, Layer layer, AnnotationType type, Integer position) { Helper.addAnnotation(ann, layer, getGroupID(ann), position, this.layers); Helper.addAnnotation(ann, type, getGroupID(ann), position, this.annotations); /* Index */ this.indexAnnotation(ann, type); }
void reindexAnnotationParaSent(Annotation ann, AnnotationType type, Integer oldSent, Integer oldPara) { String groupID = getGroupID(ann); /* Remove index */ Helper.removeFromIndex(ann, type, groupID, oldSent, this.sentIndex); Helper.removeFromIndex(ann, type, groupID, oldPara, this.paraIndex); /* Re-index */ this.indexAnnotationParaSent(ann, type); /* Re-index related annotations */ /* for (Layer relatedLayer : Layer.values()) { for (Annotation relatedAnn : this.getInverse(ann, relatedLayer)) { System.out.println("SARTZERA"); this.reindexAnnotationParaSent(relatedAnn, relatedLayer, oldSent, oldPara); } } */ }
void remove(Annotation ann, Layer layer, AnnotationType type, String group) { Helper.remove(ann, layer, this.layers); Helper.remove(ann, type, this.annotations); if (ann instanceof SentenceLevelAnnotation) { String groupID = getGroupID(ann); Integer sent = ((SentenceLevelAnnotation) ann).getSent(); List<Annotation> sentAnnotations = this.getSentAnnotations(sent, type, groupID); sentAnnotations.remove(ann); if (ann instanceof ParagraphLevelAnnotation) { Integer para = ((ParagraphLevelAnnotation) ann).getPara(); List<Annotation> paraAnnotations = this.getParaAnnotations(para, type, groupID); paraAnnotations.remove(ann); } } }
private void indexAnnotationParaSent(Annotation ann, AnnotationType type) { String groupID = getGroupID(ann); if (ann instanceof SentenceLevelAnnotation) { Integer sent = ((SentenceLevelAnnotation) ann).getSent(); Integer para = ((ParagraphLevelAnnotation) ann).getPara(); Helper.addToIndex(ann, type, groupID, sent, this.sentIndex); if (para > 0) { Helper.addToIndex(ann, type, groupID, para, this.paraIndex); if (!indexedSents.contains(sent)) { this.addSentToPara(sent, para); indexedSents.add(sent); } } } else if (ann instanceof ParagraphLevelAnnotation) { Integer para = ((ParagraphLevelAnnotation) ann).getPara(); if (para > 0) { Helper.addToIndex(ann, type, groupID, para, this.paraIndex); } } }