public static KAFDocument join(List<KAFDocument> nafs) { KAFDocument firstNaf = nafs.get(0); KAFDocument joinedNaf = new KAFDocument(firstNaf.getLang(), nafs.get(0).getVersion()); joinedNaf.setRawText(firstNaf.getRawText()); for (KAFDocument nafPart : nafs) { for (AnnotationType type : highLevelAnnotationTypes) { Layer layer = highLevelAnnotationType2Layer.get(type); List<Annotation> annotations = new ArrayList<Annotation>(); if (isMultiLayerAnnotationType(type)) { for (String groupId : nafPart.annotationContainer.getGroupIDs(type)) { annotations.addAll(nafPart.getAnnotations(type, groupId)); } } else { annotations = nafPart.getAnnotations(type); } for (Annotation ann : annotations) { joinedNaf.addExistingAnnotation(ann, layer, type); } } } return joinedNaf; }
public List<KAFDocument> splitInParagraphs() { List<KAFDocument> paraNafs = new ArrayList<KAFDocument>(); Integer numParagraphs = this.getNumParagraphs(); for (Integer paragraph = 1; paragraph <= numParagraphs; paragraph++) { KAFDocument naf = new KAFDocument(this.getLang(), this.getVersion()); naf.setRawText(this.getRawText()); for (AnnotationType type : highLevelAnnotationTypes) { Layer layer = highLevelAnnotationType2Layer.get(type); if (isParagraphLevelAnnotationType(type)) { List<Annotation> annotations = new ArrayList<Annotation>(); if (isMultiLayerAnnotationType(type)) { for (String groupId : annotationContainer.getGroupIDs(type)) { annotations.addAll(this.getByPara(type, groupId, paragraph)); } } else { annotations = this.getByPara(type, paragraph); } for (Annotation ann : annotations) { naf.addExistingAnnotation(ann, layer, type); } } } paraNafs.add(naf); } return paraNafs; }
public List<KAFDocument> splitInSentences() { List<KAFDocument> sentNafs = new ArrayList<KAFDocument>(); Integer numParagraphs = this.getNumParagraphs(); for (Integer paragraph = 1; paragraph <= numParagraphs; paragraph++) { List<Integer> sentences = this.getSentsByParagraph(paragraph); for (Integer sentence : sentences) { KAFDocument naf = new KAFDocument(this.getLang(), this.getVersion()); naf.setRawText(this.getRawText()); for (AnnotationType type : highLevelAnnotationTypes) { Layer layer = highLevelAnnotationType2Layer.get(type); if (isSentenceLevelAnnotationType(type)) { List<Annotation> annotations = new ArrayList<Annotation>(); if (isMultiLayerAnnotationType(type)) { for (String groupId : annotationContainer.getGroupIDs(type)) { annotations.addAll(this.getBySent(type, groupId, sentence)); } } else { annotations = this.getBySent(type, sentence); } for (Annotation ann : annotations) { naf.addExistingAnnotation(ann, layer, type); } } } sentNafs.add(naf); } } return sentNafs; }