I have a question about simple callbacks implementation in Python. Unfortunately the examples in src/runtime/python/examples come without any grammar (I guess it was some version of wide-coverage, but those grammars don't compile anymore) and all my attempts to adapt code from there failed.
Let's say I have a simple modification of Face grammar. Abstract:
abstract Face = {
flags startcat = Message ;
cat Message ; Person ; Object ; Number ; fun Have : Person -> Number -> Object -> Message ; -- p has n o's Like : Person -> Object -> Message ; -- p likes o You : Person ; Friend, Invitation : Object ; UnknownPerson : String -> Person ; One, Two, Hundred : Number ; }
English concrete:
concrete FaceEng of Face = open SyntaxEng, ParadigmsEng in {
lincat
Message = Cl ;
Person = NP ;
Object = CN ;
Number = Numeral ;
lin
Have p n o = mkCl p have_V2 (mkNP n o) ;
Like p o = mkCl p like_V2 (mkNP this_Quant o) ;
You = mkNP youSg_Pron ;
Friend = mkCN friend_N ;
Invitation = mkCN invitation_N ;
One = n1_Numeral ;
Two = n2_Numeral ;
Hundred = n100_Numeral ;
oper
like_V2 = mkV2 "like" ;
invitation_N = mkN "invitation" ;
friend_N = mkN "friend" ;
}
Basically, in this version any string might be a Person, provided the callback function returns it correctly.
According to Krasimir's thesis (pp. 45-48), the grammar should be compiled with -literal=Person switch, which I did.
At this point, a callback function should return UnknownPerson "anything" (e.g., by converting the string into an NP by symb in the RGL), which should be accepted by the parser. How should a working Python callback function be written for such a basic example?
Thank you for any hint!
Giuliano