private void loadDictionaryButton_Click() { string dictPath = @"C:\Users\ירדן\Desktop\לימודים\שנה ד\סמס1\אחזור מידע\data\posting"; bool stemm = false; d = new Dictionary <string, TermInfo>(); docs = new Dictionary <string, DocumentInfo>(); string p = ""; if (stemm) { p = dictPath + @"\DictionaryStemm.txt"; } else { p = dictPath + @"\Dictionary.txt"; } if (!File.Exists(p)) { System.Windows.Forms.MessageBox.Show("Dictionary not found !"); } else { Thread tDocs = new Thread(() => loadDocs(dictPath, stemm)); tDocs.Start(); string[] tempDic = File.ReadAllLines(p); for (int i = 0; i < tempDic.Length; i += 2) { string[] t = tempDic[i].Split(','); string term = t[0]; TermInfo ti = new TermInfo(t[0], int.Parse(t[1]), int.Parse(t[2]), t[3][0]); ti.setPointer(int.Parse(t[4])); t = tempDic[i + 1].Split(','); foreach (string next in t) { ti.nextString.Add(next); } d[term] = ti; } tDocs.Join(); System.Windows.Forms.MessageBox.Show("load data succeeded"); } }
/// <summary> /// load dictionary to memory /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loadDictionaryButton_Click(object sender, RoutedEventArgs e) { string dictPath = PathPostingDictionary.Text; bool stemm = false; if (stemmingCheck.HasContent && stemmingCheck.IsChecked == true) { stemm = true; } d = new Dictionary <string, TermInfo>(); docs = new Dictionary <string, DocumentInfo>(); string p = ""; if (stemm) { p = dictPath + @"\DictionaryStemm.txt"; } else { p = dictPath + @"\Dictionary.txt"; } if (!File.Exists(p)) { System.Windows.Forms.MessageBox.Show("Dictionary not found !"); } else { Thread tDocs = new Thread(() => loadDocs(dictPath, stemm)); tDocs.Start(); string[] tempDic = File.ReadAllLines(p); for (int i = 0; i < tempDic.Length; i += 2) { string[] t = tempDic[i].Split(','); string term = t[0]; TermInfo ti = new TermInfo(t[0], int.Parse(t[1]), int.Parse(t[2]), t[3][0]); ti.setPointer(int.Parse(t[4])); t = tempDic[i + 1].Split(','); foreach (string next in t) { ti.nextString.Add(next); } /* t = tempDic[i + 2].Split(','); * foreach (string next in t) * { * ti.synForTerm.Add(next); * }*/ d[term] = ti; } /* * foreach (string term in tempDic) * { * string[] t = term.Split(','); * TermInfo ti = new TermInfo(t[0], int.Parse(t[1]), int.Parse(t[2]), t[3][0]); * ti.setPointer(int.Parse(t[4])); * d[t[0]] = ti; * }*/ tDocs.Join(); System.Windows.Forms.MessageBox.Show("load data succeeded"); } }