Ejemplo n.º 1
0
        public void ReadInput(string filePath)
        {
            int h = 0;

            featureValues = new List <List <feature> >();
            yValues       = new List <int>();
            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(' ');
                            int      temp;
                            int      yval = Int32.TryParse(lineWords[0], out temp) ? temp : +1;
                            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[h].Add(tFeature);
                                if (tFeature.id > maxNumFeature)
                                {
                                    maxNumFeature = tFeature.id;
                                }
                            }
                            h++;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void ReadInput(string filePath)
 {
     int h = 0;
     featureValues = new List<List<feature>>();
     yValues = new List<int>();
     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(' ');
                     int temp;
                     int yval = Int32.TryParse(lineWords[0], out temp) ? temp : +1;
                     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[h].Add(tFeature);
                         if (tFeature.id > maxNumFeature)
                         {
                             maxNumFeature = tFeature.id;
                         }
                     }
                     h++;
                 }
             }
         }
     }
 }