| IDS-Algorithms documentation | view source | Contained in the IDS-Algorithms distribution. |
IDS::DFAState - A state in a Deterministic Finite Automata (DFA) or a Hidden Markov Model (HMM).
A usage synopsis would go here. Since it is not here, read on.
This class is for people writing various forms of finite automata. It is unlikely to be useful to others.
Note that a state is rarely accessed other than through a reference. A token is always a simple string.
A state consists of the following:
A hash with key of a reference to a state and a value of a reference to a hash indexed by tokens that that that cause a transition to us (the value of this hash is just "1"; we use a hash because it is a set and not a list). If the hash is empty, we will be pruned shortly.
Class methods that provide information relating to this variable:
How many states have transitions to us
What states have transitions to us
what are the tokens causing an inbound transition
If a state is in the list
Functions that change this variable:
Add an inbound state
A hash, indexed by tokens causing the transition, of references to states that we can transition to. We can have only one outbound transition per token, so this is a DFA and not a NFA state. Functions that provide information relating to this variable:
How many outbound links do we have
States we can reach
Tokens causing transitions
What token causes a transition to a specified state
What state we transition to for a given token.
Functions that change this variable:
Out_count keeps track of every time an edge is traversed. When used in a DFA, the counts may be used to know which edges are not used, and thus are candidates for pruning. When used in a HMM, out_count keeps track of every time an edge is traversed for computing probabilities later. This variable is a hash, indexed by the token causing the transition, with the value being the count.
Functions that provide information relating to this variable:
the count for a given token
Functions that change this variable:
As well as all of the functions that manipulate the variable outbound.
When the DFA is being used, visits keep track of the number of times this node has been visited. It is used in pruning to delete un-used nodes. Functions that provide information relating to this variable:
Functions that change this variable:
Sanity says that the sum of the out counts should equal this count.
As the state does operations, it will print messages that might be helpful for debugging. These are controlled by the verbosity level. The higher the value, the more verbose. Values beyond 2 are unlikely to be useful.
The only callers of these methods should be methods in DFA, HMM, or related classes.
Print the edges associated with this state. If a filehandle is supplied, print there, STDOUT otherwise.
The node_map is a mapping from node (IDS::DFAState) reference to the node number assigned to a node by the DFA or HMM.
Print the outbound transitions in VCG format. See SEE ALSO for a reference for the VCG format.
The node_map is a mapping from a node (IDS::DFAState) reference to the node number assigned to a node by the DFA or HMM.
Print information about this node (state) in VCG format. The node_number is our node number.
Return a list or reference to an array (depending on if we are called in scalar or list context) which is a list of inbound states.
Return the number of inbound links we have.
Return a list of tokens that cause a transition out of this state.
Return a list of states to which this state has transitions.
Return the number of outbound edges.
Return a list of tokens that cause a transition into this state.
Return the token that causes a transition to the specified state.
Return the token that causes a transition from the specified state, or undef if the state claims to have no transition to us.
Given a token, return the next state.
Verify that ``from'' is in the list of inbound states.
Compare the current state with another state. The return value is 0 if they are identical, 1 otherwise. This return value may seem odd, but it was inspired by the perl cmp and <=> operators. However, the concept of greater than and less than is not well defined.
Two states are considered identical iff:
Note that the inbound states may be different for the compared states and they will still test as identical. This is on purpose to allow the merging to occur.
Copyright 2005-2007, Kenneth Ingham. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Address bug reports and comments to: ids_test at i-pi.com. When sending bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm, IDS::DataSource.pm, the version of Perl, and the name and version of the operating system you are using. Since Kenneth is a PhD student, the speed of the response depends on how the research is proceeding.
Please report them.
IDS::Algorithm, DFA, HMM
VCG - Visualization of Compiler Graphs, Design Report and User Documentation, Ref. Compare, USAAR-1049-visual, January 1994, updated January 1995
| IDS-Algorithms documentation | view source | Contained in the IDS-Algorithms distribution. |