Package org.apache.uima.collection

Examples of org.apache.uima.collection.CollectionReaderDescription


    if (filename == null) {
      fail("Unable to find file:" + "descriptors/collection_reader/ExtendedTestFileSystemCollectionReader.xml"
              + "in classloader");
    }
    File collectionReaderDescriptor = new File(filename);
    CollectionReaderDescription collectionReaderDescription = UIMAFramework.getXMLParser()
            .parseCollectionReaderDescription(new XMLInputSource(collectionReaderDescriptor));
    CollectionReader collectionReader = UIMAFramework
            .produceCollectionReader(collectionReaderDescription);
    eeUimaEngine.setCollectionReader(collectionReader);
    initialize(eeUimaEngine, appCtx);
View Full Code Here


    AbstractSection.setVnsHostAndPort(aAe);
    // copy Ae into real descriptors if needed
    getTrueDescriptor();
    // use clones because validation modifies (imports get imported)
    if (isCollectionReaderDescriptor()) {
      CollectionReaderDescription collRdr = (CollectionReaderDescription) collectionReaderDescription
              .clone();
      try {
        collRdr.doFullValidation(createResourceManager());
      } catch (Throwable e) { // all these are Throwable to catch errors like
        // UnsupportedClassVersionError, which happens if the annotator
        // class is compiled for Java 5.0, but the CDE is running Java 1.4.2
        Utility
                .popMessage(
View Full Code Here

  public void runProcessingThread(File inputDir, File outputDir, File aeSpecifierFile,
          String xmlTag, String language, String encoding) {
    try {
      // create and configure collection reader that will read input docs
      CollectionReaderDescription collectionReaderDesc = FileSystemCollectionReader
              .getDescription();
      ConfigurationParameterSettings paramSettings = collectionReaderDesc.getMetaData()
              .getConfigurationParameterSettings();
      paramSettings.setParameterValue(FileSystemCollectionReader.PARAM_INPUTDIR, inputDir
              .getAbsolutePath());
      paramSettings.setParameterValue(FileSystemCollectionReader.PARAM_LANGUAGE, language);
      paramSettings.setParameterValue(FileSystemCollectionReader.PARAM_ENCODING, encoding);
View Full Code Here

      String testDescXml = writer.getBuffer().toString();
      // System.out.println(testDescXml);

      // parse objects from XML (no schema validation)
      InputStream is = new ByteArrayInputStream(testDescXml.getBytes());
      CollectionReaderDescription newDesc = (CollectionReaderDescription) UIMAFramework
              .getXMLParser().parse(new XMLInputSource(is, null));

      // compare
      Assert.assertEquals(mTestDesc, newDesc);
    } catch (Exception e) {
View Full Code Here

      // serialize objects to byte array

      byte[] testDescBytes = SerializationUtils.serialize(mTestDesc);

      // deserialize
      CollectionReaderDescription newDesc = (CollectionReaderDescription) SerializationUtils
              .deserialize(testDescBytes);

      Assert.assertEquals(mTestDesc, newDesc);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
View Full Code Here

   *      org.apache.uima.resource.ResourceSpecifier, java.util.Map)
   */
  public Resource produceResource(Class aResourceClass, ResourceSpecifier aSpecifier,
          Map aAdditionalParams) throws ResourceInitializationException {
    if (aSpecifier instanceof CollectionReaderDescription) {
      CollectionReaderDescription desc = (CollectionReaderDescription) aSpecifier;
     
      //check framework implementation (CollectionReaders only supported in Java)
      String frameworkImpl = desc.getFrameworkImplementation();
      if (frameworkImpl == null || frameworkImpl.length() == 0) {
        throw new ResourceInitializationException(
                ResourceInitializationException.MISSING_FRAMEWORK_IMPLEMENTATION,
                new Object[] { aSpecifier.getSourceUrlString() });
      }
      if (!frameworkImpl.startsWith(Constants.JAVA_FRAMEWORK_NAME)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION,
                new Object[] { desc.getFrameworkImplementation(), aSpecifier.getSourceUrlString() });       
      }
     
      String className = desc.getImplementationName();
     
      if (className == null || className.length() == 0) {
        throw new ResourceInitializationException(
                ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
                new Object[] {aSpecifier.getSourceUrlString()});
View Full Code Here

  public static String makeCollectionReader(String descFileName, boolean shouldCrash,
          String functionName, int errorCount, String exceptionName, int documentCount)
          throws Exception {

    XMLInputSource in = new XMLInputSource(descFileName);
    CollectionReaderDescription crd = UIMAFramework.getXMLParser()
            .parseCollectionReaderDescription(in);
    crd.getCollectionReaderMetaData().getConfigurationParameterSettings().setParameterValue(
            "DocumentCount", new Integer(documentCount));
    // set the function to crash, if desired
    if (shouldCrash) {
      crd.getCollectionReaderMetaData().getConfigurationParameterSettings().setParameterValue(
              "ErrorFunction", functionName);
      crd.getCollectionReaderMetaData().getConfigurationParameterSettings().setParameterValue(
              "ErrorCount", new Integer(errorCount));
      crd.getCollectionReaderMetaData().getConfigurationParameterSettings().setParameterValue(
              "ErrorException", exceptionName);
    }
    File baseDir = JUnitExtension.getFile("CpmTests" + FS + "CpeDesc");

    if (!baseDir.exists()) {
View Full Code Here

   * @throws IOException
   *           if the descriptor could not be read
   */
  public static CollectionReader createReaderFromPath(String descriptorPath,
          Object... configurationData) throws UIMAException, IOException {
    CollectionReaderDescription desc = createReaderDescriptionFromPath(descriptorPath,
            configurationData);
    return UIMAFramework.produceCollectionReader(desc, ResourceManagerFactory.newResourceManager(),
            null);
  }
View Full Code Here

   */
  public static CollectionReader createReader(
          Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
          TypePriorities typePriorities, Object... configurationData)
          throws ResourceInitializationException {
    CollectionReaderDescription desc = createReaderDescription(readerClass, typeSystem, typePriorities,
            configurationData);
    return createReader(desc);
  }
View Full Code Here

   * @throws ResourceInitializationException
   *           if the component could not be initialized
   */
  public static CollectionReader createReader(CollectionReaderDescription desc,
          Object... configurationData) throws ResourceInitializationException {
    CollectionReaderDescription descClone = (CollectionReaderDescription) desc.clone();
    ResourceCreationSpecifierFactory.setConfigurationParameters(descClone, configurationData);
    return UIMAFramework.produceCollectionReader(descClone,
            ResourceManagerFactory.newResourceManager(), null);
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.CollectionReaderDescription

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.