This class is used internally to parse Encog files. A file section is part of a name-value pair file.
Beispiel #1
0
        /// <summary>
        ///     Load a generic subsection.
        /// </summary>
        /// <param name="section">The section to load from.</param>
        private void LoadSubSection(EncogFileSection section)
        {
            IDictionary<String, String> prop = section.ParseParams();


            foreach (String name in prop.Keys)
            {
                String key = section.SectionName.ToUpper() + ":"
                             + section.SubSectionName.ToUpper() + "_" + name;
                String v = prop[name] ?? "";
                ValidateProperty(section.SectionName,
                                 section.SubSectionName, name, v);
                _script.Properties.SetProperty(key, v);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Process one of the subsections.
        /// </summary>
        /// <param name="section">The section.</param>
        private void ProcessSubSection(EncogFileSection section)
        {
            String currentSection = section.SectionName;
            String currentSubsection = section.SubSectionName;

            if (currentSection.Equals("SETUP")
                && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("SETUP")
                     && currentSubsection.Equals("FILENAMES", StringComparison.InvariantCultureIgnoreCase))
            {
                HandleFilenames(section);
            }
            else if (currentSection.Equals("DATA")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("DATA")
                     && currentSubsection.Equals("STATS", StringComparison.InvariantCultureIgnoreCase))
            {
                HandleDataStats(section);
            }
            else if (currentSection.Equals("DATA")
                     && currentSubsection.Equals("CLASSES", StringComparison.InvariantCultureIgnoreCase))
            {
                HandleDataClasses(section);
            }
            else if (currentSection.Equals("NORMALIZE")
                     && currentSubsection.Equals("RANGE", StringComparison.InvariantCultureIgnoreCase))
            {
                HandleNormalizeRange(section);
            }
            else if (currentSection.Equals("NORMALIZE")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("NORMALIZE")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("CLUSTER")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("SERIES")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("RANDOMIZE")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("SEGREGATE")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("SEGREGATE")
                     && currentSubsection.Equals("FILES", StringComparison.InvariantCultureIgnoreCase))
            {
                HandleSegregateFiles(section);
            }
            else if (currentSection.Equals("GENERATE")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("HEADER")
                     && currentSubsection.Equals("DATASOURCE", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("ML")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("ML")
                     && currentSubsection.Equals("TRAIN", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("TASKS")
                     && (currentSubsection.Length > 0))
            {
                HandleTask(section);
            }
            else if (currentSection.Equals("BALANCE")
                     && currentSubsection.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("CODE")
                     && currentSubsection.Equals("CONFIG"))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("PROCESS")
                     && currentSubsection.Equals("CONFIG"))
            {
                LoadSubSection(section);
            }
            else if (currentSection.Equals("PROCESS")
                     && currentSubsection.Equals("FIELDS"))
            {
                HandleProcessFields(section);
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Handle loading segregation info.
        /// </summary>
        /// <param name="section">The section being loaded.</param>
        private void HandleSegregateFiles(EncogFileSection section)
        {
            IList<AnalystSegregateTarget> nfs = new List<AnalystSegregateTarget>();
            bool first = true;

            foreach (String line in section.Lines)
            {
                if (!first)
                {
                    IList<String> cols = EncogFileSection.SplitColumns(line);
                    String filename = cols[0];
                    int percent = Int32.Parse(cols[1]);

                    var nf = new AnalystSegregateTarget(
                        filename, percent);
                    nfs.Add(nf);
                }
                else
                {
                    first = false;
                }
            }

            var array = new AnalystSegregateTarget[nfs.Count];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = nfs[i];
            }

            _script.Segregate.SegregateTargets = array;
        }
Beispiel #4
0
        /// <summary>
        ///     Handle loading a task.
        /// </summary>
        /// <param name="section">The section.</param>
        private void HandleTask(EncogFileSection section)
        {
            var task = new AnalystTask(section.SubSectionName);

            foreach (String line in section.Lines)
            {
                task.Lines.Add(line);
            }
            _script.AddTask(task);
        }
        /// <summary>
        /// Read the next section.
        /// </summary>
        ///
        /// <returns>The next section.</returns>
        public EncogFileSection ReadNextSection()
        {
            try
            {
                String line;
                var    largeArrays = new List <double[]>();

                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    // is it a comment
                    if (line.StartsWith("//"))
                    {
                        continue;
                    }

                    // is it a section or subsection
                    else if (line.StartsWith("["))
                    {
                        // handle previous section
                        section = new EncogFileSection(
                            currentSectionName, currentSubSectionName);

                        foreach (String str in lines)
                        {
                            section.Lines.Add(str);
                        }


                        // now begin the new section
                        lines.Clear();
                        String s = line.Substring(1).Trim();
                        if (!s.EndsWith("]"))
                        {
                            throw new PersistError("Invalid section: " + line);
                        }
                        s = s.Substring(0, (line.Length - 2) - (0));
                        int idx = s.IndexOf(':');
                        if (idx == -1)
                        {
                            currentSectionName    = s;
                            currentSubSectionName = "";
                        }
                        else
                        {
                            if (currentSectionName.Length < 1)
                            {
                                throw new PersistError(
                                          "Can't begin subsection when a section has not yet been defined: "
                                          + line);
                            }

                            String newSection    = s.Substring(0, (idx) - (0));
                            String newSubSection = s.Substring(idx + 1);

                            if (!newSection.Equals(currentSectionName))
                            {
                                throw new PersistError("Can't begin subsection "
                                                       + line
                                                       + ", while we are still in the section: "
                                                       + currentSectionName);
                            }

                            currentSubSectionName = newSubSection;
                        }
                        section.LargeArrays = largeArrays;
                        return(section);
                    }
                    else if (line.Length < 1)
                    {
                        continue;
                    }
                    else if (line.StartsWith("##double"))
                    {
                        double[] d = ReadLargeArray(line);
                        largeArrays.Add(d);
                    }
                    else
                    {
                        if (currentSectionName.Length < 1)
                        {
                            throw new PersistError(
                                      "Unknown command before first section: " + line);
                        }

                        lines.Add(line);
                    }
                }

                if (currentSectionName.Length == 0)
                {
                    return(null);
                }

                section = new EncogFileSection(currentSectionName,
                                               currentSubSectionName);

                foreach (String l in lines)
                {
                    section.Lines.Add(l);
                }

                currentSectionName    = "";
                currentSubSectionName = "";
                section.LargeArrays   = largeArrays;
                return(section);
            }
            catch (IOException ex)
            {
                throw new PersistError(ex);
            }
        }
Beispiel #6
0
 private void x5e3dc7f2e4f7d693(EncogFileSection xb32f8dd719a105db)
 {
     AnalystTask task = new AnalystTask(xb32f8dd719a105db.SubSectionName);
     foreach (string str in xb32f8dd719a105db.Lines)
     {
         task.Lines.Add(str);
     }
     this._x594135906c55045c.AddTask(task);
 }
Beispiel #7
0
 private void xff55b61ba453487f(EncogFileSection xb32f8dd719a105db)
 {
     // This item is obfuscated and can not be translated.
 }
Beispiel #8
0
        /// <summary>
        ///     Handle loading the data classes.
        /// </summary>
        /// <param name="section">The section being loaded.</param>
        private void HandleDataClasses(EncogFileSection section)
        {
            var map = new Dictionary<String, List<AnalystClassItem>>();

            bool first = true;

            foreach (String line in section.Lines)
            {
                if (!first)
                {
                    IList<String> cols = EncogFileSection.SplitColumns(line);

                    if (cols.Count < ColumnFour)
                    {
                        throw new AnalystError("Invalid data class: " + line);
                    }

                    String field = cols[0];
                    String code = cols[1];
                    String name = cols[2];
                    int count = Int32.Parse(cols[3]);

                    DataField df = _script.FindDataField(field);

                    if (df == null)
                    {
                        throw new AnalystError(
                            "Attempting to add class to unknown field: " + name);
                    }

                    List<AnalystClassItem> classItems;

                    if (!map.ContainsKey(field))
                    {
                        classItems = new List<AnalystClassItem>();
                        map[field] = classItems;
                    }
                    else
                    {
                        classItems = map[field];
                    }

                    classItems.Add(new AnalystClassItem(code, name, count));
                }
                else
                {
                    first = false;
                }
            }


            foreach (DataField field in _script.Fields)
            {
                if (field.Class)
                {
                    List<AnalystClassItem> classList = map[field.Name];
                    if (classList != null)
                    {
                        classList.Sort();
                        field.ClassMembers.Clear();
                        foreach (AnalystClassItem item in classList)
                        {
                            field.ClassMembers.Add(item);
                        }
                    }
                }
            }
        }
Beispiel #9
0
 private void xf9edee23632d6876(EncogFileSection xb32f8dd719a105db)
 {
     string sectionName = xb32f8dd719a105db.SectionName;
     string subSectionName = xb32f8dd719a105db.SubSectionName;
     if (!sectionName.Equals("SETUP"))
     {
         goto Label_041D;
     }
     if (0x7fffffff == 0)
     {
         if (2 != 0)
         {
             goto Label_0366;
         }
         goto Label_03A8;
     }
     if (0x7fffffff == 0)
     {
         if (0x7fffffff == 0)
         {
             return;
         }
         goto Label_041D;
     }
     if (0x7fffffff == 0)
     {
         goto Label_00C3;
     }
     if ((0 == 0) && !subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_041D;
     }
     this.xff55b61ba453487f(xb32f8dd719a105db);
     return;
     Label_000E:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_0044;
     }
     if (3 == 0)
     {
         goto Label_03ED;
     }
     return;
     Label_002D:
     if (!sectionName.Equals("BALANCE"))
     {
         return;
     }
     goto Label_000E;
     Label_0044:
     this.xff55b61ba453487f(xb32f8dd719a105db);
     return;
     Label_0055:
     if (!sectionName.Equals("TASKS"))
     {
         goto Label_002D;
     }
     if (subSectionName.Length <= 0)
     {
         if (3 != 0)
         {
             goto Label_002D;
         }
         if (0 == 0)
         {
             goto Label_000E;
         }
         if (0 != 0)
         {
             goto Label_03FF;
         }
         goto Label_0044;
     }
     this.x5e3dc7f2e4f7d693(xb32f8dd719a105db);
     return;
     Label_0088:
     if (!sectionName.Equals("ML") || !subSectionName.Equals("TRAIN", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_0055;
     }
     this.xff55b61ba453487f(xb32f8dd719a105db);
     if (-2147483648 != 0)
     {
         return;
     }
     goto Label_00C3;
     Label_00B3:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xff55b61ba453487f(xb32f8dd719a105db);
         return;
     }
     goto Label_0088;
     Label_00C3:
     if (0 != 0)
     {
         goto Label_00B3;
     }
     goto Label_0088;
     Label_00DC:
     if (!sectionName.Equals("ML"))
     {
         goto Label_0088;
     }
     goto Label_00B3;
     Label_0105:
     if (!sectionName.Equals("HEADER"))
     {
         goto Label_00DC;
     }
     if (-2 != 0)
     {
         if (8 != 0)
         {
             if (subSectionName.Equals("DATASOURCE", StringComparison.InvariantCultureIgnoreCase))
             {
                 this.xff55b61ba453487f(xb32f8dd719a105db);
                 return;
             }
             if (1 == 0)
             {
                 goto Label_02C5;
             }
             goto Label_00DC;
         }
         goto Label_0055;
     }
     if (-2147483648 != 0)
     {
         goto Label_0136;
     }
     Label_0120:
     if (!subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         if (0 != 0)
         {
             goto Label_0366;
         }
         goto Label_0105;
     }
     Label_0136:
     this.xff55b61ba453487f(xb32f8dd719a105db);
     return;
     Label_013E:
     if (sectionName.Equals("GENERATE"))
     {
         goto Label_0120;
     }
     goto Label_0105;
     Label_0164:
     if (!sectionName.Equals("SEGREGATE"))
     {
         if (4 == 0)
         {
             return;
         }
         goto Label_013E;
     }
     Label_01A4:
     if (!subSectionName.Equals("FILES", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_013E;
     }
     if (0 == 0)
     {
         this.x3ed9c05d3bbdec37(xb32f8dd719a105db);
         if (0 == 0)
         {
             return;
         }
         goto Label_02F2;
     }
     if (0 == 0)
     {
         goto Label_0293;
     }
     if (0 == 0)
     {
         return;
     }
     goto Label_022C;
     Label_01CE:
     if (!sectionName.Equals("SEGREGATE"))
     {
         goto Label_0164;
     }
     if (!subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         if (-2147483648 == 0)
         {
             return;
         }
         if (3 == 0)
         {
             return;
         }
         if (-2147483648 == 0)
         {
             goto Label_0210;
         }
         if (0 != 0)
         {
             goto Label_01A4;
         }
         goto Label_0164;
     }
     this.xff55b61ba453487f(xb32f8dd719a105db);
     if (-2 != 0)
     {
     }
     return;
     Label_0203:
     if (!sectionName.Equals("RANDOMIZE"))
     {
         goto Label_01CE;
     }
     Label_0210:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xff55b61ba453487f(xb32f8dd719a105db);
         return;
     }
     goto Label_01CE;
     Label_022C:
     if (sectionName.Equals("SERIES"))
     {
         goto Label_027B;
     }
     goto Label_0203;
     Label_0259:
     if (!sectionName.Equals("CLUSTER"))
     {
         goto Label_022C;
     }
     Label_0266:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xff55b61ba453487f(xb32f8dd719a105db);
         return;
     }
     if (-1 != 0)
     {
         goto Label_022C;
     }
     Label_027B:
     if (!subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_0203;
     }
     this.xff55b61ba453487f(xb32f8dd719a105db);
     return;
     Label_0293:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xff55b61ba453487f(xb32f8dd719a105db);
         return;
     }
     if (0 == 0)
     {
         goto Label_0259;
     }
     goto Label_0266;
     Label_02C5:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_02FF;
     }
     Label_02D3:
     if (!sectionName.Equals("NORMALIZE"))
     {
         goto Label_0259;
     }
     if (-1 != 0)
     {
         goto Label_0293;
     }
     return;
     Label_02F2:
     if (0x7fffffff != 0)
     {
         goto Label_02C5;
     }
     if (0 != 0)
     {
         goto Label_013E;
     }
     Label_02FF:
     this.xff55b61ba453487f(xb32f8dd719a105db);
     return;
     Label_0309:
     if (sectionName.Equals("NORMALIZE"))
     {
         if (subSectionName.Equals("RANGE", StringComparison.InvariantCultureIgnoreCase))
         {
             this.x23a952ae96385f94(xb32f8dd719a105db);
             return;
         }
         if (8 == 0)
         {
             return;
         }
     }
     if (!sectionName.Equals("NORMALIZE"))
     {
         goto Label_02D3;
     }
     if (-2 != 0)
     {
         goto Label_02F2;
     }
     if (0 == 0)
     {
         goto Label_02C5;
     }
     Label_0348:
     if (subSectionName.Equals("CLASSES", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xee831a85a4a1093a(xb32f8dd719a105db);
         if (0 == 0)
         {
             return;
         }
         goto Label_0293;
     }
     goto Label_0309;
     Label_0366:
     if (!sectionName.Equals("DATA"))
     {
         goto Label_0309;
     }
     if (15 != 0)
     {
         goto Label_0348;
     }
     goto Label_02C5;
     Label_038D:
     if (subSectionName.Equals("STATS", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xeb630b6ed5f8b04a(xb32f8dd719a105db);
         return;
     }
     goto Label_0366;
     Label_03A8:
     if (!sectionName.Equals("DATA"))
     {
         goto Label_0366;
     }
     goto Label_038D;
     Label_03D4:
     if (0 != 0)
     {
         goto Label_03FF;
     }
     goto Label_03A8;
     Label_03ED:
     if (subSectionName.Equals("CONFIG", StringComparison.InvariantCultureIgnoreCase))
     {
         this.xff55b61ba453487f(xb32f8dd719a105db);
         return;
     }
     if (0xff != 0)
     {
         goto Label_03A8;
     }
     goto Label_03D4;
     Label_03FF:
     if (!sectionName.Equals("DATA") && (15 != 0))
     {
         if (0 != 0)
         {
             goto Label_03D4;
         }
         if (0 == 0)
         {
             goto Label_03A8;
         }
         goto Label_038D;
     }
     goto Label_03ED;
     Label_041D:
     if (!sectionName.Equals("SETUP") || !subSectionName.Equals("FILENAMES", StringComparison.InvariantCultureIgnoreCase))
     {
         goto Label_03FF;
     }
     this.x63659fc10ec15c58(xb32f8dd719a105db);
 }
Beispiel #10
0
 private void x23a952ae96385f94(EncogFileSection xb32f8dd719a105db)
 {
     this._x594135906c55045c.Normalize.NormalizedFields.Clear();
     bool flag = true;
     using (IEnumerator<string> enumerator = xb32f8dd719a105db.Lines.GetEnumerator())
     {
         string str;
         IList<string> list;
         string str2;
         bool flag2;
         int num;
         string str3;
         double num2;
         double num3;
         NormalizationAction oneOf;
         AnalystField field;
         AnalystField field2;
         goto Label_0047;
     Label_0026:
         this._x594135906c55045c.Normalize.NormalizedFields.Add(field);
         goto Label_0047;
     Label_003F:
         if (!flag)
         {
             goto Label_02B1;
         }
         flag = false;
     Label_0047:
         if (enumerator.MoveNext())
         {
             goto Label_02C2;
         }
         goto Label_0064;
     Label_0055:
         field2.Output = flag2;
         field = field2;
         goto Label_0026;
     Label_0064:
         if (((uint) num2) >= 0)
         {
             goto Label_009C;
         }
     Label_0076:
         if ((((uint) flag) + ((uint) flag2)) > uint.MaxValue)
         {
             goto Label_0145;
         }
         field2.TimeSlice = num;
         goto Label_0055;
     Label_009C:
         if ((((uint) num3) | 0xff) != 0)
         {
             return;
         }
         goto Label_00DA;
     Label_00CA:
         field2 = new AnalystField(str2, oneOf, num2, num3);
         goto Label_0076;
     Label_00DA:
         if (str3.Equals("equilateral"))
         {
             goto Label_013D;
         }
         if (str3.Equals("single"))
         {
             oneOf = NormalizationAction.SingleField;
             goto Label_00CA;
         }
         if (!str3.Equals("oneof"))
         {
             throw new AnalystError("Unknown field type:" + str3);
         }
         oneOf = NormalizationAction.OneOf;
         if (0xff != 0)
         {
             goto Label_00CA;
         }
         goto Label_0076;
     Label_011D:
         if ((((uint) num3) + ((uint) num3)) < 0)
         {
             goto Label_024D;
         }
         goto Label_00DA;
     Label_013D:
         oneOf = NormalizationAction.Equilateral;
         goto Label_00CA;
     Label_0145:
         if (((uint) flag) > uint.MaxValue)
         {
             goto Label_0177;
         }
     Label_0157:
         if (str3.Equals("pass"))
         {
             goto Label_0177;
         }
         goto Label_00DA;
     Label_016F:
         oneOf = NormalizationAction.Ignore;
         goto Label_00CA;
     Label_0177:
         oneOf = NormalizationAction.PassThrough;
         goto Label_00CA;
     Label_017F:
         if ((((uint) flag) - ((uint) flag2)) < 0)
         {
             goto Label_00DA;
         }
         if (!str3.Equals("ignore"))
         {
             goto Label_0157;
         }
         if (((uint) flag) >= 0)
         {
             goto Label_016F;
         }
         if (((uint) num2) >= 0)
         {
             goto Label_00DA;
         }
         if ((((uint) num3) - ((uint) flag2)) <= uint.MaxValue)
         {
             goto Label_0145;
         }
         goto Label_011D;
     Label_01E9:
         oneOf = NormalizationAction.Normalize;
         goto Label_00CA;
     Label_01F1:
         if (str3.Equals("range"))
         {
             goto Label_01E9;
         }
         goto Label_017F;
     Label_0215:
         num3 = CSVFormat.EgFormat.Parse(list[5]);
         goto Label_01F1;
     Label_022D:
         str2 = list[0];
         flag2 = list[1].ToLower().Equals("output");
     Label_024D:
         num = int.Parse(list[2]);
         str3 = list[3];
         if ((((uint) flag2) - ((uint) num3)) > uint.MaxValue)
         {
             goto Label_022D;
         }
         num2 = CSVFormat.EgFormat.Parse(list[4]);
         if ((((uint) flag2) + ((uint) num)) <= uint.MaxValue)
         {
             goto Label_0215;
         }
         goto Label_01F1;
     Label_02B1:
         list = EncogFileSection.SplitColumns(str);
         goto Label_022D;
     Label_02C2:
         str = enumerator.Current;
         goto Label_003F;
     }
 }
Beispiel #11
0
 private void xee831a85a4a1093a(EncogFileSection xb32f8dd719a105db)
 {
     int num;
     DataField[] fieldArray;
     int num2;
     Dictionary<string, List<AnalystClassItem>> dictionary = new Dictionary<string, List<AnalystClassItem>>();
     bool flag = true;
     using (IEnumerator<string> enumerator = xb32f8dd719a105db.Lines.GetEnumerator())
     {
         string str;
         IList<string> list;
         string str2;
         string str3;
         string str4;
         DataField field;
         List<AnalystClassItem> list2;
     Label_00E2:
         if (enumerator.MoveNext())
         {
             goto Label_0263;
         }
         if (((uint) num) >= 0)
         {
             goto Label_02A4;
         }
         goto Label_0144;
     Label_0102:
         flag = false;
     Label_0104:
         if (-2147483648 == 0)
         {
             goto Label_0102;
         }
         goto Label_00E2;
     Label_010D:
         list2.Add(new AnalystClassItem(str3, str4, num));
         goto Label_00E2;
     Label_0121:
         if (!flag)
         {
             goto Label_0270;
         }
         goto Label_0102;
     Label_0129:
         if (!dictionary.ContainsKey(str2))
         {
             goto Label_0163;
         }
         list2 = dictionary[str2];
         if (0 == 0)
         {
             goto Label_010D;
         }
         goto Label_0102;
     Label_0144:
         dictionary[str2] = list2;
         goto Label_010D;
     Label_015A:
         if (field == null)
         {
             goto Label_0215;
         }
         goto Label_0129;
     Label_0163:
         list2 = new List<AnalystClassItem>();
         if ((((uint) num2) - ((uint) flag)) <= uint.MaxValue)
         {
             goto Label_0144;
         }
         if ((((uint) num) - ((uint) flag)) <= uint.MaxValue)
         {
             goto Label_0263;
         }
         if ((((uint) flag) & 0) != 0)
         {
             if ((((uint) flag) + ((uint) num2)) > uint.MaxValue)
             {
                 goto Label_0104;
             }
             goto Label_0129;
         }
     Label_01D4:
         str4 = list[2];
         num = int.Parse(list[3]);
         field = this._x594135906c55045c.FindDataField(str2);
         if ((((uint) num2) + ((uint) flag)) >= 0)
         {
             goto Label_015A;
         }
     Label_0215:
         throw new AnalystError("Attempting to add class to unknown field: " + str4);
         if ((((uint) num) - ((uint) num)) < 0)
         {
             goto Label_0144;
         }
         goto Label_024F;
     Label_0246:
         if (list.Count < 4)
         {
             throw new AnalystError("Invalid data class: " + str);
         }
     Label_024F:
         str2 = list[0];
         str3 = list[1];
         goto Label_01D4;
     Label_0263:
         str = enumerator.Current;
         goto Label_0121;
     Label_0270:
         list = EncogFileSection.SplitColumns(str);
         goto Label_0246;
     }
     Label_02A4:
     fieldArray = this._x594135906c55045c.Fields;
     num2 = 0;
     while (true)
     {
         DataField field2;
         if (num2 < fieldArray.Length)
         {
             field2 = fieldArray[num2];
         }
         else if (0xff != 0)
         {
             return;
         }
         if (field2.Class)
         {
             List<AnalystClassItem> list3 = dictionary[field2.Name];
         Label_000B:
             if (list3 != null)
             {
                 list3.Sort();
                 if ((0x7fffffff == 0) || ((((uint) flag) - ((uint) num)) < 0))
                 {
                     goto Label_000B;
                 }
                 field2.ClassMembers.Clear();
                 foreach (AnalystClassItem item in list3)
                 {
                     field2.ClassMembers.Add(item);
                 }
             }
         }
         num2++;
     }
 }
Beispiel #12
0
 private void xeb630b6ed5f8b04a(EncogFileSection xb32f8dd719a105db)
 {
     bool flag;
     bool flag2;
     bool flag4;
     bool flag5;
     DataField[] fieldArray;
     int num5;
     IList<DataField> list = new List<DataField>();
     goto Label_0054;
     Label_0034:
     fieldArray[num5] = list[num5];
     num5++;
     Label_0047:
     if (num5 < fieldArray.Length)
     {
         goto Label_0034;
     }
     this._x594135906c55045c.Fields = fieldArray;
     if ((((uint) flag2) - ((uint) flag4)) >= 0)
     {
         return;
     }
     Label_0054:
     flag = true;
     using (IEnumerator<string> enumerator = xb32f8dd719a105db.Lines.GetEnumerator())
     {
         string str;
         IList<string> list2;
         string str2;
         bool flag3;
         double num;
         double num2;
         double num3;
         double num4;
         DataField field2;
         goto Label_007F;
     Label_0065:
         if (!flag)
         {
             goto Label_0257;
         }
         if (((uint) flag3) >= 0)
         {
         }
         flag = false;
     Label_007F:
         if (enumerator.MoveNext())
         {
             goto Label_0269;
         }
         goto Label_02A5;
     Label_008D:
         field2.StandardDeviation = num4;
         DataField item = field2;
     Label_009A:
         list.Add(item);
         goto Label_007F;
     Label_00AB:
         field2.Integer = flag4;
         field2.Real = flag5;
         field2.Max = num;
         field2.Min = num2;
         field2.Mean = num3;
         goto Label_008D;
     Label_00DD:
         field2.Complete = flag3;
         if ((((uint) flag) + ((uint) num)) >= 0)
         {
             goto Label_00AB;
         }
         if ((((uint) flag) + ((uint) flag)) >= 0)
         {
             goto Label_0182;
         }
     Label_0119:
         if ((((uint) num2) & 0) != 0)
         {
             goto Label_0257;
         }
     Label_0130:
         num2 = CSVFormat.EgFormat.Parse(list2[6]);
         num3 = CSVFormat.EgFormat.Parse(list2[7]);
         num4 = CSVFormat.EgFormat.Parse(list2[8]);
         field2 = new DataField(str2) {
             Class = flag2
         };
         if (0xff != 0)
         {
             goto Label_00DD;
         }
     Label_0182:
         if ((((uint) flag) | 0xfffffffe) == 0)
         {
             goto Label_0130;
         }
         if ((((uint) num2) | 8) != 0)
         {
             goto Label_0119;
         }
         goto Label_00DD;
     Label_01C4:
         num = CSVFormat.EgFormat.Parse(list2[5]);
         if ((((uint) num) & 0) == 0)
         {
             goto Label_0182;
         }
         goto Label_0269;
     Label_01F3:
         if (((uint) flag4) < 0)
         {
             goto Label_009A;
         }
         str2 = list2[0];
         flag2 = int.Parse(list2[1]) > 0;
         flag3 = int.Parse(list2[2]) > 0;
         flag4 = int.Parse(list2[3]) > 0;
         flag5 = int.Parse(list2[4]) > 0;
         goto Label_01C4;
     Label_0257:
         list2 = EncogFileSection.SplitColumns(str);
         goto Label_01F3;
     Label_0269:
         str = enumerator.Current;
         goto Label_0065;
     }
     if (((uint) flag5) > uint.MaxValue)
     {
         goto Label_0034;
     }
     Label_02A5:
     fieldArray = new DataField[list.Count];
     num5 = 0;
     goto Label_0047;
 }
Beispiel #13
0
 private void x63659fc10ec15c58(EncogFileSection xb32f8dd719a105db)
 {
     IDictionary<string, string> dictionary = xb32f8dd719a105db.ParseParams();
     this._x594135906c55045c.Properties.ClearFilenames();
     foreach (KeyValuePair<string, string> pair in dictionary)
     {
         this._x594135906c55045c.Properties.SetFilename(pair.Key, pair.Value);
     }
 }
Beispiel #14
0
        private void HandleProcessFields(EncogFileSection section)
        {
            IList<ProcessField> fields = _script.Process.Fields;
            bool first = true;

            fields.Clear();

            foreach (string line in section.Lines)
            {
                if (!first)
                {
                    IList<string> cols = EncogFileSection.SplitColumns(line);
                    String name = cols[0];
                    String command = cols[1];
                    var pf = new ProcessField(name, command);
                    fields.Add(pf);
                }
                else
                {
                    first = false;
                }
            }
        }
Beispiel #15
0
        /// <summary>
        ///     Handle loading data stats.
        /// </summary>
        /// <param name="section">The section being loaded.</param>
        private void HandleDataStats(EncogFileSection section)
        {
            IList<DataField> dfs = new List<DataField>();
            bool first = true;

            foreach (String line in section.Lines)
            {
                if (!first)
                {
                    IList<String> cols = EncogFileSection.SplitColumns(line);
                    String name = cols[0];
                    bool isclass = Int32.Parse(cols[1]) > 0;
                    bool iscomplete = Int32.Parse(cols[2]) > 0;
                    bool isint = Int32.Parse(cols[ColumnThree]) > 0;
                    bool isreal = Int32.Parse(cols[ColumnFour]) > 0;
                    double amax = CSVFormat.EgFormat.Parse(cols[5]);
                    double amin = CSVFormat.EgFormat.Parse(cols[6]);
                    double mean = CSVFormat.EgFormat.Parse(cols[7]);
                    double sdev = CSVFormat.EgFormat.Parse(cols[8]);
                    String source = "";

                    // source was added in Encog 3.2, so it might not be there
                    if (cols.Count > 9)
                    {
                        source = cols[9];
                    }

                    var df = new DataField(name)
                        {
                            Class = isclass,
                            Complete = iscomplete,
                            Integer = isint,
                            Real = isreal,
                            Max = amax,
                            Min = amin,
                            Mean = mean,
                            StandardDeviation = sdev,
                            Source = source
                        };
                    dfs.Add(df);
                }
                else
                {
                    first = false;
                }
            }

            var array = new DataField[dfs.Count];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = dfs[i];
            }

            _script.Fields = array;
        }
Beispiel #16
0
 private void LoadOpcodes(EncogFileSection section)
 {
     bool first = true;
     foreach (string line in section.Lines)
     {
         if (!first)
         {
             IList<string> cols = EncogFileSection.SplitColumns(line);
             string name = cols[0];
             int childCount = int.Parse(cols[1]);
             var opcode = new ScriptOpcode(name, childCount);
             _script.Opcodes.Add(opcode);
         }
         else
         {
             first = false;
         }
     }
 }
Beispiel #17
0
        /// <summary>
        ///     Handle loading the filenames.
        /// </summary>
        /// <param name="section">The section being loaded.</param>
        private void HandleFilenames(EncogFileSection section)
        {
            IDictionary<String, String> prop = section.ParseParams();
            _script.Properties.ClearFilenames();


            foreach (var e in prop)
            {
                _script.Properties.SetFilename(e.Key, e.Value);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Read the next section.
        /// </summary>
        ///
        /// <returns>The next section.</returns>
        public EncogFileSection ReadNextSection()
        {
            try
            {
                String line;
                var largeArrays = new List<double[]>();

                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    // is it a comment
                    if (line.StartsWith("//"))
                    {
                        continue;
                    }
	
                        // is it a section or subsection
                    else if (line.StartsWith("["))
                    {
                        // handle previous section
                        section = new EncogFileSection(
                            currentSectionName, currentSubSectionName);

                        foreach (String str in lines)
                        {
                            section.Lines.Add(str);
                        }


                        // now begin the new section
                        lines.Clear();
                        String s = line.Substring(1).Trim();
                        if (!s.EndsWith("]"))
                        {
                            throw new PersistError("Invalid section: " + line);
                        }
                        s = s.Substring(0, (line.Length - 2) - (0));
                        int idx = s.IndexOf(':');
                        if (idx == -1)
                        {
                            currentSectionName = s;
                            currentSubSectionName = "";
                        }
                        else
                        {
                            if (currentSectionName.Length < 1)
                            {
                                throw new PersistError(
                                    "Can't begin subsection when a section has not yet been defined: "
                                    + line);
                            }

                            String newSection = s.Substring(0, (idx) - (0));
                            String newSubSection = s.Substring(idx + 1);

                            if (!newSection.Equals(currentSectionName))
                            {
                                throw new PersistError("Can't begin subsection "
                                                       + line
                                                       + ", while we are still in the section: "
                                                       + currentSectionName);
                            }

                            currentSubSectionName = newSubSection;
                        }
                        section.LargeArrays = largeArrays;
                        return section;
                    }
                    else if (line.Length < 1)
                    {
                        continue;
                    }
                    else if (line.StartsWith("##double"))
                    {
                        double[] d = ReadLargeArray(line);
                        largeArrays.Add(d);
                    } 
                    else
                    {
                        if (currentSectionName.Length < 1)
                        {
                            throw new PersistError(
                                "Unknown command before first section: " + line);
                        }

                        lines.Add(line);
                    }
                }

                if (currentSectionName.Length == 0)
                {
                    return null;
                }

                section = new EncogFileSection(currentSectionName,
                                               currentSubSectionName);

                foreach (String l in lines)
                {
                    section.Lines.Add(l);
                }

                currentSectionName = "";
                currentSubSectionName = "";
                section.LargeArrays = largeArrays;
                return section;
            }
            catch (IOException ex)
            {
                throw new PersistError(ex);
            }
        }
Beispiel #19
0
        /// <summary>
        ///     Handle normalization ranges.
        /// </summary>
        /// <param name="section">The section being loaded.</param>
        private void HandleNormalizeRange(EncogFileSection section)
        {
            _script.Normalize.NormalizedFields.Clear();
            bool first = true;

            foreach (String line in section.Lines)
            {
                if (!first)
                {
                    IList<String> cols = EncogFileSection.SplitColumns(line);
                    String name = cols[0];
                    bool isOutput = cols[1].ToLower()
                                           .Equals("output");
                    int timeSlice = Int32.Parse(cols[2]);
                    String action = cols[3];
                    double high = CSVFormat.EgFormat.Parse(cols[4]);
                    double low = CSVFormat.EgFormat.Parse(cols[5]);

                    NormalizationAction des;
                    if (action.Equals("range"))
                    {
                        des = NormalizationAction.Normalize;
                    }
                    else if (action.Equals("ignore"))
                    {
                        des = NormalizationAction.Ignore;
                    }
                    else if (action.Equals("pass"))
                    {
                        des = NormalizationAction.PassThrough;
                    }
                    else if (action.Equals("equilateral"))
                    {
                        des = NormalizationAction.Equilateral;
                    }
                    else if (action.Equals("single"))
                    {
                        des = NormalizationAction.SingleField;
                    }
                    else if (action.Equals("oneof"))
                    {
                        des = NormalizationAction.OneOf;
                    }
                    else
                    {
                        throw new AnalystError("Unknown field type:" + action);
                    }

                    var nf = new AnalystField(name, des, high, low) {TimeSlice = timeSlice, Output = isOutput};
                    _script.Normalize.NormalizedFields.Add(nf);
                }
                else
                {
                    first = false;
                }
            }
        }
Beispiel #20
0
 public EncogFileSection ReadNextSection()
 {
     EncogFileSection section;
     try
     {
         string str;
         string str3;
         int index;
         string str4;
         string str5;
         goto Label_0107;
     Label_0005:
         return this.xb32f8dd719a105db;
     Label_0012:
         this.x0fda809a7e14c39d = "";
         this.x0f7286e9d651365c = "";
         goto Label_00B5;
     Label_002F:
         if (this.x0fda809a7e14c39d.Length == 0)
         {
             goto Label_00CC;
         }
         this.xb32f8dd719a105db = new EncogFileSection(this.x0fda809a7e14c39d, this.x0f7286e9d651365c);
         foreach (string str6 in this.x0383ec486664fa18)
         {
             this.xb32f8dd719a105db.Lines.Add(str6);
         }
         goto Label_0012;
     Label_00B5:
         if (0 == 0)
         {
             goto Label_0005;
         }
         return section;
     Label_00CC:
         section = null;
         goto Label_0370;
     Label_00D1:
         if (this.x0fda809a7e14c39d.Length < 1)
         {
             throw new PersistError("Unknown command before first section: " + str);
         }
     Label_00F0:
         this.x0383ec486664fa18.Add(str);
         goto Label_0107;
     Label_00FE:
         if (str.Length >= 1)
         {
             goto Label_00D1;
         }
     Label_0107:
         if ((str = this.xe134235b3526fa75.ReadLine()) != null)
         {
             goto Label_0328;
         }
         if (8 != 0)
         {
             goto Label_002F;
         }
         goto Label_0370;
     Label_0125:
         if (str.StartsWith("["))
         {
             goto Label_034A;
         }
         goto Label_00FE;
     Label_0139:
         throw new PersistError("Can't begin subsection " + str + ", while we are still in the section: " + this.x0fda809a7e14c39d);
     Label_0157:
         if (!str4.Equals(this.x0fda809a7e14c39d))
         {
             goto Label_0139;
         }
     Label_0166:
         this.x0f7286e9d651365c = str5;
     Label_016E:
         return this.xb32f8dd719a105db;
     Label_017D:
         if (1 == 0)
         {
             goto Label_0166;
         }
         if (15 != 0)
         {
             goto Label_0157;
         }
         goto Label_0139;
     Label_018F:
         if (this.x0fda809a7e14c39d.Length < 1)
         {
             throw new PersistError("Can't begin subsection when a section has not yet been defined: " + str);
         }
         str4 = str3.Substring(0, index);
         str5 = str3.Substring(index + 1);
         goto Label_01D7;
     Label_01B4:
         if (index == -1)
         {
             goto Label_01FE;
         }
         if (3 == 0)
         {
             goto Label_0259;
         }
         goto Label_018F;
     Label_01D7:
         if ((((uint) index) + ((uint) index)) >= 0)
         {
             goto Label_017D;
         }
         if (0 == 0)
         {
             goto Label_0125;
         }
         goto Label_0215;
     Label_01FE:
         this.x0fda809a7e14c39d = str3;
         this.x0f7286e9d651365c = "";
         goto Label_016E;
     Label_0215:
         if (((uint) index) <= uint.MaxValue)
         {
             goto Label_00D1;
         }
         goto Label_0370;
     Label_022C:
         if (!str3.EndsWith("]"))
         {
             goto Label_0278;
         }
         goto Label_0259;
         if ((((uint) index) & 0) != 0)
         {
             goto Label_022C;
         }
         if (8 == 0)
         {
             goto Label_0335;
         }
     Label_0259:
         str3 = str3.Substring(0, str.Length - 2);
         index = str3.IndexOf(':');
         goto Label_028B;
     Label_0278:
         throw new PersistError("Invalid section: " + str);
     Label_028B:
         if (-1 != 0)
         {
             goto Label_01B4;
         }
         goto Label_0370;
     Label_029A:
         if ((((uint) index) | 2) != 0)
         {
             goto Label_022C;
         }
         if (((uint) index) < 0)
         {
             goto Label_018F;
         }
         goto Label_0278;
     Label_02CF:
         foreach (string str2 in this.x0383ec486664fa18)
         {
             this.xb32f8dd719a105db.Lines.Add(str2);
         }
         this.x0383ec486664fa18.Clear();
         str3 = str.Substring(1).Trim();
         goto Label_029A;
     Label_0328:
         str = str.Trim();
         if (0 != 0)
         {
             goto Label_00F0;
         }
     Label_0335:
         if (str.StartsWith("//"))
         {
             goto Label_0107;
         }
         goto Label_0125;
     Label_034A:
         this.xb32f8dd719a105db = new EncogFileSection(this.x0fda809a7e14c39d, this.x0f7286e9d651365c);
         goto Label_02CF;
     Label_0370:
         if ((((uint) index) & 0) == 0)
         {
             return section;
         }
         goto Label_0005;
     }
     catch (IOException exception)
     {
         throw new PersistError(exception);
     }
     return section;
 }
Beispiel #21
0
 private void x3ed9c05d3bbdec37(EncogFileSection xb32f8dd719a105db)
 {
     bool flag;
     AnalystSegregateTarget[] targetArray;
     IList<AnalystSegregateTarget> list = new List<AnalystSegregateTarget>();
     Label_003D:
     flag = true;
     if (-1 != 0)
     {
     }
     using (IEnumerator<string> enumerator = xb32f8dd719a105db.Lines.GetEnumerator())
     {
         string str;
         IList<string> list2;
         AnalystSegregateTarget target;
     Label_0055:
         if (enumerator.MoveNext())
         {
             goto Label_00A0;
         }
         goto Label_00C0;
     Label_0060:
         flag = false;
         goto Label_0055;
     Label_0064:
         list.Add(target);
         goto Label_0055;
     Label_006E:
         list2 = EncogFileSection.SplitColumns(str);
         string theFile = list2[0];
         if (-2 == 0)
         {
             goto Label_0060;
         }
         int thePercent = int.Parse(list2[1]);
         target = new AnalystSegregateTarget(theFile, thePercent);
         goto Label_0064;
     Label_00A0:
         str = enumerator.Current;
         if (!flag && (0 == 0))
         {
             goto Label_006E;
         }
         goto Label_0060;
     }
     Label_00C0:
     targetArray = new AnalystSegregateTarget[list.Count];
     int index = 0;
     if ((((uint) flag) | 0xff) != 0)
     {
         while (index < targetArray.Length)
         {
             targetArray[index] = list[index];
             index++;
         }
         this._x594135906c55045c.Segregate.SegregateTargets = targetArray;
         if (0 != 0)
         {
             goto Label_003D;
         }
     }
 }