Class Util
Static helper methods.
Note
This API is experimental and might change in incompatible ways in the next release.
Assembly: Lucene.Net.dll
Syntax
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
GetByOutput(FST<Int64>, long, BytesReader, Arc<Int64>, Arc<Int64>, Int32sRef)
Declaration
public static Int32sRef GetByOutput(FST<Int64> fst, long targetOutput, FST.BytesReader @in, FST.Arc<Int64> arc, FST.Arc<Int64> scratchArc, Int32sRef result)
Parameters
Returns
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
Returns
Type Parameters
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
Returns
Type Parameters
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
Returns
Type Parameters
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
Returns
Type Parameters
ToBytesRef(Int32sRef, BytesRef)
Declaration
public static BytesRef ToBytesRef(Int32sRef input, BytesRef scratch)
Parameters
Returns
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
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
Returns
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
Returns
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
Returns
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
Returns