Package net.openai.util.fsm

Examples of net.openai.util.fsm.Machine


    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");
View Full Code Here


    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");
View Full Code Here

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = tokens.get(i);

      Iterator<Machine> machineItr = iv_machineSet.iterator();
      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.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState) {
            endToken = tokens.get(i - 1);
          } else {
            endToken = token;
          }

          BaseToken startToken = tokens
              .get(tokenStartIndex);
          DateToken dateToken = new DateToken(startToken
              .getStartOffset(), endToken.getEndOffset());
          dateSet.add(dateToken);
          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

    // reset machines
    Iterator<Machine> itr = iv_machineSet.iterator();
    while (itr.hasNext()) {
      Machine fsm = itr.next();
      fsm.reset();
    }

    return dateSet;
  }
View Full Code Here

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = (BaseToken) tokens.get(i);

      Iterator<Machine> machineItr = iv_machineSet.iterator();
      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.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState) {
            endToken = (BaseToken) tokens.get(i - 1);
          } else {
            endToken = token;
          }

          BaseToken startToken = (BaseToken) tokens
              .get(tokenStartIndex);
          SubSectionIndicator subs = null;
          if (fsm.equals(iv_subSectionIDConfirmMachine)) {
            subs = new SubSectionIndicator(startToken
                .getStartOffset(), endToken.getEndOffset(),
                SubSectionIndicator.CONFIRMED_STATUS);
          } else if (fsm.equals(iv_subSectionIDNegateMachine)) {
            subs = new SubSectionIndicator(startToken
                .getStartOffset(), endToken.getEndOffset(),
                SubSectionIndicator.NEGATED_STATUS);
          } else if (fsm.equals(iv_subSectionIDProbableMachine)) {
            subs = new SubSectionIndicator(startToken
                .getStartOffset(), endToken.getEndOffset(),
                SubSectionIndicator.PROBABLE_STATUS);
          }
          outSet.add(subs);

          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

    // reset machines
    Iterator<Machine> itr = iv_machineSet.iterator();
    while (itr.hasNext()) {
      Machine fsm = (Machine) itr.next();
      fsm.reset();
    }
 
    return outSet;
  }
View Full Code Here

   
    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);
    Condition subFirstNext = new TextSetCondition(iv_confirmedSubNextSet,
        false);
View Full Code Here

   
    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);
    Condition subFirstBegin = new TextSetCondition(iv_probableSubBeginSet,
        false);
View Full Code Here

   
    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);
 
    startState.addTransition(subFirstBegin, caseState);
View Full Code Here

    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");
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

TOP

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

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.