Jape Grammer Rule Runs infinitely in Annie

21 Views Asked by At

My jape grammer looks as below,

Phase: PhoneFinder
Input: Token
Options: control = appelt debug = false
Rule: PhoneRule
(
 {Token.kind == number,Token.category == CD,Token.length == 10}
 |
  (
   ({Token.kind == punctuation, Token.category == "("})? 
   ({Token.kind == number, Token.category == CD})?
   ({Token.kind == punctuation, Token.category == ")"})?
   ({Token.kind == punctuation, Token.category == ":"})?
   ({Token.kind == number, Token.category == CD})?
   ({Token.kind == punctuation, Token.category == ":"})?
   ({Token.kind == number, Token.category == CD})?
   ({Token.kind == punctuation, Token.category == ":"})?
   ({Token.kind == number, Token.category == CD})?
  )
 |
 (
   ({Token.kind == punctuation, Token.category == "("})[0,1] 
   ({Token.kind == number, Token.category == CD})[1,4]
   ({Token.kind == punctuation, Token.category == ")"})[0,1] 
   ({Token.kind == punctuation, Token.category == "-"})[0,1]
   ({Token.kind == number, Token.category == CD})[1,7]
  )
)
:phoneLookup
-->
{
    AnnotationSet rawPhone = bindings.get("phoneLookup");
    if(rawPhone != null && rawPhone.size() > 0 && rawPhone.lastNode().getOffset() - rawPhone.firstNode().getOffset() >= 10){
            FeatureMap features = Factory.newFeatureMap();
            features.put("rule","PhoneRule");
            features.put("kind","phone");
            outputAS.add(rawPhone.firstNode() ,rawPhone.lastNode(),"PhoneFinder",features);
            return;
    }
}

I am working on detecting phone number from a text, and I have written a rule to do the same. It keeps running infinitely when control is set to appelt or brill. It works with control set to all.

0

There are 0 best solutions below