[rules-users] Hello and my first question

Bojan Janisch bojan.janisch at scai.fraunhofer.de
Mon Jan 14 09:28:47 EST 2013


To your questions/marks:

>is anno global?

Not it is not. I've forgot to declare the variable.
The line should be like this:
Annotation anno = new Annotation($NE1 + " " + $NE2);

Annotation is a Type I import and the beginning of the file. 


>Is list global?

Yes list is declared as a global variable. In list I store 
each different annotation, so even if I change an attribute 
to an annotation, I will have only the latest annotation, 
which contains most of the extracted information.


>You don't have any gurantee that the other rule has alread fired and
>added some "Annotation" to "list" and so the remove may fail, and
>you'll get the other Annotation object added later.

There is a guarantee that I have the annotation before I delete it. 

Until there is no Annotation of Anatomy, the second rule will not pass 
the condition, because there exists no annotation with a type of Anatomy.

But maybe you thought there would be no guarantee because I forgot to add
the annotation (created from the first rule) to the list. If so then sorry 
for my mistake, there should also something like:

    list.add(anno);

in the first rule.

----- Ursprüngliche Mail -----
Von: "Wolfgang Laun" <wolfgang.laun at gmail.com>
An: "Rules Users List" <rules-users at lists.jboss.org>
Gesendet: Montag, 14. Januar 2013 13:57:42
Betreff: Re: [rules-users] Hello and my first question

On 14/01/2013, Bojan Janisch <bojan.janisch at scai.fraunhofer.de> wrote:
> Solution:

You may want to review the syntax...

> State of my rules:
>
> rule "Annotate Anatomy"
> when
>     $NE1 : NE(Type.contains("body"))
>     $NE2 : NE(Type.contains("anatomy"))
> then
>     $anno : Annotation($NE1 + " " $NE2);

A pattern, not a statement.
Invalid expression in the parenthesis.

>     anno.setType("Anatomy");

Is anno global?

>     list.add(anno);

Is list global?

> end
>
>
> rule "Add AnatomicSide to Anatomy"
> when
>     $AN : Annotation(Type.contains("Anatomy"))
>     $NE : NE(Type.contains("anatomic"))
> then
>     $anno : Annotation($AN + " " $NE)

As above.

>     anno.setType("Anatomy");
>     list.add(anno);
>     list.remove(AN);

You don't have any gurantee that the other rule has alread fired and
added some "Annotation" to "list" and so the remove may fail, and
you'll get the other Annotation object added later.

It's not quite so simple. Take care!
-W


> end
>
>
> Thanks for solving this problem.
> Janisch
>
> ----- Ursprüngliche Mail -----
> Von: "Wolfgang Laun" <wolfgang.laun at gmail.com>
> An: "Rules Users List" <rules-users at lists.jboss.org>
> Gesendet: Montag, 14. Januar 2013 12:56:58
> Betreff: Re: [rules-users] Hello and my first question
>
> Then the approach depends on the way $NE1, $NE2 and $NE3 are to be added
> to the structured object. If the two or three values need to be
> combined (e.g., concatenated in some specific order), you might use
> two distinct rules as extensions of the common part:
>
> rule "body-anatomy"
> when
>    $NE1 : NE(Type.contains("body"))
>    $NE2 : NE(Type.contains("anatomy"))
> then
> end
>
> rule "body-anatomy anatomic"
> extends  "body-anatomy"
> when
>    $NE3: NE(Type.contains("anatomic"))
> then
>     combine $NE1, $NE2, $NE3 as required, add to...
> end
>
> rule "body-anatomy no anatomic"
> extends  "body-anatomy"
> when
>     not NE(Type.contains("anatomic"))
> then
>     combine $NE1, $NE2 as required, add to...
> end
>
> If $NE1 + $NE2 and $NE3 can be added individually, you might omit the
> third rule and add $NE1 + $NE2 in the first rule. Or use the named
> consequence feature.
>
> -W
>
>
>
> On 14/01/2013, Bojan Janisch <bojan.janisch at scai.fraunhofer.de> wrote:
>> Because the annotation should extract most of the unstructured
>> information,
>> into a structured object. So if there is optionally such an information
>> like
>> an anatomic side, I would want to add this information to my structured
>> object.
>>
>> ----- Ursprüngliche Mail -----
>> Von: "Wolfgang Laun" <wolfgang.laun at gmail.com>
>> An: "Rules Users List" <rules-users at lists.jboss.org>
>> Gesendet: Montag, 14. Januar 2013 12:22:37
>> Betreff: Re: [rules-users] Hello and my first question
>>
>> I take "optional" to mean "don't care whether it is there or not" - so
>> why don't you simply omit this condition?
>>
>> -W
>>
>> On 14/01/2013, Bojan Janisch <bojan.janisch at scai.fraunhofer.de> wrote:
>>> Hello everybody,
>>>
>>> this is my first post and also my first question to you.
>>> I've searched the net for quite some hours now, but don't get any
>>> information regarding optionally conditions.
>>>
>>> I'm using drools to annotate some textobjects and I'm stucking with the
>>> following rule:
>>>
>>> When there are two named entities, one body side and one anatomy in a
>>> text
>>> (they're defined earlier by a textannotating system, so I'm working on
>>> annotated objects) and there is a optionally anatomic side (it contains
>>> generally something like "lateral" oder "medial" and so on), then
>>> generate
>>> me a new annotation.
>>>
>>> So up to now I'm on this state:
>>>
>>> Rule "Anatomic Side"
>>>
>>> when
>>>
>>>  $NE1 : NE(Type.contains("body"))
>>>  $NE2 : NE(Type.contains("anatomy"))
>>>
>>>  //So here starts the problem
>>>  [$NE3 : NE(Type.contains("anatomic"))]
>>>
>>> then
>>>  ...
>>>
>>> How can I set a condition as optionally or is there no such way?
>>>
>>> Thanks everyone to who reads this.
>>> Janisch
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



More information about the rules-users mailing list