示例#1
0
        public void readTestFile(string filePath)
        {
            int c = 0;

            featureValues = new List <List <feature> >();
            yValues       = new List <string>();
            using (var mappedFile1 = MemoryMappedFile.CreateFromFile(filePath))
            {
                using (Stream mmStream = mappedFile1.CreateViewStream())
                {
                    using (StreamReader sr = new StreamReader(mmStream, ASCIIEncoding.ASCII))
                    {
                        while (!sr.EndOfStream)
                        {
                            var      line      = sr.ReadLine();
                            string[] lineWords = line.Split(' ');
                            string   yval      = lineWords[0];
                            yValues.Add(yval);
                            featureValues.Add(new List <feature>());
                            for (int i = 1; i < lineWords.Length; i++)
                            {
                                string[] fString  = lineWords[i].Split(':');
                                feature  tFeature = new feature();
                                tFeature.id    = Int32.Parse(fString[0]);
                                tFeature.value = Int32.Parse(fString[1]);
                                featureValues[c].Add(tFeature);
                                if (tFeature.id > maxNumFeature)
                                {
                                    maxNumFeature = tFeature.id;
                                }
                            }
                            c++;
                        }
                    }
                }
            }
        }
 public void readTestFile(string filePath)
 {
     int c = 0;
     featureValues = new List<List<feature>>();
     yValues = new List<string>();
     using (var mappedFile1 = MemoryMappedFile.CreateFromFile(filePath))
     {
         using (Stream mmStream = mappedFile1.CreateViewStream())
         {
             using (StreamReader sr = new StreamReader(mmStream, ASCIIEncoding.ASCII))
             {
                 while (!sr.EndOfStream)
                 {
                     var line = sr.ReadLine();
                     string[] lineWords = line.Split(' ');
                     string yval = lineWords[0];
                     yValues.Add(yval);
                     featureValues.Add(new List<feature>());
                     for (int i = 1; i < lineWords.Length; i++)
                     {
                         string[] fString = lineWords[i].Split(':');
                         feature tFeature = new feature();
                         tFeature.id = Int32.Parse(fString[0]);
                         tFeature.value = Int32.Parse(fString[1]);
                         featureValues[c].Add(tFeature);
                         if (tFeature.id > maxNumFeature)
                         {
                             maxNumFeature = tFeature.id;
                         }
                     }
                     c++;
                 }
             }
         }
     }
 }