private bool checkNationality(pixel pix) { bool found = false; string[] str = pix.object2.Split(' '); if (str.Length > 1) { if ((pix.Bisector != "citizen of") && (!pix.object2.Contains("city")) && (!pix.object2.Contains("capital")) && (!pix.object2.Contains("capitol")) && (!pix.object2.Contains("town")) && (!pix.object2.Contains("village")) && (!pix.object2.Contains("company")) && (!pix.object2.Contains("owned"))) { for (int i = 0; i < no_of_nationalities; i++) { if (str[0] == nationality[i]) { found = true; pixel p1 = new pixel(); p1.object1 = pix.object1; p1.Bisector = "citizen of"; p1.coherence = pix.coherence; p1.object2 = nation[i]; mindpixels.Add(p1); pix.object2 =""; for (int j = 1; j < str.Length; j++) { pix.object2 += str[j]; if (j < str.Length-1) pix.object2 += " "; } break; } } } } return(found); }
void loadGAC(int itterations, bool show_mindpixels) { int i = 0; string str, question; pixel pix; float coherence; Random rnd = new Random(); while (!oRead.EndOfStream) { str = oRead.ReadLine(); if (!initialstringFound) { /// look for an initial header string after which the data begins if (str.Contains(initialstring)) initialstringFound = true; } else { /// read the data if (str != "") { try { coherence = Convert.ToSingle(ToNumeric(str.Substring(1, 4))); if (coherence > 1) coherence = 1; question = str.Substring(6); pix = new pixel(); pix.coherence = coherence; pix.question = question.ToLower(); pix.update(prefix, no_of_prefixes, bisector, bisector_property_flags, no_of_bisectors); if (pix.object1 != "") { no_of_parsed_pixels++; /// add words to the dictionary addDictionaryEntry(pix.object1, mindpixels.Count); addDictionaryEntry(pix.object2, mindpixels.Count); } if (show_mindpixels) { if (rnd.Next(1000) < 2) { if (pix.object1 == "") Console.WriteLine("Couldn't parse question: " + pix.question); else Console.WriteLine("(" + pix.object1 + ") " + pix.Bisector + " (" + pix.object2 + ")"); } } if (pix.object1 != "") { pix.Bisector = pix.Bisector.Trim(); string[] l1 = pix.object1.Split(' '); if (l1.Length < 4) { if (l1.Length > 1) { if ((l1[0] == "does") || (l1[0] == "how")) { string new_object1 = ""; for (int j = 1; j < l1.Length; j++) { new_object1 += l1[j]; if (j < l1.Length-1) new_object1 += " "; } pix.object1 = new_object1; } } string[] l2 = pix.object2.Split(' '); if ((l2.Length < 4) && (pix.object2 != "of") && (pix.Bisector != "and")) { if (l2.Length > 1) { if (l2[l2.Length-1] == "?") { string new_object2 = ""; for (int j = 0; j < l2.Length-1; j++) { new_object2 += l2[j]; if (j < l2.Length-2) new_object2 += " "; } pix.object2 = new_object2; } } if (pix.Bisector == "") pix.Bisector = "is"; if ((!pix.object1.Contains(Convert.ToString('"'))) && (!pix.object2.Contains(Convert.ToString('"')))) { if ((!pix.object2.Contains("deletion")) && (pix.object1 != "what is")) { if (pix.Bisector.Contains(" part of")) pix.Bisector = "part of"; if (pix.Bisector.StartsWith("the ")) pix.Bisector = pix.Bisector.Substring(4); checkNationality(pix); mindpixels.Add(pix); } } } } } } catch { } } } i++; } if (oRead.EndOfStream) { oRead.Close(); //now wire everything up //createMind(); } }