[Transformation Error - RGL]

Skip to first unread message

Wilson Junior

Dec 21, 2020, 10:55:24 AM12/21/20
to Grammatical Framework
Hi all.

I am not getting transform Str to Numeral using Resource Grammar Library (NumeralEng). I saw that mkNum function works properly for entry "25", but if I try put a dynamic entry such as symbolic value, it is not working.

For example, the follow code is referring to my abstract syntax:

abstract Transform = Numeral ** {
flags startcat = Command ;

Call3 : Cardinal -> Command;
Call2 : String -> Cardinal;
Call4 : Cardinal;

and the follow code is referring to my concrete syntax:

concrete TransformEng of Transform = NumeralEng ** open SyntaxEng, ParadigmsEng, SymbolicEng, NumeralEng in {

Cardinal = Card;
Command = Num;
Call3 c = mkNum c; -- Num
Call2 s = symb (mkSymb s.s); -- Card
Call4 = mkCard "77"; -- Card


This code compile properly, but I can't transform dynamic string too numeral.

Running the code:
Transform> gt | l
seventy &+ - &+ seven

Transform> p "77"
Call3 (Call2 "77")

0 msec
Transform> p "77"|l

Inari Listenmaa

Dec 21, 2020, 11:57:38 AM12/21/20
to Grammatical Framework
Hi Wilson,

This is not a bug, but a feature of GF. When you take a runtime String as an argument, you may only take its string value and construct a NP or Card out of it. But you may not do any of the following:
a) split the string,
b) attach another string to it with +,
c) pattern match it.

In order to return "twenty-five" for the input "25", you need to pattern match the string "25". 

As long as we do this when defining our lexicon, pattern matching and using + are perfectly fine. But the problem here is that you're trying to do it in a function that takes some runtime argument. See this gist for a minimal example: https://gist.github.com/inariksit/edde72f43d439571c79f8ef758443c11 

If you need to transform digits to written numerals, it's best to do it outside GF.



You received this message because you are subscribed to the Google Groups "Grammatical Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gf-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gf-dev/778b31b9-990e-4435-9ac0-ffcccb6aa958n%40googlegroups.com.

Reply all
Reply to author
0 new messages