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 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 fractionToken = new RangeStrengthToken(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


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

    Machine m = new Machine(startState);
    State hyphState = new NamedState("HYPHTERM");
    State dosageState = new NamedState("DOSAGE");

    Condition decimalCondition = new DecimalCondition();
    Condition numberCondition = new NumberCondition();
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));
          tokenOffset1 = 0;
          tokenOffset2 = 0;
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int globalOffset = 0;
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            Integer tokenMap1 = new Integer(0);
            Integer tokenMap2 = new Integer(0);
         
            BaseToken lookUpOffset = (BaseToken) tokens.get(((Integer) o).intValue());
             
            if (overrideBeginTokenMap1.get(new Integer(lookUpOffset.getStartOffset())) != null){
              Integer offSet = (Integer) (overrideBeginTokenMap1.get(new Integer(lookUpOffset.getStartOffset())));
              tokenMap1 = new Integer(offSet.intValue()  + tokenMap1.intValue());
            }
            if (overrideBeginTokenMap2.get(new Integer(lookUpOffset.getStartOffset())) != null){
              Integer offSet = (Integer) (overrideBeginTokenMap2.get(new Integer(lookUpOffset.getStartOffset())));
              tokenMap2 = new Integer(offSet.intValue() + tokenMap2.intValue());
              }
           

            globalOffset = tokenMap1.intValue() + tokenMap2.intValue();
            tokenStartIndex = ((Integer) o).intValue() + globalOffset;
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = null;
          if (currentState instanceof IndentStartState) {
            startToken = (BaseToken) tokens
                .get(tokenStartIndex + 1);

          } else {
            startToken = (BaseToken) tokens.get(tokenStartIndex);

          }
          BaseToken endToken = token;
          if (currentState instanceof NonTerminalEndState) {
            endToken = (BaseToken) tokens.get(i - 1);

            if (endToken instanceof PunctuationTokenAdapter) {
              endToken = (BaseToken) tokens.get(i - 2);
            }
          } else {
            endToken = token;
          }
          DosageToken measurementToken = new DosageToken(startToken
              .getStartOffset(), endToken.getEndOffset());
          measurementSet.add(measurementToken);
          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

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

    return measurementSet;
  }
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, 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 = null;
          if (currentState instanceof IndentStartState) {
            startToken = (BaseToken) tokens
                .get(tokenStartIndex + 1);

          } else {
            startToken = (BaseToken) tokens.get(tokenStartIndex);

          }
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState) {
            endToken = (BaseToken) tokens.get(i - 1);
            if (endToken instanceof PunctuationTokenAdapter) {
              endToken = (BaseToken) tokens.get(i - 2);
            }
          } else {
            endToken = token;
          }
          // BaseToken endToken = token;
          DosageToken measurementToken = new DosageToken(startToken
              .getStartOffset(), endToken.getEndOffset());

          measurementSet.add(measurementToken);
          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

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

    return measurementSet;
  }
View Full Code Here

    hyphenState.addTransition(new AnyCondition() , startState);
   
    ntEndHyphState.addTransition(new AnyCondition(), startState);
    ntEndState.addTransition(new AnyCondition(), startState);
    endState.addTransition(new AnyCondition(), startState);
    Machine m = new Machine(startState);
    return m;
  }
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));
          tokenOffset1 = 0;
          tokenOffset2 = 0;
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          int globalOffset = 0;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            Integer tokenMap1 = new Integer(0);
            Integer tokenMap2 = new Integer(0);
         
            BaseToken lookUpOffset = (BaseToken) tokens.get(((Integer) o).intValue());
             
            if (overrideBeginTokenMap1.get(new Integer(lookUpOffset.getStartOffset())) != null){
              Integer offSet = (Integer) (overrideBeginTokenMap1.get(new Integer(lookUpOffset.getStartOffset())));
              tokenMap1 = new Integer(offSet.intValue()  + tokenMap1.intValue());
            }
            if (overrideBeginTokenMap2.get(new Integer(lookUpOffset.getStartOffset())) != null){
              Integer offSet = (Integer) (overrideBeginTokenMap2.get(new Integer(lookUpOffset.getStartOffset())));
              tokenMap2 = new Integer(offSet.intValue() + tokenMap2.intValue());
              }
           

            globalOffset = tokenMap1.intValue() + tokenMap2.intValue();
            tokenStartIndex = ((Integer) o).intValue() + globalOffset;
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
         
          BaseToken startToken = (BaseToken) tokens.get(tokenStartIndex);
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState && i > 0) {
            if (!currentState.getName().contentEquals("NON TERMINAL HYPH END"))
              endToken = (BaseToken) tokens.get(i - 1);
            else if (i > 1)
              endToken = (BaseToken) tokens.get(i - 2);
          } else {
            endToken = token;
          }
          /*if (fsm.equals(iv_strengthMachine)){
            startToken = (BaseToken) tokens  .get(tokenStartIndex+1);
          } else {*/
        //      startToken = (BaseToken) tokens.get(tokenStartIndex); 
          //}
          StrengthToken measurementToken = new StrengthToken(startToken
              .getStartOffset(), endToken.getEndOffset());
          measurementSet.add(measurementToken);
          fsm.reset();
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

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

    return measurementSet;
  }
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));
          tokenOffset = 0;
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            Integer tokenMap = new Integer(0);
                     
            BaseToken lookUpOffset = (BaseToken) tokens.get(((Integer) o).intValue());
             
            if (overrideBeginTokenMap.get(new Integer(lookUpOffset.getStartOffset())) != null){
              Integer offSet = (Integer) (overrideBeginTokenMap.get(new Integer(lookUpOffset.getStartOffset())));
              tokenMap = new Integer(offSet.intValue()  + tokenMap.intValue());
            }
           
           
            tokenStartIndex = ((Integer) o).intValue() + tokenMap.intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = (BaseToken) tokens
              .get(tokenStartIndex);
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState && i > 0) {
            if (!currentState.getName().contentEquals("NON TERMINAL HYPH END"))
              endToken = (BaseToken) tokens.get(i - 1);
            else if (i > 0)
              endToken = (BaseToken) tokens.get(i - 2);
          } else {
            endToken = token;
          }
          /*if (fsm.equals(iv_strengthMachine)){
            startToken = (BaseToken) tokens  .get(tokenStartIndex+1);
          } else {*/
          //    startToken = (BaseToken) tokens.get(tokenStartIndex); 
          //}
          StrengthToken measurementToken = new StrengthToken(startToken
                .getStartOffset(), endToken.getEndOffset());
          measurementSet.add(measurementToken);
     
          fsm.reset();
         
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

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

    return measurementSet;
  }
View Full Code Here

      Integer key = new Integer(token.getStartOffset());


      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));
          tokenOffset = 0;
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            Integer tokenMap = new Integer(0);
                     
            BaseToken lookUpOffset = (BaseToken) tokens.get(((Integer) o).intValue());
             
           
            tokenStartIndex = ((Integer) o).intValue() + tokenMap.intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = (BaseToken) tokens
              .get(tokenStartIndex);
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState && i > 0) {
            if (!currentState.getName().contentEquals("NON TERMINAL HYPH END"))
              endToken = (BaseToken) tokens.get(i - 1);
            else if (i > 0)
              endToken = (BaseToken) tokens.get(i - 2);
          } else {
            endToken = token;
          }
          /*if (fsm.equals(iv_strengthMachine)){
            startToken = (BaseToken) tokens  .get(tokenStartIndex+1);
          } else {*/
          //    startToken = (BaseToken) tokens.get(tokenStartIndex); 
          //}
          StrengthToken measurementToken = new StrengthToken(startToken
                .getStartOffset(), endToken.getEndOffset());
          measurementSet.add(measurementToken);
     
          fsm.reset();
         
        }
      }
    }

    // cleanup
    tokenStartMap.clear();

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

    return measurementSet;
  }
View Full Code Here

      State ntEndState = new NonTerminalEndState("NON TERMINAL END");
      ntEndState.setEndStateFlag(true);
      endState.setEndStateFlag(true);
      State leftAbbreviateState = new NamedState("LEFT_FREQ");
     
      Machine m = new Machine(startState);
 
      State leftAbbreviateQState = new NamedState("LEFT_Q");

      State middleAbbreviateQtoWState = new NamedState("MID_Q2W");
 
View Full Code Here

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

    Machine m = new Machine(startState);
    State hyphState = new NamedState("HYPHSTATE");
    State rangeState = new NamedState("RANGESTAGE");
    State handleRangeState = new NamedState("HANDLERANGE");
    State leftAbbreviateTState = new NamedState("LEFT_T");
    State middleAbbreviateTtoIState = new NamedState("MID_T2I");
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.