コード例 #1
0
 private void testStem_Click(object sender, RoutedEventArgs e)
 {
     if (textStem.Text.Length > 0)
     {
         labelStemRes.Content = Stemmer.stem(textStem.Text);
     }
 }
コード例 #2
0
ファイル: Query.cs プロジェクト: cjeane/infoRet
        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);
        }
コード例 #3
0
ファイル: Query.cs プロジェクト: cjeane/infoRet
 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));
         }
     }
 }
コード例 #4
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());
            }
        }