use of org.apache.uima.analysis_engine.AnalysisEngine in project lucene-solr by apache.
the class BasicAEProviderTest method testBasicInitialization.
@Test
public void testBasicInitialization() throws Exception {
AEProvider basicAEProvider = new BasicAEProvider("/uima/TestEntityAnnotatorAE.xml");
AnalysisEngine analysisEngine = basicAEProvider.getAE();
assertNotNull(analysisEngine);
}
use of org.apache.uima.analysis_engine.AnalysisEngine in project lucene-solr by apache.
the class OverridingParamsAEProviderTest method testEmptyMapInitialization.
@Test
public void testEmptyMapInitialization() throws Exception {
AEProvider aeProvider = new OverridingParamsAEProvider("/uima/TestEntityAnnotatorAE.xml", new HashMap<String, Object>());
AnalysisEngine analysisEngine = aeProvider.getAE();
assertNotNull(analysisEngine);
}
use of org.apache.uima.analysis_engine.AnalysisEngine in project stanbol by apache.
the class UIMALocal method processText.
/*
* process a field value executing UIMA the CAS containing it as document
* text - From SOLR.
*/
private JCas processText(String textFieldValue) throws ResourceInitializationException, AnalysisEngineProcessException {
logger.info(new StringBuffer("Analazying text").toString());
/*
* get the UIMA analysis engine
*/
AnalysisEngine ae = aeProvider.getAE();
/*
* create a JCas which contain the text to analyze
*/
JCas jcas = ae.newJCas();
jcas.setDocumentText(textFieldValue);
/*
* perform analysis on text field
*/
ae.process(jcas);
logger.info(new StringBuilder("Text processing completed").toString());
return jcas;
}
use of org.apache.uima.analysis_engine.AnalysisEngine in project tika by apache.
the class CTAKESUtils method getAnalysisEngine.
/**
* Returns a new UIMA Analysis Engine (AE). This method ensures that only
* one instance of an AE is created.
*
* <p>
* 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.
* </p>
*
* @param aeDescriptor
* pathname for XML file including an AnalysisEngineDescription
* that contains all of the information needed to instantiate and
* use an AnalysisEngine.
* @param umlsUser
* UMLS username for NLM database
* @param umlsPass
* UMLS password for NLM database
* @return an Analysis Engine for analyzing unstructured information.
* @throws IOException
* if any I/O error occurs.
* @throws InvalidXMLException
* if the input XML is not valid or does not specify a valid
* ResourceSpecifier.
* @throws ResourceInitializationException
* if a failure occurred during production of the resource.
* @throws URISyntaxException
* if URL of the resource is not formatted strictly according to
* to RFC2396 and cannot be converted to a URI.
*/
public static AnalysisEngine getAnalysisEngine(String aeDescriptor, String umlsUser, String umlsPass) throws IOException, InvalidXMLException, ResourceInitializationException, URISyntaxException {
// UMLS user ID and password.
String aeDescriptorPath = CTAKESUtils.class.getResource(aeDescriptor).toURI().getPath();
// get Resource Specifier from XML
XMLInputSource aeIputSource = new XMLInputSource(aeDescriptorPath);
ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser().parseResourceSpecifier(aeIputSource);
// UMLS user ID and password
if ((umlsUser != null) && (!umlsUser.isEmpty()) && (umlsPass != null) && (!umlsPass.isEmpty())) {
/*
* It is highly recommended that you change UMLS credentials in the
* XML configuration file instead of giving user and password using
* CTAKESConfig.
*/
System.setProperty(CTAKES_UMLS_USER, umlsUser);
System.setProperty(CTAKES_UMLS_PASS, umlsPass);
}
// create AE
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
return ae;
}
use of org.apache.uima.analysis_engine.AnalysisEngine in project lucene-solr by apache.
the class OverridingParamsAEProviderTest method testOverridingParamsInitialization.
@Test
public void testOverridingParamsInitialization() throws Exception {
Map<String, Object> runtimeParameters = new HashMap<>();
runtimeParameters.put("ngramsize", "3");
AEProvider aeProvider = new OverridingParamsAEProvider("/uima/AggregateSentenceAE.xml", runtimeParameters);
AnalysisEngine analysisEngine = aeProvider.getAE();
assertNotNull(analysisEngine);
Object parameterValue = analysisEngine.getConfigParameterValue("ngramsize");
assertNotNull(parameterValue);
assertEquals(Integer.valueOf(3), Integer.valueOf(parameterValue.toString()));
}
Aggregations