2

Below JAPE rule will replace the Email annotation by Address or just add an extra annotation Address ?

Rule: EmailFinal
Priority: 50
(
{Email}
)
:address
-->
:address.Address = {kind = "email", rule = "EmailFinal"}
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
Anuj Jain
  • 245
  • 1
  • 2
  • 5

1 Answers1

2

A :label.Type = {...} will always create a new annotation, but it won't touch the existing ones. If you want to delete the input annotation then you need to add a second action to your rule:

Rule: EmailFinal
Priority: 50
(
{Email}
)
:address
-->
:address.Address = {kind = "email", rule = "EmailFinal"},
:address { inputAS.removeAll(addressAnnots); }
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • Wau `inputAS.removeAll(addressAnnots);` is a great shortcut for the old way using `bindings`. – dedek Nov 19 '15 at 08:38
  • @dedek yes, labelled blocks `:label { ... }` are a handy shorthand - it gives you an automatic variable `labelAnnots` inside the block equivalent to `bindings.get("label")`, _and_ the block is guaranteed to run only in cases where that set is not empty. – Ian Roberts Nov 19 '15 at 11:54