Package org.apache.ctakes.core.fsm.token

Examples of org.apache.ctakes.core.fsm.token.BaseToken


    // maps a fsm to a token start index
    // key = fsm , value = token start index
    Map<Machine, Integer> tokenStartMap = new HashMap<Machine, Integer>();

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = (BaseToken) tokens.get(i);

      Iterator<Machine> machineItr = iv_machineSet.iterator();
      while (machineItr.hasNext()) {
        Machine fsm = machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken endToken = null;
          if (currentState instanceof NonTerminalEndState) {
            endToken = (BaseToken) tokens.get(i - 1);
          } else {
            endToken = token;
          }

          BaseToken startToken = (BaseToken) tokens
              .get(tokenStartIndex);
          NegationIndicator neg = new NegationIndicator(startToken
              .getStartOffset(), endToken.getEndOffset());
          outSet.add(neg);
          fsm.reset();
        }
      }
View Full Code Here


    // maps a fsm to a token start index
    // key = fsm , value = token start index
    Map<Machine, Integer> tokenStartMap = new HashMap<Machine, Integer>();

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = tokens.get(i);

      Iterator<Machine> machineItr = iv_machineSet.iterator();
      while (machineItr.hasNext()) {
        Machine fsm = machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = tokens.get(tokenStartIndex);
          BaseToken endToken = token;
          PersonTitleToken ptToken = new PersonTitleToken(startToken
              .getStartOffset(), endToken.getEndOffset());
          personTitleSet.add(ptToken);
          fsm.reset();
        }
      }
    }
View Full Code Here

        // key = Machine , value = token start index
        Map<Machine, Integer> tokenStartMap = new HashMap<Machine, Integer>();

        for (int i = 0; i < tokens.size(); i++)
        {
            BaseToken token = tokens.get(i);

            Iterator<Machine> machineItr = iv_machineSet.iterator();
            while (machineItr.hasNext())
            {
                Machine m = machineItr.next();

                m.input(token);

                State currentState = m.getCurrentState();
                if (currentState.getStartStateFlag())
                {
                    tokenStartMap.put(m, new Integer(i));
                }
                if (currentState.getEndStateFlag())
                {
                    Object o = tokenStartMap.get(m);
                    int tokenStartIndex;
                    if (o == null)
                    {
                        // By default, all machines start with token zero.
                        tokenStartIndex = 0;
                    }
                    else
                    {
                        tokenStartIndex = ((Integer) o).intValue();
                        // skip ahead over single token we don't want
                        tokenStartIndex++;
                    }
                    BaseToken endToken = null;
                    if (currentState instanceof NonTerminalEndState)
                    {
                        endToken = tokens.get(i - 1);
                    }
                    else
                    {
                        endToken = token;
                    }

                    BaseToken startToken = tokens.get(tokenStartIndex);
                    StatusIndicator si = null;
                    if (m.equals(iv_historyMachine))
                    {
                        si = new StatusIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                StatusIndicator.HISTORY_STATUS);
                    }
                    else if (m.equals(iv_probableMachine))
                    {
                        si = new StatusIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                StatusIndicator.PROBABLE_STATUS);
                    }
                    else if (m.equals(iv_familyHistoryMachine))
                    {
                        si = new StatusIndicator(
                                startToken.getStartOffset(),
                                endToken.getEndOffset(),
                                StatusIndicator.FAMILY_HISTORY_STATUS);
                    }
                    outSet.add(si);
                    m.reset();
View Full Code Here

    // maps a fsm to a token start index
    // key = fsm , value = token start index
    Map<Machine, Integer> tokenStartMap = new HashMap<Machine, Integer>();

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = tokens.get(i);

      Iterator<Machine> machineItr = iv_machineSet.iterator();
      while (machineItr.hasNext()) {
        Machine fsm = machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }

          BaseToken startToken = tokens.get(tokenStartIndex);
          BaseToken endToken = token;
          RomanNumeralToken rnToken = new RomanNumeralToken(
              startToken.getStartOffset(), endToken
                  .getEndOffset());
          romanNumeralSet.add(rnToken);
          fsm.reset();
        }
      }
View Full Code Here

    // maps a fsm to a token start index
    // key = fsm , value = token start index
    Map<Machine, Integer> tokenStartMap = new HashMap<Machine, Integer>();

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = tokens.get(i);

      Iterator<Machine> machineItr = iv_machineSet.iterator();
      while (machineItr.hasNext()) {
        Machine fsm = machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = tokens.get(tokenStartIndex);
          BaseToken endToken = token;
          TimeToken timeToken = new TimeToken(startToken
              .getStartOffset(), endToken.getEndOffset());
          timeSet.add(timeToken);
          fsm.reset();
        }
      }
    }
View Full Code Here

        List<BaseToken> baseTokenList = new ArrayList<BaseToken>();
        while (btaItr.hasNext()) {
          org.apache.ctakes.typesystem.type.syntax.BaseToken bta = (org.apache.ctakes.typesystem.type.syntax.BaseToken) btaItr
              .next();
          // ignore newlines, avoid null tokens
          BaseToken bt = adaptToBaseToken(bta);
          if(bt != null && !(bt instanceof EolToken))
            baseTokenList.add(bt);
        }

        // execute FSM logic
View Full Code Here

    Iterator overrideTokenItr = overrideSet.iterator();
    // key = start offset, value = override BaseToken object
    Map overrideTokenMap = new HashMap();
    while (overrideTokenItr.hasNext()) {
      BaseToken t = (BaseToken) overrideTokenItr.next();
      Integer key = new Integer(t.getStartOffset());
      overrideTokenMap.put(key, t);
    }

    boolean overrideOn = false;
    int overrideEndOffset = -1;
    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = (BaseToken) tokens.get(i);

      Integer key = new Integer(token.getStartOffset());

      if (overrideOn) {
        if (token.getStartOffset() >= overrideEndOffset) {
          overrideOn = false;
          overrideEndOffset = -1;
        } else {
          // step to next iteration of for loop
          continue;
        }
      } else {
        if (overrideTokenMap.containsKey(key)) {
          // override one or more tokens until the override
          // token is complete
          token = (BaseToken) overrideTokenMap.get(key);
          overrideOn = true;
          overrideEndOffset = token.getEndOffset();
        }
      }

      Iterator machineItr = iv_machineSet.iterator();
      while (machineItr.hasNext()) {
        Machine fsm = (Machine) machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = (BaseToken) tokens
              .get(tokenStartIndex);
          BaseToken endToken = token;
          RouteToken segmentToken = null;
         
          if (fsm.equals(iv_PatchesMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.TRANSDERMAL);
          }
          else if (fsm.equals(iv_GastricMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.GASTRIC);
          }
          else if (fsm.equals(iv_TopicalMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.TOPICAL);
          }
          else if (fsm.equals(iv_OralMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.ORAL);
          }
          else if (fsm.equals(iv_RectalMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.RECTAL);
          }
          else if (fsm.equals(iv_InjectMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.INTRAVENOUS);
          }
          rangeSet.add(segmentToken);
          fsm.reset();
View Full Code Here

    // maps a fsm to a token start index
    // key = fsm , value = token start index
    Map tokenStartMap = new HashMap();

    for (int i = 0; i < tokens.size(); i++) {
      BaseToken token = (BaseToken) tokens.get(i);

      Iterator machineItr = iv_machineSet.iterator();
      while (machineItr.hasNext()) {
        Machine fsm = (Machine) machineItr.next();

        fsm.input(token);

        State currentState = fsm.getCurrentState();
        if (currentState.getStartStateFlag()) {
          tokenStartMap.put(fsm, new Integer(i));
        }
        if (currentState.getEndStateFlag()) {
          Object o = tokenStartMap.get(fsm);
          int tokenStartIndex;
          if (o == null) {
            // By default, all machines start with
            // token zero.
            tokenStartIndex = 0;
          } else {
            tokenStartIndex = ((Integer) o).intValue();
            // skip ahead over single token we don't want
            tokenStartIndex++;
          }
          BaseToken startToken = (BaseToken) tokens
              .get(tokenStartIndex);
          BaseToken endToken = token;
          RouteToken segmentToken = null;
         
          if (fsm.equals(iv_PatchesMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.TRANSDERMAL);
          }
          else if (fsm.equals(iv_GastricMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.GASTRIC);
          }
          else if (fsm.equals(iv_TopicalMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.TOPICAL);
          }
          else if (fsm.equals(iv_OralMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.ORAL);
          }
          else if (fsm.equals(iv_RectalMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.RECTAL);
          }
          else if (fsm.equals(iv_InjectMachine)){
            segmentToken = new RouteToken(
                startToken.getStartOffset(), endToken
                    .getEndOffset());
            segmentToken.setFormMethod(RouteToken.INTRAVENOUS);
          }
         
          fractionSet.add(segmentToken);
View Full Code Here

TOP

Related Classes of org.apache.ctakes.core.fsm.token.BaseToken

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.