Package org.apache.ctakes.core.resource

Examples of org.apache.ctakes.core.resource.FileResource


      location      = new ArrayList<Object>();
      boundaryAnns  = new ArrayList<Object>();
      ignoreP1Types = new ArrayList<Integer>();
      ignoreP2Types = new ArrayList<Integer>();
     
      FileResource resrcStopWords = (FileResource) aCtx.getResourceObject(STOP_WORDS_FILE);
      File stopWordsFile = resrcStopWords.getFile();

      //gather annotation types that will be used in pairs
      annotationPartOneOfPair = (String)aCtx.getConfigParameterValue(ANNOTATION_PART_ONE_OF_PAIR);
      annotationPartTwoOfPair = (String)aCtx.getConfigParameterValue(ANNOTATION_PART_TWO_OF_PAIR);
     
View Full Code Here


      // What type of operating system type are we running on? Unix or Windows
      if (System.getProperty("file.separator").matches("/"))
        windowsSystem = false;
     
      // load TAE from XML descriptor
      FileResource fResrc = (FileResource) aContext.getResourceObject(PARAM_SMOKING_STATUS_DESC_STEP1KEY);
      File descFile = fResrc.getFile();
      taeSpecifierStep1 = UIMAFramework.getXMLParser().parseResourceSpecifier(
      new XMLInputSource(fResrc.getFile()));     

      fResrc = (FileResource) aContext.getResourceObject(PARAM_SMOKING_STATUS_DESC_STEP2KEY);
      descFile = fResrc.getFile();

      taeSpecifierStep2 = UIMAFramework.getXMLParser().parseResourceSpecifier(
          new XMLInputSource(fResrc.getFile()));     

      ra = new ResolutionAnnotator();
      ra.initialize(aContext);
      String dataPath  = aContext.getDataPath();
      System.out.println("descFile "+descFile.getAbsolutePath());
View Full Code Here

  public void initialize(UimaContext aCtx)
      throws ResourceInitializationException {
    super.initialize(aCtx);
    iv_subMedSectionFSM = new SubSectionPadIdFSM();
    FileResource resrcExamTitle;
    try {
      resrcExamTitle = (FileResource) aCtx
          .getResourceObject(EXAM_TITLE_WORDS_FILE);
      File examTitleWordsFile = resrcExamTitle.getFile();
      loadExamTitleWords(examTitleWordsFile);
    } catch (Exception e) {
      throw new ResourceInitializationException(e);
    }
View Full Code Here

    try {
      Object paramValue = aContext
          .getConfigParameterValue("CaseSensitive");
      if (paramValue != null)
        caseSensitive = ((Boolean) paramValue).booleanValue();
      FileResource stopWordsFileName = (FileResource) aContext
          .getResourceObject("StopWordsFile");
      stopWords = readLinesFromFile(stopWordsFileName.getFile()
          .getAbsolutePath());
      FileResource pcsKeyWordFile = (FileResource) aContext
          .getResourceObject("PCSKeyWordFile");
      goWords = readOrderedLinesFromFile(pcsKeyWordFile.getFile()
          .getAbsolutePath());
      FileResource pathOfTrainedModel = (FileResource) aContext
          .getResourceObject("PathOfModel");

      model = svm.svm_load_model(pathOfTrainedModel.getFile()
          .getAbsolutePath());
    } catch (Exception ace) {
      ace.printStackTrace();
    }
  }
View Full Code Here

   /**
    * Reads configuration parameters.
    */
   private void configInit( final UimaContext uimaContext ) throws ResourceInitializationException {
      try {
         final FileResource fResrc = (FileResource) uimaContext.getResourceObject("LookupDescriptor");
         final File descFile = fResrc.getFile();
         _logger.info( "Parsing descriptor: " + descFile.getAbsolutePath() );
         _lookupSpecSet = LookupParseUtilities.parseDescriptor( descFile, uimaContext );
      } catch ( ResourceAccessException raE ) {
         // thrown by uimaContext.getResourceObject
         throw new ResourceInitializationException( raE );
View Full Code Here

      IndexReader indexReader;
      String indexDirAbsPath = null;
      try {

         // ohnlp Bugs tracker ID: 3425014 SNOMED lucene dictionary lookup hardcodes resource path
         FileResource fResrc = (FileResource) aCtx.getResourceObject( SNOMED_CODE_LIST_CONFIG_PARM );
         if ( fResrc == null ) {
            logger.error( "Unable to find config parm " + SNOMED_CODE_LIST_CONFIG_PARM + "." );
         }
         File indexDir = fResrc.getFile();
         indexDirAbsPath = indexDir.getAbsolutePath();

         try {
            logger.info( "Using lucene index: " + indexDir.getAbsolutePath() );
         } catch ( Exception e ) {
View Full Code Here

      // TODO Consider using a parameter for hyphWindow/HyphenDetectionWindow
        //int hyphWindow = ((Integer) getConfigParameterValue("HyphenDetectionWindow")).intValue();
        int hyphWindow = 3;

        try {
            FileResource hyphResrc = (FileResource) uimaContext.getResourceObject("HyphenDictionary");
            File hyphFile = hyphResrc.getFile();
          logger.info("Hyphen dictionary: " + hyphFile.getAbsolutePath());

            tm = new HyphenTextModifierImpl(
                    hyphFile.getAbsolutePath(),
                    hyphWindow);

            FileResource dtdResrc = (FileResource) uimaContext.getResourceObject("DTD");
            dtdFile = dtdResrc.getFile();
          logger.info("DTD: " + dtdFile.getAbsolutePath());
        }
        catch (Exception e) {
            throw new ResourceInitializationException(e);
        }
View Full Code Here

    //    coref_idx = labels[0]==1 ? 0 : 1;

    // Load stop words list
    try {
      stopwords = new HashSet<String>();
      FileResource r = (FileResource) uc.getResourceObject("stopWords");
      Scanner scanner = new Scanner(r.getFile());
      String l;
      while (scanner.hasNextLine()) {
        l = scanner.nextLine().trim();
        if (l.length()==0) continue;
        int i = l.indexOf('|');
        if (i > 0)
          stopwords.add(l.substring(0,i).trim());
        else if (i < 0)
          stopwords.add(l.trim());
      }
      logger.info("Stop words list loaded: " + r.getFile().getAbsolutePath());
      vecCreator = new SvmVectorCreator(stopwords);

      treeFrags = new ArrayList<String>();
      r = (FileResource) uc.getResourceObject("frags");
      if(r != null){
        scanner = new Scanner(r.getFile());
        while(scanner.hasNextLine()){
          String line = scanner.nextLine();
          treeFrags.add(line.split(" ")[1]);
        }
        vecCreator.setFrags(treeFrags);
      }
      logger.info("Tree fragment features loaded: " + r.getFile().getAbsolutePath());
    } catch (Exception e) {
      e.printStackTrace();
      logger.error("Error loading stop words list");
    }
  }
View Full Code Here

   * Reads configuration parameters.
   */
  private void configInit() throws ResourceInitializationException
  {
    try {
    FileResource fResrc = (FileResource) iv_context.getResourceObject("LookupDescriptor");
    File descFile = fResrc.getFile();

      iv_logger.info("Parsing descriptor: " + descFile.getAbsolutePath());
      iv_lookupSpecSet = LookupParseUtilities.parseDescriptor(descFile, iv_context);
    }
    catch (Exception e) {
View Full Code Here

    super.initialize(uc);
   
    // Load stop words list
    try {
      stopwords = new HashSet<String>();
      FileResource r = (FileResource) uc.getResourceObject("stopWords");
      BufferedReader br = new BufferedReader(new FileReader(r.getFile()));
      String l;
      while ((l = br.readLine())!=null) {
        l = l.trim();
        if (l.length()==0) continue;
        int i = l.indexOf('|');
        if (i > 0)
          stopwords.add(l.substring(0,i).trim());
        else if (i < 0)
          stopwords.add(l.trim());
      }
      logger.info("Stop words list loaded: " + r.getFile().getAbsolutePath());
    } catch (Exception e) {
      e.printStackTrace();
      logger.error("Error loading stop words list");
    }
   
View Full Code Here

TOP

Related Classes of org.apache.ctakes.core.resource.FileResource

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.