Package net.openai.util.fsm

Examples of net.openai.util.fsm.Machine


       
        State fslashState = new NamedState("FORWARD_SLASH");

        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);

        Condition historyC = new TextSetCondition(iv_historySet, false);
 
        startState.addTransition(historyC, endState);
        startState
View Full Code Here


        // for case h/o
        State familyState = new NamedState("FAMILY");

        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);

        Condition familyHistoryC = new TextSetCondition(
                iv_familyHistorySet,
                false);
View Full Code Here

            BaseToken token = (BaseToken) tokens.get(i);

            Iterator machineItr = iv_machineSet.iterator();
            while (machineItr.hasNext())
            {
                Machine m = (Machine) machineItr.next();
                m.input(token);

                State currentState = m.getCurrentState();
                if (currentState.getStartStateFlag())
                {
                    tokenStartMap.put(m, new Integer(i));
                }
                if (currentState.getEndStateFlag())
                {
                    Object o = tokenStartMap.get(m);
                    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);
                    StatusIndicator si = null;
                    if (m.equals(iv_historyMachine))
                    {
                        si = new StatusIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                StatusIndicator.HISTORY_STATUS);
                    }
                    else if (m.equals(iv_probableMachine) || (m.equals(iv_probableMachineNoTerm)))
                    {

                        si = new StatusIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                StatusIndicator.PROBABLE_STATUS);
                    }
                    else if (m.equals(iv_familyHistoryMachine))
                    {
                        si = new StatusIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                StatusIndicator.FAMILY_HISTORY_STATUS);
                    }
                    outSet.add(si);
                    m.reset();
                }
            }
        }

        // TODO resolve conflict between history & family history

        // cleanup
        tokenStartMap.clear();

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

        return outSet;
    }
View Full Code Here

  {
      State startState = new NamedState("START");
      State endState = new NamedState("END");
      endState.setEndStateFlag(true);
 
      Machine m = new Machine(startState);
      State numeratorLeftState = new NamedState("NUMERATOR_LEFT");
      State remainderRightState = new NamedState("REMAINDER_RIGHT");
      State numeratorRightState = new NamedState("NUMERATOR_RIGHT");
      State decPartNumState = new NamedState("DECIMAL_NUM");
      State fslashState = new NamedState("FORWARD-SLASH");
View Full Code Here

    {
        State startState = new NamedState("START");
        State endState = new NamedState("END");
        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);
        State numeratorNumState = new NamedState("NUMERATOR_NUM");
        State fslashState = new NamedState("FORWARD_SLASH");
        State numeratorTextState = new NamedState("NUMERATOR_TEXT");

        Condition intNumeratorCondition = new NumberCondition();
View Full Code Here

            BaseToken token = (BaseToken) tokens.get(i);

            Iterator 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, Integer.valueOf(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 startToken =
                  (BaseToken) tokens.get(tokenStartIndex);
                BaseToken endToken = token;
                FractionStrengthToken fractionToken =
                  new FractionStrengthToken(
                      startToken.getStartOffset(),
                      endToken.getEndOffset());
                fractionSet.add(fractionToken);
                fsm.reset();
              }
            }
        }

        // cleanup
        tokenStartMap.clear();

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

        return fractionSet;
    }
View Full Code Here

  {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    endState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
   
    State leftNumTextState = new NamedState("LEFT_NUM_TEXT");
    State rightNumTextState = new NamedState("RIGHT_NUM_TEXT");
    State middleDash = new NamedState("MIDDASH");
    State dashAnotherState = new NamedState("DASH_2");
View Full Code Here

  {
      State startState = new NamedState("START");
      State endState = new NamedState("END");
      endState.setEndStateFlag(true);
 
      Machine m = new Machine(startState);
      State leftNumIntegerState = new NamedState("LEFT_NUM_INTEGER");
      State leftNumTextState = new NamedState("LEFT_NUM_TEXT");
      State dashState = new NamedState("DASH1");
      State dash1State = new NamedState("DASH_1");
   
View Full Code Here

  {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    endState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
    State leftNumIntegerState = new NamedState("LEFT_N2_INT");
    State decPartNumState = new NamedState("DECIMAL_NUM");

    State dashState = new NamedState("DASH");
    State dotState = new NamedState("DOT");
View Full Code Here

      }

      Iterator 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 startToken =
            (BaseToken) tokens.get(tokenStartIndex);
          BaseToken endToken = token;
          RangeStrengthToken segmentToken =
            new RangeStrengthToken(
              startToken.getStartOffset(),
              endToken.getEndOffset());
          rangeSet.add(segmentToken);
          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

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

    return rangeSet;
  }
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.