isValid() public method

public isValid ( List uncheckedAttributes ) : bool
uncheckedAttributes List
return bool
Beispiel #1
0
	public static Example exampleFromString(String data,
			DataSetSpecification dataSetSpec, Char separator) {
		Dictionary<String, LearningAttribute> attributes = new Dictionary<String, LearningAttribute>();
        List<String> attributeValues = new List<String>();

        string [] vals = data.Split(new char[] { ' ', '\t', ',' });
        foreach (string v in vals)
        {
            if (!String.IsNullOrWhiteSpace(v))
            {
                attributeValues.Add(v);
            }
        }
		if (dataSetSpec.isValid(attributeValues)) {
			List<String> names = dataSetSpec.getAttributeNames();
			List<String>.Enumerator nameiter = names.GetEnumerator();
            List<String>.Enumerator valueiter = attributeValues.GetEnumerator();
			while (nameiter.MoveNext() && valueiter.MoveNext()) {
                String name = nameiter.Current;
				AttributeSpecification attributeSpec = dataSetSpec
						.getAttributeSpecFor(name);
				LearningAttribute attribute = attributeSpec.createAttribute(valueiter.Current);
				attributes.Add(name, attribute);
			}
			String targetAttributeName = dataSetSpec.getTarget();
			return new Example(attributes, attributes[targetAttributeName]);
		} else {
			throw new ApplicationException("Unable to construct Example from "
					+ data);
		}
	}
Beispiel #2
0
        public static Example exampleFromString(String data,
                                                DataSetSpecification dataSetSpec, Char separator)
        {
            Dictionary <String, LearningAttribute> attributes = new Dictionary <String, LearningAttribute>();
            List <String> attributeValues = new List <String>();

            string [] vals = data.Split(new char[] { ' ', '\t', ',' });
            foreach (string v in vals)
            {
                if (!String.IsNullOrWhiteSpace(v))
                {
                    attributeValues.Add(v);
                }
            }
            if (dataSetSpec.isValid(attributeValues))
            {
                List <String>             names     = dataSetSpec.getAttributeNames();
                List <String> .Enumerator nameiter  = names.GetEnumerator();
                List <String> .Enumerator valueiter = attributeValues.GetEnumerator();
                while (nameiter.MoveNext() && valueiter.MoveNext())
                {
                    String name = nameiter.Current;
                    AttributeSpecification attributeSpec = dataSetSpec
                                                           .getAttributeSpecFor(name);
                    LearningAttribute attribute = attributeSpec.createAttribute(valueiter.Current);
                    attributes.Add(name, attribute);
                }
                String targetAttributeName = dataSetSpec.getTarget();
                return(new Example(attributes, attributes[targetAttributeName]));
            }
            else
            {
                throw new ApplicationException("Unable to construct Example from "
                                               + data);
            }
        }