Example #1
0
 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));
         }
     }
 }
Example #2
0
        /// <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());
            }
        }