GetStringDistance() public method

Returns the StringDistance instance used by this SpellChecker instance.
public GetStringDistance ( ) : StringDistance
return StringDistance
 public StemFilter(TokenStream in_Renamed, LuceneSpellChecker spellChecker, int numberOfSuggestions)
     : base(in_Renamed)
 {
     SpellChecker        = spellChecker;
     NumberOfSuggestions = numberOfSuggestions;
     _defaultDistance    = spellChecker.GetStringDistance();
     _customDistance     = new StemDistance(_defaultDistance);
 }
Exemplo n.º 2
0
        static void MainV2()
        {
            var numberOfSuggestion = 100;

            var testFilePath       = @"C:/lucene/test1.txt";
            var testDictionaryPath = @"C:/lucene/ruStem.dict";
            var testIndexPath      = @"C:/lucene/indexV2";
            var stopWordsPath      = @"C:/lucene/stopWords.txt";

            var stopWordsSet = new HashSet <string>();

            using (var reader = new StreamReader(stopWordsPath))
            {
                while (!reader.EndOfStream)
                {
                    stopWordsSet.Add(reader.ReadLine());
                }
            }

            using (var reader = new StreamReader(testFilePath))
            {
                var directory    = new SimpleFSDirectory(new DirectoryInfo(testIndexPath));
                var spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(directory);
                spellChecker.IndexDictionary(new PlainTextDictionary(new FileInfo(testDictionaryPath)));

                StringDistance getDist = spellChecker.GetStringDistance();

                var analyzer = new StemmerCompareAnalyzer(stopWordsSet, spellChecker, numberOfSuggestion);

                var stream = analyzer.TokenStream(null, reader);

                while (stream.IncrementToken())
                {
                    var termAttribute  = stream.GetAttribute <ITermAttribute>().Term;
                    var spellAttribute = stream.GetAttribute <ISpellAttribute>().Term;
                    var stemAttribute  = stream.GetAttribute <IStemAttribute>().Term;

                    Console.WriteLine("{0, 20} {1, 20} {2, 20}", termAttribute, spellAttribute, stemAttribute);
                }
            }
        }