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, 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;
          DrugChangeStatusToken fractionToken = null;
          if (fsm.equals(iv_startStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(),DrugChangeStatusToken.START);
          } else if (fsm.equals(iv_stopStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.STOP);
          } else if (fsm.equals(iv_increaseFromStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.INCREASEFROM);
          } else if (fsm.equals(iv_decreaseFromStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.DECREASEFROM);
          else if (fsm.equals(iv_increaseStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.INCREASE);
          } else if (fsm.equals(iv_decreaseStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.DECREASE);
          } else if (fsm.equals(iv_noChangeStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.NOCHANGE);
           
          } else if (fsm.equals(iv_changeStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.OTHER);
          } else if (fsm.equals(iv_sumStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.SUM);
           
          } else if (fsm.equals(iv_maxStatusMachine)) {
            fractionToken = new DrugChangeStatusToken(startToken
                .getStartOffset(), endToken.getEndOffset(), DrugChangeStatusToken.MAX);
           
          }

          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


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

    Machine m = new Machine(startState);

    State leftNumTextState = new NamedState("LEFT_DOSAGE");
    State rightNumTextState = new NamedState("RIGHT_DOSAGE");
    State fslashState = new NamedState("FSLASH");
    Condition dashCondition = new PunctuationValueCondition('/');
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;
          SuffixStrengthToken segmentToken = new SuffixStrengthToken(
              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

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

    Machine m = new Machine(startState);

    State leftAbbreviateQState = new NamedState("LEFT_Q");
    State leftAbbreviateBState = new NamedState("LEFT_B");
    State leftAbbreviatePState = new NamedState("LEFT_P");
    State leftAbbreviateTState = new NamedState("LEFT_T");
View Full Code Here

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

    Machine m = new Machine(startState);

    State leftAbbreviateQState = new NamedState("LEFT_Q");
    State leftAbbreviateAState = new NamedState("LEFT_A");
    State leftAbbreviateOState = new NamedState("LEFT_O");
    State leftAbbreviateHState = new NamedState("LEFT_H");
View Full Code Here

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

    Machine m = new Machine(startState);

    State leftAbbreviateState = new NamedState("LEFT_FREQ");

    State lastTextState = new NamedState("RIGHT_FREQ");
    State middleATextState = new NamedState("MID_TEXT");
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;
          SuffixFrequencyToken segmentToken = new SuffixFrequencyToken(
              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

    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;
          SuffixFrequencyToken fractionToken = new SuffixFrequencyToken(
              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);
    ntEndState.setEndStateFlag(true);
    endState.setEndStateFlag(true);

    Machine m = new Machine(startState);

    State leftAbbreviateState = new NamedState("LEFT_FREQ");

    State lastTextState = new NamedState("RIGHT_FREQ");
    State middleATextState = new NamedState("MID_TEXT");
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 = 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);
          } else {
            endToken = token;
          }
          FrequencyToken segmentToken = new FrequencyToken(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.