Hi all,
Could anybody has a solution to the problem I describe below?
Thanks in adv,
Isaac
- What I Want:
set an array of String as a feature and get them
- Phenomenon:
-- Exception occurs and application terminates after executing
System.out.print(person.getCompany_related().toArray())
Exception in thread "main" java.lang.NullPointerException
at org.apache.uima.cas.impl.CASImpl.ll_getFSForRef(CASImpl.java:2745)
-- the content of variable shows "com.sun.jdi.InvocationException
occurred invoking method." after executing
person.setCompany_related(compArray).
This can be seen by using eclipse' debug mode.
- java code
private void extractNeeFromText(String descpath, String htmlBody,
Annotation person) {
XMLInputSource in = null;
try {
in = new XMLInputSource(descpath);
} catch (IOException e) {
e.printStackTrace();
}
AnalysisEngine ae = AnalysisEngineUtil.getAeInstance(in);
ResourceSpecifier specifier = null;
AnalysisEngine ae = null;
try {
specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(
desc);
ae = UIMAFramework.produceAnalysisEngine(specifier);
} catch (InvalidXMLException e) {
e.printStackTrace();
} catch (ResourceInitializationException e) {
e.printStackTrace();
}
JCas jcas = AnalysisEngineUtil.analyzeByAnalysisEngine(ae, htmlBody);
FSIndex index = jcas.getJFSIndexRepository().getAnnotationIndex(
Company.type);
StringArray compArray = new StringArray(jcas, index.size());
FSIterator compIter = index.iterator();
int num_company = 0;
while (compIter.hasNext()) {
Company annot = (Company) compIter.next();
compArray.set(num_company, annot.getLex());
// TODO remove redundunt values
num_company++;
}
person.setCompany_related(compArray);
System.out.println(person.getCompany_related().toArray());
}
- type system desctiption
<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
<name>Person-Wikip_TypeSystemDescriptor</name>
<description></description>
<version>1.0</version>
<vendor>ISAAC</vendor>
<imports>
<import location="../../tae_nee_apacheUima/desc/NamedEntityTypeSystemDescriptor.xml"/>
</imports>
<types>
<typeDescription>
<name>jp.ac.keio.dmc.context.srw.types.PersonWikip</name>
<description>w</description>
<supertypeName>uima.tcas.Annotation</supertypeName>
<features>
<featureDescription>
<name>company_related</name>
<description></description>
<rangeTypeName>uima.cas.StringArray</rangeTypeName>
</featureDescription>
</features>
</typeDescription>
</types>
</typeSystemDescription>
- Referred conversation
http://www.ibm.com/developerworks/forums/thread.jspa?threadID=129534
|