Example #1
0
        /// ------------------------------------------------------------------------------------
        public void AddTextTierWithEmptySegments(string id)
        {
            var newTier = new TextTier(id);

            Add(newTier);

            for (int i = 0; i < GetTimeTier().Segments.Count; i++)
            {
                newTier.AddSegment(string.Empty);
            }
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        public TimeSpan GetTotalAnnotatedTime(TextAnnotationType type)
        {
            TextTier textTier = (type == TextAnnotationType.Transcription ? GetTranscriptionTier() :
                                 GetFreeTranslationTier());
            TimeSpan totalTime = TimeSpan.Zero;

            // ReSharper disable once LoopCanBeConvertedToQuery
            for (var i = 0; i < GetTimeTier().Segments.Count; i++)
            {
                if (!string.IsNullOrEmpty(textTier.Segments[i].Text))
                {
                    totalTime += GetTimeTier().Segments[i].TimeRange.Duration;
                }
            }

            return(totalTime);
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        public TierCollection GetTierCollection()
        {
            var collection = new TierCollection();

            var timeSlots = GetTimeSlots();

            var transcriptionAnnotations = GetTranscriptionTierAnnotations();

            if (transcriptionAnnotations.Count == 0)
            {
                return(collection);
            }

            var freeTransAnnotations = GetFreeTranslationTierAnnotations();

            EnsureMediaFileIsCorrect();

            var timeOrderTier     = new TimeTier(GetFullPathToMediaFile());
            var transcriptionTier = new TextTier(TextTier.ElanTranscriptionTierId);
            var freeTransTier     = new TextTier(TextTier.ElanTranslationTierId);

            foreach (var kvp in transcriptionAnnotations)
            {
                var start = timeSlots[kvp.Value.Attribute("TIME_SLOT_REF1").Value];
                var stop  = timeSlots[kvp.Value.Attribute("TIME_SLOT_REF2").Value];
                timeOrderTier.AddSegment(start, stop);
                transcriptionTier.AddSegment(kvp.Value.Value);

                string freeTransValue;
                freeTransTier.AddSegment(freeTransAnnotations.TryGetValue(kvp.Key,
                                                                          out freeTransValue) ? freeTransValue : string.Empty);
            }

            // Add the time and transcription tiers to the collection.
            collection.Add(timeOrderTier);
            collection.Add(transcriptionTier);
            collection.Add(freeTransTier);

            timeOrderTier.ReadOnlyTimeRanges = GetDoesTranscriptionTierHaveDepedentTimeSubdivisionTier();

            return(collection);
        }
Example #4
0
 /// <summary>
 /// Need this because the ignored flag is stored on the transcription and not the translation
 /// </summary>
 public bool GetIsComplete(TextTier transcriptionTier)
 {
     return(!Segments.Where((t, i) => string.IsNullOrEmpty(t.Text) && transcriptionTier.Segments[i].Text != TierCollection.kIgnoreSegment).Any());
 }