Package org.apache.uima.annotator.regex

Examples of org.apache.uima.annotator.regex.ConceptFileParser


      // 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 configuration parameter settings
      // get parameter ConceptFiles, default is an empty array
      String[] conceptFileNames = safeGetConfigParameterStringArrayValue(
            getContext(), REGEX_CONCEPTS_FILES, new String[] {});

      // 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
         ConceptFile file = resolveRelativeFilePath(conceptFileNames[i],
               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] });
         } else {
            // log concept file path
            this.logger.logrb(Level.CONFIG, "RegExAnnotator", "initialize",
                  MESSAGE_DIGEST, "regex_annotator_rule_set_file",
                  new Object[] { file.getFilePath() });

            // parse concept file to internal objects
            Concept[] currentConcepts = parser.parseConceptFile(file
                  .getFilePath(), file.getStream());
            // add all concepts to the concepts list
            for (int c = 0; c < currentConcepts.length; c++) {
               concepts.add(currentConcepts[c]);
            }
View Full Code Here


    // 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 configuration parameter settings
    // get parameter ConceptFiles, default is an empty array
    String[] conceptFileNames = safeGetConfigParameterStringArrayValue(getContext(),
        REGEX_CONCEPTS_FILES, new String[] {});

    // 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(),
View Full Code Here

TOP

Related Classes of org.apache.uima.annotator.regex.ConceptFileParser

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.