|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmorfologik.fsa.core.FSA
public abstract class FSA
FSA (Finite State Automaton) traversal implementation, abstract base class for all versions of FSA.
This class implements Finite State Automaton traversal as described in Jan Daciuk's Incremental Construction of Finite-State Automata and Transducers, and Their Use in the Natural Language Processing (PhD thesis, Technical University of Gdansk).
This is a Java port of the original fsa
class, implemented by
Jan Daciuk in the FSA package. Major redesign has been done, however, to fit this
implementation to the specifics of Java language and its coding style.
Nested Class Summary | |
---|---|
static interface |
FSA.Arc
An arc (a labelled transition between two nodes) of the FSA. |
static interface |
FSA.Node
A node of the FSA. |
Field Summary | |
---|---|
protected byte |
filler
The meaning of this field is not clear (check the FSA docs). |
static int |
FSA_FLEXIBLE
These flags control the internal representation of a FSA. |
static int |
FSA_LARGE_DICTIONARIES
|
static int |
FSA_NEXTBIT
|
static int |
FSA_STOPBIT
|
static int |
FSA_TAILS
|
static int |
FSA_WEIGHTED
|
protected byte |
gotoLength
Size of transition's destination node "address". |
protected byte |
version
Dictionary version (derived from the combination of flags). |
static byte |
VERSION_5
Version number for version 5 of the automaton. |
Constructor Summary | |
---|---|
protected |
FSA(java.io.InputStream fsaStream,
java.lang.String dictionaryEncoding)
Creates a new automaton reading the FSA automaton from an input stream. |
Method Summary | |
---|---|
char |
getAnnotationSeparator()
|
char |
getFillerCharacter()
|
int |
getFlags()
Returns a set of flags for this FSA instance. |
static FSA |
getInstance(java.io.File fsaFile,
java.lang.String dictionaryEncoding)
This static method will attempt to instantiate an appropriate implementation of the FSA for the version found in file given in the input argument. |
static FSA |
getInstance(java.io.InputStream fsaStream,
java.lang.String dictionaryEncoding)
This static method will attempt to instantiate an appropriate implementation of the FSA for the version found in file given in the input argument. |
abstract int |
getNumberOfArcs()
Returns the number of arcs in this automaton. |
abstract int |
getNumberOfNodes()
Returns the number of nodes in this automaton. |
abstract FSA.Node |
getStartNode()
Returns the start node of this automaton. |
FSATraversalHelper |
getTraversalHelper()
|
int |
getVersion()
Returns a version number of this FSA. |
protected byte[] |
readFully(java.io.InputStream stream)
Reads all bytes from an input stream. |
protected void |
readHeader(java.io.DataInput in,
long fileSize)
Reads a FSA header from a stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FSA_FLEXIBLE
public static final int FSA_STOPBIT
public static final int FSA_NEXTBIT
public static final int FSA_TAILS
public static final int FSA_WEIGHTED
public static final int FSA_LARGE_DICTIONARIES
public static final byte VERSION_5
protected byte version
protected byte filler
protected byte gotoLength
Constructor Detail |
---|
protected FSA(java.io.InputStream fsaStream, java.lang.String dictionaryEncoding) throws java.io.IOException
fsaStream
- An input stream with FSA automaton.
java.io.IOException
- if the dictionary file cannot be read, or version of the
file is not supported.Method Detail |
---|
public final int getVersion()
The version number is a derivation of combination of flags and is exactly the same as in Jan Daciuk's FSA package.
public final int getFlags()
FSA_FLEXIBLE
flag, one must perform a bitwise AND:
boolean isFlexible = ((dict.getFlags() & FSA.FSA_FLEXIBLE ) != 0)
.
public final char getAnnotationSeparator()
public final char getFillerCharacter()
public abstract int getNumberOfArcs()
public abstract int getNumberOfNodes()
public abstract FSA.Node getStartNode()
public FSATraversalHelper getTraversalHelper()
public static FSA getInstance(java.io.File fsaFile, java.lang.String dictionaryEncoding) throws java.io.IOException
java.io.IOException
- An exception is thrown if no corresponding FSA parser
is found or if the input file cannot be opened.public static FSA getInstance(java.io.InputStream fsaStream, java.lang.String dictionaryEncoding) throws java.io.IOException
java.io.IOException
- An exception is thrown if no corresponding FSA parser
is found or if the input file cannot be opened.protected void readHeader(java.io.DataInput in, long fileSize) throws java.io.IOException
java.io.IOException
- If the stream is not a dictionary,
or if the version is not supported.protected byte[] readFully(java.io.InputStream stream) throws java.io.IOException
stream
-
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |