Exemple #1
0
        static List <AlignmentElement> ReadInputData(string inputFile, bool swapAlignments = false)
        {
            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.CurrencyDecimalSeparator = ".";
            nfi.NumberDecimalSeparator   = ".";
            nfi.PercentDecimalSeparator  = ".";
            List <AlignmentElement> alignments = new List <AlignmentElement>();
            StreamReader            sr         = new StreamReader(inputFile, Encoding.UTF8);

            char[] sep = { '\t' };
            while (!sr.EndOfStream)
            {
                string   line = sr.ReadLine().Trim();
                string[] data = line.Split(sep, StringSplitOptions.None);
                if (data.Length >= 3)//Only MPAligner ref_tabsep output data is supported!
                {
                    AlignmentElement ae = new AlignmentElement();
                    if (!swapAlignments)
                    {
                        ae.srcTerm        = data[0];
                        ae.trgTerm        = data[1];
                        ae.alignmentScore = Convert.ToDouble(data[2], nfi);
                        if (data.Length >= 9)
                        {
                            ae.srcMsd   = data[3];
                            ae.srcLemma = data[4];
                            ae.trgMsd   = data[5];
                            ae.trgLemma = data[6];
                            ae.srcFile  = data[7];
                            ae.trgFile  = data[8];
                        }
                    }
                    else
                    {
                        ae.srcTerm        = data[1];
                        ae.trgTerm        = data[0];
                        ae.alignmentScore = Convert.ToDouble(data[2], nfi);
                        if (data.Length >= 9)
                        {
                            ae.srcMsd   = data[5];
                            ae.srcLemma = data[6];
                            ae.trgMsd   = data[3];
                            ae.trgLemma = data[4];
                            ae.srcFile  = data[8];
                            ae.trgFile  = data[7];
                        }
                    }
                    alignments.Add(ae);
                }
            }
            sr.Close();
            return(alignments);
        }
Exemple #2
0
 static List<AlignmentElement> ReadInputData(string inputFile, bool swapAlignments = false)
 {
     NumberFormatInfo nfi = new NumberFormatInfo();
     nfi.CurrencyDecimalSeparator = ".";
     nfi.NumberDecimalSeparator = ".";
     nfi.PercentDecimalSeparator = ".";
     List<AlignmentElement> alignments = new List<AlignmentElement>();
     StreamReader sr = new StreamReader(inputFile,Encoding.UTF8);
     char[] sep = { '\t' };
     while(!sr.EndOfStream)
     {
         string line = sr.ReadLine().Trim();
         string[] data = line.Split(sep,StringSplitOptions.None);
         if (data.Length>=3)//Only MPAligner ref_tabsep output data is supported!
         {
             AlignmentElement ae = new AlignmentElement();
             if (!swapAlignments)
             {
                 ae.srcTerm = data[0];
                 ae.trgTerm = data[1];
                 ae.alignmentScore = Convert.ToDouble(data[2],nfi);
                 if (data.Length>=9)
                 {
                     ae.srcMsd = data[3];
                     ae.srcLemma = data[4];
                     ae.trgMsd = data[5];
                     ae.trgLemma = data[6];
                     ae.srcFile = data[7];
                     ae.trgFile = data[8];
                 }
             }
             else
             {
                 ae.srcTerm = data[1];
                 ae.trgTerm = data[0];
                 ae.alignmentScore = Convert.ToDouble(data[2],nfi);
                 if (data.Length>=9)
                 {
                     ae.srcMsd = data[5];
                     ae.srcLemma = data[6];
                     ae.trgMsd = data[3];
                     ae.trgLemma = data[4];
                     ae.srcFile = data[8];
                     ae.trgFile = data[7];
                 }
             }
             alignments.Add(ae);
         }
     }
     sr.Close();
     return alignments;
 }