## org.opencyc.conversation
Class FsmFactory

    java.lang.Object
      |
      +--org.opencyc.conversation.FsmFactory

public class FsmFactory
extends java.lang.Object

Makes finite state machines which can be interpreted by the Interpreter.

Author:
  Stephen L. Reed

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Field Summary
`static int` `DEFAULT_VERBOSITY` The default verbosity of the solution output.
`protected static java.util.HashMap` `fsmClassStore` Stores fsm class objects by name.
`protected static java.util.HashMap` `fsmStore` Stores fsm objects by name.
`protected TemplateFactory` `templateFactory` Template object factory
`protected int` `verbosity` Sets verbosity of the constraint solver output.

Constructor Summary
`FsmFactory()` Constructs a new FsmFactory object.

Method Summary
`protected void` `fixupSubFsmForwardReferences()` Fixes up the sub fsm forward references.
`static Fsm` `getFsm(java.lang.String name)` Returns the Fsm having the given name;
`static FsmClass` `getFsmClass(java.lang.String name)` Returns the FsmClass having the given name;
`void` `initialize()` Initializes this object.
`protected void` `makeAllFsmClasses()` Make all the fsm classes.
`protected void` `makeAllFsms()` Make all the fsms.
`void` `makeChat()` Makes a "chat" Fsm.
`void` `makeChatFsmClass()` Makes a chat fsm class object.
`void` `makeDisambiguatePhrase()` Makes a "disambiguate-phrase" Fsm.
`void` `makeDisambiguatePhraseFsmClass()` Makes a "disambiguate-phrase" Fsm class.
`void` `makeDisambiguateTermQuery()` Makes a "disambiguate-term-query" Fsm.
`void` `makeDisambiguateTermQueryFsmClass()` Makes a "disambiguate-term-query" Fsm class object.
`void` `makeDoNotUnderstoodArc(State currentState)` Makes a "do-not-understand" arc given the current state.
`void` `makeQuitArc(State currentState)` Makes a "quit" arc given the current state.
`void` `makeRootFsmClass()` Makes a root fsm class object.
`void` `makeStartEndFsmClass()` Makes a start-end fsm class object.
`void` `makeTermQuery()` Makes a "term-query" Fsm.
`void` `makeTermQueryFsmClass()` Makes a "term-query" Fsm class.
`static void` `reset()` Resets the fsm stores.
`void` `setVerbosity(int verbosity)` Sets verbosity of the output.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_VERBOSITY

    public static final int DEFAULT_VERBOSITY

  The default verbosity of the solution output. 0 --> quiet ... 9 -> maximum diagnostic input.

### verbosity

    protected int verbosity

  Sets verbosity of the constraint solver output. 0 --> quiet ... 9 -> maximum diagnostic input.

### fsmClassStore

    protected static java.util.HashMap fsmClassStore

  Stores fsm class objects by name. name --> FsmClass

### fsmStore

    protected static java.util.HashMap fsmStore

  Stores fsm objects by name. name --> Fsm

### templateFactory

    protected TemplateFactory templateFactory

  Template object factory

Constructor Detail

### FsmFactory

    public FsmFactory()

  Constructs a new FsmFactory object.

Method Detail

### reset

    public static void reset()

  Resets the fsm stores.

### initialize

    public void initialize()

  Initializes this object.

### makeAllFsmClasses

    protected void makeAllFsmClasses()

  Make all the fsm classes. Make superclass before making the subclasses.

### makeAllFsms

    protected void makeAllFsms()

  Make all the fsms.

### getFsmClass

    public static FsmClass getFsmClass(java.lang.String name)

  Returns the FsmClass having the given name;
  Parameters:
    `name` - the fsmClass name

### getFsm

    public static Fsm getFsm(java.lang.String name)

  Returns the Fsm having the given name;
  Parameters:
    `name` - the fsm name

### makeDoNotUnderstoodArc

    public void makeDoNotUnderstoodArc(State currentState)

  Makes a "do-not-understand" arc given the current state. 1. If we are in the current-state state and get a not-understand performative, transition to the current-state state, and perform the do-not-understand action.
  Parameters:
    `currentState` - the current state

### makeQuitArc

    public void makeQuitArc(State currentState)

  Makes a "quit" arc given the current state. 1. If we are in the current-state state and get a quit performative, transition to the final state, and perform the do-finalization action.
  Parameters:
    `currentState` - the current state

### makeRootFsmClass

    public void makeRootFsmClass()

  Makes a root fsm class object. The root class has a start state and a quit arc.

### makeStartEndFsmClass

    public void makeStartEndFsmClass()

  Makes a start-end fsm class object. The start-end class inherits from root and has an end state.

### makeChatFsmClass

    public void makeChatFsmClass()

  Makes a chat fsm class object. 1. If we are in the start state and get a disambiguate-term-query performative, transition to the start state and perform the do-disambiguate-term-query action.

### makeChat

    public void makeChat()

  Makes a "chat" Fsm.

### makeDisambiguateTermQueryFsmClass

    public void makeDisambiguateTermQueryFsmClass()

  Makes a "disambiguate-term-query" Fsm class object.
  Input "disambiguation words" --> ArrayList disambiguationWords
  1. If we are in the start state and get a start-new-fsm performative, transition to the disambiguate-phrase state and perform the disambiguate-phrase sub fsm.
  2. If we are in the disambiguate-phrase state and get a resume-previous-fsm performative, transition to the term-query state and perform the term-query sub fsm.
  3. If we are in the term-query state and get a resume-previous-fsm performative, transition to the end state and perform the end-sub-fsm action.

### makeDisambiguateTermQuery

    public void makeDisambiguateTermQuery()

  Makes a "disambiguate-term-query" Fsm.

### makeDisambiguatePhraseFsmClass

    public void makeDisambiguatePhraseFsmClass()

  Makes a "disambiguate-phrase" Fsm class.
  Input "disambiguation words" --> ArrayList disambiguationWords
  Output "disambiguated term" --> CycFort disambiguatedTerm
  1. If we are in the start state and get a start performative, transition to the disambiguate-phrase state and perform the do-disambiguate-parse-phase action.
  2. If we are in the disambiguate-phrase state and get a term-match performative, transition to the end state and perform the do-end-sub-fsm action.
  3. If we are in the disambiguate-phrase state and get a term-choice performative, transition to the term-choice state and perform the do-disambiguate-term-choice action.
  4. If we are in the term-choice state and get a choice-is-number performative, transition to (stay in) the term-choice state and perform the do-disambiguate-choice-is-number action.
  5. If we are in the term-choice state and get a choice-is-phrase performative, transition to (stay in) the term-choice state and perform the do-disambiguate-choice-is-term action.
  6. If we are in the term-choice state and get an end performative, transition to the end state and perform the do-end-sub-fsm action.

### makeDisambiguatePhrase

    public void makeDisambiguatePhrase()

  Makes a "disambiguate-phrase" Fsm.

### makeTermQueryFsmClass

    public void makeTermQueryFsmClass()

  Makes a "term-query" Fsm class.
  input "disambiguated term" --> CycFort disambiguatedTerm
  1. If we are in the start state and get a term-query performative, transition to the retrieve-first-fact state and perform the do-reply-with-first-fact action.
  2. If we are in the retrieve-first-fact state and get a more performative, transition to the prompt-for-more state and perform the do-reply-with-next-fact action.
  3. If we are in the prompt-for-more state and get a done performative, transition to the end state and perform the do-end-sub-fsm action.

### makeTermQuery

    public void makeTermQuery()

  Makes a "term-query" Fsm.

### fixupSubFsmForwardReferences

    protected void fixupSubFsmForwardReferences()

  Fixes up the sub fsm forward references.

### setVerbosity

    public void setVerbosity(int verbosity)

  Sets verbosity of the output. 0 --> quiet ... 9 -> maximum diagnostic input.
  Parameters:
    `verbosity` - 0 --> quiet ... 9 -> maximum diagnostic input