public AnswerTreeNode(DatumSchema schema, string answer, Datum[] data, int level) { Level = level; if(schema.AnswerValidator(answer)) { /* for (int i = 0; i < Level; i++) Console.Write(" |"); Console.WriteLine(" Answer: {0}", answer); */ Answer = answer; for(int i = 0; i < data.Length; i++) { if(data[i].Answer != Answer) { throw new InvalidOperationException(String.Format( "The datum {0} does not have the answer {1}.", data[i], Answer)); } } Data = data; Working.Printf("Every element in the current data subset (\\{{{0}\\}}) now " + "all share the same answer of \\texttt{{{1}}}. Hence, " + "that is the answer that should be declared given this " + "node of the decision tree has been reached.", String.Join(", ", Data.Select(d => d.ToString())), Answer); } else { throw new InvalidOperationException(String.Format( "The answer {0} is not valid with the given schema.", answer)); } }
public AnswerTreeNode(DatumSchema schema, string answer, Datum[] data, int level) { Level = level; if (schema.AnswerValidator(answer)) { /* for (int i = 0; i < Level; i++) * Console.Write(" |"); * Console.WriteLine(" Answer: {0}", answer); */ Answer = answer; for (int i = 0; i < data.Length; i++) { if (data[i].Answer != Answer) { throw new InvalidOperationException(String.Format( "The datum {0} does not have the answer {1}.", data[i], Answer)); } } Data = data; Working.Printf("Every element in the current data subset (\\{{{0}\\}}) now " + "all share the same answer of \\texttt{{{1}}}. Hence, " + "that is the answer that should be declared given this " + "node of the decision tree has been reached.", String.Join(", ", Data.Select(d => d.ToString())), Answer); } else { throw new InvalidOperationException(String.Format( "The answer {0} is not valid with the given schema.", answer)); } }
public Datum(DatumSchema schema, string answer, params string[] values) { Schema = schema; if(values.Length == Schema.Attributes.Length) { Values = new Dictionary<Attribute, string>(); for(int i = 0; i < values.Length; i++) { Values[Schema.Attributes[i]] = values[i]; } } if (schema.AnswerValidator(answer)) { Answer = answer; } }
public Datum(DatumSchema schema, string answer, params string[] values) { Schema = schema; if (values.Length == Schema.Attributes.Length) { Values = new Dictionary <Attribute, string>(); for (int i = 0; i < values.Length; i++) { Values[Schema.Attributes[i]] = values[i]; } } if (schema.AnswerValidator(answer)) { Answer = answer; } }