1

I am learning to use Gate to retrieve information from documents. Could somebody please explain to me exactly what I have to do to get my JAPE grammar rule to work. I have checked most tutorials and Gate manual but I am still not getting the point. I would like to extract person, location and date as my named entities.

So what I did is: 1. Identified my date patterns in the documents 2. Create JAPE grammar rules for each pattern 3. Load .jape file into gate as a new jape transducer

My date patterns are as follows: 1. DateMonthYear 2. MonthYear

So if I understand correctly, I would have to define JAPE grammar rules for each of these patterns. And that is what I am trying to do. I have defined my rules in a .jape file but it wouldn load into gate and it gives me an error that resource can not be created, the .jape file is as follow:

Phase: datetimefinder
Input: Token Lookup SpaceToken
Options: control = appelt

Macro: DAY_ONEDIGIT
({Toke.kind == number,Token.category==CD, Token.length == "1"})

Macro: DAY_TWODIGIT
({Token.kind == number,Token.category==CD, Token.length == "2"})

Macro: MONTH
({Lookup.MajorType="Month"})

Macro: YEAR
({Token.kind== number,Token.category==CD, Token.length== "4"})

////////Rule number 1
Rule: ddmmyyyy
priority:50
(
    (
    (DAY_ONEDIGIT|DAY_TWODIGIT)
    ({Token.kind==punctuation}|{SpaceToken})?
    )
    (
    (MONTH)
    ({Token.kind==punctuation}|{SpaceToken})?
    (YEAR)
    )
)  
:ddmmyyyy
-->  
 :ddmmyyyy.DateMonthYear= {rule = "ddmmyyyy"} 

//Rule number 2 
Rule: mmyyyy
priority: 50
(    
    (MONTH)
    ({Token})?
    ({SpaceToken})?
    (YEAR)  
)  
:mmyyyy
-->  
 :mmyyyy.MonthYear= {rule = "mmyyyy"}

I am not sure if I need to have new lists of the different annotation patterns (e.g DateMonth). Can someone please tell me what I should have, and do in order for this to run. I checked gate manual and other questions here but I cant find anything that give a complete tutorial on how to set this whole framework up.

1 Answers1

0

The error message is:

gate.creole.ResourceInstantiationException: gate.jape.parser.ParseException: Cannot parse a phase in file:/your_jape_file_path.jape: Encountered " "=" "= "" at line 12, column 19.
Was expecting:
    <attrOp> ...

    at gate.jape.plus.Transducer.init(Transducer.java:642)

See the typo at line 12, column 19 of your jape file: ({Lookup.MajorType="Month"}), you need to double the equals symbol: ({Lookup.MajorType=="Month"}).

After correction, see another message:

Rule ddmmyyyy contains unlisted annotation type Toke

There is another typo at line 6: ({Toke.kind == number,.... It should be ({Token.kind == number,....

dedek
  • 7,981
  • 3
  • 38
  • 68
  • Unbelievable.. I rectifies the typo and it worked, thank you. But do you think this is right? I am just learning not sure if my grammar is right. – Nampa Gwakondo Jul 17 '17 at 13:22
  • @NampaGwakondo I think its ok, quite a basic stuff (except advanced use of macros :-), If it is doing (annotating) what you expected, then it is ok, don't you think? – dedek Jul 17 '17 at 15:23