Package net.openai.util.fsm

Examples of net.openai.util.fsm.Machine


    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 = 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);
          NegationIndicator neg = new NegationIndicator(startToken
              .getStartOffset(), endToken.getEndOffset());
          outSet.add(neg);
          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

    // reset machines
    Iterator<Machine> itr = iv_machineSet.iterator();
    while (itr.hasNext()) {
      Machine fsm = itr.next();
      fsm.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);

        Condition breastDxC = new TextSetCondition(iv_breastDxSet, false);

        startState.addTransition(breastDxC, endState);
        startState.addTransition(new AnyCondition(), startState);
View Full Code Here


  
        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);

        Condition brainDxC = new TextSetCondition(iv_brainDxSet, false);

        startState.addTransition(brainDxC, endState);
        startState.addTransition(new AnyCondition(), startState);
View Full Code Here

        State startState = new NamedState("START");
        State endState = new NamedState("END");

        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);

        Condition colonDxC = new TextSetCondition(
                iv_colonDxSet,
                false);
View Full Code Here

        State pad2of3State = new NamedState("TWOOFTHREE");
        State pad3of3State = new NamedState("THREEOFTHREE");
       
        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);

        Condition padDxC = new TextSetCondition(iv_padDxSet, false);
        Condition padDxHyphenBeginC = new TextSetCondition(iv_padDxHyphenBeginSet, false);
        Condition padDxHyphenEndC = new TextSetCondition(iv_padDxHyphenEndSet, false);
        Condition pad1of2DxC = new TextSetCondition(iv_padOneOfTwoDxSet, false);
View Full Code Here

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

            Iterator<Machine>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);
                    IllnessDxIndicator si = null;
                    if (m.equals(iv_brainDxMachine))
                    {
                        si = new IllnessDxIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                IllnessDxIndicator.BRAIN_STATUS);
                    }
                    else if (m.equals(iv_breastDxMachine))
                    {
                        si = new IllnessDxIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                IllnessDxIndicator.BREAST_STATUS);
                    }
                    else if (m.equals(iv_colonDxMachine))
                    {
                        si = new IllnessDxIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                IllnessDxIndicator.COLON_STATUS);
                    }
                    else if (m.equals(iv_padDxMachine))
                    {
                        si = new IllnessDxIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                IllnessDxIndicator.PAD_STATUS);
                    }
                    outSet.add(si);
                    m.reset();
                }
            }
        }


        // cleanup
        tokenStartMap.clear();

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

        return outSet;
    }
View Full Code Here

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

        Machine m = new Machine(startState);

        Condition negInitDetC = new TextSetCondition(iv_negInitialDeterminersSet, false);
        Condition negInit1of2DetC = new TextSetCondition(iv_negCol1of2PartSet, false);
        Condition negInit2of2DetC = new TextSetCondition(iv_negCol2of2PartSet, false);
View Full Code Here

            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);
                    NegationIndicator neg = null;
                    if (fsm.equals(iv_negInitialDetermineMachine))
                    {
                        neg =  new NegationIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset());
                    }
                    else neg = new NegationIndicator(
                            startToken.getStartOffset(),
                            endToken.getEndOffset());
                    outSet.add(neg);
                    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 startState = new NamedState("START");
        State endState = new NamedState("END");
        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);
        State zeroNumState = new NamedState("ZERO_NUM");
        State fractionTextState = new NamedState("NUMERATOR_TEXT");
        State dashState = new NamedState("DASH");
        startState.addTransition(new IntegerValueCondition(0), zeroNumState);
        startState.addTransition(new AnyCondition(), startState);
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;
                    DecimalStrengthToken fractionToken =
                        new DecimalStrengthToken(
                            startToken.getStartOffset(),
                            endToken.getEndOffset());
                    fractionSet.add(fractionToken);
                    fsm.reset();
                }
            }
        }

        // cleanup
        tokenStartMap.clear();

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

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