Class Util
Static helper methods.
This is a Lucene.NET EXPERIMENTAL API, use at your own risk
Inheritance
System.Object
Util
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Lucene.Net.dll
Syntax
Methods
|
Improve this Doc
View Source
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)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
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)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
GetByOutput(FST<Nullable<Int64>>, Int64)
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 , 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<long?> fst, long targetOutput)
Parameters
Type |
Name |
Description |
FST<System.Nullable<System.Int64>> |
fst |
|
System.Int64 |
targetOutput |
|
Returns
|
Improve this Doc
View Source
GetByOutput(FST<Nullable<Int64>>, Int64, FST.BytesReader, FST.Arc<Nullable<Int64>>, FST.Arc<Nullable<Int64>>, Int32sRef)
Declaration
public static Int32sRef GetByOutput(FST<long?> fst, long targetOutput, FST.BytesReader in, FST.Arc<long?> arc, FST.Arc<long?> scratchArc, Int32sRef result)
Parameters
Type |
Name |
Description |
FST<System.Nullable<System.Int64>> |
fst |
|
System.Int64 |
targetOutput |
|
FST.BytesReader |
in |
|
FST.Arc<System.Nullable<System.Int64>> |
arc |
|
FST.Arc<System.Nullable<System.Int64>> |
scratchArc |
|
Int32sRef |
result |
|
Returns
|
Improve this Doc
View Source
ReadCeilArc<T>(Int32, FST<T>, FST.Arc<T>, FST.Arc<T>, FST.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)
Parameters
Type |
Name |
Description |
System.Int32 |
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 Parameters
|
Improve this Doc
View Source
ShortestPaths<T>(FST<T>, FST.Arc<T>, T, IComparer<T>, Int32, Boolean)
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)
Parameters
Type |
Name |
Description |
FST<T> |
fst |
|
FST.Arc<T> |
fromNode |
|
T |
startOutput |
|
System.Collections.Generic.IComparer<T> |
comparer |
|
System.Int32 |
topN |
|
System.Boolean |
allowEmptyString |
|
Returns
Type Parameters
|
Improve this Doc
View Source
ToBytesRef(Int32sRef, BytesRef)
Just converts Int32sRef to BytesRef; you must ensure the
System.Int32 values fit into a System.Byte.
Declaration
public static BytesRef ToBytesRef(Int32sRef input, BytesRef scratch)
Parameters
Returns
|
Improve this Doc
View Source
ToDot<T>(FST<T>, TextWriter, Boolean, Boolean)
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)
Parameters
Type |
Name |
Description |
FST<T> |
fst |
|
System.IO.TextWriter |
out |
|
System.Boolean |
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.
|
System.Boolean |
labelStates |
If true states will have labels equal to their offsets in their
binary format. Expands the graph considerably.
|
Type Parameters
|
Improve this Doc
View Source
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
|
Improve this Doc
View Source
ToUTF16(String, Int32sRef)
Just maps each UTF16 unit (char) to the System.Int32s in an
Int32sRef.
Declaration
public static Int32sRef ToUTF16(string s, Int32sRef scratch)
Parameters
Type |
Name |
Description |
System.String |
s |
|
Int32sRef |
scratch |
|
Returns
|
Improve this Doc
View Source
ToUTF32(Char[], Int32, Int32, 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 |
System.Char[] |
s |
|
System.Int32 |
offset |
|
System.Int32 |
length |
|
Int32sRef |
scratch |
|
Returns
|
Improve this Doc
View Source
ToUTF32(String, Int32sRef)
Decodes the Unicode codepoints from the provided
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 |
System.String |
s |
|
Int32sRef |
scratch |
|
Returns
Extension Methods