Package net.openai.util.fsm

Examples of net.openai.util.fsm.State


   *     <li>patches</li>
   * </ol>
   * @return
   */
  private Machine getPatchesMachine() {
    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 leftDosagesState = new NamedState("LEFT_DOSE");
    State lastTextState = new NamedState("RIGHT_FREQ");
    State middleATextState = new NamedState("MID_TEXT");
    State firstDashState = new NamedState("FIRSTDASH");
    State secondDashState = new NamedState("SECONDDASH");
 

    Condition firstDashCondition = new PunctuationValueCondition('-');
    Condition secondDashCondition = new PunctuationValueCondition('-');
    Condition rangeCombineCondition = new DisjoinCondition(
    new RangeCondition(),
    new RangeStrengthCondition()
    );
 
 
    Condition initialMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    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 specificWordCondition = new WordSetCondition(
        iv_specifiedPatchesWordSet, false);
   
 
    startState.addTransition(new TextValueCondition("a", true),
        leftAbbreviateState);
    startState.addTransition(initialMiddleTextCondition, leftAbbreviateState);
    startState.addTransition(rangeCombineCondition, leftDosagesState);
    startState.addTransition(specificWordCondition, endState);
    startState.addTransition(new AnyCondition(), startState);
 
   
    leftAbbreviateState.addTransition(firstMiddleTextCondition,
        middleATextState);
    leftAbbreviateState.addTransition(firstDashCondition, firstDashState);
    leftAbbreviateState.addTransition(new AnyCondition(), startState);
 
    firstDashState
        .addTransition(thirdMiddleTextCondition, middleATextState);
    firstDashState.addTransition(new AnyCondition(), startState);
 
    middleATextState
        .addTransition(secondMiddleTextCondition, lastTextState);
    middleATextState.addTransition(secondDashCondition, secondDashState);
    middleATextState.addTransition(new AnyCondition(), startState);
 
    secondDashState.addTransition(fourthMiddleTextCondition, lastTextState);
    secondDashState.addTransition(new AnyCondition(), startState);
 
 
    lastTextState.addTransition(new AnyCondition(), startState);
 
    endState.addTransition(new AnyCondition(), startState);
View Full Code Here


   *     <li>gastric tube</li>
   * </ol>
   * @return
   */
  private Machine getGastricMachine() {
    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 leftDosagesState = new NamedState("LEFT_DOSE");
    State lastTextState = new NamedState("RIGHT_FREQ");
    State middleATextState = new NamedState("MID_TEXT");
    State firstDashState = new NamedState("FIRSTDASH");
    State secondDashState = new NamedState("SECONDDASH");
 
 
    Condition firstDashCondition = new PunctuationValueCondition('-');
    Condition secondDashCondition = new PunctuationValueCondition('-');
    Condition rangeCombineCondition = new DisjoinCondition(
    new RangeCondition(),
    new RangeStrengthCondition()
    );
 
 
    Condition initialMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    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 specificWordCondition = new WordSetCondition(
        iv_specifiedGastricWordSet, false);
   
 
    startState.addTransition(new TextValueCondition("a", true),
        leftAbbreviateState);
    startState.addTransition(initialMiddleTextCondition, leftAbbreviateState);
    startState.addTransition(rangeCombineCondition, leftDosagesState);
    startState.addTransition(specificWordCondition, endState);
    startState.addTransition(new AnyCondition(), startState);
 
   
    leftAbbreviateState.addTransition(firstMiddleTextCondition,
        middleATextState);
    leftAbbreviateState.addTransition(firstDashCondition, firstDashState);
    leftAbbreviateState.addTransition(new AnyCondition(), startState);
 
    firstDashState
        .addTransition(thirdMiddleTextCondition, middleATextState);
    firstDashState.addTransition(new AnyCondition(), startState);
 
    middleATextState
        .addTransition(secondMiddleTextCondition, lastTextState);
    middleATextState.addTransition(secondDashCondition, secondDashState);
    middleATextState.addTransition(new AnyCondition(), startState);
 
    secondDashState.addTransition(fourthMiddleTextCondition, lastTextState);
    secondDashState.addTransition(new AnyCondition(), startState);
 

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

   *
   * @return
   */
  private Machine getProbableMachine()
  {
      State startState = new NamedState("START");
      State endState = new NamedState("END");
      State dualState = new NamedState("DUALSTATE");

      endState.setEndStateFlag(true);
 
      Machine m = new Machine(startState);
 
      Condition probableC = new TextSetCondition(iv_probableSet, false);
    
 
      startState.addTransition(probableC, endState);
      startState.addTransition(new AnyCondition(), startState);

 
      dualState.addTransition(new AnyCondition(), startState);
     
      endState.addTransition(new AnyCondition(), startState);
 
      return m;
  }
View Full Code Here

     *
     * @return
     */
    private Machine getProbableMachineNonTerm()
    {
        State startState = new NamedState("START");
        State endState = new NamedState("END");
        State anyState = new NamedState("ANY");

        State ntEndState = new NonTerminalEndState("NON TERMINAL END");
        endState.setEndStateFlag(true);
        ntEndState.setEndStateFlag(true);
        // for case h/o
        State hAbbrState = new NamedState("HISTORY_ABBR");
        State oAbbrState = new NamedState("OF_ABBR");
       
        Machine m = new Machine(startState);
        State fslashState = new NamedState("FORWARD_SLASH");
        State probCollocState = new NamedState("PROB_COLLOC");
        State probFamilyPartState = new NamedState("PROB_FAMC");
        State probColPartState = new NamedState("PROB_COLPART");
       // Condition probableFHC = new TextValueCondition("family", false);
        Condition probCollecC = new TextSetCondition(iv_probableCollocSet, false);
        Condition probColPartC = new TextSetCondition(iv_probableColPartSet, false);
        
 
        startState.addTransition(probCollecC, probCollocState); //questionable
        startState.addTransition(new AnyCondition(), startState);

        probCollocState.addTransition(probColPartC, probColPartState); //history
        probCollocState.addTransition(new TextValueCondition("h", false), hAbbrState); //h  
       // probCollocState.addTransition(probableFHC, probFamilyPartState);
        probCollocState.addTransition(new AnyCondition(), anyState);
       
        hAbbrState.addTransition(
                new TextValueCondition("/", false),
                fslashState);
      hAbbrState.addTransition(new AnyCondition(), startState);
               

     
      probFamilyPartState.addTransition(new AnyCondition(), ntEndState);
     
     // anyState.addTransition(probableFHC, probFamilyPartState); 
     // anyState.addTransition(probColPartC, probColPartState);
        anyState.addTransition(new TextValueCondition("h", false), hAbbrState);
       // anyState.addTransition(new TextValueCondition("/", false), fslashState);
        anyState.addTransition(new AnyCondition(), anyState);
       
        fslashState.addTransition(new TextValueCondition("o", false), oAbbrState);
      fslashState.addTransition(new AnyCondition(), startState);
     
        oAbbrState.addTransition(new AnyCondition(), ntEndState);
        oAbbrState.addTransition(new AnyCondition(), startState);
       
      probColPartState.addTransition(new AnyCondition(), ntEndState);
      //probColPartState.addTransition(new AnyCondition(), startState);
      ntEndState.addTransition(new AnyCondition(), startState);
        return m;
    }
View Full Code Here

   *     <li>drops</li>
   * </ol>
   * @return
   */
  private Machine getTopicalMachine() {
    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 leftDosagesState = new NamedState("LEFT_DOSE");
    State lastTextState = new NamedState("RIGHT_FREQ");
    State middleATextState = new NamedState("MID_TEXT");
    State firstDashState = new NamedState("FIRSTDASH");
    State secondDashState = new NamedState("SECONDDASH");

    State leftAbbreviatePState = new NamedState("LEFT_P");
      State rightAbbreviatePVState = new NamedState("RIGHT_PV");
      State firstDotPState = new NamedState("FIRSTDOTP");

      //Condition secondPVDotCondition = new PunctuationValueCondition('.');
    Condition firstDashCondition = new PunctuationValueCondition('-');
    Condition secondDashCondition = new PunctuationValueCondition('-');
    Condition rangeCombineCondition = new DisjoinCondition(
    new RangeCondition(),
    new RangeStrengthCondition()
    );
 
 
    Condition initialMiddleTextCondition = new WordSetCondition(
        iv_middleTermSet, true);
    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 soloCondition = new WordSetCondition(iv_singleTopicalWordSet, true);
 
   
 
    startState.addTransition(new TextValueCondition("a", true),
        leftAbbreviateState);
    startState.addTransition(new TextValueCondition("p", true),
        leftAbbreviatePState);
    startState.addTransition(initialMiddleTextCondition, leftAbbreviateState);
    startState.addTransition(rangeCombineCondition, leftDosagesState);
    startState.addTransition(soloCondition, endState);
 
    startState.addTransition(new AnyCondition(), startState);
 
    leftAbbreviatePState.addTransition(new PunctuationValueCondition('.'), firstDotPState);
    leftAbbreviatePState.addTransition(new AnyCondition(), startState);

    firstDotPState.addTransition(soloCondition, endState);
    firstDotPState.addTransition(new TextValueCondition("v", true),
        rightAbbreviatePVState);
    firstDotPState.addTransition(new AnyCondition(), startState);
    leftAbbreviateState.addTransition(firstMiddleTextCondition,
        middleATextState);
    leftAbbreviateState.addTransition(firstDashCondition, firstDashState);
    leftAbbreviateState.addTransition(soloCondition, endState);
    leftAbbreviateState.addTransition(new AnyCondition(), startState);
View Full Code Here

     *
     * @return
     */
    private Machine getHistoryMachine()
    {
        State startState = new NamedState("START");
        State endState = new NamedState("END");
     
        //Condition negCollocC = new TextSetCondition(iv_negCollocSet, false);
        //Condition negColPartC = new TextSetCondition(iv_negColPartSet, false);
        // for case h/o
        State hAbbrState = new NamedState("HISTORY_ABBR");
        // for case s/p
        State sAbbrState = new NamedState("STATUS_ABBR");
       
        State fslashState = new NamedState("FORWARD_SLASH");

        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);

        Condition historyC = new TextSetCondition(iv_historySet, false);
 
        startState.addTransition(historyC, endState);
        startState
                .addTransition(new TextValueCondition("h", false), hAbbrState);
        startState
        .addTransition(new TextValueCondition("s", false), hAbbrState);
        startState.addTransition(new AnyCondition(), startState);

        hAbbrState.addTransition(
                new TextValueCondition("/", false),
                fslashState);
        hAbbrState.addTransition(new AnyCondition(), startState);
    
        sAbbrState.addTransition(
                new TextValueCondition("/", false),
                fslashState);
        sAbbrState.addTransition(new AnyCondition(), startState);

        fslashState.addTransition(new TextValueCondition("o", false), endState);
        fslashState.addTransition(new TextValueCondition("p", false), endState);
        fslashState.addTransition(new AnyCondition(), startState);

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

        return m;
    }
View Full Code Here

   * </ol>
   * @return
   */
  private Machine getStrengthSlashMachine()
  {
      State startState = new NamedState("START");
      State endState = new NamedState("END");
      endState.setEndStateFlag(true);
 
      Machine m = new Machine(startState);
      State numeratorLeftState = new NamedState("NUMERATOR_LEFT");
      State remainderRightState = new NamedState("REMAINDER_RIGHT");
      State numeratorRightState = new NamedState("NUMERATOR_RIGHT");
      State decPartNumState = new NamedState("DECIMAL_NUM");
      State fslashState = new NamedState("FORWARD-SLASH");
      State hypenState = new NamedState("HYPHEN");
      State dotLeftState = new NamedState("DOT_LEFT");
      State dotRightState = new NamedState("DOT_RIGHT");
      Condition intNumeratorCondition = new NumberCondition();
      Condition decPartInt = new NumberCondition();
      Condition fslashCondition = new PunctuationValueCondition('/');
      Condition intDenominatorCondition = new NumberCondition();
      Condition decDenominatorCondition = new DecimalCondition();
      Condition decimalCondition = new DecimalCondition();
      Condition containsdotCondition = new PunctuationValueCondition('.');
      Condition leftContainsShortDose = new ContainsSetTextValueCondition(
        iv_textNumeratorSet, false);
   
      startState.addTransition(intNumeratorCondition, numeratorLeftState);
      startState.addTransition(leftContainsShortDose, numeratorLeftState);
      startState.addTransition(new DecimalCondition(), numeratorLeftState);
      startState.addTransition(new AnyCondition(), startState);
     
      numeratorLeftState.addTransition(containsdotCondition, dotLeftState);
      numeratorLeftState.addTransition(fslashCondition, fslashState);
      numeratorLeftState.addTransition(new PunctuationValueCondition('-'), numeratorRightState);
      numeratorLeftState.addTransition(new AnyCondition(), startState);
     
      dotLeftState.addTransition(decPartInt, hypenState);
      dotLeftState.addTransition(decDenominatorCondition, hypenState);
      dotLeftState.addTransition(new AnyCondition(), startState);
   
      hypenState.addTransition(new PunctuationValueCondition('-'), numeratorRightState);
      hypenState.addTransition(new AnyCondition(), startState);
     
      numeratorRightState.addTransition(new NumberCondition(), endState);
      numeratorRightState.addTransition(new DecimalCondition(), endState);
      numeratorRightState.addTransition(new AnyCondition(), startState);
     
      dotRightState.addTransition(new PunctuationValueCondition('.'), fslashState);
      dotRightState.addTransition(new AnyCondition(), startState);
     
      decPartNumState.addTransition(fslashCondition, fslashState);
      decPartNumState.addTransition(new AnyCondition(), startState);
     
      fslashState.addTransition(intDenominatorCondition, endState);
View Full Code Here

     * </ol>
     * @return
     */
    private Machine getStandardMachine()
    {
        State startState = new NamedState("START");
        State endState = new NamedState("END");
        endState.setEndStateFlag(true);

        Machine m = new Machine(startState);
        State numeratorNumState = new NamedState("NUMERATOR_NUM");
        State fslashState = new NamedState("FORWARD_SLASH");
        State numeratorTextState = new NamedState("NUMERATOR_TEXT");

        Condition intNumeratorCondition = new NumberCondition();
        Condition fslashCondition = new PunctuationValueCondition('/');
        Condition intDenominatorCondition = new NumberCondition();
        Condition decimalCondition = new DecimalCondition();
        Condition textNumeratorCondition =
            new WordSetCondition(iv_textNumeratorSet, false);
        Condition textDenominatorCondition =
            new WordSetCondition(iv_textDenominatorSet, false);

        startState.addTransition(intNumeratorCondition, numeratorNumState);
        startState.addTransition(decimalCondition, numeratorNumState);
    startState.addTransition(textNumeratorCondition, numeratorTextState);
    startState.addTransition(textDenominatorCondition, endState);
        startState.addTransition(new AnyCondition(), startState);

        numeratorNumState.addTransition(fslashCondition, fslashState);
    numeratorNumState.addTransition(textDenominatorCondition, endState);
        numeratorNumState.addTransition(new AnyCondition(), startState);

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

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

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

        return m;
    }
View Full Code Here

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

   * </ol>
   * @return
   */
  private Machine getDashDashMachine()
  {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    endState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
   
    State leftNumTextState = new NamedState("LEFT_NUM_TEXT");
    State rightNumTextState = new NamedState("RIGHT_NUM_TEXT");
    State middleDash = new NamedState("MIDDASH");
    State dashAnotherState = new NamedState("DASH_2");
    State dash2State = new NamedState("DASH2");
   
    Condition rightIntCondition = new NumberCondition();
   
    Condition rightNumTextCondition =
      new WordSetCondition(iv_textNumberSet, false);
 
   
    startState.addTransition(new WordSetCondition(iv_textNumberSet, false), leftNumTextState);
    startState.addTransition(new AnyCondition(), startState);
 
    leftNumTextState.addTransition(new PunctuationValueCondition('-'), dash2State);
    leftNumTextState.addTransition(new WordSetCondition(iv_rangeSet, false), rightNumTextState);
    leftNumTextState.addTransition(new AnyCondition(), startState);
 
     
      dash2State.addTransition(rightIntCondition, endState);
    dash2State.addTransition(rightNumTextCondition, endState);
    dash2State.addTransition(new WordSetCondition(iv_rangeSet, false), middleDash);
    dash2State.addTransition(new AnyCondition(), startState);
   
    middleDash.addTransition(new PunctuationValueCondition('-'), dashAnotherState);
    middleDash.addTransition(new AnyCondition(), startState);
   
    rightNumTextState.addTransition(new NumberCondition(), endState);
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.