Package org.apache.incubator.uima

Examples of org.apache.incubator.uima.DictionaryDocument


         throws Exception {

      ArrayList<String> dictEntries = new ArrayList<String>();

      // parse the dictionary file and extract the content
      DictionaryDocument dictionaryDoc;
      try {
         dictionaryDoc = DictionaryDocument.Factory.parse(dictionaryFile);
      } catch (Exception ex) {
         throw new DictionaryAnnotatorConfigException(
               "dictionary_annotator_error_parsing_dictionary_file",
               new Object[] { dictionaryFile.getAbsolutePath() }, ex);
      }

      // get dictionary document
      DictionaryDocument.Dictionary dictionary = dictionaryDoc.getDictionary();

      // get dictionary entries
      EntriesDocument.Entries entries = dictionary.getTypeCollection()
            .getEntries();
      EntryDocument.Entry[] entryArray = entries.getEntryArray();
View Full Code Here


   public Dictionary parseDictionaryFile(String dictionaryFilePath,
         InputStream dictionaryFileStream, DictionaryBuilder dictBuilder)
         throws ResourceInitializationException {

      // parse the dictionary file and extract the content
      DictionaryDocument dictionaryDoc;
      try {
         dictionaryDoc = DictionaryDocument.Factory.parse(dictionaryFileStream);
      } catch (Exception ex) {
         throw new DictionaryAnnotatorConfigException(
               "dictionary_annotator_error_parsing_dictionary_file",
               new Object[] { dictionaryFilePath }, ex);
      }

      // validate input file
      ArrayList<XmlError> validationErrors = new ArrayList<XmlError>();
      XmlOptions validationOptions = new XmlOptions();
      validationOptions.setErrorListener(validationErrors);

      boolean isValid = dictionaryDoc.validate(validationOptions);

      // output the errors if the XML is invalid.
      if (!isValid) {
         Iterator<XmlError> iter = validationErrors.iterator();
         StringBuffer errorMessages = new StringBuffer();
         while (iter.hasNext()) {
            errorMessages.append("\n>> ");
            errorMessages.append(iter.next());
         }
         throw new DictionaryAnnotatorConfigException(
               "dictionary_annotator_error_xml_validation", new Object[] {
                     dictionaryFilePath, errorMessages.toString() });
      }

      // get dictionary document
      DictionaryDocument.Dictionary dictionary = dictionaryDoc.getDictionary();

      // get type collection settings
      TypeCollectionDocument.TypeCollection typeCollection = dictionary
            .getTypeCollection();
      DictionaryMetaData dictMetaData = typeCollection.getDictionaryMetaData();
View Full Code Here

TOP

Related Classes of org.apache.incubator.uima.DictionaryDocument

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.