org.apache.lucene.util.fst
Class Util

java.lang.Object
  extended by org.apache.lucene.util.fst.Util

public final class Util
extends Object

Static helper methods

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

Method Summary
static
<T> T
get(FST<T> fst, BytesRef input)
          Looks up the output for this input, or null if the input is not accepted
static
<T> T
get(FST<T> fst, char[] input, int offset, int length)
          Logically casts input to UTF32 ints then looks up the output or null if the input is not accepted.
static
<T> T
get(FST<T> fst, CharSequence input)
          Logically casts input to UTF32 ints then looks up the output or null if the input is not accepted.
static
<T> T
get(FST<T> fst, IntsRef input)
          Looks up the output for this input, or null if the input is not accepted.
static
<T> void
toDot(FST<T> fst, Writer out, boolean sameRank, boolean labelStates)
          Dumps an FST to a GraphViz's dot language description for visualization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static <T> T get(FST<T> fst,
                        IntsRef input)
             throws IOException
Looks up the output for this input, or null if the input is not accepted. FST must be INPUT_TYPE.BYTE4.

Throws:
IOException

get

public static <T> T get(FST<T> fst,
                        char[] input,
                        int offset,
                        int length)
             throws IOException
Logically casts input to UTF32 ints then looks up the output or null if the input is not accepted. FST must be INPUT_TYPE.BYTE4.

Throws:
IOException

get

public static <T> T get(FST<T> fst,
                        CharSequence input)
             throws IOException
Logically casts input to UTF32 ints then looks up the output or null if the input is not accepted. FST must be INPUT_TYPE.BYTE4.

Throws:
IOException

get

public static <T> T get(FST<T> fst,
                        BytesRef input)
             throws IOException
Looks up the output for this input, or null if the input is not accepted

Throws:
IOException

toDot

public static <T> void toDot(FST<T> fst,
                             Writer out,
                             boolean sameRank,
                             boolean labelStates)
                  throws IOException
Dumps an FST to a GraphViz's dot language description for visualization. Example of use:
 PrintStream ps = new PrintStream("out.dot");
 fst.toDot(ps);
 ps.close();
 
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.

Parameters:
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.
labelStates - If true states will have labels equal to their offsets in their binary format. Expands the graph considerably.
Throws:
IOException
See Also:
"http://www.graphviz.org/"


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.