Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            StringReader reader = new StringReader("بِسْمِ اللّهِ الرَّحْمنِ الرَّحِيمِ");
            StringReader reader2 = new StringReader("في من بسم الله عن اعوذ عثمان");

            //string test = reader.ReadToEnd();
            //foreach (string s in FilterData.stopChars)
            //{
            //    test = test.Replace(s, "");
            //}
            //textBox1.Text = test + Environment.NewLine;

            //Analyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(FilterData.stopWords);
            //Lucene.Net.Analysis.TokenStream ts = analyzer.TokenStream(reader2);
            //Token tok = null;
            //while ((tok = ts.Next()) != null)
            //{
            //    textBox1.AppendText(tok.TermText() + Environment.NewLine);
            //}

            Analyzer analyzer2 = new DiacriticAnalyzer(FilterData.stopWords);
            Lucene.Net.Analysis.TokenStream ts2 = analyzer2.TokenStream(reader);
            Token tok2 = null;
            while ((tok2 = ts2.Next()) != null)
            {
                textBox1.AppendText(tok2.TermText() + Environment.NewLine);
            }
        }
Exemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            FilterData.PrepareCharMap();
            textBox1.Clear();
            DiacriticAnalyzer analyzer = new DiacriticAnalyzer(FilterData.stopWords);
            string contents = File.ReadAllText("c:\\1.txt");
            TokenStream stream = analyzer.TokenStream(new StringReader(contents));
            Token t = null;
            while ((t = stream.Next()) != null)
            {
                textBox1.AppendText(t.TermText() + Environment.NewLine);
            }

            Store.RAMDirectory dir = new Store.RAMDirectory();
            IndexWriter indexer = new IndexWriter(dir, analyzer, true);
            Documents.Document doc = new Lucene.Net.Documents.Document();
            doc.Add(Documents.Field.Text("contents", contents));
            indexer.AddDocument(doc);
            indexer.Close();

            IndexSearcher searcher = new IndexSearcher(dir);
            Hits hits = searcher.Search(QueryParser.Parse("انعمت", "contents", analyzer));
            MessageBox.Show(hits.Length().ToString());
            searcher.Close();

            dir.Close();
        }