コード例 #1
0
        public static void Export(string referencePrefix, string mediaFileName, string outputFilePath, TierCollection tiers)
        {
            const string ktimeFormat = "00.00###";

            using (var stream = File.CreateText(outputFilePath))
            {
                int count                   = tiers.GetTimeTier().Segments.Count;
                var timeSegments            = tiers.GetTimeTier().Segments;
                var transcriptionSegments   = tiers.GetTranscriptionTier(true).Segments;
                var freeTranslationSegments = tiers.GetFreeTranslationTier(true).Segments;

                for (int i = 0; i < count; i++)
                {
                    stream.WriteLine("\\ref " + referencePrefix + "_" + (1 + i).ToString("0000"));
                    var begin = timeSegments[i].TimeRange.StartSeconds.ToString(ktimeFormat);
                    var end   = timeSegments[i].TimeRange.EndSeconds.ToString(ktimeFormat);
                    stream.WriteLine("\\begin " + begin);
                    stream.WriteLine("\\end " + end);
                    stream.WriteLine("\\media " + mediaFileName + " " + begin + " " + end);
                    stream.WriteLine("\\t " + transcriptionSegments[i].Text);
                    stream.WriteLine("\\f " + freeTranslationSegments[i].Text);
                    stream.WriteLine();
                }
            }
        }
コード例 #2
0
        public static void Export(string outputFilePath, TierCollection tiers)
        {
            const string ktimeFormat = "hh\\:mm\\:ss\\.ff";             //ISO 8601 and what ELAN import expects

            using (var stream = File.CreateText(outputFilePath))
            {
                int count                   = tiers.GetTimeTier().Segments.Count;
                var timeSegments            = tiers.GetTimeTier().Segments;
                var transcriptionSegments   = tiers.GetTranscriptionTier(true).Segments;
                var freeTranslationSegments = tiers.GetFreeTranslationTier(true).Segments;

                for (int i = 0; i < count; i++)
                {
                    stream.Write(i + 1 + ",");
                    stream.Write(timeSegments[i].TimeRange.Start.ToString(ktimeFormat));
                    stream.Write(",");
                    stream.Write(timeSegments[i].TimeRange.End.ToString(ktimeFormat) + ",");
                    stream.Write(Escape(transcriptionSegments[i].Text));
                    stream.Write(",");
                    stream.Write(Escape(freeTranslationSegments[i].Text));
                    stream.WriteLine();
                }
            }
        }
コード例 #3
0
ファイル: FLExTextExporter.cs プロジェクト: vkarthim/saymore
        /// ------------------------------------------------------------------------------------
        public IEnumerable <XElement> CreateParagraphElements()
        {
            var transcriptionTier = _tierCollection.GetTranscriptionTier();

            // TODO: This will need refactoring when display name is localizable.
            var translationTier = _tierCollection.GetDependentTextTiers()
                                  .FirstOrDefault(t => t.DisplayName.ToLower() == TextTier.FreeTranslationTierDisplayName.ToLower());

            var segmentList = transcriptionTier.Segments.ToArray();

            var timeTier = _tierCollection.GetTimeTier();

            var timeSegmentList = timeTier.Segments.ToArray();


            for (int i = 0; i < segmentList.Length; i++)
            {
                // _worker will be null during tests.
                if (_worker != null)
                {
                    _worker.ReportProgress(i + 1);
                }

                int startTime = (int)Math.Round(timeSegmentList[i].Start * 1000);
                int endTime   = (int)Math.Round(timeSegmentList[i].End * 1000);

                if (translationTier != null)
                {
                    AnnotationSegment freeTranslationSegment;
                    translationTier.TryGetSegment(i, out freeTranslationSegment);
                    yield return(CreateSingleParagraphElement(segmentList[i].Text,
                                                              (freeTranslationSegment != null ? freeTranslationSegment.Text : null),
                                                              startTime.ToString(CultureInfo.InvariantCulture),
                                                              endTime.ToString(CultureInfo.InvariantCulture)
                                                              ));
                }
            }
        }
コード例 #4
0
 public void GetDoTimeSegmentsExist_WhenSegmentsDoNotExist_ReturnsFalse()
 {
     _collection.GetTimeTier().Segments.Clear();
     Assert.IsFalse(_collection.GetDoTimeSegmentsExist());
 }