org.apache.uima.test.junit_extension
Class AnnotatorTester

java.lang.Object
  extended by org.apache.uima.test.junit_extension.AnnotatorTester

public class AnnotatorTester
extends java.lang.Object

AnnotatorTester is the helper class to test annotators.


Constructor Summary
AnnotatorTester(java.io.File descFile)
          Constructor save the specified descriptor file path and initialize the analysis engine.
AnnotatorTester(java.lang.String descFilePath)
          Constructor save the specified descriptor file path and initialize the analysis engine.
AnnotatorTester(java.lang.String descFilePath, ResourceManager mgr)
          Constructor save the specified descriptor file path and initialize the analysis engine.
 
Method Summary
 void changeDelegateParameterSetting(java.lang.String delegeteKey, java.lang.String groupName, java.lang.String paramName, java.lang.Object paramValue)
          change the parameter name for the given delegate analysis engine key
 void changeParameterSetting(java.lang.String groupName, java.lang.String paramName, java.lang.Object paramValue)
          change the parameter name for the given analysis engine
static void checkResult(CAS cas, java.lang.String[] AnnotationTypes, java.io.File refFile, java.io.File testFile)
          checkResult compares the analyzed document with the reference output.
static AnalysisEngine doConfigurationTest(java.lang.String configDescFilePath)
          does configuration parameter test
static CAS getCASfromXCAS(java.io.File tsFile, java.io.File xcasFile)
          create a CAS object from the given XCAS and typesystem files
 CAS performTest(CAS cas)
          performs a test on the initialized annotator.
 CAS performTest(java.lang.String text, java.lang.String language)
          performs a test on the initialized annotator.
static CAS performTest(java.lang.String descFilePath, java.lang.String text, java.lang.String language)
          performs a test with a special annotator configuration.
static java.lang.String readFileContent(java.io.File file, java.lang.String encoding)
          Reads the content form a file to a String with respect to the file encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotatorTester

public AnnotatorTester(java.lang.String descFilePath)
                throws java.lang.Exception
Constructor save the specified descriptor file path and initialize the analysis engine.

Parameters:
descFilePath - descriptor file path
Throws:
java.lang.Exception - if an analysis engine initialize error occurs.

AnnotatorTester

public AnnotatorTester(java.io.File descFile)
                throws java.lang.Exception
Constructor save the specified descriptor file path and initialize the analysis engine.

Parameters:
descFile - descriptor file
Throws:
java.lang.Exception - if an analysis engine initialize error occurs.

AnnotatorTester

public AnnotatorTester(java.lang.String descFilePath,
                       ResourceManager mgr)
                throws java.lang.Exception
Constructor save the specified descriptor file path and initialize the analysis engine.

Parameters:
descFilePath - descriptor file path
mgr - a ResourceManager
Throws:
java.lang.Exception - if an analysis engine initialize error occurs.
Method Detail

changeParameterSetting

public void changeParameterSetting(java.lang.String groupName,
                                   java.lang.String paramName,
                                   java.lang.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

changeDelegateParameterSetting

public void changeDelegateParameterSetting(java.lang.String delegeteKey,
                                           java.lang.String groupName,
                                           java.lang.String paramName,
                                           java.lang.Object paramValue)
                                    throws InvalidXMLException,
                                           ResourceInitializationException,
                                           java.io.IOException
change the parameter name for the given delegate analysis engine key

Parameters:
delegeteKey - analysis engine key
groupName - group name
paramName - parameter name
paramValue - parameter value
Throws:
InvalidXMLException
ResourceInitializationException
java.io.IOException

doConfigurationTest

public static AnalysisEngine doConfigurationTest(java.lang.String configDescFilePath)
                                          throws java.lang.Exception
does configuration parameter test

Parameters:
configDescFilePath -
Returns:
AnalysisEngine
Throws:
java.lang.Exception

performTest

public CAS performTest(java.lang.String text,
                       java.lang.String language)
                throws java.lang.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:
java.lang.Exception

performTest

public CAS performTest(CAS cas)
                throws java.lang.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:
java.lang.Exception

performTest

public static CAS performTest(java.lang.String descFilePath,
                              java.lang.String text,
                              java.lang.String language)
                       throws java.lang.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:
java.lang.Exception

getCASfromXCAS

public static CAS getCASfromXCAS(java.io.File tsFile,
                                 java.io.File xcasFile)
                          throws java.lang.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:
java.lang.Exception

readFileContent

public static java.lang.String readFileContent(java.io.File file,
                                               java.lang.String encoding)
                                        throws java.lang.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:
java.lang.Exception

checkResult

public static void checkResult(CAS cas,
                               java.lang.String[] AnnotationTypes,
                               java.io.File refFile,
                               java.io.File testFile)
                        throws java.lang.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:
java.lang.Exception


Copyright © 2012. All Rights Reserved.