SpellChecker.Net.Search.Spell.SpellChecker.Exist C# (CSharp) Method

Exist() public method

Check whether the word exists in the index.
public Exist ( System word ) : bool
word System String ///
return bool
        public virtual bool Exist(System.String word)
        {
            // obtainSearcher calls ensureOpen
            IndexSearcher indexSearcher = ObtainSearcher();
            try
            {
                return indexSearcher.DocFreq(F_WORD_TERM.CreateTerm(word)) > 0;
            }
            finally
            {
                ReleaseSearcher(indexSearcher);
            }
        }

Usage Example

Exemplo n.º 1
0
        internal List <string> SuggestSimilar(string prefix, int maxItems)
        {
            var items = spellChecker.SuggestSimilar(prefix, maxItems, null, null, true).ToList();

            if (spellChecker.Exist(prefix))
            {
                items.Add(prefix);
            }
            return(items);
        }