public class CTAKESUtils extends Object
CTAKESContentHandler
that relies on Apache cTAKES.
Apache cTAKES is built on top of Apache UIMA framework and OpenNLP toolkit.
Constructor and Description |
---|
CTAKESUtils() |
Modifier and Type | Method and Description |
---|---|
static org.apache.uima.analysis_engine.AnalysisEngine |
getAnalysisEngine(String aeDescriptor,
String umlsUser,
String umlsPass)
Returns a new UIMA Analysis Engine (AE).
|
static String |
getAnnotationProperty(org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation annotation,
CTAKESAnnotationProperty property)
Returns the annotation value based on the given annotation type.
|
static org.apache.uima.jcas.JCas |
getJCas(org.apache.uima.analysis_engine.AnalysisEngine ae)
Returns a new JCas () appropriate for the given Analysis Engine.
|
static void |
reset(org.apache.uima.analysis_engine.AnalysisEngine ae,
org.apache.uima.jcas.JCas jcas)
Resets cTAKES objects, if created.
|
static void |
resetAE(org.apache.uima.analysis_engine.AnalysisEngine ae)
Resets the AE (AnalysisEngine), releasing all resources held by the
current AE.
|
static void |
resetCAS(org.apache.uima.jcas.JCas jcas)
Resets the CAS (Common Analysis System), emptying it of all content.
|
static void |
serialize(org.apache.uima.jcas.JCas jcas,
CTAKESSerializer type,
boolean prettyPrint,
OutputStream stream)
Serializes a CAS in the given format.
|
public static org.apache.uima.analysis_engine.AnalysisEngine getAnalysisEngine(String aeDescriptor, String umlsUser, String umlsPass) throws IOException, org.apache.uima.util.InvalidXMLException, org.apache.uima.resource.ResourceInitializationException, URISyntaxException
An Analysis Engine is a component responsible for analyzing unstructured information, discovering and representing semantic content. Unstructured information includes, but is not restricted to, text documents.
aeDescriptor
- pathname for XML file including an AnalysisEngineDescription
that contains all of the information needed to instantiate and
use an AnalysisEngine.umlsUser
- UMLS username for NLM databaseumlsPass
- UMLS password for NLM databaseIOException
- if any I/O error occurs.org.apache.uima.util.InvalidXMLException
- if the input XML is not valid or does not specify a valid
ResourceSpecifier.org.apache.uima.resource.ResourceInitializationException
- if a failure occurred during production of the resource.URISyntaxException
- if URL of the resource is not formatted strictly according to
to RFC2396 and cannot be converted to a URI.public static org.apache.uima.jcas.JCas getJCas(org.apache.uima.analysis_engine.AnalysisEngine ae) throws org.apache.uima.resource.ResourceInitializationException
Important: It is highly recommended that you reuse CAS objects rather than creating new CAS objects prior to each analysis. This is because CAS objects may be expensive to create and may consume a significant amount of memory.
ae
- AnalysisEngine used to create an appropriate JCas object.org.apache.uima.resource.ResourceInitializationException
- if a CAS could not be created because this AnalysisEngine's
CAS metadata (type system, type priorities, or FS indexes)
are invalid.public static void serialize(org.apache.uima.jcas.JCas jcas, CTAKESSerializer type, boolean prettyPrint, OutputStream stream) throws SAXException, IOException
jcas
- CAS (Common Analysis System) to be serialized.type
- type of cTAKES (UIMA) serializer used to write CAS.prettyPrint
- true
to do pretty printing of output.stream
- OutputStream
object used to print out information
extracted by using cTAKES.SAXException
- if there was a SAX exception.IOException
- if any I/O error occurs.public static String getAnnotationProperty(org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation annotation, CTAKESAnnotationProperty property)
annotation
- IdentifiedAnnotation
object.property
- CTAKESAnnotationProperty
enum used to identify the
annotation type.public static void reset(org.apache.uima.analysis_engine.AnalysisEngine ae, org.apache.uima.jcas.JCas jcas)
ae
- UIMA Analysis Enginejcas
- JCas objectpublic static void resetCAS(org.apache.uima.jcas.JCas jcas)
jcas
- JCas objectpublic static void resetAE(org.apache.uima.analysis_engine.AnalysisEngine ae)
ae
- UIMA Analysis EngineCopyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.