private void testStem_Click(object sender, RoutedEventArgs e) { if (textStem.Text.Length > 0) { labelStemRes.Content = Stemmer.stem(textStem.Text); } }
public bool setQuery(string qLine, string qWLine) { qTerms = new List <Value>(); string[] temp; temp = qLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); temp = temp.ToArray(); string[] temp2; temp2 = qWLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); temp2 = temp2.ToArray(); double num; if (temp.Count() != temp2.Count()) { return(false); } for (int i = 0; i < temp.Count(); i++) { if (double.TryParse(temp2[i], out num)) { qTerms.Add(new Value(Stemmer.stem(temp[i]), double.Parse(temp2[i]))); } else { qTerms.Clear(); return(false); } } return(true); }
public void setQuery(string qLine) { qTerms = new List <Value>(); string[] temp; temp = qLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); temp = temp.Distinct().ToArray(); foreach (string str in temp) { if (!docReader.stopWords.Contains(str.ToLower())) { qTerms.Add(new Value(Stemmer.stem(str), 10)); } } }
/// <summary> /// reads in the document and passes each word to the stemmer /// </summary> /// <param name="fileName"></param> public static void parseDoc(string fileName) { if (DocCollection.containsDoc(fileName)) { return; } Doc currentDoc = new Doc(fileName); string line; try { using (TextReader input = File.OpenText(fileName)) { while ((line = input.ReadLine()) != null) { string[] wordsLine = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); foreach (string str in wordsLine) { if (!stopWords.Contains(str.ToLower())) { string temp = str.ToLower(); temp = Stemmer.stem(temp); currentDoc.addTerms(temp); } } } ((MainWindow)System.Windows.Application.Current.MainWindow).ProgressLabel.Content = "Read " + currentDoc.getName(); DocCollection.addDoc(currentDoc); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("!!!File not read error: " + ex.ToString()); } }