Package org.apache.ctakes.core.fsm.state

Examples of org.apache.ctakes.core.fsm.state.NamedState


   * </ol>
   *
   * @return
   */
  private Machine getIncreaseFromAndTheStatusMachine() {
    State startState = new NamedState("START7");
    State endState = new NamedState("END7");
    endState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
 
    State thenStatusState = new NamedState("DUALSTARTTHENINCREASEFROM");
    State sectionStatusState = new NamedState("DUALFROMINCREASE");

    Condition firstDualCondition = new WordSetCondition(
        iv_firstIncreaseDualWordSet, 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 getDecreaseStatusMachine() {
    State startState = new NamedState("START8");
    State endState = new NamedState("END8");
    endState.setEndStateFlag(true);

    Machine m = new Machine(startState);

    State leftStatusState = new NamedState("LEFT_STATUS_DECREASE");
    State thenStatusState = new NamedState("DUALSTARTTHENDECREASE");
    State sectionStatusState = new NamedState("DUALSTARTDECREASE");

    Condition soloCondition = new WordSetCondition(iv_singleDecreaseWordSet,
        false);
    Condition firstDualCondition = new WordSetCondition(
        iv_firstDecreaseDualWordSet, false);
    Condition secondDualCondition = new WordSetCondition(
        iv_secondDualWordSet, false);
    Condition thenCondition = new WordSetCondition(
        iv_multiThenWordSet, false);
 
    startState.addTransition(thenCondition, thenStatusState);
    startState.addTransition(soloCondition, endState);
    startState.addTransition(firstDualCondition, sectionStatusState);
    startState.addTransition(new AnyCondition(), startState);
   
    thenStatusState.addTransition(soloCondition, endState);
    thenStatusState.addTransition(firstDualCondition, sectionStatusState);
    thenStatusState.addTransition(new AnyCondition(), startState);

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

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

View Full Code Here

   * </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

   * </ol>
   *
   * @return
   */
  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('/');

    Condition leftNumTextCondition = new StrengthCondition();
    Condition rightIntegerCondition = new IntegerCondition();
    Condition rightNumTextCondition = new WordSetCondition(
        iv_textSuffixSet, false);

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

    leftNumTextState.addTransition(dashCondition, fslashState);
    leftNumTextState.addTransition(new AnyCondition(), startState);

    fslashState.addTransition(rightNumTextCondition, endState);
    fslashState.addTransition(rightIntegerCondition, rightNumTextState);
    fslashState.addTransition(new AnyCondition(), startState);

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

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

   * </ol>
   *
   * @return
   */
  private Machine getSixTimesADayMachine() {
    State startState = new NamedState("START_6TDM");
    State endState = new NamedState("END_6TDM");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    State hyphState = new NamedState("HYPHSTATE");
    State handleRangeState = new NamedState("HANDLERANGE");
    State numState = new NamedState("NUMSTATE");
    ntEndState.setEndStateFlag(true);
    endState.setEndStateFlag(true);

   
    State middleAbbreviateQtoDState = new NamedState("MID_Q2D");
    State rightAbbreviateQDSState = new NamedState("RIGHT_QDS");

    State fourHourState = new NamedState("FOURHOUR");
    State firstDotQState = new NamedState("FIRSTDOTQ");
    State secondDotQtoDState = new NamedState("SECONDDOTQ2D");

    Machine m = new Machine(startState);

    startState.addTransition(new TextSetCondition(
        iv_sixTimesPerDayWordSet, false) , endState);
    startState.addTransition(new IntegerValueCondition(4), fourHourState);
    startState.addTransition(new DisjoinCondition(new CombineCondition(new NegateCondition(new IntegerRangeCondition(1,3)), new IntegerCondition()), new IntegerValueCondition(4)), handleRangeState);
    startState.addTransition(new DisjoinCondition(new TextSetCondition(iv_postFourWordSet, false), new TextValueCondition("four", false)), fourHourState);
   
    startState.addTransition(new AnyCondition(), startState);
   
    handleRangeState.addTransition(new PunctuationValueCondition('-'), hyphState);
    handleRangeState.addTransition(new AnyCondition(), startState);
   
    fourHourState.addTransition(new PunctuationValueCondition('-'), hyphState);
    fourHourState.addTransition(new TextValueCondition("to", false), hyphState);
    //fourHourState.addTransition(new TextSetCondition(iv_hourlySuffixSet, false), endState);
   
    fourHourState.addTransition(new AnyCondition(), startState);
   
    firstDotQState.addTransition(new TextValueCondition("d", false),
        middleAbbreviateQtoDState);

        firstDotQState.addTransition(new AnyCondition(), startState);
       
        hyphState.addTransition(new IntegerRangeCondition(5,8), numState);
        hyphState.addTransition(new TextValueCondition("five", false), numState);
        hyphState.addTransition(new TextValueCondition("six", false), numState);
        hyphState.addTransition(new TextValueCondition("seven", false), numState);
        hyphState.addTransition(new TextValueCondition("eight", false), numState);
        hyphState.addTransition(new AnyCondition(), startState);
       
        numState.addTransition(new TextSetCondition(iv_hourlySuffixSet, false), endState);
        numState.addTransition(new AnyCondition(), startState);
       
    middleAbbreviateQtoDState.addTransition(new PunctuationValueCondition('.'),
        secondDotQtoDState);
    middleAbbreviateQtoDState.addTransition(new AnyCondition(), startState);
   
           
    secondDotQtoDState.addTransition(new TextValueCondition("s", false),
        rightAbbreviateQDSState);
    secondDotQtoDState.addTransition(new AnyCondition(), startState);

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

     * </ol>
     *
     * @return
     */
    private Machine getDailyMachine() {
      State startState = new NamedState("START");
      State endState = new NamedState("END");
     
      State ntEndState = new NonTerminalEndState("NON TERMINAL END");
      ntEndState.setEndStateFlag(true);
      endState.setEndStateFlag(true);
      Machine m = new Machine(startState);

      State leftAbbreviateState = new NamedState("LEFT_FREQ");

      State clockState = new NamedState("CLOCK");
      //2 and 3 letter latin abbreviations
      State leftAbbreviateAState = new NamedState("LEFT_A");
      State leftAbbreviatePState = new NamedState("LEFT_P");
      State leftAbbreviateQState = new NamedState("LEFT_Q");
      State leftAbbreviateOState = new NamedState("LEFT_O");
      State leftAbbreviateHState = new NamedState("LEFT_H");
     
 
  //    2 letter latin abbreviations   
      State rightAbbreviateODState = new NamedState("RIGHT_OD");
      State rightAbbreviateQDState = new NamedState("RIGHT_QD");
      State rightAbbreviateHSState = new NamedState("RIGHT_HS");
      State rightAbbreviateAMState = new NamedState("RIGHT_AM");
      State rightAbbreviatePMState = new NamedState("RIGHT_PM");
  //    3 letter latin abbreviations
      State middleAbbreviateQtoHState = new NamedState("MID_Q2H");
 
      State rightAbbreviateQHSState = new NamedState("RIGHT_QHS");
      State secondDotQtoHState = new NamedState("SECONDDOTQ2H");
     
      State firstDotAState = new NamedState("FIRSTDOTA");
      State firstDotPState = new NamedState("FIRSTDOTP");
      State firstDotQState = new NamedState("FIRSTDOTQ");
      State firstDotOState = new NamedState("FIRSTDOTO");
      State firstDotHState = new NamedState("FIRSTDOTH");
     
 
     
      Condition specificWordCondition = new TextSetCondition(
          iv_dailyWordSet, false);
      Condition soloCondition = new TextSetCondition(iv_perDayWordSet, false);
      Condition containsSoloTermCondition = new ContainsSetTextValueCondition(
          iv_perDayWordSet, false);
       
     
      startState.addTransition(new TextValueCondition("q", false),
          leftAbbreviateQState);
      startState.addTransition(new TextValueCondition("o", false),
          leftAbbreviateOState);
      startState.addTransition(new TextValueCondition("h", false),
          leftAbbreviateHState);
 
            startState.addTransition(new IntegerRangeCondition(1,12), clockState);
            startState.addTransition(new TimeCondition(), endState);
      startState.addTransition(new TextValueCondition("bed", false),
          leftAbbreviateState);
      startState.addTransition(new TextValueCondition("per", false),
          leftAbbreviateState);
 
      startState.addTransition(specificWordCondition, endState);
      startState.addTransition(soloCondition, endState);
      startState.addTransition(containsSoloTermCondition, endState);
     
      startState.addTransition(new AnyCondition(), startState);
     
      clockState.addTransition(new TextValueCondition("a", false),
      leftAbbreviateAState);
      clockState.addTransition(new TextValueCondition("p", false),
      leftAbbreviatePState);
      clockState.addTransition(new AnyCondition(), startState);
     
      leftAbbreviateState.addTransition(specificWordCondition, endState);
      leftAbbreviateState.addTransition(new TextValueCondition("time", false), endState);
      leftAbbreviateState.addTransition(new AnyCondition(), startState);
     
      leftAbbreviateQState.addTransition(new PunctuationValueCondition('.'), firstDotQState);
      leftAbbreviateQState.addTransition(new AnyCondition(), startState);
       
      leftAbbreviateOState.addTransition(new PunctuationValueCondition('.'), firstDotOState);
      leftAbbreviateOState.addTransition(new AnyCondition(), startState);
     
      leftAbbreviateHState.addTransition(new PunctuationValueCondition('.'), firstDotHState);
      leftAbbreviateHState.addTransition(new AnyCondition(), startState);
     
      firstDotQState.addTransition(new TextValueCondition("d", false),
          rightAbbreviateQDState);
      firstDotQState.addTransition(new TextValueCondition("h", false),
          middleAbbreviateQtoHState);
      firstDotQState.addTransition(new AnyCondition(), startState);
     
      firstDotOState.addTransition(new TextValueCondition("d", false),
          rightAbbreviateODState);
      firstDotOState.addTransition(new AnyCondition(), startState);
     
      middleAbbreviateQtoHState.addTransition(new PunctuationValueCondition('.'),
          secondDotQtoHState);
      middleAbbreviateQtoHState.addTransition(new AnyCondition(), startState);
     
      leftAbbreviateAState.addTransition(new PunctuationValueCondition('.'), firstDotAState);
      //leftAbbreviateAState.addTransition(soloCondition, endState);
      leftAbbreviateAState.addTransition(new AnyCondition(), startState);
   
      leftAbbreviatePState.addTransition(new PunctuationValueCondition('.'), firstDotPState);
      leftAbbreviatePState.addTransition(new AnyCondition(), startState);
   
      firstDotAState.addTransition(new TextValueCondition("m", false),
          rightAbbreviateAMState);
      firstDotAState.addTransition(new AnyCondition(), startState);
     

       
      firstDotPState.addTransition(new TextValueCondition("m", false),
          rightAbbreviatePMState);
      firstDotPState.addTransition(new AnyCondition(), startState);
     
      secondDotQtoHState.addTransition(new TextValueCondition("s", false),
          rightAbbreviateQHSState);
     
      secondDotQtoHState.addTransition(new AnyCondition(), startState);
     

      rightAbbreviateAMState.addTransition(new PunctuationValueCondition('.'), endState);
      rightAbbreviateAMState.addTransition(new AnyCondition(), startState);
   
      rightAbbreviatePMState.addTransition(new PunctuationValueCondition('.'), endState);
      rightAbbreviatePMState.addTransition(new AnyCondition(), startState);
     
      firstDotHState.addTransition(new TextValueCondition("s", false),
          rightAbbreviateHSState);
      firstDotHState.addTransition(new AnyCondition(), startState);
     
      rightAbbreviateODState.addTransition(new PunctuationValueCondition('.'), endState);
      rightAbbreviateODState.addTransition(new AnyCondition(), startState);
     
      rightAbbreviateQDState.addTransition(new PunctuationValueCondition('.'), endState);
View Full Code Here

TOP

Related Classes of org.apache.ctakes.core.fsm.state.NamedState

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.