Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class Util

    Static helper methods.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    Util
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Util.Fst
    Assembly: Lucene.Net.dll
    Syntax
    public static class Util

    Methods

    GetByOutput(FST<Int64>, long)

    Reverse lookup (lookup by output instead of by input), in the special case when your FSTs outputs are strictly ascending. This locates the input/output pair where the output is equal to the target, and will return null if that output does not exist.

    NOTE: this only works with FST<T>, only works when the outputs are ascending in order with the inputs. For example, simple ordinals (0, 1, 2, ...), or file offets (when appending to a file) fit this.
    Declaration
    public static Int32sRef GetByOutput(FST<Int64> fst, long targetOutput)
    Parameters
    Type Name Description
    FST<Int64> fst
    long targetOutput
    Returns
    Type Description
    Int32sRef

    GetByOutput(FST<Int64>, long, BytesReader, Arc<Int64>, Arc<Int64>, Int32sRef)

    Expert: like GetByOutput(FST<Int64>, long) except reusing FST.BytesReader, initial and scratch Arc, and result.

    Declaration
    public static Int32sRef GetByOutput(FST<Int64> fst, long targetOutput, FST.BytesReader @in, FST.Arc<Int64> arc, FST.Arc<Int64> scratchArc, Int32sRef result)
    Parameters
    Type Name Description
    FST<Int64> fst
    long targetOutput
    FST.BytesReader in
    FST.Arc<Int64> arc
    FST.Arc<Int64> scratchArc
    Int32sRef result
    Returns
    Type Description
    Int32sRef

    Get<T>(FST<T>, BytesRef)

    Looks up the output for this input, or null if the input is not accepted

    Declaration
    public static T Get<T>(FST<T> fst, BytesRef input) where T : class
    Parameters
    Type Name Description
    FST<T> fst
    BytesRef input
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    Get<T>(FST<T>, Int32sRef)

    Looks up the output for this input, or null if the input is not accepted.

    Declaration
    public static T Get<T>(FST<T> fst, Int32sRef input) where T : class
    Parameters
    Type Name Description
    FST<T> fst
    Int32sRef input
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    ReadCeilArc<T>(int, FST<T>, Arc<T>, Arc<T>, BytesReader)

    Reads the first arc greater or equal that the given label into the provided arc in place and returns it iff found, otherwise return null.

    Declaration
    public static FST.Arc<T> ReadCeilArc<T>(int label, FST<T> fst, FST.Arc<T> follow, FST.Arc<T> arc, FST.BytesReader @in) where T : class
    Parameters
    Type Name Description
    int label

    the label to ceil on

    FST<T> fst

    the fst to operate on

    FST.Arc<T> follow

    the arc to follow reading the label from

    FST.Arc<T> arc

    the arc to read into in place

    FST.BytesReader in

    the fst's FST.BytesReader

    Returns
    Type Description
    FST.Arc<T>
    Type Parameters
    Name Description
    T

    ShortestPaths<T>(FST<T>, Arc<T>, T, IComparer<T>, int, bool)

    Starting from node, find the top N min cost completions to a final node.

    Declaration
    public static Util.TopResults<T> ShortestPaths<T>(FST<T> fst, FST.Arc<T> fromNode, T startOutput, IComparer<T> comparer, int topN, bool allowEmptyString) where T : class
    Parameters
    Type Name Description
    FST<T> fst
    FST.Arc<T> fromNode
    T startOutput
    IComparer<T> comparer
    int topN
    bool allowEmptyString
    Returns
    Type Description
    Util.TopResults<T>
    Type Parameters
    Name Description
    T

    ToBytesRef(Int32sRef, BytesRef)

    Just converts Int32sRef to BytesRef; you must ensure the int values fit into a byte.

    Declaration
    public static BytesRef ToBytesRef(Int32sRef input, BytesRef scratch)
    Parameters
    Type Name Description
    Int32sRef input
    BytesRef scratch
    Returns
    Type Description
    BytesRef

    ToDot<T>(FST<T>, TextWriter, bool, bool)

    Dumps an FST<T> to a GraphViz's dot language description for visualization. Example of use:

    using (TextWriter sw = new StreamWriter("out.dot"))
    {
        Util.ToDot(fst, sw, true, true);
    }

    and then, from command line:

    dot -Tpng -o out.png out.dot

    Note: larger FSTs (a few thousand nodes) won't even render, don't bother. If the FST is > 2.1 GB in size then this method will throw strange exceptions.

    See also http://www.graphviz.org/.
    Declaration
    public static void ToDot<T>(FST<T> fst, TextWriter @out, bool sameRank, bool labelStates) where T : class
    Parameters
    Type Name Description
    FST<T> fst
    TextWriter out
    bool sameRank

    If true, the resulting dot file will try to order states in layers of breadth-first traversal. This may mess up arcs, but makes the output FST's structure a bit clearer.

    bool labelStates

    If true states will have labels equal to their offsets in their binary format. Expands the graph considerably.

    Type Parameters
    Name Description
    T

    ToInt32sRef(BytesRef, Int32sRef)

    Just takes unsigned byte values from the BytesRef and converts into an Int32sRef.

    NOTE: This was toIntsRef() in Lucene
    Declaration
    public static Int32sRef ToInt32sRef(BytesRef input, Int32sRef scratch)
    Parameters
    Type Name Description
    BytesRef input
    Int32sRef scratch
    Returns
    Type Description
    Int32sRef

    ToUTF16(string, Int32sRef)

    Just maps each UTF16 unit (char) to the ints in an Int32sRef.

    Declaration
    public static Int32sRef ToUTF16(string s, Int32sRef scratch)
    Parameters
    Type Name Description
    string s
    Int32sRef scratch
    Returns
    Type Description
    Int32sRef

    ToUTF32(char[], int, int, Int32sRef)

    Decodes the Unicode codepoints from the provided char[] and places them in the provided scratch Int32sRef, which must not be null, returning it.

    Declaration
    public static Int32sRef ToUTF32(char[] s, int offset, int length, Int32sRef scratch)
    Parameters
    Type Name Description
    char[] s
    int offset
    int length
    Int32sRef scratch
    Returns
    Type Description
    Int32sRef

    ToUTF32(string, Int32sRef)

    Decodes the Unicode codepoints from the provided J2N.Text.ICharSequence and places them in the provided scratch Int32sRef, which must not be null, returning it.

    Declaration
    public static Int32sRef ToUTF32(string s, Int32sRef scratch)
    Parameters
    Type Name Description
    string s
    Int32sRef scratch
    Returns
    Type Description
    Int32sRef
    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.