Package net.openai.util.fsm

Examples of net.openai.util.fsm.State


   * </ol>
   *
   * @return
   */
  private Machine getDecreaseFromAndTheStatusMachine() {
    State startState = new NamedState("START9");
    State endState = new NamedState("END9");
    endState.setEndStateFlag(true);

    Machine m = new Machine(startState);

    State thenStatusState = new NamedState("DUALSTARTTHENDECREASEFROM");
    State sectionStatusState = new NamedState("DUALFROMDECREASE");
//    State firstTheState = new NamedState("FIRSTTHEDECREASE");
//    State secondTheState = new NamedState("SECONDTHEDECREASE");
   
    Condition firstDualCondition = new WordSetCondition(
        iv_firstDecreaseDualWordSet, false);
    Condition secondDualCondition = new WordSetCondition(
        iv_secondDualFromWordSet, false);
    Condition thenCondition = new WordSetCondition(
        iv_multiThenWordSet, false);

    startState.addTransition(thenCondition, thenStatusState);
    startState.addTransition(firstDualCondition, sectionStatusState);
    startState.addTransition(new AnyCondition(), startState);

    thenStatusState.addTransition(firstDualCondition, sectionStatusState);
    thenStatusState.addTransition(new AnyCondition(), startState);
   
    sectionStatusState.addTransition(secondDualCondition, endState);
    sectionStatusState.addTransition(new AnyCondition(), startState);

       
    endState.addTransition(new AnyCondition(), startState);

    return m;
View Full Code Here


   * </ol>
   *
   * @return
   */
  private Machine getStopStatusMachine() {
    State startState = new NamedState("START10");
    State endState = new NamedState("END10");
    endState.setEndStateFlag(true);

    Machine m = new Machine(startState);
   
    State thenStatusState = new NamedState("DUALSTARTTHENSTOP");
    State leftStatusState = new NamedState("LEFT_STATUS_STOP");
    State leftDosagesState = new NamedState("LEFT_DOSE_STOP");
    State lastTextState = new NamedState("RIGHT_FREQ_STOP");
    State middleATextState = new NamedState("MID_TEXT_STOP");
    State firstDashState = new NamedState("FIRSTDASHSTOP");
    State beginEndState = new NamedState("STOPBEGINSTOP");
    State endEndState = new NamedState("STOPENDSTOP");
    State sectionStatusState = new NamedState("DUALSTARTSTOP");

    Condition rangeCombineCondition = new DisjoinCondition(
        new RangeCondition(), new RangeStrengthCondition());

    Condition sectionBracket = new PunctuationValueCondition('[');
    Condition soloCondition = new WordSetCondition(iv_singleStopWordSet,
        false);
    Condition soloEndCondition = new WordSetCondition(iv_singleStopWordSet,
        false);
    Condition firstDualCondition = new WordSetCondition(
        iv_firstStopDualWordSet, false);
    Condition secondOffDualCondition = new WordSetCondition(
        iv_secondOffDualWordSet, false);
    Condition secondDualCondition = new WordSetCondition(
        iv_secondDualWordSet, false);
    Condition thenCondition = new WordSetCondition(
        iv_multiThenWordSet, false);
   
    Condition containsDosagesCondition = new StrengthCondition();

    startState.addTransition(thenCondition, thenStatusState);
    startState.addTransition(soloCondition, endState);
    startState.addTransition(firstDualCondition, sectionStatusState);
    startState.addTransition(sectionBracket, beginEndState);
    startState.addTransition(rangeCombineCondition, leftDosagesState);
    startState.addTransition(containsDosagesCondition, leftStatusState);
    startState.addTransition(new AnyCondition(), startState);
   
    thenStatusState.addTransition(soloCondition, endState);
    thenStatusState.addTransition(firstDualCondition, sectionStatusState);
    thenStatusState.addTransition(new AnyCondition(), startState);
   
    sectionStatusState.addTransition(secondDualCondition, endState);
    sectionStatusState.addTransition(secondOffDualCondition, endState);
    sectionStatusState.addTransition(new AnyCondition(), startState);

    beginEndState.addTransition(soloEndCondition, endEndState);
    beginEndState.addTransition(new AnyCondition(), startState);

    endEndState.addTransition(new TextValueCondition("section", true),
View Full Code Here

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

   *     <li>32.1-47.3mg/wk</li>
   * </ol>
   * @return
   */
  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");

    State middleAbbreviateQtoAState = new NamedState("MID_Q2A");
    State middleAbbreviateQtoDState = new NamedState("MID_Q2D");
    State middleAbbreviateQtoHState = new NamedState("MID_Q2H");
    State middleAbbreviateQtoIState = new NamedState("MID_Q2I");
    State middleAbbreviateQtoMState = new NamedState("MID_Q2M");
    State middleAbbreviateQtoOState = new NamedState("MID_Q2O");
    State middleAbbreviateQtoWState = new NamedState("MID_Q2W");
    State middleAbbreviateQtoPState = new NamedState("MID_Q2P");

    State middleAbbreviatePtoRState = new NamedState("MID_P2R");
    State middleAbbreviateTtoIState = new NamedState("MID_T2I");

    State middleAbbreviateBtoIState = new NamedState("MID_B2I");

    State rightAbbreviateQIDState = new NamedState("RIGHT_QID");
    State rightAbbreviateQADState = new NamedState("RIGHT_QAD");
    State rightAbbreviateQDSState = new NamedState("RIGHT_QDS");
    State rightAbbreviateQHSState = new NamedState("RIGHT_QHS");
    State rightAbbreviateQWKState = new NamedState("RIGHT_QWK");
    State rightAbbreviateQODState = new NamedState("RIGHT_QOD");
    State rightAbbreviateQAMState = new NamedState("RIGHT_QAM");
    State rightAbbreviateQPMState = new NamedState("RIGHT_QPM");
    State rightAbbreviateQMTState = new NamedState("RIGHT_QMT");
    State rightAbbreviateBIDState = new NamedState("RIGHT_BID");
    State rightAbbreviatePRNState = new NamedState("RIGHT_PRN");
    State rightAbbreviateTIDState = new NamedState("RIGHT_TID");

    State firstDotQState = new NamedState("FIRSTDOTQ");
    State firstDotBState = new NamedState("FIRSTDOTB");
    State firstDotPState = new NamedState("FIRSTDOTP");
    State firstDotTState = new NamedState("FIRSTDOTT");

    State secondDotQtoAState = new NamedState("SECONDDOTQ2A");
    State secondDotQtoDState = new NamedState("SECONDDOTQ2D");
    State secondDotQtoHState = new NamedState("SECONDDOTQ2H");
    State secondDotQtoIState = new NamedState("SECONDDOTQ2I");
    State secondDotQtoMState = new NamedState("SECONDDOTQ2M");
    State secondDotQtoOState = new NamedState("SECONDDOTQ2O");
    State secondDotQtoWState = new NamedState("SECONDDOTQ2W");
    State secondDotQtoPState = new NamedState("SECONDDOTQ2P");
    State secondDotBtoIState = new NamedState("SECONDDOTB2I");
    State secondDotPtoRState = new NamedState("SECONDDOTP2R");
    State secondDotTtoIState = new NamedState("SECONDDOTT2I");

    Condition firstDotConditionQ = new PunctuationValueCondition('.');
    Condition firstDotConditionB = new PunctuationValueCondition('.');
    Condition firstDotConditionP = new PunctuationValueCondition('.');
    Condition firstDotConditionT = new PunctuationValueCondition('.');
    Condition secondDotConditionQH = new PunctuationValueCondition('.');
    Condition secondDotConditionQI = new PunctuationValueCondition('.');
    Condition secondDotConditionQA = new PunctuationValueCondition('.');
    Condition secondDotConditionQD = new PunctuationValueCondition('.');
    Condition secondDotConditionQM = new PunctuationValueCondition('.');
    Condition secondDotConditionQO = new PunctuationValueCondition('.');
    Condition secondDotConditionQW = new PunctuationValueCondition('.');
    Condition secondDotConditionQP = new PunctuationValueCondition('.');
    Condition secondDotConditionBI = new PunctuationValueCondition('.');
    Condition secondDotConditionPR = new PunctuationValueCondition('.');
    Condition secondDotConditionTI = new PunctuationValueCondition('.');
    Condition thirdDotConditionQHS = new PunctuationValueCondition('.');
    Condition thirdDotConditionQAD = new PunctuationValueCondition('.');
    Condition thirdDotConditionQID = new PunctuationValueCondition('.');
    Condition thirdDotConditionQDS = new PunctuationValueCondition('.');
    Condition thirdDotConditionQMT = new PunctuationValueCondition('.');
    Condition thirdDotConditionQOD = new PunctuationValueCondition('.');
    Condition thirdDotConditionQWK = new PunctuationValueCondition('.');
    Condition thirdDotConditionQAM = new PunctuationValueCondition('.');
    Condition thirdDotConditionQPM = new PunctuationValueCondition('.');
    Condition thirdDotConditionBID = new PunctuationValueCondition('.');
    Condition thirdDotConditionPRN = new PunctuationValueCondition('.');
    Condition thirdDotConditionTID = new PunctuationValueCondition('.');

    startState.addTransition(new TextValueCondition("q", true),
        leftAbbreviateQState);
    startState.addTransition(new TextValueCondition("b", true),
        leftAbbreviateBState);
    startState.addTransition(new TextValueCondition("p", true),
        leftAbbreviatePState);
    startState.addTransition(new TextValueCondition("t", true),
        leftAbbreviateTState);
    startState.addTransition(new AnyCondition(), startState);

    leftAbbreviateQState.addTransition(firstDotConditionQ, firstDotQState);
    leftAbbreviateQState.addTransition(new AnyCondition(), startState);

    firstDotQState.addTransition(new TextValueCondition("a", true),
        middleAbbreviateQtoAState);
    firstDotQState.addTransition(new TextValueCondition("d", true),
        middleAbbreviateQtoDState);
    firstDotQState.addTransition(new TextValueCondition("h", true),
        middleAbbreviateQtoHState);
    firstDotQState.addTransition(new TextValueCondition("i", true),
        middleAbbreviateQtoIState);
    firstDotQState.addTransition(new TextValueCondition("m", true),
        middleAbbreviateQtoMState);
    firstDotQState.addTransition(new TextValueCondition("o", true),
        middleAbbreviateQtoOState);
    firstDotQState.addTransition(new TextValueCondition("w", true),
        middleAbbreviateQtoWState);
    firstDotQState.addTransition(new TextValueCondition("p", true),
        middleAbbreviateQtoPState);
    firstDotQState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoAState.addTransition(secondDotConditionQA,
        secondDotQtoAState);
    middleAbbreviateQtoAState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoDState.addTransition(secondDotConditionQD,
        secondDotQtoDState);
    middleAbbreviateQtoDState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoHState.addTransition(secondDotConditionQH,
        secondDotQtoHState);
    middleAbbreviateQtoHState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoIState.addTransition(secondDotConditionQI,
        secondDotQtoIState);
    middleAbbreviateQtoIState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoMState.addTransition(secondDotConditionQM,
        secondDotQtoMState);
    middleAbbreviateQtoMState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoOState.addTransition(secondDotConditionQO,
        secondDotQtoOState);
    middleAbbreviateQtoOState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoWState.addTransition(secondDotConditionQW,
        secondDotQtoWState);
    middleAbbreviateQtoWState.addTransition(new AnyCondition(), startState);

    middleAbbreviateQtoPState.addTransition(secondDotConditionQP,
        secondDotQtoPState);
    middleAbbreviateQtoPState.addTransition(new AnyCondition(), startState);

    secondDotQtoAState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateQADState);
    secondDotQtoAState.addTransition(new AnyCondition(), startState);

    secondDotQtoDState.addTransition(new TextValueCondition("s", true),
        rightAbbreviateQDSState);
    secondDotQtoDState.addTransition(new AnyCondition(), startState);

    secondDotQtoHState.addTransition(new TextValueCondition("s", true),
        rightAbbreviateQHSState);
    secondDotQtoHState.addTransition(new AnyCondition(), startState);

    secondDotQtoIState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateQIDState);
    secondDotQtoIState.addTransition(new AnyCondition(), startState);

    secondDotQtoMState.addTransition(new TextValueCondition("t", true),
        rightAbbreviateQMTState);
    secondDotQtoMState.addTransition(new AnyCondition(), startState);

    secondDotQtoOState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateQODState);
    secondDotQtoOState.addTransition(new AnyCondition(), startState);

    secondDotQtoWState.addTransition(new TextValueCondition("k", true),
        rightAbbreviateQWKState);
    secondDotQtoWState.addTransition(new AnyCondition(), startState);

    secondDotQtoAState.addTransition(new TextValueCondition("m", true),
        rightAbbreviateQAMState);
    secondDotQtoAState.addTransition(new AnyCondition(), startState);

    secondDotQtoPState.addTransition(new TextValueCondition("m", true),
        rightAbbreviateQPMState);
    secondDotQtoPState.addTransition(new AnyCondition(), startState);

    secondDotBtoIState.addTransition(new TextValueCondition("d", true),
        endState);
    secondDotBtoIState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQADState.addTransition(thirdDotConditionQAD, endState);
    rightAbbreviateQADState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQDSState.addTransition(thirdDotConditionQDS, endState);
    rightAbbreviateQDSState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQHSState.addTransition(thirdDotConditionQHS, endState);
    rightAbbreviateQHSState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQIDState.addTransition(thirdDotConditionQID, endState);
    rightAbbreviateQIDState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQMTState.addTransition(thirdDotConditionQMT, endState);
    rightAbbreviateQMTState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQODState.addTransition(thirdDotConditionQOD, endState);
    rightAbbreviateQODState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQWKState.addTransition(thirdDotConditionQWK, endState);
    rightAbbreviateQWKState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQAMState.addTransition(thirdDotConditionQAM, endState);
    rightAbbreviateQAMState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQPMState.addTransition(thirdDotConditionQPM, endState);
    rightAbbreviateQPMState.addTransition(new AnyCondition(), startState);

    leftAbbreviateBState.addTransition(firstDotConditionB, firstDotBState);
    leftAbbreviateBState.addTransition(new AnyCondition(), startState);

    firstDotBState.addTransition(new TextValueCondition("i", true),
        middleAbbreviateBtoIState);
    firstDotBState.addTransition(new AnyCondition(), startState);

    middleAbbreviateBtoIState.addTransition(secondDotConditionBI,
        secondDotBtoIState);
    middleAbbreviateBtoIState.addTransition(new AnyCondition(), startState);

    secondDotBtoIState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateBIDState);
    secondDotBtoIState.addTransition(new AnyCondition(), startState);

    rightAbbreviateBIDState.addTransition(thirdDotConditionBID, endState);

    leftAbbreviatePState.addTransition(firstDotConditionP, firstDotPState);
    leftAbbreviatePState.addTransition(new AnyCondition(), startState);

    leftAbbreviateTState.addTransition(firstDotConditionT, firstDotTState);
    leftAbbreviateTState.addTransition(new AnyCondition(), startState);

    firstDotPState.addTransition(new TextValueCondition("r", true),
        middleAbbreviatePtoRState);
    firstDotPState.addTransition(new AnyCondition(), startState);

    firstDotTState.addTransition(new TextValueCondition("i", true),
        middleAbbreviateTtoIState);
    firstDotTState.addTransition(new AnyCondition(), startState);

    middleAbbreviatePtoRState.addTransition(secondDotConditionPR,
        secondDotPtoRState);
    middleAbbreviatePtoRState.addTransition(new AnyCondition(), startState);

    middleAbbreviateTtoIState.addTransition(secondDotConditionTI,
        secondDotTtoIState);
    middleAbbreviateTtoIState.addTransition(new AnyCondition(), startState);

    secondDotPtoRState.addTransition(new TextValueCondition("n", true),
        rightAbbreviatePRNState);
    secondDotPtoRState.addTransition(new AnyCondition(), startState);

    secondDotTtoIState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateTIDState);
    secondDotTtoIState.addTransition(new AnyCondition(), startState);

    rightAbbreviatePRNState.addTransition(thirdDotConditionPRN, endState);
    rightAbbreviateTIDState.addTransition(thirdDotConditionTID, endState);

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

   *     <li>32.1-47.3mg/wk</li>
   * </ol>
   * @return
   */
  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");
    State leftAbbreviatePState = new NamedState("LEFT_P");

    State rightAbbreviateQDState = new NamedState("RIGHT_QD");
    State rightAbbreviateQHState = new NamedState("RIGHT_QH");
    State rightAbbreviateAMState = new NamedState("RIGHT_AM");
    State rightAbbreviateODState = new NamedState("RIGHT_OD");
    State rightAbbreviateHSState = new NamedState("RIGHT_HS");
    State rightAbbreviatePMState = new NamedState("RIGHT_PM");

    State firstDotQState = new NamedState("FIRSTDOTQ");
    State firstDotAState = new NamedState("FIRSTDOTA");
    State firstDotOState = new NamedState("FIRSTDOTO");
    State firstDotHState = new NamedState("FIRSTDOTH");
    State firstDotPState = new NamedState("FIRSTDOTP");

    Condition firstQDDotCondition = new PunctuationValueCondition('.');
    Condition secondQDDotCondition = new PunctuationValueCondition('.');
    Condition firstODDotCondition = new PunctuationValueCondition('.');
    Condition secondQHDotCondition = new PunctuationValueCondition('.');
    Condition secondODDotCondition = new PunctuationValueCondition('.');
    Condition firstAMDotCondition = new PunctuationValueCondition('.');
    Condition firstPMDotCondition = new PunctuationValueCondition('.');
    Condition secondAMDotCondition = new PunctuationValueCondition('.');
    Condition secondPMDotCondition = new PunctuationValueCondition('.');
    Condition firstHSDotCondition = new PunctuationValueCondition('.');
    Condition secondHSDotCondition = new PunctuationValueCondition('.');

    Condition soloCondition = new WordSetCondition(iv_singleWordSet, true);

    startState.addTransition(new TextValueCondition("q", true),
        leftAbbreviateQState);
    startState.addTransition(new TextValueCondition("a", true),
        leftAbbreviateAState);
    startState.addTransition(new TextValueCondition("o", true),
        leftAbbreviateOState);
    startState.addTransition(new TextValueCondition("h", true),
        leftAbbreviateHState);
    startState.addTransition(new TextValueCondition("p", true),
        leftAbbreviatePState);
    startState.addTransition(new AnyCondition(), startState);

    leftAbbreviateQState.addTransition(firstQDDotCondition, firstDotQState);

    leftAbbreviateQState.addTransition(new AnyCondition(), startState);

    leftAbbreviateAState.addTransition(firstAMDotCondition, firstDotAState);
    leftAbbreviateAState.addTransition(new AnyCondition(), startState);

    leftAbbreviateOState.addTransition(firstODDotCondition, firstDotOState);
    leftAbbreviateOState.addTransition(new AnyCondition(), startState);

    leftAbbreviateHState.addTransition(firstHSDotCondition, firstDotHState);
    leftAbbreviateHState.addTransition(new AnyCondition(), startState);

    leftAbbreviatePState.addTransition(firstPMDotCondition, firstDotPState);
    leftAbbreviatePState.addTransition(new AnyCondition(), startState);

    firstDotQState.addTransition(soloCondition, endState);
    firstDotQState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateQDState);
    firstDotQState.addTransition(new TextValueCondition("h", true),
        rightAbbreviateQHState);
    firstDotQState.addTransition(new AnyCondition(), startState);

    firstDotAState.addTransition(new TextValueCondition("m", true),
        rightAbbreviateAMState);
    firstDotAState.addTransition(new AnyCondition(), startState);

    firstDotOState.addTransition(new TextValueCondition("d", true),
        rightAbbreviateODState);
    firstDotOState.addTransition(new AnyCondition(), startState);

    firstDotHState.addTransition(new TextValueCondition("s", true),
        rightAbbreviateHSState);
    firstDotHState.addTransition(new AnyCondition(), startState);

    firstDotPState.addTransition(new TextValueCondition("m", true),
        rightAbbreviatePMState);
    firstDotPState.addTransition(new AnyCondition(), startState);

    rightAbbreviateQHState.addTransition(secondQHDotCondition, endState);
    rightAbbreviateQHState.addTransition(new AnyCondition(), startState);

    rightAbbreviateAMState.addTransition(secondAMDotCondition, endState);
View Full Code Here

   *     <li>once-a-day</li>
   * </ol>
   * @return
   */
  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");
    State firstDashState = new NamedState("FIRSTDASH");
    State secondDashState = new NamedState("SECONDDASH");

    Condition integerCondition = new IntegerCondition();
    Condition firstDashCondition = new PunctuationValueCondition('-');
    Condition secondDashCondition = new PunctuationValueCondition('-');

    Condition numericStartCondition = new WordSetCondition(iv_frequencySet,
        false);
    Condition hyphenatedCondition = new WordSetCondition(iv_hyphenatedSet,
        false);
    Condition firstMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    Condition secondMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    Condition thirdMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    Condition fourthMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    Condition lastTextCondition = new WordSetCondition(iv_textSuffixSet,
        false);
    Condition firstTextCondition = new WordSetCondition(iv_textPrefixSet,
        false);
    Condition soloCondition = new WordSetCondition(iv_singleWordSet, true);
    Condition specificWordCondition = new WordSetCondition(
        iv_specifiedWordSet, false);
    Condition containsSoloTermCondition = new ContainsSetTextValueCondition(
        iv_singleWordSet, true);

    startState.addTransition(numericStartCondition, leftAbbreviateState);
    startState.addTransition(firstTextCondition, leftAbbreviateState);
    startState.addTransition(new TextValueCondition("a", true),
        leftAbbreviateState);
    startState.addTransition(integerCondition, leftAbbreviateState);
    startState.addTransition(hyphenatedCondition, endState);
    startState.addTransition(containsSoloTermCondition, endState);
    startState.addTransition(soloCondition, endState);

    startState.addTransition(new AnyCondition(), startState);

    leftAbbreviateState.addTransition(firstMiddleTextCondition,
        middleATextState);
    leftAbbreviateState.addTransition(firstDashCondition, firstDashState);
    leftAbbreviateState.addTransition(soloCondition, endState);
    leftAbbreviateState.addTransition(specificWordCondition, endState);
    leftAbbreviateState.addTransition(hyphenatedCondition, endState);
    leftAbbreviateState.addTransition(new AnyCondition(), startState);

    firstDashState
        .addTransition(thirdMiddleTextCondition, middleATextState);
    firstDashState.addTransition(new AnyCondition(), startState);

    middleATextState
        .addTransition(secondMiddleTextCondition, lastTextState);
    middleATextState.addTransition(secondDashCondition, secondDashState);
    middleATextState.addTransition(lastTextCondition, endState);
    middleATextState.addTransition(new AnyCondition(), startState);

    secondDashState.addTransition(fourthMiddleTextCondition, lastTextState);
    secondDashState.addTransition(lastTextCondition, endState);
    secondDashState.addTransition(new AnyCondition(), startState);

    lastTextState.addTransition(lastTextCondition, endState);
    lastTextState.addTransition(new AnyCondition(), startState);

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

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

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

   * </ol>
   *
   * @return
   */
  private Machine getFrequencyMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State ntFalseTermState = new IndentStartState("NON TERMINAL START");
    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");
    State midTermState = new NamedState("MID_TERM");
    State termState = new NamedState("SKIP_TERM");

    Condition integerCondition = new IntegerRangeCondition(0,5);
   
    Condition rangeCombineCondition = new DisjoinCondition(
        new RangeCondition(), new RangeStrengthCondition());

//    Condition hyphenatedCondition = new WordSetCondition(iv_hyphenatedSet,
//        false);

    Condition secondMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, false);

    startState.addTransition(rangeCombineCondition, leftAbbreviateState);
    startState.addTransition(new WordSetCondition(iv_frequencySet,
        false), leftAbbreviateState);
    startState.addTransition(integerCondition, leftAbbreviateState);
    startState.addTransition(new WordSetCondition(iv_hyphenatedSet,
        false), endState);
    startState.addTransition(new AnyCondition(), startState);

    leftAbbreviateState.addTransition(new WordSetCondition(
        iv_middleTermSet, false), middleATextState);
    leftAbbreviateState.addTransition(new NumberCondition(),
        middleATextState);
    leftAbbreviateState.addTransition(new WordSetCondition(iv_frequencySet,
        false), midTermState);
    leftAbbreviateState.addTransition(new WordSetCondition(iv_hyphenatedSet,
        false), endState);
    leftAbbreviateState.addTransition(new FrequencyUnitCondition(),
        ntEndState);
    leftAbbreviateState.addTransition(new AnyCondition(), startState);


    midTermState.addTransition(new WordSetCondition(iv_middleTermSet, false), termState);
    midTermState.addTransition(new AnyCondition(),  startState);
   
    middleATextState
        .addTransition(secondMiddleTextCondition, lastTextState);

    middleATextState
        .addTransition(new FrequencyUnitCondition(), ntEndState);
    middleATextState.addTransition(new RouteCondition(), endState);
    middleATextState.addTransition(new AnyCondition(), startState);
   

    termState
        .addTransition(new FrequencyUnitCondition(), ntFalseTermState);
    termState.addTransition(new RouteCondition(), ntFalseTermState);
    termState.addTransition(new AnyCondition(), startState);


    lastTextState.addTransition(new FrequencyUnitCondition(), ntEndState);
    lastTextState.addTransition(new RouteCondition(), ntEndState);
    lastTextState.addTransition(new AnyCondition(), startState);
View Full Code Here

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

TOP

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

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.