Class AnnotatorTester
- java.lang.Object
-
- org.apache.uima.test.junit_extension.AnnotatorTester
-
public class AnnotatorTester extends java.lang.Object
AnnotatorTester is the helper class to test annotators.
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 keyvoid
changeParameterSetting(java.lang.String groupName, java.lang.String paramName, java.lang.Object paramValue)
change the parameter name for the given analysis enginestatic 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.CAS
createCAS()
Creates a new fresh CAS instance which can be used for testing.static AnalysisEngine
doConfigurationTest(java.lang.String configDescFilePath)
does configuration parameter teststatic CAS
getCASfromXCAS(java.io.File tsFile, java.io.File xcasFile)
create a CAS object from the given XCAS and typesystem filesCAS
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.CAS
performTest(CAS cas)
performs a test on the initialized annotator.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.
-
-
-
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
- passthru 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
- passthru 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 pathmgr
- 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 nullparamName
- parameter nameparamValue
- parameter value- Throws:
ResourceConfigurationException
- passthru
-
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 keygroupName
- group nameparamName
- parameter nameparamValue
- parameter value- Throws:
InvalidXMLException
- passthruResourceInitializationException
- passthrujava.io.IOException
- passthru
-
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
- passthru
-
createCAS
public CAS createCAS() throws java.lang.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:
java.lang.Exception
- passthru
-
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 textlanguage
- the document text language- Returns:
- CAS - results of the analysis
- Throws:
java.lang.Exception
- passthru
-
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
- passthru
-
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 pathtext
- a document textlanguage
- the document text language- Returns:
- CAS - results of the analysis
- Throws:
java.lang.Exception
- passthru
-
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 filexcasFile
- - a xcas file- Returns:
- CAS - CAS object created from the given input data
- Throws:
java.lang.Exception
- passthru
-
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 sourceencoding
- file encoding- Returns:
- String - file content
- Throws:
java.lang.Exception
- passthru
-
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 dataAnnotationTypes
- respected annotation typesrefFile
- reference outputtestFile
- test file for the current output- Throws:
java.lang.Exception
- passthru
-
-