IDS::DFAState - A state in a Deterministic Finite Automata (L)


IDS-Algorithms documentation  | view source Contained in the IDS-Algorithms distribution.

Index


NAME

Top

IDS::DFAState - A state in a Deterministic Finite Automata (DFA) or a Hidden Markov Model (HMM).

SYNOPSIS

Top

A usage synopsis would go here. Since it is not here, read on.

DESCRIPTION

Top

Introduction

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:

inbound

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

in_states

What states have transitions to us

in_tokens

what are the tokens causing an inbound transition

exists_inbound_from

If a state is in the list

Functions that change this variable:

add_inbound

Add an inbound state

absorb
dropped_edge

outbound

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

out_states

States we can reach

out_tokens

Tokens causing transitions

token_to

What token causes a transition to a specified state

next

What state we transition to for a given token.

Functions that change this variable:

add_outbound
absorb
move
drop_edge

out_count

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:

out_count

the count for a given token

Functions that change this variable:

followed
reset_counters

As well as all of the functions that manipulate the variable outbound.

visits

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:

visits

Functions that change this variable:

visited
reset_counters

Sanity says that the sum of the out counts should equal this count.

verbose

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.

Methods

The only callers of these methods should be methods in DFA, HMM, or related classes.

I/O methods

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.

Methods for information about this state

in_states()

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.

out_tokens()

Return a list of tokens that cause a transition out of this state.

out_states()

Return a list of states to which this state has transitions.

Return the number of outbound edges.

in_tokens()

Return a list of tokens that cause a transition into this state.

token_to(state)

Return the token that causes a transition to the specified state.

token_from(state)

Return the token that causes a transition from the specified state, or undef if the state claims to have no transition to us.

next(token)

Given a token, return the next state.

exists_inbound_from(from)

Verify that ``from'' is in the list of inbound states.

compare(otherstate)

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:

* They have the same number of outbound states.
* Every token for one state has a transition in the other state with the same destination.

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.

AUTHOR INFORMATION

Top

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.

BUGS

Top

Please report them.

SEE ALSO

Top

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.