public void LoadData() { StreamReader sr = new StreamReader("C:/Users/Jacques/source/repos/ExpertProject1/ConsoleApp1/data.txt"); String currentLine = sr.ReadLine(); String split; String result; string[] symptoms; string[] treatments; Cancer c = new Cancer(); while (!sr.EndOfStream) { if (currentLine.Contains("Cancer:")) { split = "Cancer: "; result = currentLine.Substring(currentLine.IndexOf(split) + split.Length); c.SetResult(new Statement(result, "=", "yes")); } else if (currentLine.Contains("Symptoms:")) { split = "Symptoms: "; result = currentLine.Substring(currentLine.IndexOf(split) + split.Length); symptoms = result.Split('|'); for (int i = 0; i < symptoms.Length; i++) { c.AddCondition(new Statement(symptoms[i], "=", "yes")); } } else if (currentLine.Contains("Treatments:")) { split = "Treatment: "; result = currentLine.Substring(currentLine.IndexOf(split) + split.Length); treatments = result.Split('|'); for (int i = 0; i < treatments.Length; i++) { c.AddTreatment(new Statement(treatments[i], "=", "yes")); } } else { Cancers.Add(c); c = new Cancer(); } currentLine = sr.ReadLine(); // next line } sr.Close(); }
public void AddCancer(Cancer cancer) { kb.Cancers.Add(cancer); }