Package org.mitre.medfacts.i2b2.util

Examples of org.mitre.medfacts.i2b2.util.Location


      logger.info(String.format("====== BEGIN RUN # %d WITH %d FILES IN TRAINING SET =====", i, size));

      BatchRunner b = new BatchRunner();
      b.setMode(Mode.EVAL);

      ScopeParser scopeParser = new ScopeParser(scopeFile.getAbsolutePath(), cueFile.getAbsolutePath());
      b.setScopeParser(scopeParser);

      b.setBaseDirectoryString(baseDirectoryString);
      b.setTrainingDirectory(trainDirectory.getAbsolutePath());
      b.setDecodeDirectory(evalDirectory.getAbsolutePath());
View Full Code Here


      posModelFile = new File(baseDir, posModelFileName);
    }

    logger.info(String.format("cue model file: %s%n", cueModelFile.getAbsolutePath()));
    //initialize scope/cue parser
    ScopeParser scopeParser = new ScopeParser(scopeModelFile.getAbsolutePath(), cueModelFile.getAbsolutePath());
    PartOfSpeechTagger posTagger = new PartOfSpeechTagger(posModelFile.getAbsolutePath());

//    String baseDirectory = args[0];
//    logger.info(String.format("base directory: %s%n", baseDirectory);
View Full Code Here

      AssertionDecoderConfiguration assertionDecoderConfiguration = new AssertionDecoderConfiguration();

      logger.info(String.format("scope model file: %s", scopeModelFilePath));
      logger.info(String.format("cue model file: %s", cueModelFilePath));
      ScopeParser scopeParser = new ScopeParser(scopeModelFilePath,
          cueModelFilePath);
      assertionDecoderConfiguration.setScopeParser(scopeParser);

      logger.info(String.format("pos model file: %s", posModelFilePath));
      PartOfSpeechTagger posTagger = new PartOfSpeechTagger(posModelFilePath);
View Full Code Here

    String beginLine = matcher.group(2);
    String beginCharacter = matcher.group(3);
    String endLine = matcher.group(4);
    String endCharacter = matcher.group(5);
    String scopeTypeText = matcher.group(6);
    ScopeType scopeType = ScopeType.valueOf(scopeTypeText.toUpperCase());

    ScopeOrCueAnnotation annotation = null;

    switch (scopeType)
    {
View Full Code Here

          if (checkForEnabledFeature("zone"))
          {
            if (a instanceof ZoneAnnotation)
            {
              ZoneAnnotation zone = (ZoneAnnotation)a;
              trainingInstance.addFeature("zone_" + MedFactsRunner.escapeFeatureName(zone.getZoneName()));
            }
          }

        } // end of for loop over a : annotationsAtCurrentPosition
      }
View Full Code Here

            continue;
          }
          endToken = textLookup[i].length - 1;
        }

        ZoneAnnotation zone = new ZoneAnnotation();
        zone.setZoneName(currentRange.getLabel());
        Location begin = new Location();
        begin.setLine(i);
        begin.setTokenOffset(beginToken);
        zone.setBegin(begin);
        Location end = new Location();
        end.setLine(i);
        end.setTokenOffset(endToken);
        zone.setEnd(end);

//        allAnnotationList.add(zone);
//        List<Annotation> zoneAnnotationList = annotationsByType.get(AnnotationType.ZONE);
//        if (zoneAnnotationList == null)
//        {
View Full Code Here

          if (checkForEnabledFeature("zone"))
          {
            if (a instanceof ZoneAnnotation)
            {
              ZoneAnnotation zone = (ZoneAnnotation)a;
              final String zoneFeatureName = "zone_" + escapeFeatureName(zone.getZoneName());
              //logger.info("### zone feature: " + zoneFeatureName);
              trainingInstance.addFeature(zoneFeatureName);
            }
          }
        }
View Full Code Here

    ArrayList<ApiConcept> apiConceptList = new ArrayList<ApiConcept>();
    for (Annotation annotation : conceptAnnotationIndex)
    {
      Concept conceptAnnotation = (Concept) annotation;

      ApiConcept apiConcept = new ApiConcept();
      int begin = conceptAnnotation.getBegin();
      int end = conceptAnnotation.getEnd();
      String conceptText = contents.substring(begin, end);

      apiConcept.setBegin(begin);
      apiConcept.setEnd(end);
      apiConcept.setText(conceptText);
      apiConcept.setType(conceptAnnotation.getConceptType());
      apiConcept.setExternalId(conceptAnnotation.getAddress());

      apiConceptList.add(apiConcept);
    }

    // String conceptFilePath =
    // currentTextFile.getAbsolutePath().replaceFirst("\\.txt$", ".con");
    // File conceptFile = new File(conceptFilePath);
    // logger.info(String.format("    - using concept file \"%s\"...",
    // conceptFile.getName()));
    // String conceptFileContents =
    // StringHandling.readEntireContents(conceptFile);
    // //List<Concept> parseConceptFileContents(conceptFileContents);
    //
    // LineTokenToCharacterOffsetConverter converter =
    // new LineTokenToCharacterOffsetConverter(contents);
    //
    // List<ApiConcept> apiConceptList = parseConceptFile(conceptFile, contents,
    // converter);

    // LineTokenToCharacterOffsetConverter converter =
    // new LineTokenToCharacterOffsetConverter(contents);


    // SingleDocumentProcessor p = new SingleDocumentProcessor();
    SingleDocumentProcessorCtakes p = new SingleDocumentProcessorCtakes();
    p.setJcas(jcas);
    p.setAssertionDecoderConfiguration(assertionDecoderConfiguration);
    // p.setContents(tokenizedContents);
    p.setContents(contents);
    CharacterOffsetToLineTokenConverter converter = new CharacterOffsetToLineTokenConverterCtakesImpl(
        jcas);
    p.setConverter2(converter);
    for (ApiConcept apiConcept : apiConceptList)
    {
      //logger
      //    .info(String.format("dir loader concept: %s", apiConcept.toString()));
      p.addConcept(apiConcept);
    }

    logger
        .debug("(logging statement) AssertionAnalysisEngine.process() BEFORE CALLING p.processSingleDocument()");

    p.processSingleDocument();

    logger
        .debug("(logging statement) AssertionAnalysisEngine.process() AFTER CALLING p.processSingleDocument()");

    Map<Integer, String> assertionTypeMap = p.getAssertionTypeMap();
    //logger.info(String.format("    - done processing ..\"."));

    // Map<Integer, Annotation> annotationMap = generateAnnotationMap(jcas,
    // Concept.type);
    CasIndexer<Annotation> indexer = new CasIndexer<Annotation>(jcas, null);

    //logger.info("assertionTypeMap loop OUTSIDE BEFORE...");
    for (Entry<Integer, String> current : assertionTypeMap.entrySet())
    {
      //logger.info("    assertionTypeMap loop INSIDE BEGIN");
      String currentAssertionType = current.getValue();
      //logger.info(String.format("  currentAssertionType: %s",
      //    currentAssertionType));
      Integer currentIndex = current.getKey();
      ApiConcept originalConcept = apiConceptList.get(currentIndex);

      Concept associatedConcept = (Concept) indexer
          .lookupByAddress(originalConcept.getExternalId());
      int entityAddress = associatedConcept.getOriginalEntityExternalId();
      IdentifiedAnnotation annotation = (IdentifiedAnnotation) indexer
          .lookupByAddress(entityAddress);

      // possible values for currentAssertionType:
View Full Code Here

    ArrayList<ApiConcept> apiConceptList = new ArrayList<ApiConcept>();
    for (Annotation annotation : conceptAnnotationIndex)
    {
      Concept conceptAnnotation = (Concept) annotation;

      ApiConcept apiConcept = new ApiConcept();
      int begin = conceptAnnotation.getBegin();
      int end = conceptAnnotation.getEnd();
      String conceptText = contents.substring(begin, end);

      apiConcept.setBegin(begin);
      apiConcept.setEnd(end);
      apiConcept.setText(conceptText);
      apiConcept.setType(conceptAnnotation.getConceptType());
      apiConcept.setExternalId(conceptAnnotation.getAddress());

      apiConceptList.add(apiConcept);
    }

    // String conceptFilePath =
    // currentTextFile.getAbsolutePath().replaceFirst("\\.txt$", ".con");
    // File conceptFile = new File(conceptFilePath);
    // logger.info(String.format("    - using concept file \"%s\"...",
    // conceptFile.getName()));
    // String conceptFileContents =
    // StringHandling.readEntireContents(conceptFile);
    // //List<Concept> parseConceptFileContents(conceptFileContents);
    //
    // LineTokenToCharacterOffsetConverter converter =
    // new LineTokenToCharacterOffsetConverter(contents);
    //
    // List<ApiConcept> apiConceptList = parseConceptFile(conceptFile, contents,
    // converter);

    // LineTokenToCharacterOffsetConverter converter =
    // new LineTokenToCharacterOffsetConverter(contents);


    // SingleDocumentProcessor p = new SingleDocumentProcessor();
    SingleDocumentProcessorCtakes p = new SingleDocumentProcessorCtakes();
    p.setJcas(jcas);
    p.setAssertionDecoderConfiguration(assertionDecoderConfiguration);
    // p.setContents(tokenizedContents);
    p.setContents(contents);
    CharacterOffsetToLineTokenConverter converter = new CharacterOffsetToLineTokenConverterCtakesImpl(
        jcas);
    p.setConverter2(converter);
    for (ApiConcept apiConcept : apiConceptList)
    {
      //logger
      //    .info(String.format("dir loader concept: %s", apiConcept.toString()));
      p.addConcept(apiConcept);
    }

    logger
        .info("(logging statement) AssertionAnalysisEngine.process() BEFORE CALLING p.processSingleDocument()");

    p.processSingleDocument();

    logger
        .info("(logging statement) AssertionAnalysisEngine.process() AFTER CALLING p.processSingleDocument()");

    Map<Integer, String> assertionTypeMap = p.getAssertionTypeMap();
    //logger.info(String.format("    - done processing ..\"."));

    // Map<Integer, Annotation> annotationMap = generateAnnotationMap(jcas,
    // Concept.type);
    CasIndexer<Annotation> indexer = new CasIndexer<Annotation>(jcas, null);

    //logger.info("assertionTypeMap loop OUTSIDE BEFORE...");
    for (Entry<Integer, String> current : assertionTypeMap.entrySet())
    {
      //logger.info("    assertionTypeMap loop INSIDE BEGIN");
      String currentAssertionType = current.getValue();
      //logger.info(String.format("  currentAssertionType: %s",
      //    currentAssertionType));
      Integer currentIndex = current.getKey();
      ApiConcept originalConcept = apiConceptList.get(currentIndex);

      Concept associatedConcept = (Concept) indexer
          .lookupByAddress(originalConcept.getExternalId());
      int entityAddress = associatedConcept.getOriginalEntityExternalId();
      IdentifiedAnnotation annotation = (IdentifiedAnnotation) indexer
          .lookupByAddress(entityAddress);

      // possible values for currentAssertionType:
View Full Code Here

    ArrayList<ApiConcept> apiConceptList = new ArrayList<ApiConcept>();
    for (Annotation annotation : conceptAnnotationIndex)
    {
      Concept conceptAnnotation = (Concept) annotation;

      ApiConcept apiConcept = new ApiConcept();
      int begin = conceptAnnotation.getBegin();
      int end = conceptAnnotation.getEnd();
      String conceptText = contents.substring(begin, end);

      apiConcept.setBegin(begin);
      apiConcept.setEnd(end);
      apiConcept.setText(conceptText);
      apiConcept.setType(conceptAnnotation.getConceptType());
      apiConcept.setExternalId(conceptAnnotation.getAddress());

      apiConceptList.add(apiConcept);
    }

    // String conceptFilePath =
    // currentTextFile.getAbsolutePath().replaceFirst("\\.txt$", ".con");
    // File conceptFile = new File(conceptFilePath);
    // logger.info(String.format("    - using concept file \"%s\"...",
    // conceptFile.getName()));
    // String conceptFileContents =
    // StringHandling.readEntireContents(conceptFile);
    // //List<Concept> parseConceptFileContents(conceptFileContents);
    //
    // LineTokenToCharacterOffsetConverter converter =
    // new LineTokenToCharacterOffsetConverter(contents);
    //
    // List<ApiConcept> apiConceptList = parseConceptFile(conceptFile, contents,
    // converter);

    // LineTokenToCharacterOffsetConverter converter =
    // new LineTokenToCharacterOffsetConverter(contents);


    // SingleDocumentProcessor p = new SingleDocumentProcessor();
    SingleDocumentProcessorCtakes p = new SingleDocumentProcessorCtakes();
    p.setJcas(jcas);
    p.setAssertionDecoderConfiguration(assertionDecoderConfiguration);
    // p.setContents(tokenizedContents);
    p.setContents(contents);
    CharacterOffsetToLineTokenConverter converter = new CharacterOffsetToLineTokenConverterCtakesImpl(
        jcas);
    p.setConverter2(converter);
    for (ApiConcept apiConcept : apiConceptList)
    {
      //logger
      //    .info(String.format("dir loader concept: %s", apiConcept.toString()));
      p.addConcept(apiConcept);
    }

    logger
        .info("(logging statement) AssertionAnalysisEngine.process() BEFORE CALLING p.processSingleDocument()");

    p.processSingleDocument();

    logger
        .info("(logging statement) AssertionAnalysisEngine.process() AFTER CALLING p.processSingleDocument()");

    Map<Integer, String> assertionTypeMap = p.getAssertionTypeMap();
    //logger.info(String.format("    - done processing ..\"."));

    // Map<Integer, Annotation> annotationMap = generateAnnotationMap(jcas,
    // Concept.type);
    CasIndexer<Annotation> indexer = new CasIndexer<Annotation>(jcas, null);

    //logger.info("assertionTypeMap loop OUTSIDE BEFORE...");
    for (Entry<Integer, String> current : assertionTypeMap.entrySet())
    {
      //logger.info("    assertionTypeMap loop INSIDE BEGIN");
      String currentAssertionType = current.getValue();
      //logger.info(String.format("  currentAssertionType: %s",
      //    currentAssertionType));
      Integer currentIndex = current.getKey();
      ApiConcept originalConcept = apiConceptList.get(currentIndex);

      Concept associatedConcept = (Concept) indexer
          .lookupByAddress(originalConcept.getExternalId());
      int entityAddress = associatedConcept.getOriginalEntityExternalId();
      IdentifiedAnnotation annotation = (IdentifiedAnnotation) indexer
          .lookupByAddress(entityAddress);

      // possible values for currentAssertionType:
View Full Code Here

TOP

Related Classes of org.mitre.medfacts.i2b2.util.Location

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.