📄 acm23transcriptionstore.java
字号:
} else { annotation = new AlignableAnnotation((TimeSlot) timeSlothash.get( annotationRecord.getBeginTimeSlotId()), (TimeSlot) timeSlothash.get( annotationRecord.getEndTimeSlotId()), tier); } /* annotation = new SVGAlignableAnnotation((TimeSlot) timeSlothash.get( timeSlotId1), (TimeSlot) timeSlothash.get(timeSlotId2), tier, null); */ } else if (annotationRecord.getAnnotationType().equals(AnnotationRecord.ALIGNABLE_SVG)) { annotation = new SVGAlignableAnnotation((TimeSlot) timeSlothash.get( annotationRecord.getBeginTimeSlotId()), (TimeSlot) timeSlothash.get( annotationRecord.getEndTimeSlotId()), tier, annotationRecord.getSvgReference()); } else if (annotationRecord.getAnnotationType().equals(AnnotationRecord.REFERENCE)) { annotation = new RefAnnotation(null, tier); references.put(annotationRecord.getAnnotationId(), annotationRecord.getReferredAnnotId()); if (annotationRecord.getPreviousAnnotId() != null) { referenceChains.put(annotationRecord.getAnnotationId(), annotationRecord.getPreviousAnnotId()); } } if (annotationRecord.getValue() != null) { annotation.setValue(annotationRecord.getValue()); } annotation.setId(annotationRecord.getAnnotationId()); idToAnnotation.put(annotationRecord.getAnnotationId(), annotation); // tier.addAnnotation(annotation); // HB, 2-1-02 tempAnnotations.add(annotation); } // end of loop over annotation records // HB, 2-1-02 tempAnnotationsForTiers.put(tier, tempAnnotations); } // end of loop over tierIter // realize object references Iterator refIter = references.keySet().iterator(); while (refIter.hasNext()) { String key = (String) refIter.next(); Annotation referedAnnotation = (Annotation) idToAnnotation.get(references.get( key)); RefAnnotation refAnnotation = null; try { refAnnotation = (RefAnnotation) idToAnnotation.get(key); refAnnotation.addReference(referedAnnotation); } catch (Exception ex) { //MK:02/09/17 adding exception handler Object o = idToAnnotation.get(key); LOG.warning("failed to add a refanno to (" + referedAnnotation.getTier().getName() + ", " + referedAnnotation.getBeginTimeBoundary() + ", " + referedAnnotation.getEndTimeBoundary() + ") " + referedAnnotation.getValue()); if (o instanceof AlignableAnnotation) { AlignableAnnotation a = (AlignableAnnotation) o; LOG.warning(" found AlignableAnnotation (" + a.getTier().getName() + ", " + a.getBeginTimeBoundary() + ", " + a.getEndTimeBoundary() + ") " + a.getValue()); } else { LOG.warning(" found " + o); } } } // realize reference chains (== within tiers) Iterator rIter = referenceChains.keySet().iterator(); while (rIter.hasNext()) { String key = (String) rIter.next(); RefAnnotation previous = (RefAnnotation) idToAnnotation.get(referenceChains.get( key)); RefAnnotation a = (RefAnnotation) idToAnnotation.get(key); if (previous != null) { previous.setNext(a); } } // HB, 2-1-01: with object references in place, add annotations to the correct tiers. // This is now done in the correct order (RefAnnotation.compareTo delegates comparison // to it's parent annotation. Iterator tIter = tempAnnotationsForTiers.keySet().iterator(); while (tIter.hasNext()) { TierImpl t = (TierImpl) tIter.next(); ArrayList annots = (ArrayList) tempAnnotationsForTiers.get(t); Iterator aIter = annots.iterator(); while (aIter.hasNext()) { // HB, 14 aug 02, changed from addAnnotation t.insertAnnotation((Annotation) aIter.next()); } } // HB, 4-7-02: with all annotations on the proper tiers, register implicit // parent-child relations between alignable annotations explicitly Iterator tierIter2 = tiers.iterator(); while (tierIter2.hasNext()) { TierImpl t = (TierImpl) tierIter2.next(); if (t.isTimeAlignable() && t.hasParentTier()) { Iterator alannIter = t.getAnnotations().iterator(); while (alannIter.hasNext()) { Annotation a = (Annotation) alannIter.next(); if (a instanceof AlignableAnnotation) { ((AlignableAnnotation) a).registerWithParent(); } } } } if (debug) { System.out.println("Creating and connecting annotations took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } // HS jun 2004 create the ControlledVocabularies, if any HashMap cvTable = parser.getControlledVocabularies(trPathName); if ((cvTable != null) && (cvTable.size() > 0)) { ControlledVocabulary cv = null; Iterator cvIt = cvTable.keySet().iterator(); while (cvIt.hasNext()) { String cvName = (String) cvIt.next(); if (cvName == null) { continue; } cv = new ControlledVocabulary(cvName); // the contents vector can contain one description String // and many CVEntryRecords ArrayList contents = (ArrayList) cvTable.get(cvName); if (contents.size() > 0) { Object next; CVEntry entry; for (int i = 0; i < contents.size(); i++) { next = contents.get(i); if (next instanceof String) { cv.setDescription((String) next); } else if (next instanceof CVEntryRecord) { entry = new CVEntry(((CVEntryRecord) next).getValue(), ((CVEntryRecord) next).getDescription()); if (entry != null) { cv.addEntry(entry); } } } } //cv.setACMEditableObject(attisTr); attisTr.addControlledVocabulary(cv); } } if (debug) { System.out.println("Creating CV's took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } // if all root annotations unaligned (in case of shoebox or chat import) // align them at 1 second intervals if (attisTr.allRootAnnotsUnaligned()) { attisTr.alignRootAnnots(); } // hb, 23-9-04 // There are cases where more than one symbolically associated annotation refers // to the same parent annotation (e.g. shoebox files with interlinearized tiers // with 'tokens' separated by spaces, as for Advanced Glossing stuff. // Fix this by concatenating the values of those annotations in one RefAnnotation concatenateSymbolicAssociations(attisTr); if (debug) { System.out.println("Post-processing took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } //System.out.println("getName: " + attisTr.getName()); //System.out.println("fullpath: " + attisTr.getFullPath()); //System.out.println("pathname: " + attisTr.getPathName()); } private void concatenateSymbolicAssociations( TranscriptionImpl transcription) { Annotation lastParent = null; RefAnnotation lastAnnot = null; Vector annotsToRemove = new Vector(); Vector tiers = transcription.getTiers(); Iterator tierIter = tiers.iterator(); while (tierIter.hasNext()) { lastParent = null; lastAnnot = null; annotsToRemove.clear(); TierImpl t = (TierImpl) tierIter.next(); LinguisticType lt = t.getLinguisticType(); Constraint c = null; if (lt != null) { c = lt.getConstraints(); } if ((c != null) && (c.getStereoType() == Constraint.SYMBOLIC_ASSOCIATION)) { // iterate over annots, take annots with same parent together Iterator annIter = t.getAnnotations().iterator(); while (annIter.hasNext()) { RefAnnotation a = (RefAnnotation) annIter.next(); if (a.getParentAnnotation() == lastParent) { lastAnnot.setValue(lastAnnot.getValue() + " " + a.getValue()); annotsToRemove.add(a); } else { lastParent = a.getParentAnnotation(); lastAnnot = a; } } // remove concatenated annots Iterator rIter = annotsToRemove.iterator(); while (rIter.hasNext()) { t.removeAnnotation((Annotation) rIter.next()); } } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -