I have a set of documents and each document has different heading. Example if document heading says "Psychological Evaluation" I want to tag the document as "Medicalrule".
- I loaded the document and loaded ANNIE with defaults.
- In Processing Resources > New > Jape Transducer 2.1 wrote the following code in the text document and saved it as .JAPE extension
CODE :
Phase: ConjunctionIdentifier
Input: Token Split
Rule: Medicalrule
(
({Token.string=="Psychological"})+({Token.string == " "})+ ({Token.string == "Evaluation"}):Meddoc({Token.kind=="word"})
)
-->
:Meddoc
{
gate.AnnotationSet matchedAnns= (gate.AnnotationSet) bindings.get("Meddoc"); gate.FeatureMap newFeatures= Factory.newFeatureMap();newFeatures.put("rule","Medicalrule");annotations.add(matchedAnns.firstNode(),matchedAnns.lastNode(),"CC", newFeatures);
}
- Loaded the above created .JAPE file and reinitialized
After the application is run the Annotation Set does not show the tag !
Am I doing wrong somewhere ?It would be great if someone could help me on this.
Appreciate your time.
Thank you
There are three issues I can see here.
Token
annotations - this is deliberate as in most cases you don't care about the spacing between words, only the words themselves.({Token.kind=="word"})
means that the rule will only match when "Psychological Evaluation" is followed by another word before the end of the current sentence (because you've gotSplit
in the Input line).Meddoc
label to the "Evaluation" token, not to the whole match.I would try and simplify the LHS of the rule:
and for the RHS (a) you don't need to do the explicit
bindings.get
because you've used a labelled block so you already have the bound annots available, (b) you should useoutputAS
instead ofannotations
, and (c) you should generally avoid theadd
method that takes nodes, as it isn't safe if the input and output annotation sets are different. If you're using a recent snapshot of GATE then thegate.Utils
static methods can help you a lot hereIf you're using 7.1 or earlier then the
addAnn
method isn't available so it's slightly more convoluted:Finally, just to check, you did definitely add your new JAPE Transducer PR to the end of the pipeline?