<s> """<STR_LIT>""" <EOL> from refo import Group , Plus , Question <EOL> from quepy . parsing import Lemma , Pos , QuestionTemplate , Token , Particle , Lemmas <EOL> from quepy . dsl import HasKeyword , IsRelatedTo , HasType <EOL> from dsl import DefinitionOf , LabelOf , IsPlace , UTCof , LocationOf <EOL> LISTOPEN = Lemma ( "<STR_LIT:list>" ) | Lemma ( "<STR_LIT:name>" ) <EOL> class Thing ( Particle ) : <EOL> regex = Question ( Pos ( "<STR_LIT>" ) ) + ( Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) ) | Pos ( "<STR_LIT>" ) <EOL> def interpret ( self , match ) : <EOL> return HasKeyword ( match . words . tokens ) <EOL> class WhatIs ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> regex = Lemma ( "<STR_LIT>" ) + Lemma ( "<STR_LIT>" ) + Question ( Pos ( "<STR_LIT>" ) ) + Thing ( ) + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> label = DefinitionOf ( match . thing ) <EOL> return label , "<STR_LIT>" <EOL> class ListEntity ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> entity = Group ( Pos ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> target = Group ( Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) , "<STR_LIT:target>" ) <EOL> regex = LISTOPEN + entity + target <EOL> def interpret ( self , match ) : <EOL> entity = HasKeyword ( match . entity . tokens ) <EOL> target_type = HasKeyword ( match . target . lemmas ) <EOL> target = HasType ( target_type ) + IsRelatedTo ( entity ) <EOL> label = LabelOf ( target ) <EOL> return label , "<STR_LIT>" <EOL> class WhatTimeIs ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> nouns = Plus ( Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) ) <EOL> place = Group ( nouns , "<STR_LIT>" ) <EOL> openings = ( Lemma ( "<STR_LIT>" ) + <EOL> ( ( Token ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) + Question ( Lemma ( "<STR_LIT>" ) ) + <EOL> Question ( Lemma ( "<STR_LIT>" ) ) + Lemma ( "<STR_LIT:time>" ) ) | <EOL> ( Lemma ( "<STR_LIT:time>" ) + Token ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) ) ) ) | Lemma ( "<STR_LIT:time>" ) <EOL> regex = openings + Pos ( "<STR_LIT>" ) + place + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> place = HasKeyword ( match . place . lemmas . title ( ) ) + IsPlace ( ) <EOL> utc_offset = UTCof ( place ) <EOL> return utc_offset , "<STR_LIT:time>" <EOL> class WhereIsQuestion ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> thing = Group ( Plus ( Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) ) , <EOL> "<STR_LIT>" ) <EOL> regex = Lemma ( "<STR_LIT>" ) + Question ( Lemmas ( "<STR_LIT>" ) ) + Lemma ( "<STR_LIT>" ) + Question ( Pos ( "<STR_LIT>" ) ) + thing + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> thing = HasKeyword ( match . thing . tokens ) <EOL> location = LocationOf ( thing ) <EOL> location_name = LabelOf ( location ) <EOL> return location_name , "<STR_LIT>" </s>
