Пример #1
0
 private void TaggingSyl()
 {
     foreach (TextGridItem tgi in ItemDict["SYL"])
     {
         if (tgi.Text.Contains('/') || tgi.Text.Contains('\\'))
         {
             tgi.UpdateText("<overlap>");
         }
         else
         {
             string tagText   = StringProcess.NormXSil(tgi.Text);
             string cleanText = StringProcess.CleanupSpace(tagText);
             tgi.UpdateText(cleanText);
         }
     }
 }
Пример #2
0
        private IEnumerable <IInterval> IntervalTransform <T>(IEnumerable <T> collection, IEnumerable <IInterval> intervalList)
        {
            int i     = 0;
            var array = collection.ToArray();

            foreach (var interval in intervalList)
            {
                if (!StringProcess.IsTag(interval.Value()))
                {
                    TextGridInterval ti = new TextGridInterval(interval, array[i].ToString());
                    yield return(ti as IInterval);

                    i++;
                }
            }
        }
Пример #3
0
        private void CreateNewData(string cleanDataPath, string tagDataPath, string noEmptyPath, string wbrPath, string outputPath)
        {
            var noEmptyList = File.ReadLines(cleanDataPath).Select(x => x.Replace(" ", string.Empty));

            File.WriteAllLines(noEmptyPath, noEmptyList);
            var tagList = File.ReadLines(tagDataPath).Select(x => StringProcess.GetTagPrefixIndices(x));



            //RunWordBreak rwb = new RunWordBreak(Cfg);
            //rwb.WordBreak(noEmptyPath, wbrPath);

            var wbrList    = File.ReadLines(wbrPath);
            var outputList = wbrList.Zip(tagList, (x, y) => StringProcess.InsertTagToWords(x, " <bi> ", y)).Select(x => StringProcess.CleanupSpace(x));

            File.WriteAllLines(outputPath, outputList);
        }
Пример #4
0
        private void RefreshTextGridWbr(string cleanDatapath, string tagDataPath, string outputPath, string wbrPath, string tag)
        {
            string tmpName     = Guid.NewGuid().ToString();
            string noEmptyPath = Path.Combine(Cfg.TmpFolder, tmpName + ".noEmpty");

            var noEmptyList = File.ReadLines(cleanDatapath).Select(x => x.Replace(" ", string.Empty));

            File.WriteAllLines(noEmptyPath, noEmptyList);

            RunWordBreak rwb = new RunWordBreak(Cfg);

            rwb.WordBreak(noEmptyPath, wbrPath);

            var tagList    = File.ReadLines(tagDataPath).Select(x => StringProcess.GetTagPrefixIndices(x));
            var wbrList    = File.ReadLines(wbrPath);
            var outputList = wbrList.Zip(tagList, (x, y) => StringProcess.InsertTagToWords(x, " " + tag + " ", y)).Select(x => StringProcess.CleanupSpace(x));

            File.WriteAllLines(outputPath, outputList);
        }
Пример #5
0
        public static void RemoveTagsFromFile(string tagPath, string cleanPath)
        {
            var list = File.ReadLines(tagPath).Select(x => StringProcess.CleanupTag(x));

            File.WriteAllLines(cleanPath, list);
        }
Пример #6
0
        private static IEnumerable <Tuple <string, string> > MatchPairFiles(string pathLine)
        {
            string srcFilePath = pathLine.Split('\t')[1];
            string tgtFilePath = pathLine.Split('\t')[3];

            Console.WriteLine("Processing " + srcFilePath);
            var srcList = File.ReadLines(srcFilePath).Select(x => new InfoLine(x).Transcription).Select(x => StringProcess.CleanupEnuString(x));
            var tgtList = File.ReadLines(tgtFilePath).Select(x => new InfoLine(x).Transcription).Select(x => StringProcess.CleanupChsString(x));

            return(srcList.Zip(tgtList, (x, y) => new Tuple <string, string>(x, y)).Where(ValidPair));
        }
        private void CleanupWbr(string wbrPath, string outputPath)
        {
            var list = File.ReadLines(wbrPath).Select(x => StringProcess.CleanupSpace(x));

            File.WriteAllLines(outputPath, list);
        }