Package net.openai.util.fsm

Examples of net.openai.util.fsm.State


   * </ol>
   *
   * @return
   */
  private Machine getNumericDateMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);

    Machine machine = new Machine(startState);
    State monthNumState = new NamedState("MONTH_NUM");
    State monthDaySeparatorState = new NamedState("MONTH_DAY_SEP");
    State dayNumState = new NamedState("DAY_NUM");
    State dayYearSeparatorState = new NamedState("DAY_YEAR_SEP");

    Condition monthNumCondition = new IntegerRangeCondition(MIN_MONTH,
        MAX_MONTH);
    Condition mdFslashCondition = new PunctuationValueCondition('/');
    Condition mdDashCondition = new PunctuationValueCondition('-');
    Condition dyFslashCondition = new PunctuationValueCondition('/');
    Condition dyDashCondition = new PunctuationValueCondition('-');
    Condition dayNumCondition = new IntegerRangeCondition(MIN_DAY, MAX_DAY);
    Condition yearNumCondition = new IntegerRangeCondition(MIN_YEAR,
        MAX_YEAR);

    // condition that is not a fslash or dash
    Condition notFslashNotDashCondition = new CombineCondition(
        new NegateCondition(mdFslashCondition), new NegateCondition(
            mdDashCondition));

    startState.addTransition(monthNumCondition, monthNumState);
    startState.addTransition(new AnyCondition(), startState);

    monthNumState.addTransition(mdFslashCondition, monthDaySeparatorState);
    monthNumState.addTransition(mdDashCondition, monthDaySeparatorState);
    monthNumState.addTransition(new AnyCondition(), startState);

    monthDaySeparatorState.addTransition(dayNumCondition, dayNumState);
    monthDaySeparatorState.addTransition(new AnyCondition(), startState);

    dayNumState.addTransition(dyFslashCondition, dayYearSeparatorState);
    dayNumState.addTransition(dyDashCondition, dayYearSeparatorState);
    dayNumState.addTransition(notFslashNotDashCondition, ntEndState);
    dayNumState.addTransition(new AnyCondition(), startState);

    dayYearSeparatorState.addTransition(yearNumCondition, endState);
    dayYearSeparatorState.addTransition(new AnyCondition(), startState);

    endState.addTransition(new AnyCondition(), startState);
    ntEndState.addTransition(new AnyCondition(), startState);

    return machine;
View Full Code Here


   * </ol>
   *
   * @return
   */
  private Machine getTextualDateMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);

    Machine m = new Machine(startState);

    State monthFullTextState = new NamedState("MONTH_FULL_TEXT");
    State monthShortTextState = new NamedState("MONTH_SHORT_TEXT");
    State dayNumState = new NamedState("DAY_NUM");
    State commaState = new NamedState("COMMA");
    State periodState = new NamedState("PERIOD");

    Condition monthFullTextCondition = new WordSetCondition(
        iv_monthFullNameSet, false);
    Condition monthShortTextCondition = new WordSetCondition(
        iv_monthShortNameSet, false);
    Condition dayNumCondition = new IntegerRangeCondition(MIN_DAY, MAX_DAY);
    Condition periodCondition = new PunctuationValueCondition('.');
    Condition yearNumCondition = new IntegerRangeCondition(MIN_YEAR,
        MAX_YEAR);
    Condition commaCondition = new PunctuationValueCondition(',');

    // condition for not being a comma or year number
    Condition notCommaNotYearNumCondition = new CombineCondition(
        new NegateCondition(commaCondition), new NegateCondition(
            yearNumCondition));

    // condition for being a year num and not a day num
    Condition yearNotDayNumCondition = new CombineCondition(
        yearNumCondition, new NegateCondition(dayNumCondition));

    startState.addTransition(monthFullTextCondition, monthFullTextState);
    startState.addTransition(monthShortTextCondition, monthShortTextState);
    startState.addTransition(new AnyCondition(), startState);

    monthFullTextState.addTransition(dayNumCondition, dayNumState);
    monthFullTextState.addTransition(yearNotDayNumCondition, endState);
    monthFullTextState.addTransition(new AnyCondition(), startState);

    monthShortTextState.addTransition(dayNumCondition, dayNumState);
    monthShortTextState.addTransition(periodCondition, periodState);
    monthShortTextState.addTransition(yearNotDayNumCondition, endState);
    monthShortTextState.addTransition(new AnyCondition(), startState);

    periodState.addTransition(dayNumCondition, dayNumState);
    periodState.addTransition(yearNotDayNumCondition, endState);
    periodState.addTransition(new AnyCondition(), startState);

    dayNumState.addTransition(yearNumCondition, endState);
    dayNumState.addTransition(commaCondition, commaState);
    dayNumState.addTransition(notCommaNotYearNumCondition, ntEndState);
    dayNumState.addTransition(new AnyCondition(), startState);
View Full Code Here

      while (machineItr.hasNext()) {
        Machine fsm = machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
View Full Code Here

      while (machineItr.hasNext()) {
        Machine fsm = (Machine) machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
View Full Code Here

 
    return outSet;
  }

  private Machine getConfirmSubSectionMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State medState = new NamedState("MED");
    State tailState = new NamedState("TAIL");
    State caseState = new NamedState("COLON");
    State nonCaseState = new NamedState("NOCOLON");
    State fslashState = new NamedState("FSLASH");
    State orState = new NamedState("OR");
    State altTailState = new NamedState("ALTTAIL");
    State finishAltState = new NamedState("EXTREMITY");
   
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
 
    Condition subFirstBegin = new TextSetCondition(iv_confirmedSubBeginSet,
        false);
View Full Code Here

    return m;
  }


  private Machine getProbableSubSectionMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
      State nonCaseState = new NamedState("NOCOLON");
    State casenState = new NamedState("COLON");
   
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
 
    Condition subFirstSolo = new TextSetCondition(iv_probableSubSet,
        false);
View Full Code Here

    return m;
  }


  private Machine getNegateSubSectionMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State caseState = new NamedState("COLON");
    State nonCaseState = new NamedState("NOCOLON");
   
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
 
    Condition subFirstBegin = new TextSetCondition(iv_negateSubSet,
        false);
View Full Code Here

    iv_machineSet.add(getAdjNegIndicatorMachine());

  }

  private Machine getAspectualNegIndicatorMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State anyState = new NamedState("ANY");

    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);

    Machine m = new Machine(startState);
    State regModalState = new NamedState("REG_MODAL");
    State negPartState = new NamedState("NEG_PART");
    State negVerbState = new NamedState("NEG_VERB");
    State negCollocState = new NamedState("NEG_COLLOC");
    State negColPartState = new NamedState("NEG_COLPART");

    Condition regModalC = new TextSetCondition(iv_modalVerbsSet, false);
    Condition negPartC = new TextSetCondition(iv_negParticlesSet, false);
    Condition regVerbC = new TextSetCondition(iv_regVerbsSet, false);
    Condition negVerbC = new TextSetCondition(iv_negVerbsSet, false);
    Condition negDetC = new TextSetCondition(iv_negDeterminersSet, false);
    Condition negCollocC = new TextSetCondition(iv_negCollocSet, false);
    Condition negColPartC = new TextSetCondition(iv_negColPartSet, false);

    Condition notCollocC = new NegateCondition(negCollocC);

    startState.addTransition(negVerbC, negVerbState);
    startState.addTransition(negCollocC, negCollocState); // rule

    startState.addTransition(new DisjoinCondition(regModalC, regVerbC),
        regModalState); // start with a modal
    startState.addTransition(new DisjoinCondition(negPartC, negDetC),
        negPartState);

    startState.addTransition(new AnyCondition(), startState);

    regModalState.addTransition(negCollocC, negCollocState);
    negCollocState.addTransition(negColPartC, negColPartState); // out
    negColPartState.addTransition(new AnyCondition(), ntEndState);
    negCollocState.addTransition(new AnyCondition(), startState);

    regModalState.addTransition(new DisjoinCondition(negPartC, negDetC),
        negPartState);
    regModalState.addTransition(new AnyCondition(), anyState);
View Full Code Here

   *  </ul>
   * <p> and D is anything
   * @return
   */
  private Machine getNominalNegIndicatorMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State anyState = new NamedState("ANY");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);

    Machine m = new Machine(startState);
    State negPrepState = new NamedState("NEG_PREP");
    State negDetState = new NamedState("NEG_DET");
    State regNounState = new NamedState("REG_NOUN");

    Condition negPrepC = new TextSetCondition(iv_negPrepositionsSet, false);
    Condition negDetC = new TextSetCondition(iv_negDeterminersSet, false);
    Condition regNounC = new TextSetCondition(iv_regNounsSet, false);

    startState.addTransition(negDetC, negDetState); // start with a modal
    startState.addTransition(negPrepC, negPrepState);
    startState.addTransition(new AnyCondition(), startState);

    negPrepState.addTransition(new AnyCondition(), ntEndState);
    negDetState.addTransition(regNounC, regNounState);
    negDetState.addTransition(new AnyCondition(), ntEndState);
    negDetState.addTransition(new AnyCondition(), anyState);

    anyState.addTransition(regNounC, regNounState);
    anyState.addTransition(new AnyCondition(), anyState);

    regNounState.addTransition(new AnyCondition(), ntEndState);

    ntEndState.addTransition(new AnyCondition(), endState);

    return m;
  }
View Full Code Here

   * where A is unremarkable, unlikely, or negative
   * and B is of, in, for, or with
   */

  private Machine getAdjNegIndicatorMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);

    Machine m = new Machine(startState);
    State regPrepState = new NamedState("REG_PREP");
    State negAdjState = new NamedState("NEG_ADJ");

    Condition regPrepC = new TextSetCondition(iv_regPrepositionsSet, false);
    Condition negAdjC = new TextSetCondition(iv_negAdjectivesSet, false);

    startState.addTransition(negAdjC, negAdjState); // start with a modal
    startState.addTransition(new AnyCondition(), startState);

    negAdjState.addTransition(regPrepC, regPrepState);
    regPrepState.addTransition(new AnyCondition(), ntEndState);
    negAdjState.addTransition(new AnyCondition(), startState);

    ntEndState.addTransition(new AnyCondition(), endState);

    return m;
  }
View Full Code Here

TOP

Related Classes of net.openai.util.fsm.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.