public BratDocument(AnnotationConfiguration config, String id, String text, Collection<BratAnnotation> annotations) { this.config = config; this.id = id; this.text = text; Map<String, BratAnnotation> annMap = new HashMap<>(); List<AnnotatorNoteAnnotation> noteList = new ArrayList<>(); for (BratAnnotation annotation : annotations) { if (annotation instanceof AnnotatorNoteAnnotation) { noteList.add((AnnotatorNoteAnnotation)annotation); } else { annMap.put(annotation.getId(), annotation); } } // attach AnnotatorNote to the appropriate Annotation. // the note should ALWAYS have an appropriate id in the map, // but just to be safe, check for null. for (AnnotatorNoteAnnotation note: noteList) { BratAnnotation annotation = annMap.get(note.getAttachedId()); if (annotation != null) { annotation.setNote(note.getNote()); } } annotationMap = Collections.unmodifiableMap(annMap); }
public BratDocument(AnnotationConfiguration config, String id, String text, Collection<BratAnnotation> annotations) { this.config = config; this.id = id; this.text = text; Map<String, BratAnnotation> annMap = new HashMap<>(); List<AnnotatorNoteAnnotation> noteList = new ArrayList<>(); for (BratAnnotation annotation : annotations) { if (annotation instanceof AnnotatorNoteAnnotation) { noteList.add((AnnotatorNoteAnnotation)annotation); } else { annMap.put(annotation.getId(), annotation); } } // attach AnnotatorNote to the appropriate Annotation. // the note should ALWAYS have an appropriate id in the map, // but just to be safe, check for null. for (AnnotatorNoteAnnotation note: noteList) { BratAnnotation annotation = annMap.get(note.getAttachedId()); if (annotation != null) { annotation.setNote(note.getNote()); } } annotationMap = Collections.unmodifiableMap(annMap); }