Search code examples
stanford-nlptemporalsutime

How to write custom rules for sutime in stanford temporal tagger?


Stanford temporal tagger is working fine for most cases. For example "I should be in school tomorrow by 9'o clock." is having 9'o clock as time. But SUTime is not identifying it :(

So I want to add rule based on this. Any suggestions ?

I'm using this


Solution

  • I added this rule right below the "9 o'clock" rule:

    { ( (?: /the/ /hour/ /of/?)? ([ $INT & { numcompvalue<=24 } ]) (/'/ /o/ /clock/)) => IsoTime($1[0].numcompvalue, 0, NIL) }
    

    in:

    edu/stanford/nlp/models/sutime/english.sutime.txt

    and was able to recognize the pattern you described.

    Note that the tokenizer splits "9'o clock" into ["9", "'", "o", "clock"].

    In general if you add rules to that file you can add custom patterns for cases you wish to cover. That file can be found in this jar:

    stanford-corenlp-3.5.2-models.jar