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

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


   * @return
   */
  private Machine getDotDashMachine()
 
  {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    endState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
    State leftNumIntegerState = new NamedState("LEFT_N2_INT");
    State decPartNumState = new NamedState("DECIMAL_NUM");

    State dashState = new NamedState("DASH");
    State dotState = new NamedState("DOT");

    Condition rangeCondition = new RangeCondition();
    Condition leftIntCondition = new NumberCondition();
    Condition decIntCondition = new NumberCondition();
    Condition rightIntCondition = new NumberCondition();

    Condition rightDecimalCondition = new DecimalCondition();
    Condition dashCondition = new PunctuationValueCondition('-');
   
    Condition dotCondition = new PunctuationValueCondition('.');

    Condition rightDoseagesCondition = new FractionStrengthCondition();
 
    startState.addTransition(leftIntCondition, leftNumIntegerState);
    startState.addTransition(rangeCondition, leftNumIntegerState);

 
    startState.addTransition(new AnyCondition(), startState);
   
     
    leftNumIntegerState.addTransition(dotCondition, dotState);
    leftNumIntegerState.addTransition(new AnyCondition(), startState);
 
    dotState.addTransition(decIntCondition, decPartNumState);
    dotState.addTransition(new AnyCondition(), startState);
   
    decPartNumState.addTransition(dashCondition, dashState);
    decPartNumState.addTransition(new AnyCondition(), startState);

 
View Full Code Here


   * </ol>
   *
   * @return
   */
  private Machine getDosageQuantityMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State ofState = new NamedState("OF");
    State aState = new NamedState("A");
    State numState = new NamedState("NUMVALUE");
    State formState = new NamedState("FORM");
    State leftParenState = new NamedState("LEFTPAREN");
    State ntFalseTermState = new IndentStartState("NON TERMINAL START");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    ntFalseTermState.setEndStateFlag(true);
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);

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

    Condition decimalCondition = new DecimalCondition();
    Condition numberCondition = new NumberCondition();
    Condition strengthFormCondition = new DisjoinCondition(
        new RouteCondition(), new FormCondition());
    Condition numberTextCondition = new WordSetCondition(iv_textNumberSet,
        false);
    Condition rangeCondition = new RangeStrengthCondition();
    Condition fractionRangeCondition = new FractionStrengthCondition();
    Condition decimalStart = new DisjoinCondition(
        new IntegerValueCondition(0), new NumberCondition());

    startState.addTransition(new WordSetCondition(iv_soloTextSet, true),
        endState);
    startState.addTransition(numberCondition, dosageState);
    startState.addTransition(decimalCondition, dosageState);
    startState.addTransition(rangeCondition, dosageState);
    startState.addTransition(fractionRangeCondition, dosageState);
    startState.addTransition(numberTextCondition, dosageState);
    startState.addTransition(decimalStart, dosageState);
    /*startState.addTransition(new DisjoinCondition(new StrengthCondition(),
        new FormCondition()), formState);*/

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

    formState.addTransition(new WordSetCondition(iv_textNumberSet, true),
        ntFalseTermState);
    formState.addTransition(new AnyCondition(), startState);

    dosageState.addTransition(strengthFormCondition, ntEndState);
    dosageState
        .addTransition(new PunctuationValueCondition('-'), hyphState);

    dosageState.addTransition(new PunctuationValueCondition('('),
        leftParenState);
    dosageState.addTransition(new TextValueCondition("of", false), ofState);
    dosageState.addTransition(new AnyCondition(), startState);

    ofState.addTransition(new TextValueCondition("a", false), aState);
    ofState.addTransition(new AnyCondition(), startState);

    aState.addTransition(new DisjoinCondition(new RouteCondition(),
View Full Code Here

   *     <li>25.7-30.2 mg</li>
   *     <li>two-3.5mg</li>
   *  </ol>
   */
  private Machine getStrengthMachine(){
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    State connectState = new NamedState("CONNECT");
    State unitState = new NamedState("UNIT");
    State decimalState = new NamedState("DOT");
    State complexState = new NamedState("COMPLEX");
    State hyphenState = new NamedState("HYPHEN");
    State dateState = new NamedState("DATE");
    State ntEndState = new NonTerminalEndState("NON TERMINAL END");
    State ntEndHyphState = new NonTerminalEndState("NON TERMINAL HYPH END");
    endState.setEndStateFlag(true);
    ntEndState.setEndStateFlag(true);
    ntEndHyphState.setEndStateFlag(true);

    startState.addTransition(new RangeStrengthCondition(), endState);
    startState.addTransition(new FractionStrengthCondition(), dateState);
    startState.addTransition(new NumberCondition(), connectState);
    startState.addTransition(new IntegerCondition(), connectState);
    startState.addTransition(new DecimalCondition(), connectState);
    startState.addTransition(new WordSetCondition(iv_numberTextSet, false), connectState);
    //Mayo SPM 2/20/2012 Changed due to separation of strength tokens
//    startState.addTransition(new StrengthUnitCondition(), ntEndState);
    startState.addTransition(new StrengthUnitCombinedCondition(), endState);
    startState.addTransition(new AnyCondition(), startState);
   
    dateState.addTransition(new NegateCondition( new PunctuationValueCondition('/')), connectState);
    dateState.addTransition(new AnyCondition(), startState);
   
    //Mayo SPM 2/20/2012 Changed due to separation of strength tokens
    connectState.addTransition(new StrengthUnitCondition(), ntEndState);
    connectState.addTransition(new StrengthUnitCombinedCondition(), endState);
    connectState.addTransition(new PunctuationValueCondition('-'), unitState);
View Full Code Here

   * </ol>
   *
   * @return
   */
  private Machine geDuration2ndMachine() {
    State startState = new NamedState("START");
    State endState = new NamedState("END");
    endState.setEndStateFlag(true);
 
    Machine m = new Machine(startState);
 
    State startAbbreviateState = new NamedState("START_ABBR");
    State middleTermState = new NamedState("MID_TERM");
    State finalTextState = new NamedState("FIN_TEXT");
    State finalTermState = new NamedState("FIN_TERM");
    State finalAppendState = new NamedState("FIN_APPEND");
    State anotherAppendState = new NamedState("ANOTHER_APPEND");
   
  //  State firstDashState = new NamedState("FIRST_DASH");
  //  State secondDashState = new NamedState("SECOND_DASH");
 
  //  Condition firstDashCondition = new PunctuationValueCondition('-');
  //  Condition secondDashCondition = new PunctuationValueCondition('-');
 
    Condition numericTextCondition = new WordSetCondition(
        iv_middleNumericTermSet, true);
    Condition periodCondition = new WordSetCondition(iv_periodSet, true);
    Condition periodAdditionalCondition = new WordSetCondition(iv_periodSet, true);
    Condition periodAdditional2Condition = new WordSetCondition(iv_periodSet, true);
    Condition specificWordCondition = new WordSetCondition(
        iv_specifiedWordSet, false);
    Condition containsAppendTermCondition = new WordSetCondition(
        iv_appendWordSet, true);
    Condition containsSecondAppendTermCondition = new WordSetCondition(
        iv_appendWordSet, true);
 
    startState.addTransition(specificWordCondition, startAbbreviateState);
    startState.addTransition(new AnyCondition(), startState);
 
    startAbbreviateState.addTransition(containsAppendTermCondition,
        middleTermState);

  //  startAbbreviateState.addTransition(firstDashCondition, firstDashState);
      startAbbreviateState.addTransition(new NumberCondition(),
        finalTermState);
   
 
    startAbbreviateState.addTransition(new AnyCondition(), startState);
 
 
    middleTermState.addTransition(new RangeStrengthCondition(), anotherAppendState);
    middleTermState.addTransition(containsSecondAppendTermCondition, finalTermState);
    middleTermState.addTransition(numericTextCondition, finalAppendState);
    middleTermState.addTransition(new NumberCondition(), anotherAppendState);
   
    middleTermState.addTransition(new AnyCondition(), startState);
 
  //  secondDashState.addTransition(containsSecondAppendTermCondition, finalTextState);
  //  secondDashState.addTransition(periodCondition, endState);
  //  secondDashState.addTransition(new AnyCondition(), startState);
 
    //finalTermState.addTransition(periodCondition, endState);
    finalTermState.addTransition(new RangeStrengthCondition(), finalTextState);
    finalTermState.addTransition(numericTextCondition, finalTextState);
    finalTermState.addTransition(new NumberCondition(), finalTextState);
   
    finalTermState.addTransition(new AnyCondition(), startState);
   
    finalAppendState.addTransition(periodAdditionalCondition, endState);
    finalAppendState.addTransition(new AnyCondition(), startState);
   
    anotherAppendState.addTransition(periodAdditional2Condition, endState);
    anotherAppendState.addTransition(new AnyCondition(), startState);
   
    finalTextState.addTransition(periodCondition, endState);
    finalTextState.addTransition(new AnyCondition(), startState);
 
    endState.addTransition(new AnyCondition(), startState);
View Full Code Here

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

    Machine m = new Machine(startState);

    State leftAbbreviateState = new NamedState("LEFT_ABBR");
    State lastTextState = new NamedState("LAST_TEXT");
    State middleTextState = new NamedState("MID_TEXT");
    State firstDashState = new NamedState("FIRSTDASH");
    State secondDashState = new NamedState("SECONDDASH");

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

    Condition firstMiddleTextCondition = new WordSetCondition(
        iv_middleNumericTermSet, true);
    Condition secondMiddleTextCondition = new WordSetCondition(
        iv_middleNumericTermSet, true);
    Condition thirdMiddleTextCondition = new WordSetCondition(
        iv_middleNumericTermSet, true);
    Condition fourthMiddleTextCondition = new WordSetCondition(
        iv_middleNumericTermSet, true);

    Condition periodCondition = new WordSetCondition(iv_periodSet, true);
    Condition specificWordCondition = new WordSetCondition(
        iv_specifiedWordSet, false);


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

    leftAbbreviateState.addTransition(new RangeStrengthCondition(), middleTextState);
    leftAbbreviateState.addTransition(firstMiddleTextCondition,
        middleTextState);
    leftAbbreviateState.addTransition(firstDashCondition, firstDashState);
    leftAbbreviateState.addTransition(new NumberCondition(),
        middleTextState);
   
        leftAbbreviateState.addTransition(new WordSetCondition(
        iv_combinedSet, false), endState);
    leftAbbreviateState.addTransition(new AnyCondition(), startState);

    middleTextState.addTransition(new RangeStrengthCondition(), lastTextState);
    middleTextState.addTransition(secondMiddleTextCondition, lastTextState);
    middleTextState.addTransition(firstDashCondition, firstDashState);
    middleTextState.addTransition(secondDashCondition, secondDashState);
 
    middleTextState.addTransition(periodCondition, endState);
    middleTextState.addTransition(new AnyCondition(), startState);

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


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

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

View Full Code Here

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

    Machine m = new Machine(startState);
    State systolicState = new NamedState("SYSTOLIC");
    State fslashState = new NamedState("FSLASH");

    Condition systolicCondition = new IntegerRangeCondition(80, 200);
    Condition diastolicCondition = new IntegerRangeCondition(60, 160);
    Condition fslashCondition = new PunctuationValueCondition('/');

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

    systolicState.addTransition(fslashCondition, fslashState);
    systolicState.addTransition(new AnyCondition(), startState);

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

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

    return m;
  }
View Full Code Here

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

    Machine m = new Machine(startState);
 

 
    Condition fullTextCondition = new WordSetCondition(iv_fullTextSet,
        false);

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


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

    return m;
  }
View Full Code Here

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

    Machine m = new Machine(startState);
    State quanitityState = new NamedState("QUANITITY");

    Condition numberCondition = new NumberCondition();
    Condition numberTextCondition = new WordSetCondition(iv_textNumberSet,
        false);
    Condition rangeCondition = new RangeCondition();
    Condition fullTextCondition = new WordSetCondition(iv_fullTextSet,
        false);
    Condition shortTextCondition = new WordSetCondition(iv_shortTextSet,
        false);

    startState.addTransition(numberCondition, quanitityState);
    startState.addTransition(rangeCondition, quanitityState);
    startState.addTransition(numberTextCondition, quanitityState);
    startState.addTransition(new AnyCondition(), startState);

    quanitityState.addTransition(fullTextCondition, endState);
    quanitityState.addTransition(shortTextCondition, endState);
    quanitityState.addTransition(new AnyCondition(), startState);

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

    return m;
  }
View Full Code Here

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

    Machine machine = new Machine(startState);
    State monthNumState = new NamedState("MONTH_NUM");
    State monthDaySeparatorState = new NamedState("MONTH_DAY_SEP");
    State dayNumState = new NamedState("DAY_NUM");
    State dayYearSeparatorState = new NamedState("DAY_YEAR_SEP");

    Condition monthNumCondition = new IntegerRangeCondition(MIN_MONTH,
        MAX_MONTH);
    Condition mdFslashCondition = new PunctuationValueCondition('/');
    Condition mdDashCondition = new PunctuationValueCondition('-');
    Condition dyFslashCondition = new PunctuationValueCondition('/');
    Condition dyDashCondition = new PunctuationValueCondition('-');
    Condition dayNumCondition = new IntegerRangeCondition(MIN_DAY, MAX_DAY);
    Condition yearNumCondition = new IntegerRangeCondition(MIN_YEAR,
        MAX_YEAR);

    // condition that is not a fslash or dash
    Condition notFslashNotDashCondition = new CombineCondition(
        new NegateCondition(mdFslashCondition), new NegateCondition(
            mdDashCondition));

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

    monthNumState.addTransition(mdFslashCondition, monthDaySeparatorState);
    monthNumState.addTransition(mdDashCondition, monthDaySeparatorState);
    monthNumState.addTransition(new AnyCondition(), startState);

    monthDaySeparatorState.addTransition(dayNumCondition, dayNumState);
    monthDaySeparatorState.addTransition(new AnyCondition(), startState);

    dayNumState.addTransition(dyFslashCondition, dayYearSeparatorState);
    dayNumState.addTransition(dyDashCondition, dayYearSeparatorState);
    dayNumState.addTransition(notFslashNotDashCondition, ntEndState);
    dayNumState.addTransition(new AnyCondition(), startState);

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

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

    return machine;
View Full Code Here

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

    Machine m = new Machine(startState);

    State monthFullTextState = new NamedState("MONTH_FULL_TEXT");
    State monthShortTextState = new NamedState("MONTH_SHORT_TEXT");
    State dayNumState = new NamedState("DAY_NUM");
    State commaState = new NamedState("COMMA");
    State periodState = new NamedState("PERIOD");

    Condition monthFullTextCondition = new WordSetCondition(
        iv_monthFullNameSet, false);
    Condition monthShortTextCondition = new WordSetCondition(
        iv_monthShortNameSet, false);
    Condition dayNumCondition = new IntegerRangeCondition(MIN_DAY, MAX_DAY);
    Condition periodCondition = new PunctuationValueCondition('.');
    Condition yearNumCondition = new IntegerRangeCondition(MIN_YEAR,
        MAX_YEAR);
    Condition commaCondition = new PunctuationValueCondition(',');

    // condition for not being a comma or year number
    Condition notCommaNotYearNumCondition = new CombineCondition(
        new NegateCondition(commaCondition), new NegateCondition(
            yearNumCondition));

    // condition for being a year num and not a day num
    Condition yearNotDayNumCondition = new CombineCondition(
        yearNumCondition, new NegateCondition(dayNumCondition));

    startState.addTransition(monthFullTextCondition, monthFullTextState);
    startState.addTransition(monthShortTextCondition, monthShortTextState);
    startState.addTransition(new AnyCondition(), startState);

    monthFullTextState.addTransition(dayNumCondition, dayNumState);
    monthFullTextState.addTransition(yearNotDayNumCondition, ntEndState);
    monthFullTextState.addTransition(new AnyCondition(), startState);

    monthShortTextState.addTransition(dayNumCondition, dayNumState);
    monthShortTextState.addTransition(periodCondition, periodState);
    monthShortTextState.addTransition(yearNotDayNumCondition, ntEndState);
    monthShortTextState.addTransition(new AnyCondition(), startState);

    periodState.addTransition(dayNumCondition, dayNumState);
    periodState.addTransition(yearNotDayNumCondition, ntEndState);
    periodState.addTransition(new AnyCondition(), startState);

    dayNumState.addTransition(yearNumCondition, endState);
    dayNumState.addTransition(commaCondition, commaState);
    dayNumState.addTransition(notCommaNotYearNumCondition, ntEndState);
    dayNumState.addTransition(new AnyCondition(), startState);
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.