1

Please help.

I have some text " 99285/25 EMERGENCY SE 850.0 650.00 04/05/12

INTERPRET 813.44 $36.00 04/05/12 CARLOS "

I need to tag 650.00 also as Money, Gate automatically picks up $36.00 as Money tag. How do I specify it?

Imports: { import static gate.Utils.*; }
Phase: Number  
Input: Token Number  
Options: control = all  

Macro: AMOUNT_NUMBER
({Token.kind == number}
(({Token.string == ","}|  
{Token.string == "."}  
   )  
   {Token.kind == number}  
  )
Rule: MoneyCurrencyUnit  
  (  
      (AMOUNT_NUMBER)  
  ({Number.majorType == currency_unit})  
  )  
:number --> 
  :number {
  {
  {kind = "number", rule = "MoneyCurrencyUnit"}
}
 catch(InvalidOffsetException e) {
 // not possible
 throw new LuckyException("Invalid offset from annotation");
   }
 }

I'm new using JAPE Grammar please help.

Thank you.

Sanjeev
  • 49
  • 9

1 Answers1

0

If you want to tag 650.00 as Money, you will also tag 813.44 (for example) as Money.

If you really want to do that you just have to modify your JAPE rule to match a Token.kind == number separated by a . or a , with Token.kind == number just after.

In other word, the same thing you did but with an optional currency_unit.

In JAPE, the ? operator allow a pattern in parentheses to be optional. You can probably try this:

Rule: MoneyCurrencyUnit  
  (  
      (AMOUNT_NUMBER)  
  ({Number.majorType == currency_unit})?  
  )