📄 acm23transcriptionstore.java
字号:
if (debug) { System.out.println("Parsing eaf took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } if ((mediaFileName != null) && (mediaFileName.startsWith("file:"))) { mediaFileName = mediaFileName.substring(5); } attisTr.setMainMediaFile(mediaFileName); // make media descriptors available in transcription ArrayList mediaDescriptors = parser.getMediaDescriptors(trPathName); attisTr.setMediaDescriptors(new Vector(mediaDescriptors)); String svgFile = parser.getSVGFile(trPathName); if (svgFile != null) { if (!svgFile.startsWith("file:")) { svgFile = "file:" + mediaFileName; } attisTr.setSVGFile(svgFile); } // add linked file descriptors ArrayList linkedFileDescriptors = parser.getLinkedFileDescriptors(trPathName); if (linkedFileDescriptors != null) { attisTr.setLinkedFileDescriptors(new Vector(linkedFileDescriptors)); } // set author String author = parser.getAuthor(trPathName); if (attisTr.getAuthor().equals("")) { attisTr.setAuthor(author); } if (debug) { System.out.println("Extracting header took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } // make linguistic types available in transcription ArrayList linguisticTypes = parser.getLinguisticTypes(trPathName); ArrayList typesCopy = new ArrayList(linguisticTypes.size()); for (int i = 0; i < linguisticTypes.size(); i++) { // typesCopy.add(i, linguisticTypes.get(i)); LingTypeRecord ltr = (LingTypeRecord) linguisticTypes.get(i); LinguisticType lt = new LinguisticType(ltr.getLingTypeId()); boolean timeAlignable = true; if (ltr.getTimeAlignable().equals("false")) { timeAlignable = false; } lt.setTimeAlignable(timeAlignable); boolean graphicReferences = false; if (ltr.getGraphicReferences().equals("true")) { graphicReferences = true; } lt.setGraphicReferences(graphicReferences); String stereotype = ltr.getStereoType(); Constraint c = null; if (stereotype != null) { stereotype = stereotype.replace('_', ' '); // for backwards compatibility if (stereotype.equals( Constraint.stereoTypes[Constraint.TIME_SUBDIVISION])) { c = new TimeSubdivision(); } else if (stereotype.equals( Constraint.stereoTypes[Constraint.SYMBOLIC_SUBDIVISION])) { c = new SymbolicSubdivision(); } else if (stereotype.equals( Constraint.stereoTypes[Constraint.SYMBOLIC_ASSOCIATION])) { c = new SymbolicAssociation(); } else if (stereotype.equals( Constraint.stereoTypes[Constraint.INCLUDED_IN])) { c = new IncludedIn(); } } if (c != null) { lt.addConstraint(c); } lt.setControlledVocabularyName(ltr.getControlledVocabulary()); typesCopy.add(lt); } attisTr.setLinguisticTypes(new Vector(typesCopy)); if (debug) { System.out.println("Creating linguistic types took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } //attisTr.setLinguisticTypes(linguisticTypes); TimeOrder timeOrder = attisTr.getTimeOrder(); // populate TimeOrder with TimeSlots ArrayList order = parser.getTimeOrder(trPathName); HashMap slots = parser.getTimeSlots(trPathName); HashMap timeSlothash = new HashMap(); // temporarily stores map from id to TimeSlot object Iterator orderedIter = order.iterator(); TimeSlot ts = null; String tsKey = null; long time; ArrayList tempSlots = new ArrayList(order.size()); int index = 0; // jan 2006: sort the timeslots before adding them all to the TimeOrder object // (for performance reasons) while (orderedIter.hasNext()) { tsKey = (String) orderedIter.next(); time = Long.parseLong((String) slots.get(tsKey)); if (time != TimeSlot.TIME_UNALIGNED) { ts = new TimeSlotImpl(time, timeOrder); } else { ts = new TimeSlotImpl(timeOrder); } ts.setIndex(index++); //timeOrder.insertTimeSlot(ts); tempSlots.add(ts); timeSlothash.put(tsKey, ts); } Collections.sort(tempSlots, new TimeSlotComparator()); ((TimeOrderImpl) timeOrder).insertOrderedSlots(tempSlots); if (debug) { System.out.println("Creating time slots and time order took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } HashMap parentHash = new HashMap(); if (!attisTr.isLoaded()) { Iterator iter = parser.getTierNames(trPathName).iterator(); // HB, 27 aug 03, moved earlier attisTr.setLoaded(true); // else endless recursion !!!!! while (iter.hasNext()) { String tierName = (String) iter.next(); TierImpl tier = new TierImpl(null, tierName, null, attisTr, null); // set tier's metadata String participant = parser.getParticipantOf(tierName, trPathName); String linguisticTypeID = parser.getLinguisticTypeIDOf(tierName, trPathName); LinguisticType linguisticType = null; Iterator typeIter = typesCopy.iterator(); while (typeIter.hasNext()) { LinguisticType lt = (LinguisticType) typeIter.next(); if (lt.getLinguisticTypeName().equals(linguisticTypeID)) { linguisticType = lt; break; } } Locale defaultLanguage = parser.getDefaultLanguageOf(tierName, trPathName); tier.setMetadata("PARTICIPANT", participant); tier.setLinguisticType(linguisticType); if (defaultLanguage != null) { // HB, 29 oct 02: added condition, since DEFAULT_LOCALE is IMPLIED tier.setMetadata("DEFAULT_LOCALE", defaultLanguage); } // potentially, set tier's parent String parentId = parser.getParentNameOf(tierName, trPathName); if (parentId != null) { // store tier-parent_id pair until all Tiers instantiated parentHash.put(tier, parentId); } attisTr.addTier(tier); } } // all Tiers are created. Now set all parent tiers Iterator parentIter = parentHash.keySet().iterator(); while (parentIter.hasNext()) { TierImpl t = (TierImpl) parentIter.next(); t.setParentTier(attisTr.getTierWithId((String) parentHash.get(t))); } if (debug) { System.out.println("Creating tiers took: " + (System.currentTimeMillis() - beginTime) + " ms"); beginTime = System.currentTimeMillis(); } // attisTr.setLoaded(true); // else endless recursion !!!!! Vector tiers = attisTr.getTiers(); // create Annotations. Algorithm: // 1. loop over annotationRecords Vector. Instantiate right Annotations. Store // references to annotations in intermediate data structures // 2. loop over intermediate structure. Realize references to Annotations by object // references, iso using annotation_id's HashMap idToAnnotation = new HashMap(); HashMap references = new HashMap(); HashMap referenceChains = new HashMap(); // HB, 2-1-02: temporarily store annotations, before adding them to tiers. // Reason: object reference have to be in place to add annotations in correct order. HashMap tempAnnotationsForTiers = new HashMap(); // create Annotations, either AlignableAnnotations or RefAnnotations Iterator tierIter = tiers.iterator(); while (tierIter.hasNext()) { Tier tier = (Tier) tierIter.next(); ArrayList annotationRecords = parser.getAnnotationsOf(tier.getName(), trPathName); // HB, 2-1-02 ArrayList tempAnnotations = new ArrayList(); Iterator it1 = annotationRecords.iterator(); while (it1.hasNext()) { Annotation annotation = null; AnnotationRecord annotationRecord = (AnnotationRecord) it1.next(); if (annotationRecord.getAnnotationType().equals(AnnotationRecord.ALIGNABLE)) { // when the parser does not find an SVG_REF attribute the annotation is // marked alignable even if it is on a tier that allows graphic references, // therefore check here whether to create an AlignableAnnotation or a // SVGAlignableAnnotation if (((TierImpl) tier).getLinguisticType() .hasGraphicReferences()) { annotation = new SVGAlignableAnnotation((TimeSlot) timeSlothash.get( annotationRecord.getBeginTimeSlotId()), (TimeSlot) timeSlothash.get( annotationRecord.getEndTimeSlotId()), tier, null);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -