Don't melt on your computer with your 30° ! :)
Thanks to keep it in touch.
if it can help, here comes my test class in mail (strange that you don't
get it, ml return it in my mail-box) :
===== begin class
package OpenCalais;
import java.io.PrintStream;
import org.apache.clerezza.uima.utils.ExternalServicesFacade;
import org.apache.uima.jcas.tcas.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Iterator;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.FloatArrayFS;
import org.apache.uima.cas.IntArrayFS;
import org.apache.uima.cas.StringArrayFS;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
ExternalServicesFacade esf = new ExternalServicesFacade();
//String document = "Algeria 0-1 Slovenia - Group C - Polokwane. The
Balkan nation claimed their first World Cup win and went top of Group C
after Robert Koren’s late shot somehow evaded goalkeeper Faouzi Chaouchi
and found the right corner. While not on a par with Robert Green’s howler,
it was a bad mistake by Chaouchi. Algeria blamed the Jabulani ball (Lionel
Messi has also now spoken against it) but the replay showed no major
movement in the air.";
//String document ="Algeria The Balkan nation claimed their first World
Cup win and went top of Group C";
String document =" Photographie des ultimes annonces et rumeurs données
par nos confrères les plus en pointe, partout en Europe. Après avoir
recruté Jimmy Briand, Lyon pourrait s'atttacher les services d'Adil Rami.
Taye Taiwo intéresse Sunderland. West Ham a coché le nom du Stéphanois
Bergessio.";
try{
List<Annotation> annotations = esf.getCalaisAnnotations(document);
System.out.println("taille liste
"+Integer.toString(annotations.size()));
for (Annotation anno : annotations){
/*System.out.println("Debut d'une nouvelle annotation");
System.out.println("-- texte couvert --");
System.out.println(anno.getCoveredText());
System.out.println("commes displays");
*/
printFS(anno, anno.getCAS(), 2, System.out);
}
}
catch(Exception e){
System.out.println("In exception");
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Message");
System.out.println(e.getMessage());
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Cause");
System.out.println(e.getCause());
}
System.out.println("###### Ouhaou ! the end of code !!###");
}
//code import for
sources2/uimaj/uimaj-examples/src/main/java/org/apache/uima/examples/PrintAnnotations.java
/**
* Prints a FeatureStructure to a PrintStream.
*
* @param aFS
* the FeatureStructure to print
* @param aCAS
* the CAS containing the FeatureStructure
* @param aNestingLevel
* number of tabs to print before each line
* @param aOut
* the PrintStream to which output will be written
*/
public static void printFS(FeatureStructure aFS, CAS aCAS, int
aNestingLevel, PrintStream aOut) {
Type stringType = aCAS.getTypeSystem().getType(CAS.TYPE_NAME_STRING);
printTabs(aNestingLevel, aOut);
aOut.println(aFS.getType().getName());
// if it's an annotation, print the first 64 chars of its covered text
if (aFS instanceof AnnotationFS) {
AnnotationFS annot = (AnnotationFS) aFS;
String coveredText = "** BUG, getBegin and getEnd are out of bound
(<0), so getCoveredText throw an error";//annot.getCoveredText();
//si begin >0 alors on initialise le coveredText, sinon affichage du
bug
if (annot.getBegin() > 0){
coveredText = annot.getCoveredText();
}
printTabs(aNestingLevel + 1, aOut);
aOut.print("\"");
if (coveredText.length() <= 64) {
aOut.print(coveredText);
} else {
aOut.println(coveredText.substring(0, 64) + "...");
}
aOut.println("\"");
}
// print all features
List aFeatures = aFS.getType().getFeatures();
Iterator iter = aFeatures.iterator();
while (iter.hasNext()) {
Feature feat = (Feature) iter.next();
printTabs(aNestingLevel + 1, aOut);
// print feature name
aOut.print(feat.getShortName());
aOut.print(" = ");
// prnt feature value (how we get this depends on feature's range
type)
String rangeTypeName = feat.getRange().getName();
if (aCAS.getTypeSystem().subsumes(stringType, feat.getRange())) //
must check for subtypes of
//
string
{
String str = aFS.getStringValue(feat);
if (str == null) {
aOut.println("null");
} else {
aOut.print("\"");
if (str.length() > 64) {
str = str.substring(0, 64) + "...";
}
aOut.print(str);
aOut.println("\"");
}
} else if (CAS.TYPE_NAME_INTEGER.equals(rangeTypeName)) {
aOut.println(aFS.getIntValue(feat));
} else if (CAS.TYPE_NAME_FLOAT.equals(rangeTypeName)) {
aOut.println(aFS.getFloatValue(feat));
} else if (CAS.TYPE_NAME_STRING_ARRAY.equals(rangeTypeName)) {
StringArrayFS arrayFS = (StringArrayFS) aFS.getFeatureValue(feat);
if (arrayFS == null) {
aOut.println("null");
} else {
String[] vals = arrayFS.toArray();
aOut.print("[");
for (int i = 0; i < vals.length - 1; i++) {
aOut.print(vals[i]);
aOut.print(',');
}
if (vals.length > 0) {
aOut.print(vals[vals.length - 1]);
}
aOut.println("]\"");
}
} else if (CAS.TYPE_NAME_INTEGER_ARRAY.equals(rangeTypeName)) {
IntArrayFS arrayFS = (IntArrayFS) aFS.getFeatureValue(feat);
if (arrayFS == null) {
aOut.println("null");
} else {
int[] vals = arrayFS.toArray();
aOut.print("[");
for (int i = 0; i < vals.length - 1; i++) {
aOut.print(vals[i]);
aOut.print(',');
}
if (vals.length > 0) {
aOut.print(vals[vals.length - 1]);
}
aOut.println("]\"");
}
} else if (CAS.TYPE_NAME_FLOAT_ARRAY.equals(rangeTypeName)) {
FloatArrayFS arrayFS = (FloatArrayFS) aFS.getFeatureValue(feat);
if (arrayFS == null) {
aOut.println("null");
} else {
float[] vals = arrayFS.toArray();
aOut.print("[");
for (int i = 0; i < vals.length - 1; i++) {
aOut.print(vals[i]);
aOut.print(',');
}
if (vals.length > 0) {
aOut.print(vals[vals.length - 1]);
}
aOut.println("]\"");
}
} else // non-primitive type
{
FeatureStructure val = aFS.getFeatureValue(feat);
if (val == null) {
aOut.println("null");
} else {
printFS(val, aCAS, aNestingLevel + 1, aOut);
}
}
}
}
/**
* Prints tabs to a PrintStream.
*
* @param aNumTabs
* number of tabs to print
* @param aOut
* the PrintStream to which output will be written
*/
private static void printTabs(int aNumTabs, PrintStream aOut) {
for (int i = 0; i < aNumTabs; i++) {
aOut.print("\t");
}
}
}
===== end class
cheers
On Wed, 16 Jun 2010 12:10:02 +0200, Tommaso Teofili
<[email protected]> wrote:
> I am pretty sure it's a bug in OpenCalaisAnnotator (UIMA side), I ran
> OpenCalaisAnnotator with CasVisualDebugger for the text:
> President Obama vows to "make BP pay" for the Gulf oil spill, and says
the
> US must end its fossil fuel "addiction" (first snippet on BBC website
> today)
> and got 2 Annotations of type org.apache.uima.calais.Company, the first
one
> with the "fancy" -7 begin and end.
> I'll open an issue on UIMA for this one (and hopefully fix it) later
today.
> Cheers,
> Tommaso
>
> still inspecting on what it's causing it.
> Cheers,
> Tommaso
>
> 2010/6/16 Tommaso Teofili <[email protected]>
>
>> Hi Florent,
>> I managed to reproduce your same error, now inspecting.
>> I'll let you know.
>> Thanks,
>> Tommaso
>>
>> 2010/6/16 Tommaso Teofili <[email protected]>
>>
>> Hi Florent
>>>
>>> 2010/6/16 Florent André <[email protected]>
>>>
>>> Hi Tommaso, Hi all,
>>>>
>>>> Hope you have a more real summer weather that us...
>>>>
>>>
>>> Yes, we have real warm sunny days at 30°C average :)
>>>
>>>
>>>>
>>>> $ sudo history | grep "useful part" :
>>>>
>>>> On Sun, 30 May 2010 16:39:06 +0200, Tommaso Teofili
>>>> <[email protected]> wrote:
>>>> > 2010/5/30 Oliver Strässer <[email protected]>
>>>> >>
>>>> >> Maybe we can begin the "getting started" page here ? :)
>>>> >> Here comes my "really just user" questions :
>>>> >>
>>>> >> A/ How to use OpenCalais and AlchemyAPI services ?
>>>> >>
>>>> >
>>>> > There is the UIMA integration which uses AlchemyAPI and OpenCalais
to
>>>> > enrich
>>>> > graphnodes, documentation still needs to be done, I'll do it as
soon
>>>> > as
>>>> > possible but firstly I think we need to write an ontology for
>>>> > generated
>>>> > UIMA
>>>> > entities (I am doing this at the moment but I think that if Oliver
>>>> > has
>>>> > already something in place it would be nice to have a look) so that
>>>> > the
>>>> > graph gets enrihced in a proper RDF way.
>>>> >
>>>> > Take a look at this in the meantime:
>>>> >
>>>>
>>>>
http://svn.apache.org/repos/asf/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.uima/org.apache.clerezza.uima.metadata-generator/src/main/java/org/apache/clerezza/uima/metadatagenerator/UIMABaseMetadataGenerator.java
>>>> > and at
>>>> >
>>>>
>>>>
http://svn.apache.org/repos/asf/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.uima/org.apache.clerezza.uima.utils/src/main/java/org/apache/clerezza/uima/utils/ExternalServicesFacade.java
>>>> >
>>>>
>>>>
>>>> I try (and get) a result from ExternalServicesFacade. I have a
>>>> List<Annotation> result from esf.getCalaisAnnotations(document).
>>>>
>>>> But the problem is that I can't use the annot.getCoveredText() on the
2
>>>> firsts of the list because annot.begin() and annot.end() contains -7.
>>>> So
>>>> annot.getCoveredText() send an outOfBound error...
>>>>
>>>
>>> It's a strange behavior since tests on ESF involve also a call to
>>> annot.getCoveredText() to control text inside it, without arising any
>>> issue.
>>> Could you paste here which text do you pass to ESF as a parameter?
>>>
>>>
>>>>
>>>> As I'm not really involve in Clerezza and uima structure for now, do
>>>> you
>>>> have suggestion for this error ? It's a bug ? If yes more Clerezza
part
>>>> or
>>>> uima one ?
>>>>
>>>
>>> Could you explain better the use case where the method call arises
this
>>> issue?
>>>
>>>
>>>>
>>>> My test class in attachment if any (code on a motorcycle :) ).
>>>>
>>>
>>> I can't find any test class in attachment (or maybe I misunderstood
what
>>> you mean :P).
>>> However I am doing some tests to see what could cause such a issue
both
>>> on
>>> UIMA and Clerezza UIMA modules.
>>> Cheers.
>>> Tommaso
>>>
>>>
>>>
>>>>
>>>> Have a good day.
>>>>
>>>>
>>>
>>