public void initialize(UimaContext aContext) throws ResourceInitializationException {
   super.initialize(aContext);

   // initialize annotator logger
   this.logger = getContext().getLogger();

   // default initialization for number format
   this.floatNumberFormat = NumberFormat.getNumberInstance();
   this.integerNumberFormat = NumberFormat.getIntegerInstance();

   // create a concept file parser object
   ConceptFileParser parser = new ConceptFileParser_impl();

   // get UIMA datapath and tokenize it into its elements
   StringTokenizer tokenizer = new StringTokenizer(getContext().getDataPath(), PATH_SEPARATOR);
   ArrayList<File> datapathElements = new ArrayList<File>();
   while (tokenizer.hasMoreTokens()) {
     // add datapath elements to the 'datapathElements' array list
     datapathElements.add(new File(tokenizer.nextToken()));
   }

   // try to resolve the concept file names
   ArrayList<Concept> concepts = new ArrayList<Concept>();
   for (int i = 0; i < conceptFileNames.length; i++) {
     // try to resolve the relative file name with classpath or datapath
     String filename = conceptFileNames[i];
     List<ConceptFile> cfList = new ArrayList<ConceptFile>();
     if (containsWildcardChar(filename)) {
       resolveRelativeWildcardFilePath(filename, datapathElements, cfList);
     } else {
       ConceptFile file = resolveRelativeFilePath(filename, datapathElements);
       // if the current concept file wasn't found, throw an exception
       if (file == null) {
         throw new RegexAnnotatorConfigException("regex_annotator_resource_not_found",
             new Object[] { conceptFileNames[i] });
       }
       cfList.add(file);
       // log concept file path
       this.logger.logrb(Level.CONFIG, "RegExAnnotator", "initialize", MESSAGE_DIGEST,
           "regex_annotator_rule_set_file", new Object[] { file.getFilePath() });

     }

     for (ConceptFile file : cfList) {
       // parse concept file to internal objects
       Concept[] currentConcepts = parser.parseConceptFile(file.getFilePath(), file.getStream());
       try {
         file.getStream().close();
       } catch (IOException e) {
         this.logger.logrb(Level.WARNING, "RegExAnnotator", "initialize", MESSAGE_DIGEST,
             "regex_annotator_error_closing_input_stream", new Object[] { file.getFilePath(),
                 e.getMessage() });
       }
       // add all concepts to the concepts list
       for (int c = 0; c < currentConcepts.length; c++) {
         concepts.add(currentConcepts[c]);
       }
     }
   }

   // get one array that contains all the concepts
   this.regexConcepts = concepts.toArray(new Concept[] {});

   // check duplicate concept names
   HashSet<String> conceptNames = new HashSet<String>(this.regexConcepts.length);
   for (int i = 0; i < this.regexConcepts.length; i++) {
     String name = this.regexConcepts[i].getName();
     // check if concept name was set, if not, skip concept
     if (name == null) {
       continue;
     }
     // concept name was set, check for duplicate concept names
     // duplicate concept names can occurs, just log a warning!
     if (conceptNames.contains(name)) {
       this.logger.logrb(Level.WARNING, "RegExAnnotator", "initialize", MESSAGE_DIGEST,
           "regex_annotator_warning_duplicate_concept_name", new Object[] { name });
     } else {
       // add concept name to the concept name list
       conceptNames.add(name);
     }
   }

   // initialize the regex concepts
   for (int i = 0; i < this.regexConcepts.length; i++) {
     ((Concept_impl) this.regexConcepts[i]).initialize(this.logger);
   }
 }
public void initialize ( UimaContext aContext ) throws ResourceInitializationException { super . initialize ( aContext ) ; this . logger = getContext ( ) . getLogger ( ) ; this . floatNumberFormat = NumberFormat . getNumberInstance ( ) ; this . integerNumberFormat = NumberFormat . getIntegerInstance ( ) ; ConceptFileParser parser = new ConceptFileParser_impl ( ) ; StringTokenizer tokenizer = new StringTokenizer ( getContext ( ) . getDataPath ( ) , PATH_SEPARATOR ) ; ArrayList < File > datapathElements = new ArrayList < File > ( ) ; while ( tokenizer . hasMoreTokens ( ) ) { datapathElements . add ( new File ( tokenizer . nextToken ( ) ) ) ; } ArrayList < Concept > concepts = new ArrayList < Concept > ( ) ; for ( int i = 0 ; i < conceptFileNames . length ; i ++ ) { String filename = conceptFileNames [ i ] ; List < ConceptFile > cfList = new ArrayList < ConceptFile > ( ) ; if ( containsWildcardChar ( filename ) ) { resolveRelativeWildcardFilePath ( filename , datapathElements , cfList ) ; } else { ConceptFile file = resolveRelativeFilePath ( filename , datapathElements ) ; if ( file == null ) { throw new RegexAnnotatorConfigException ( "regex_annotator_resource_not_found" , new Object [ ] { conceptFileNames [ i ] } ) ; } cfList . add ( file ) ; this . logger . logrb ( Level . CONFIG , "RegExAnnotator" , "initialize" , MESSAGE_DIGEST , "regex_annotator_rule_set_file" , new Object [ ] { file . getFilePath ( ) } ) ; } for ( ConceptFile file : cfList ) { Concept [ ] currentConcepts = parser . parseConceptFile ( file . getFilePath ( ) , file . getStream ( ) ) ; try { file . getStream ( ) . close ( ) ; } catch ( IOException e ) { this . logger . logrb ( Level . WARNING , "RegExAnnotator" , "initialize" , MESSAGE_DIGEST , "regex_annotator_error_closing_input_stream" , new Object [ ] { file . getFilePath ( ) , e . getMessage ( ) } ) ; } for ( int c = 0 ; c < currentConcepts . length ; c ++ ) { concepts . add ( currentConcepts [ c ] ) ; } } } this . regexConcepts = concepts . toArray ( new Concept [ ] { } ) ; HashSet < String > conceptNames = new HashSet < String > ( this . regexConcepts . length ) ; for ( int i = 0 ; i < this . regexConcepts . length ; i ++ ) { String name = this . regexConcepts [ i ] . getName ( ) ; if ( name == null ) { continue ; } if ( conceptNames . contains ( name ) ) { this . logger . logrb ( Level . WARNING , "RegExAnnotator" , "initialize" , MESSAGE_DIGEST , "regex_annotator_warning_duplicate_concept_name" , new Object [ ] { name } ) ; } else { conceptNames . add ( name ) ; } } for ( int i = 0 ; i < this . regexConcepts . length ; i ++ ) { ( ( Concept_impl ) this . regexConcepts [ i ] ) . initialize ( this . logger ) ; } }
Performs any startup tasks required by this annotator. This implementation reads the
configuration parameters and compiles the regular expressions.