Esempio n. 1
0
  /**
   * @param aContext
   * @throws ResourceInitializationException
   */
  @Override
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    debug("initialize ()");
    super.initialize(aContext);

    GenResourceLoader loader = new GenResourceLoader();

    int i = 0;

    String text = loader.getTextResource2(stopwordFile);

    if (text == null) {
      debug("Input error, unable to read stopword file: " + stopwordFile);
      return;
    }

    stopList = new HashMap<String, Integer>();

    String lines[] = text.split("\\n");

    for (i = 0; i < lines.length; i++) {
      String aWord = lines[i];
      stopList.put(aWord.toLowerCase(), i);
    }

    debug("Loaded " + stopList.size() + " stopwords");
  }
  @Override
  public void initialize(UimaContext c) throws ResourceInitializationException {
    super.initialize(c);

    try {
      nerModelFile =
          new File(
              new URI(
                  AustinMaKeytermExtractor.class
                      .getResource("/ne-en-bio-genetag.HmmChunker")
                      .toString()));
      chunker = (Chunker) AbstractExternalizable.readObject(nerModelFile);
    } catch (IOException e) {
      System.err.println("IOException in creating chunker");
      throw new ResourceInitializationException(
          "Unable to load NER model file", "load_ner_model_error", new Object[] {nerModelFile}, e);
    } catch (ClassNotFoundException e) {
      System.err.println("ClassNotFoundException in creating chunker");
      throw new ResourceInitializationException(
          "Unable to load NER model file", "load_ner_model_error", new Object[] {nerModelFile}, e);
    } catch (URISyntaxException e) {
      e.printStackTrace();
      throw new ResourceInitializationException(
          "Unable to load NER model file", "load_ner_model_error", new Object[] {nerModelFile}, e);
    }

    // Read in the geneDictionary
    geneDictionary = new HashSet<String>();
    try {
      File geneDictionaryFile =
          new File(new URI(AustinMaKeytermExtractor.class.getResource("/ref.dic").toString()));
      BufferedReader reader = new BufferedReader(new FileReader(geneDictionaryFile));
      String line;
      try {
        while ((line = reader.readLine()) != null) geneDictionary.add(line);
      } catch (IOException e) {
        System.err.println("IOException in reading gene dictionary file");
        throw new ResourceInitializationException(
            "Unable to load gene dictionary file", "load_gene_dic_error", new Object[] {}, e);
      }
    } catch (FileNotFoundException e) {
      System.err.println("FileNotFoundException in reading gene dictionary file");
      throw new ResourceInitializationException(
          "Unable to find gene dictionary file", "load_gene_dic_error", new Object[] {}, e);
    } catch (URISyntaxException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
      throw new ResourceInitializationException(
          "Unable to find gene dictionary file", "load_gene_dic_error", new Object[] {}, e1);
    }
  }
 @Override
 public void initialize(UimaContext aContext) throws ResourceInitializationException {
   super.initialize(aContext);
   // initialization part from annotator
   String model = (String) aContext.getConfigParameterValue("TrainedModel");
   modelFile = new File(model);
   try {
     extractor = (Chunker) AbstractExternalizable.readObject(modelFile);
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Esempio n. 4
0
 /**
  * @param aContext
  * @throws ResourceInitializationException
  */
 @Override
 public void initialize(UimaContext aContext) throws ResourceInitializationException {
   debug("initialize ()");
   super.initialize(aContext);
 }