Example #1
0
        /// <summary>
        /// The phrase suggester adds additional logic on top of the term suggester to select entire corrected phrases
        /// instead of individual tokens weighted based on ngram-langugage models.
        /// </summary>
        public SuggestDescriptor <T> Phrase(string name, Func <PhraseSuggestDescriptor <T>, PhraseSuggestDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty("name");
            suggest.ThrowIfNull("suggest");

            var desc = new PhraseSuggestDescriptor <T>();
            var item = suggest(desc);

            Self.Suggest.Add(name, item);
            return(this);
        }
Example #2
0
        public SearchDescriptor <T> PhraseSuggest(string name, Func <PhraseSuggestDescriptor <T>, PhraseSuggestDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty("name");
            suggest.ThrowIfNull("suggest");
            if (this._Suggest == null)
            {
                this._Suggest = new Dictionary <string, SuggestDescriptorBucket <T> >();
            }
            PhraseSuggestDescriptor <T> desc   = new PhraseSuggestDescriptor <T>();
            PhraseSuggestDescriptor <T> item   = suggest(desc);
            SuggestDescriptorBucket <T> bucket = new SuggestDescriptorBucket <T> {
                _Text = item._Text, PhraseSuggest = item
            };

            this._Suggest.Add(name, bucket);
            return(this);
        }
Example #3
0
        /// <summary>
        /// The phrase suggester adds additional logic on top of the term suggester to select entire corrected phrases
        /// instead of individual tokens weighted based on ngram-langugage models.
        /// </summary>
        public SearchDescriptor <T> SuggestPhrase(string name, Func <PhraseSuggestDescriptor <T>, PhraseSuggestDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty("name");
            suggest.ThrowIfNull("suggest");
            if (Self.Suggest == null)
            {
                Self.Suggest = new Dictionary <string, ISuggestBucket>();
            }

            var desc           = new PhraseSuggestDescriptor <T>();
            var item           = suggest(desc);
            IPhraseSuggester i = item;
            var bucket         = new SuggestBucket {
                Text = i.Text, Phrase = item
            };

            Self.Suggest.Add(name, bucket);
            return(this);
        }