Interface AnalysisEngine

    • Field Detail

      • PARAM_NUM_SIMULTANEOUS_REQUESTS

        static final String PARAM_NUM_SIMULTANEOUS_REQUESTS
        Key for the initialization parameter whose value is the number of simultaneous calls to process(CAS) that will be supported. Analysis Engine implementations may use this to create a pool of objects (e.g. Annotators), each of which can process only one request at a time. Applications should be careful about setting this number higher than is necessary, since large pools of objects may increase initialization time and consume resources. Not all analysis engine implementations pay attention to this parameter.

        This value is used as a key in the aAdditionalParams Map that is passed to the initialize(ResourceSpecifier,Map) method.

        See Also:
        Constant Field Values
      • PARAM_TIMEOUT_PERIOD

        static final String PARAM_TIMEOUT_PERIOD
        Key for the initialization parameter whose value is the maximum number of milliseconds to wait for a pooled object (see PARAM_NUM_SIMULTANEOUS_REQUESTS) to become available to serve a process(CAS) request. If the processing has not begun within this time, an exception will be thrown. A value of zero will cause the AnalysisEngine to wait forever. Not all analysis* engine implementations pay attention to this parameter.

        This value is used as a key in the aAdditionalParams Map that is passed to the initialize(ResourceSpecifier,Map) method.

        See Also:
        Constant Field Values
      • PARAM_MBEAN_SERVER

        static final String PARAM_MBEAN_SERVER
        Key for the initialization parameter whose value is a JMX MBeanServer instance, with which this AnalysisEngine will register an MBean that allows monitoring of the AE's performance through JMX. If this is null, the platform MBean Server (Java 1.5 only) will be used.

        This value is used as a key in the aAdditionalParams Map that is passed to the initialize(ResourceSpecifier,Map) method.

        See Also:
        Constant Field Values
      • PARAM_MBEAN_NAME_PREFIX

        static final String PARAM_MBEAN_NAME_PREFIX
        Key for the initialization parameter whose value is a String representing the prefix that will be added to all of the JMX MBean names that are generated by this AE (and its components, if it is an aggregate). This allows an application that has its own MBeans to control how the UIMA MBeans are organized relative to the application's own MBeans.

        The string must be a valid JMX MBean name (although a name with only a domain and no keys is permitted). See http://java.sun.com/j2se/1.5.0/docs/api/javax/management/ObjectName.html for details.

        Examples of valid prefixes are:

        • foo.bar:
        • foo.bar:category=Stuff
        • foo.bar:category=Stuff,type=UIMA

        UIMA will append additional key,value pairs to this prefix. In particular, UIMA uses the key "name" (as the very last component of the MBean name), as well as the keys "p0","p1","p2",etc (to represent the chain of aggregates containing an AE). So the application may not use any of these keys in its prefix.

        This value is used as a key in the aAdditionalParams Map that is passed to the initialize(ResourceSpecifier,Map) method.

        See Also:
        Constant Field Values
    • Method Detail

      • initialize

        boolean initialize​(ResourceSpecifier aSpecifier,
                           Map<String,​Object> aAdditionalParams)
                    throws ResourceInitializationException
        Initializes this Resource from a ResourceSpecifier. Applications do not need to call this method. It is called automatically by the ResourceFactory and cannot be called a second time.

        The AnalysisEngine interface defines several optional parameter that can be passed in the aAdditionalParams Map - see the PARAM constants on this interface.

        Specified by:
        initialize in interface Resource
        Parameters:
        aSpecifier - specifies how to create a resource or locate an existing resource service.
        aAdditionalParams - a Map containing additional parameters. May be null if there are no parameters. Each class that implements this interface can decide what additional parameters it supports.
        Returns:
        true if and only if initialization completed successfully. Reutrns false if the given ResourceSpecifier is not of an appropriate type for this Resource. If the ResourceSpecifier is of an appropriate type but is invalid or if some other failure occurs, an exception should be thrown.
        Throws:
        ResourceInitializationException - if a failure occurs during initialization.
        See Also:
        Resource.initialize(ResourceSpecifier,Map)
      • newCAS

        CAS newCAS()
            throws ResourceInitializationException
        Creates a new Common Analysis System appropriate for this Analysis Engine. An application can pre-populate this CAS, then pass it to the process(CAS) method. Then, when the process method returns, the CAS will contain the results of the analysis.

        Important: CAS creation is expensive, so if at all possible an application should reuse CASes. When a CAS instance is no longer being used, call its CAS.reset() method, which will remove all prior analysis information, and then reuse that same CAS instance for another call to process(CAS).

        Note that the CAS allows multiple subjects of analysis (e.g. documents) and defines a separate "view" for each of them. If your application wants to work with a single subject of analysis, call the method CAS.getCurrentView() and operate on the returned view.

        Returns:
        a new CAS appropriate for this AnalysisEngine.
        Throws:
        ResourceInitializationException - if a CAS could not be created because this AnalysisEngine's CAS metadata (type system, type priorities, or FS indexes) are invalid. Ideally this would be checked at AnalysisEngine initialization time, and it will likely be moved in the future.
      • newJCas

        JCas newJCas()
              throws ResourceInitializationException
        Similar to newCAS() but wraps the new CAS objects with the Java-object-based JCas interface.

        Note: the JCas that is returned is equivalent to what you would get if you called newCAS().getCurrentView().getJCas(). That is, this method returns a view of the default Sofa, NOT a Base CAS.

        Important: CAS creation is expensive, so if at all possible an application should reuse CASes. When a JCas instance is no longer being used, call its JCas.reset() method, which will remove all prior analysis information, and then reuse that same JCas instance for another call to process(JCas).

        Returns:
        a new CAS appropriate for this AnalysisEngine.
        Throws:
        ResourceInitializationException - if a CAS could not be created because this AnalysisEngine's CAS metadata (type system, type priorities, or FS indexes) are invalid. Ideally this would be checked at AnalysisEngine initialization time, and it will likely be moved in the future.
      • process

        ProcessTrace process​(CAS aCAS,
                             ResultSpecification aResultSpec)
                      throws ResultNotSupportedException,
                             AnalysisEngineProcessException
        Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's Capability specification.)

        This version of the process method takes a ResultSpecification as an argument. The ResultSpecification is alist of output types and features that the application wants this AnalysisEngine to produce. If you are going to use the same ResultSpecification for multiple calls to process, it is not recommended to use this method. Instead call setResultSpecification(ResultSpecification) once and then call process(CAS) for each CAS that you want to process.

        Parameters:
        aCAS - the CAS containing the inputs to the processing. Analysis results will also be written to this CAS.
        aResultSpec - a list of outputs that this AnalysisEngine should produce.
        Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
        Throws:
        ResultNotSupportedException - if this AnalysisEngine is not capable of producing the results requested in aResultSpec.
        AnalysisEngineProcessException - if a failure occurs during processing.
      • process

        ProcessTrace process​(CAS aCAS)
                      throws AnalysisEngineProcessException
        Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's Capability specification.)

        This version of process does not take a ResultSpecification parameter. You may specify a ResultSpecification by calling setResultSpecification(ResultSpecification) prior to calling this method.

        Parameters:
        aCAS - the CAS containing the inputs to the processing. Analysis results will also be written to this CAS.
        Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
        Throws:
        AnalysisEngineProcessException - if a failure occurs during processing.
      • process

        void process​(CAS aCAS,
                     ResultSpecification aResultSpec,
                     ProcessTrace aTrace)
              throws ResultNotSupportedException,
                     AnalysisEngineProcessException
        Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's Capability specification.)

        This version of the process method takes a ResultSpecification as an argument. The ResultSpecification is a list of output types and features that the application wants this AnalysisEngine to produce. If you are going to use the same ResultSpecification for multiple calls to process, it is not recommended to use this method. Instead call setResultSpecification(ResultSpecification) once and then call process(CAS) for each CAS that you want to process.

        This version of this method also takes a ProcessTrace object as a parameter. This allows trace events to be written to an existing ProcessTrace rather than a new one.

        Parameters:
        aCAS - the CAS containing the inputs to the processing. Analysis results will also be written to this CAS.
        aResultSpec - a list of outputs that this AnalysisEngine should produce.
        aTrace - the object to which trace events will be recorded
        Throws:
        ResultNotSupportedException - if this AnalysisEngine is not capable of producing the results requested in aResultSpec.
        AnalysisEngineProcessException - if a failure occurs during processing.
      • process

        @Deprecated
        void process​(AnalysisProcessData aProcessData,
                     ResultSpecification aResultSpec)
              throws ResultNotSupportedException,
                     AnalysisEngineProcessException
        Deprecated.
        This is no longer used by the framework and was never intended for users to call. Use {#link #process(CAS)} instead.
        Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's Capability specification.)

        This version of this method is not normally used directly by applications. It is used to call Analysis Engines that are components within an aggregate Analysis Engine, so that they can share all information in the AnalysisProcessData object, which includes the CAS and the ProcessTrace.

        Parameters:
        aResultSpec - a list of outputs that this AnalysisEngine should produce. A null result specification is equivalent to a request for all possible results.
        aProcessData - the data that will be modified during processing. This includes the CAS and the ProcessTrace.
        Throws:
        ResultNotSupportedException - if this AnalysisEngine is not capable of producing the results requested in aResultSpec.
        AnalysisEngineProcessException - if a failure occurs during processing.
      • process

        ProcessTrace process​(JCas aJCas)
                      throws AnalysisEngineProcessException
        Similar to process(CAS) but uses the Java-object-based JCas interface instead of the general CAS interface.
        Parameters:
        aJCas - the JCas containing the inputs to the processing. Analysis results will also be written to this JCas.
        Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
        Throws:
        AnalysisEngineProcessException - if a failure occurs during processing.
      • processAndOutputNewCASes

        CasIterator processAndOutputNewCASes​(CAS aCAS)
                                      throws AnalysisEngineProcessException
        Processes a CAS, possibly producing multiple CASes as a result. The application uses the CasIterator interface to step through the output CASes.

        If this Analysis Engine does not produce output CASes, then the CasIterator will return no elements. You can check if an AnalysisEngine is capable of producing output CASes by checking the OperationalProperties.getOutputsNewCASes() operational property (getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()).

        Once this method is called, the AnalysisEngine "owns" aCAS until such time as the CasIterator.hasNext() method returns false. That is, the caller should not attempt to modify or access the input CAS until it has read all of the elements from the CasIterator. If the caller wants to abort the processing before having read all of the output CASes, it may call CasIterator.release(), which will stop further processing from occurring, and ownership of aCAS will revert to the caller.

        Parameters:
        aCAS - the CAS to be processed
        Returns:
        an object for iterating through any output CASes
        Throws:
        AnalysisEngineProcessException - if a failure occurs during processing
      • processAndOutputNewCASes

        JCasIterator processAndOutputNewCASes​(JCas aJCAS)
                                       throws AnalysisEngineProcessException
        Processes a JCAS, possibly producing multiple JCASes as a result. The application uses the JCasIterator interface to step through the output JCASes.

        If this Analysis Engine does not produce output CASes, then the CasIterator will return no elements. You can check if an AnalysisEngine is capable of producing output CASes by checking the OperationalProperties.getOutputsNewCASes() operational property (getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()).

        Once this method is called, the AnalysisEngine "owns" aJCAS until such time as the JCasIterator.hasNext() method returns false. That is, the caller should not attempt to modify or access the input JCAS until it has read all of the elements from the JCasIterator. outputCASes, it may call JCasIterator.release(), which will stop further processing from occurring, and ownership of aJCAS will revert to the caller.

        Parameters:
        aJCAS - the JCAS to be processed
        Returns:
        an object for iterating through any output JCASes
        Throws:
        AnalysisEngineProcessException - if a failure occurs during processing
      • batchProcessComplete

        void batchProcessComplete()
                           throws AnalysisEngineProcessException
        Notifies this AnalysisEngine that processing of a batch has completed. It is up to the caller to determine the size of a batch. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.
        Throws:
        AnalysisEngineProcessException - if an exception occurs during processing
      • collectionProcessComplete

        void collectionProcessComplete()
                                throws AnalysisEngineProcessException
        Notifies this AnalysisEngine that processing of an entire collection has completed. It is up to the caller to determine when this has occurred. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.

        If this AnalysisEngine is an aggregate, this method will call the collectionProcessComplete method of all components of that aggregate. If the aggregate descriptor declares a fixedFlow or capabilityLanguageFlow, then the components' collectionProcessComplete methods will be called in the order specified by that flow element. Once all components in the flow have been called, any components not declared in the flow will be called, in arbitrary order. If there is no fixedFlow or capabilityLanguageFlow, then all components in the aggregate will be called in arbitrary order.

        Throws:
        AnalysisEngineProcessException - if an exception occurs during processing
      • getLogger

        Logger getLogger()
        Gets the Logger that this Analysis Engine is currently using.
        Specified by:
        getLogger in interface Resource
        Returns:
        this AnalysisEngine's logger
      • setLogger

        void setLogger​(Logger aLogger)
        Sets the Logger that this Analysis Engine will use. If this method is not called, the default logger (UIMAFramework.getLogger()) will be used.
        Specified by:
        setLogger in interface Resource
        Parameters:
        aLogger - the logger for this Analysis Engine to use
      • getFeatureNamesForType

        String[] getFeatureNamesForType​(String aTypeName)
        Gets the names of the features that are defined on one of the CAS types that this AE inputs or outputs. When a AE's capabilities are declared with allAnnotatorFeatures == true, this method can be used to determine all of the feature names.
        Parameters:
        aTypeName - type for which to get features
        Returns:
        an array of feature names. If aTypeName is not defined, null will be returned.
      • getPerformanceTuningSettings

        Properties getPerformanceTuningSettings()
        Gets the performance tuning settings in effect for this Analysis Engine.
        Returns:
        performance tuning settings
      • setResultSpecification

        void setResultSpecification​(ResultSpecification aResultSpec)
        Sets the list of output types and features that the application wants this AnalysisEngine to produce. This is only a guideline. Annotators may use this information to avoid doing unnecessary work, but they are not required to do so.
        Parameters:
        aResultSpec - specifies the list of output types and features that the application is interested in.
      • getManagementInterface

        AnalysisEngineManagement getManagementInterface()
        Gets an object that can be used to do monitoring or management of this AnalysisEngine.
        Returns:
        an object exposing a management interface to this AE