I'm trying to add decimals and fractions of two digits into RGL while keeping the original singular/plural rules of the noun that comes after mkNumeral or mkDigits. I tried using multiple nouns as
mkNP(mkCN
(mkN("ein"))
(mkNP(mkCN
(mkN("ein"))
(mkNP(mkN("halb"))))));
but this method doesn't work for all languages as in German eineinhalb
has no space in between, and using aPl_Det
to get the plural of a noun might work for English and German, but not for other languages such as French which actually has a real aPl_Det
.
Thus I tried extending an NP and added multiple strings into its s, such as follow
open SyntaxEng, ParadigmsEng, ResEng in {
oper
newNp : Str -> N -> NP =
\num, noun -> case occur (".")(num) of{
PTrue =>
let myNewNP = it_NP ** {s = (mkNP(mkDet(mkNumeral(dropDec num)))).s ++ "point" ++ (mkNP(mkDet(mkNumeral(decNum num)))).s ++ noun ! Pl} ;
-- noun is plural here because any number greater than 1 is plural, and I don't expect the user to input 1.00
in myNewNP;
PFalse => mkNP(mkDet(mkNumeral (num)))(noun)};
decNum : Str -> Str = \num -> dp (2) (num);
dropDec : Str -> Str = \num -> tk (3) (num);
}}
The error message I get is as below. The signs (...) mean there are other instances of mkDet, but they are not important for this problem.
no overload instance of mkDet
for
{s : Bool => CardOrd => Case => Str; lock_Numeral : {}; n : Number}
among
...
...
{s : Bool => CardOrd => Case => Str; lock_Numeral : {}; n : Number}
...
...
with value type Str
What does with value type Str mean and how to solve such a problem?
Card/Det or NP
Do you want to use fractions as determiners ("eineinhalb Katzen"), or just standalone noun phrases ("eineinhalb")? Either way, there are a couple different ways, none of which requires extending NPs.
Quick and dirty solution if the fractions don't inflect
Unfortunately, the RGL oper for
mkCard
expects input like "35", and it gives an error if you type letters or decimal points.But if your fractions don't inflect, or even if they inflect in the language but your application doesn't need the inflection, then the easiest way is to use Symbolic module, particularly the following pair of opers
That
symb
function makes theCard
plural by default. So you can make any Card like this:GF grammar
Here's working GF code for German.
Test the output:
Depending on the language and application, this could be an acceptable quick and dirty solution. But in general, this should be addressed in the RGL, not so that everyone makes their own hacks.
It's very much nontrivial to know which parts of the fractions inflect. For instance in Swedish, "one" is "en" or "ett" depending on the gender, and "one and half" is "en och en halv" or "ett och ett halvt". These are complicated things whose implementation belongs in the RGL.
General solution for inflecting fractions
We should just extend the
mkCard
oper in the RGL so that it accepts input like "3.5" or "1½". I can volunteer to do that for the languages I know myself, but it won't be on top of my priority list.If you want to give it a try in your own fork of the RGL, have a look at the Numeral modules of different languages, and see how the numerals are constructed. For instance, this is the
mkDigit
for German, you can play with it and try to figure out the following questionsmkCard
, notmkNumeral
:-P)