Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class FSTCompletionLookup

    An adapter from Lookup API to FSTCompletion.

    This adapter differs from FSTCompletion in that it attempts to discretize any "weights" as passed from in Weight to match the number of buckets. For the rationale for bucketing, see FSTCompletion.

    Note:Discretization requires an additional sorting pass.

    The range of weights for bucketing/ discretization is determined by sorting the input by weight and then dividing into equal ranges. Then, scores within each range are assigned to that bucket.

    Note that this means that even large differences in weights may be lost during automaton construction, but the overall distinction between "classes" of weights will be preserved regardless of the distribution of weights.

    For fine-grained control over which weights are assigned to which buckets, use FSTCompletion directly or TSTLookup, for example.

    Inheritance
    object
    Lookup
    FSTCompletionLookup
    Inherited Members
    Lookup.CHARSEQUENCE_COMPARER
    Lookup.Build(IDictionary)
    Lookup.Load(Stream)
    Lookup.Store(Stream)
    Lookup.DoLookup(string, bool, int)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Search.Suggest.Fst
    Assembly: Lucene.Net.Suggest.dll
    Syntax
    public class FSTCompletionLookup : Lookup

    Constructors

    FSTCompletionLookup()

    This constructor prepares for creating a suggested FST using the Build(IInputEnumerator) method. The number of weight discretization buckets is set to DEFAULT_BUCKETS and exact matches are promoted to the top of the suggestions list.

    Declaration
    public FSTCompletionLookup()
    See Also
    FSTCompletion

    FSTCompletionLookup(FSTCompletion, bool)

    This constructor takes a pre-built automaton.

    Declaration
    public FSTCompletionLookup(FSTCompletion completion, bool exactMatchFirst)
    Parameters
    Type Name Description
    FSTCompletion completion

    An instance of FSTCompletion.

    bool exactMatchFirst

    If

    true
    exact matches are promoted to the top of the suggestions list. Otherwise they appear in the order of discretized weight and alphabetical within the bucket.
    See Also
    FSTCompletion

    FSTCompletionLookup(int, bool)

    This constructor prepares for creating a suggested FST using the Build(IInputEnumerator) method.

    Declaration
    public FSTCompletionLookup(int buckets, bool exactMatchFirst)
    Parameters
    Type Name Description
    int buckets

    The number of weight discretization buckets (see FSTCompletion for details).

    bool exactMatchFirst

    If true exact matches are promoted to the top of the suggestions list. Otherwise they appear in the order of discretized weight and alphabetical within the bucket.

    See Also
    FSTCompletion

    Properties

    Count

    Get the number of entries the lookup was built with

    Declaration
    public override long Count { get; }
    Property Value
    Type Description
    long

    total number of suggester entries

    Overrides
    Lookup.Count
    See Also
    FSTCompletion

    Methods

    Build(IInputEnumerator)

    Builds up a new internal Lookup representation based on the given IInputEnumerator. The implementation might re-sort the data internally.

    Declaration
    public override void Build(IInputEnumerator enumerator)
    Parameters
    Type Name Description
    IInputEnumerator enumerator
    Overrides
    Lookup.Build(IInputEnumerator)
    See Also
    FSTCompletion

    DoLookup(string, IEnumerable<BytesRef>, bool, int)

    Look up a key and return possible completion for this key.

    Declaration
    public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, bool higherWeightsFirst, int num)
    Parameters
    Type Name Description
    string key

    lookup key. Depending on the implementation this may be a prefix, misspelling, or even infix.

    IEnumerable<BytesRef> contexts

    contexts to filter the lookup by, or null if all contexts are allowed; if the suggestion contains any of the contexts, it's a match

    bool higherWeightsFirst
    int num

    maximum number of results to return

    Returns
    Type Description
    IList<Lookup.LookupResult>

    a list of possible completions, with their relative weight (e.g. popularity)

    Overrides
    Lookup.DoLookup(string, IEnumerable<BytesRef>, bool, int)
    See Also
    FSTCompletion

    Get(string)

    Returns the bucket (weight) as a Nullable{long} for the provided key if it exists, otherwise null if it does not.

    Declaration
    public virtual long? Get(string key)
    Parameters
    Type Name Description
    string key
    Returns
    Type Description
    long?
    See Also
    FSTCompletion

    GetSizeInBytes()

    Get the size of the underlying lookup implementation in memory

    Declaration
    public override long GetSizeInBytes()
    Returns
    Type Description
    long

    ram size of the lookup implementation in bytes

    Overrides
    Lookup.GetSizeInBytes()
    See Also
    FSTCompletion

    Load(DataInput)

    Discard current lookup data and load it from a previously saved copy. Optional operation.

    Declaration
    public override bool Load(DataInput input)
    Parameters
    Type Name Description
    DataInput input

    the Lucene.Net.Store.DataInput to load the lookup data.

    Returns
    Type Description
    bool

    true if completed successfully, false if unsuccessful or not supported.

    Overrides
    Lookup.Load(DataInput)
    Exceptions
    Type Condition
    IOException

    when fatal IO error occurs.

    See Also
    FSTCompletion

    Store(DataOutput)

    Persist the constructed lookup data to a directory. Optional operation.

    Declaration
    public override bool Store(DataOutput output)
    Parameters
    Type Name Description
    DataOutput output

    Lucene.Net.Store.DataOutput to write the data to.

    Returns
    Type Description
    bool

    true if successful, false if unsuccessful or not supported.

    Overrides
    Lookup.Store(DataOutput)
    Exceptions
    Type Condition
    IOException

    when fatal IO error occurs.

    See Also
    FSTCompletion

    See Also

    FSTCompletion
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.