<s> """<STR_LIT>""" <EOL> from refo import Plus , Question <EOL> from quepy . dsl import HasKeyword <EOL> from quepy . parsing import Lemma , Pos , QuestionTemplate , Token , Particle <EOL> from dsl import IsCountry , IncumbentOf , CapitalOf , LabelOf , LanguageOf , PopulationOf , PresidentOf <EOL> class Country ( Particle ) : <EOL> regex = Plus ( Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) | Pos ( "<STR_LIT>" ) ) <EOL> def interpret ( self , match ) : <EOL> name = match . words . tokens . title ( ) <EOL> return IsCountry ( ) + HasKeyword ( name ) <EOL> class PresidentOfQuestion ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> regex = Pos ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) + Question ( Pos ( "<STR_LIT>" ) ) + Lemma ( "<STR_LIT>" ) + Pos ( "<STR_LIT>" ) + Country ( ) + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> president = PresidentOf ( match . country ) <EOL> incumbent = IncumbentOf ( president ) <EOL> label = LabelOf ( incumbent ) <EOL> return label , "<STR_LIT>" <EOL> class CapitalOfQuestion ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> opening = Lemma ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) <EOL> regex = opening + Pos ( "<STR_LIT>" ) + Lemma ( "<STR_LIT>" ) + Pos ( "<STR_LIT>" ) + Question ( Pos ( "<STR_LIT>" ) ) + Country ( ) + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> capital = CapitalOf ( match . country ) <EOL> label = LabelOf ( capital ) <EOL> return label , "<STR_LIT>" <EOL> class LanguageOfQuestion ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> openings = ( Lemma ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) + Pos ( "<STR_LIT>" ) + <EOL> Question ( Lemma ( "<STR_LIT>" ) ) + Lemma ( "<STR_LIT>" ) ) | ( Lemma ( "<STR_LIT>" ) + Lemma ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) + <EOL> Lemma ( "<STR_LIT>" ) ) <EOL> regex = openings + Pos ( "<STR_LIT>" ) + Question ( Pos ( "<STR_LIT>" ) ) + Country ( ) + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> language = LanguageOf ( match . country ) <EOL> return language , "<STR_LIT>" <EOL> class PopulationOfQuestion ( QuestionTemplate ) : <EOL> """<STR_LIT>""" <EOL> openings = ( Pos ( "<STR_LIT>" ) + Token ( "<STR_LIT>" ) + Pos ( "<STR_LIT>" ) + <EOL> Lemma ( "<STR_LIT>" ) + Pos ( "<STR_LIT>" ) ) | ( Pos ( "<STR_LIT>" ) + Lemma ( "<STR_LIT>" ) + Lemma ( "<STR_LIT>" ) + <EOL> Token ( "<STR_LIT>" ) + Pos ( "<STR_LIT>" ) ) <EOL> regex = openings + Question ( Pos ( "<STR_LIT>" ) ) + Country ( ) + Question ( Pos ( "<STR_LIT:.>" ) ) <EOL> def interpret ( self , match ) : <EOL> population = PopulationOf ( match . country ) <EOL> return population , "<STR_LIT>" </s>
