示例#1
0
        public ArffRecord ReadNextRecord()
        {
            if (!csvReader.ReadNextRecord())
            {
                return(null);
            }

            ArffRecord record = new ArffRecord();

            record.Values = new ArffValue[this.attributeCount];

            for (int i = 0; i < this.attributeCount; i++)
            {
                var arffVal = record.Values[i] = new ArffValue();
                var val     = csvReader[i].Unescape();
                if (val == "?")
                {
                    arffVal.NominalValueIndex = -1;
                }
                else
                {
                    arffVal.NominalValueIndex = this.Attributes[i].NominalValues.IndexOf(val);

                    if (arffVal.NominalValueIndex == -1)
                    {
                        throw new ArffReaderException("Unknown nominal value \"" + val + "\" for attribute \"" + this.Attributes[i].Name + "\".");
                    }
                }
            }

            return(record);
        }
示例#2
0
        public ArffRecord ReadNextRecord()
        {
            if (!csvReader.ReadNextRecord()) return null;

            ArffRecord record = new ArffRecord();
            record.Values = new ArffValue[this.attributeCount];

            for (int i = 0; i < this.attributeCount; i++)
            {
                var arffVal = record.Values[i] = new ArffValue();
                var val = csvReader[i].Unescape();
                if (val == "?")
                {
                    arffVal.NominalValueIndex = -1;
                }
                else
                {
                    arffVal.NominalValueIndex = this.Attributes[i].NominalValues.IndexOf(val);

                    if (arffVal.NominalValueIndex == -1)
                    {
                        throw new ArffReaderException("Unknown nominal value \"" + val + "\" for attribute \"" + this.Attributes[i].Name + "\".");
                    }
                }
            }

            return record;
        }