Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [smila-user] Attributes and annotations

Hi Giorgio,

I'm not sure which object you want to annotate:

1) If you want to annotate the Literal, then you have to add the annotation on the Literal object. There are no Blackboard methods available for doing this. E.g.

	Annotation ann = getBlackboard().createAnnotation(id);
	ann.addAnonValue("emotion value");
	literal.addAnnotation("Emotion", ann);
	getBlackboard().setLiteral(id, p, literal);


2) If you want to set the Annotation on the Attribute you can do this via the Blackboard methods, but you have to use a special Path (this is rather tricky):

    Annotation ann = getBlackboard().createAnnotation(id);
    ann.addAnonValue("emotion value");    
    Path ap = new Path();
    ap.add("Lyrics", PathStep.ATTRIBUTE_ANNOTATION);
    getBlackboard().addAnnotation(id, ap, "Emotion", ann);


Besides this, you make use of a variable blackboard and the method getBlackboard() in your code. You should make sure that both refer to the same object.

Bye,
Daniel

-----Ursprüngliche Nachricht-----
Von: smila-user-bounces@xxxxxxxxxxx [mailto:smila-user-bounces@xxxxxxxxxxx] Im Auftrag von Giorgio Sironi
Gesendet: Dienstag, 18. Mai 2010 15:17
An: Smila project user mailing list
Betreff: [smila-user] Attributes and annotations

I'm having trouble adding a simple attribute and annotation during
tests (extension of DeclarativeServiceTestCase):

final Id id = createBlackboardRecord("source", "item");
Path p = new Path("Lyrics");
final Literal literal = getBlackboard().createLiteral(id);
literal.setStringValue("my lyrics value");
getBlackboard().setLiteral(id, p, literal);
Annotation ann = blackboard.createAnnotation(id);
ann.addAnonValue("emotion value");
blackboard.addAnnotation(id, p, "Emotion", ann);

causes:
java.lang.NullPointerException
	at org.eclipse.smila.blackboard.impl.TransientBlackboardImpl.addAnnotation(TransientBlackboardImpl.java:518)
	at it.polimi.chansonnier.processing.EmotionProcessingService.process(EmotionProcessingService.java:29)
	at it.polimi.chansonnier.core.test.EmotionProcessingServiceTest.testAnnotatesTextWithTheEmotionFound(EmotionProcessingServiceTest.java:24)
        ...
It seems that getAnnotableObject() returns null when it finds the
Lyrics attribute, because attribute.getObjects() is empty. But it
*must* be empty, I have not subattributes in this attribute nor I can
add metadata objects since the blackboard has only Literal-oriented
methods. Maybe I can only create attributes with the record and not
via addition of literals? I just want to add the annotation to this
attribute.

-- 
Giorgio Sironi
Piccolo Principe & Web Engineer
http://giorgiosironi.blogspot.com
http://twitter.com/giorgiosironi
_______________________________________________
smila-user mailing list
smila-user@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/smila-user


Back to the top