Class AnnotatorTester


  • public class AnnotatorTester
    extends Object
    AnnotatorTester is the helper class to test annotators.
    • Constructor Detail

      • AnnotatorTester

        public AnnotatorTester​(String descFilePath)
                        throws Exception
        Constructor save the specified descriptor file path and initialize the analysis engine.
        Parameters:
        descFilePath - descriptor file path
        Throws:
        Exception - passthru if an analysis engine initialize error occurs.
      • AnnotatorTester

        public AnnotatorTester​(File descFile)
                        throws Exception
        Constructor save the specified descriptor file path and initialize the analysis engine.
        Parameters:
        descFile - descriptor file
        Throws:
        Exception - passthru if an analysis engine initialize error occurs.
      • AnnotatorTester

        public AnnotatorTester​(String descFilePath,
                               ResourceManager mgr)
                        throws Exception
        Constructor save the specified descriptor file path and initialize the analysis engine.
        Parameters:
        descFilePath - descriptor file path
        mgr - a ResourceManager
        Throws:
        Exception - if an analysis engine initialize error occurs.
    • Method Detail

      • changeParameterSetting

        public void changeParameterSetting​(String groupName,
                                           String paramName,
                                           Object paramValue)
                                    throws ResourceConfigurationException
        change the parameter name for the given analysis engine
        Parameters:
        groupName - group name, if no group is available, pass null
        paramName - parameter name
        paramValue - parameter value
        Throws:
        ResourceConfigurationException - passthru
      • doConfigurationTest

        public static AnalysisEngine doConfigurationTest​(String configDescFilePath)
                                                  throws Exception
        does configuration parameter test
        Parameters:
        configDescFilePath -
        Returns:
        AnalysisEngine
        Throws:
        Exception - passthru
      • createCAS

        public CAS createCAS()
                      throws Exception
        Creates a new fresh CAS instance which can be used for testing.
        Returns:
        a new fresh CAS instance which can be used for testing
        Throws:
        Exception - passthru
      • performTest

        public CAS performTest​(String text,
                               String language)
                        throws Exception
        performs a test on the initialized annotator. The specified document is processed with the given language.
        Parameters:
        text - a document text
        language - the document text language
        Returns:
        CAS - results of the analysis
        Throws:
        Exception - passthru
      • performTest

        public CAS performTest​(CAS cas)
                        throws Exception
        performs a test on the initialized annotator. The specified CAS is processed and the results are returned.
        Parameters:
        cas - a CAS for processing
        Returns:
        CAS - results of the analysis
        Throws:
        Exception - passthru
      • performTest

        public static CAS performTest​(String descFilePath,
                                      String text,
                                      String language)
                               throws Exception
        performs a test with a special annotator configuration. For this a new AE is created and used to process the specified document for the specified language.
        Parameters:
        descFilePath - Descriptor file path
        text - a document text
        language - the document text language
        Returns:
        CAS - results of the analysis
        Throws:
        Exception - passthru
      • getCASfromXCAS

        public static CAS getCASfromXCAS​(File tsFile,
                                         File xcasFile)
                                  throws Exception
        create a CAS object from the given XCAS and typesystem files
        Parameters:
        tsFile - - a typesystem file
        xcasFile - - a xcas file
        Returns:
        CAS - CAS object created from the given input data
        Throws:
        Exception - passthru
      • readFileContent

        public static String readFileContent​(File file,
                                             String encoding)
                                      throws Exception
        Reads the content form a file to a String with respect to the file encoding.
        Parameters:
        file - a file with the source
        encoding - file encoding
        Returns:
        String - file content
        Throws:
        Exception - passthru
      • checkResult

        public static void checkResult​(CAS cas,
                                       String[] AnnotationTypes,
                                       File refFile,
                                       File testFile)
                                throws Exception
        checkResult compares the analyzed document with the reference output.
        Parameters:
        cas - a cas with the analyzed data
        AnnotationTypes - respected annotation types
        refFile - reference output
        testFile - test file for the current output
        Throws:
        Exception - passthru