diff --git a/resource/abstract/Lang.gf b/resource/abstract/Lang.gf index efebecea5..72a14cdf3 100644 --- a/resource/abstract/Lang.gf +++ b/resource/abstract/Lang.gf @@ -6,7 +6,8 @@ abstract Lang = Structural, Basic, Time, - Country + Country, + Math ** { fun diff --git a/resource/abstract/Math.gf b/resource/abstract/Math.gf new file mode 100644 index 000000000..45ebfb785 --- /dev/null +++ b/resource/abstract/Math.gf @@ -0,0 +1,52 @@ + + +abstract Math = Categories ** { + +--3 Noun phrases with symbols + +fun + SymbPN : String -> PN ; -- "x" + IntPN : Int -> PN ; -- "27" + IntNP : CN -> Int -> NP ; -- "level 53" + + IndefSymbNumNP : Num -> CN -> SymbList -> NP ; -- "(2) numbers x and y" + DefSymbNumNP : Num -> CN -> SymbList -> NP ; -- "the (2) numbers x and y" + NDetSymbNP : NDet -> Num -> CN -> SymbList -> NP ; -- "some (3) points x, y and z" + +--3 Symbol lists + +-- A symbol list has at least two elements. The last two are separated +-- by a conjunction ("and" in English), the others by commas. +-- This produces "x, y and z", in English. + +cat + SymbList ; + +fun + SymbTwo : String -> String -> SymbList ; + SymbMore : String -> SymbList -> SymbList ; + +--3 Special forms of expression + +-- These expression forms are typical of mathematical texts. + + LetCN : String -> CN -> Imp ; -- Let x be a number. + LetNumCN : SymbList -> Num -> CN -> Imp ; -- Let x and y be (2) numbers. + +-- This rule is slightly overgenerating: "there exists every number x". +-- The problem seems to be of semantic nature. By this we avoid having many rules. + + ExistNP : NP -> Cl ; -- there exist (2) number(s) x and y + +--3 Rules moved from $Rules$. + +-- This rule is powerful but overgenerating. + + SymbCN : CN -> String -> CN ; -- "number x" + +-- This rule is simply wrong, and will be deprecated: the correct +-- value type is $NP$. + + IntCN : CN -> Int -> CN ; -- "level 53" + +} diff --git a/resource/abstract/Rules.gf b/resource/abstract/Rules.gf index fe44038d5..c3dbfb276 100644 --- a/resource/abstract/Rules.gf +++ b/resource/abstract/Rules.gf @@ -17,9 +17,12 @@ fun UseN : N -> CN ; -- "car" UsePN : PN -> NP ; -- "John" +-- These three rules have been moved to the module $Math$. + {- SymbPN : String -> PN ; -- "x" SymbCN : CN -> String -> CN ; -- "number x" IntCN : CN -> Int -> CN ; -- "number 53" + -} IndefOneNP : CN -> NP ; -- "a car", "cars" IndefNumNP : Num -> CN -> NP ; -- "houses", "86 houses" diff --git a/resource/danish/MathDan.gf b/resource/danish/MathDan.gf new file mode 100644 index 000000000..809df1cb5 --- /dev/null +++ b/resource/danish/MathDan.gf @@ -0,0 +1,4 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +concrete MathDan of Math = CategoriesDan ** + MathScand with (SyntaxScand=SyntaxDan) ; diff --git a/resource/danish/SyntaxDan.gf b/resource/danish/SyntaxDan.gf index f8b9df029..9d59588b7 100644 --- a/resource/danish/SyntaxDan.gf +++ b/resource/danish/SyntaxDan.gf @@ -116,4 +116,5 @@ instance SyntaxDan of SyntaxScand = TypesDan ** {s = verbVara.s ; s1 = "ved" ; isAux = False} vp) ; + conjEt = "og" ; } \ No newline at end of file diff --git a/resource/english/LangEng.gf b/resource/english/LangEng.gf index 3187ecaf9..5c12ef028 100644 --- a/resource/english/LangEng.gf +++ b/resource/english/LangEng.gf @@ -6,7 +6,8 @@ concrete LangEng of Lang = StructuralEng, BasicEng, TimeEng, - CountryEng + CountryEng, + MathEng ** open Prelude, ParadigmsEng in { diff --git a/resource/english/MathEng.gf b/resource/english/MathEng.gf new file mode 100644 index 000000000..037f16cbb --- /dev/null +++ b/resource/english/MathEng.gf @@ -0,0 +1,49 @@ +--# -path=.:../abstract:../../prelude + +concrete MathEng of Math = CategoriesEng ** open Prelude, SyntaxEng, ParadigmsEng in { + +lin + SymbPN i = {s = \\c => caseSymb c i.s ; g = Neutr} ; + IntPN i = {s = \\c => caseSymb c i.s ; g = Neutr} ; + IntNP cn i = nameNounPhrase { + s = \\c => (cn.s ! Sg ! Nom ++ caseSymb c i.s) ; + g = Neutr + } ; + + IndefSymbNumNP nu cn xs = + addSymbNounPhrase (indefNounPhraseNum plural nu cn) xs.s ; + DefSymbNumNP nu cn xs = + addSymbNounPhrase (defNounPhraseNum plural nu cn) xs.s ; + NDetSymbNP det nu cn xs = + addSymbNounPhrase (numDetNounPhrase det nu cn) xs.s ; + +lincat + SymbList = SS ; + +lin + SymbTwo = infixSS "and" ; + SymbMore = infixSS "," ; + + + LetCN x cn = { + s = \\_ => "let" ++ x.s ++ "be" ++ (indefNounPhrase singular cn).s ! NomP + } ; + LetNumCN x nu cn = { + s = \\_ => "let" ++ x.s ++ "be" ++ (indefNounPhraseNum plural nu cn).s ! NomP + } ; + ExistNP np = predVerbClause + (nameNounPhraseN (fromAgr np.a).n (nameReg "there" Neutr)) + (regV "exist") + (complNounPhrase np) ; + +-- Moved from $RulesEng$. + + SymbCN cn s = + {s = \\n,c => cn.s ! n ! Nom ++ caseSymb c s.s ; + g = cn.g} ; + IntCN cn s = + {s = \\n,c => cn.s ! n ! Nom ++ caseSymb c s.s ; + g = cn.g} ; + + +} diff --git a/resource/english/RulesEng.gf b/resource/english/RulesEng.gf index f4793d680..f162763ab 100644 --- a/resource/english/RulesEng.gf +++ b/resource/english/RulesEng.gf @@ -28,14 +28,6 @@ lin UseN = noun2CommNounPhrase ; UsePN = nameNounPhrase ; - SymbPN i = {s = table {Nom => i.s ; Gen => i.s ++ "'s"} ; g = Neutr} ; --- - SymbCN cn s = - {s = \\n,c => cn.s ! n ! c ++ s.s ; - g = cn.g} ; - IntCN cn s = - {s = \\n,c => cn.s ! n ! c ++ s.s ; - g = cn.g} ; - IndefOneNP = indefNounPhrase singular ; IndefNumNP = indefNounPhraseNum plural ; DefOneNP = defNounPhrase singular ; diff --git a/resource/english/SyntaxEng.gf b/resource/english/SyntaxEng.gf index 758571544..f31500013 100644 --- a/resource/english/SyntaxEng.gf +++ b/resource/english/SyntaxEng.gf @@ -66,11 +66,17 @@ oper APl p => {n = Pl ; p = p ; g = human} } ; - nameNounPhrase : ProperName -> NounPhrase = \john -> - {s = \\c => john.s ! toCase c ; a = toAgr Sg P3 john.g} ; + caseSymb : Case -> Str -> Str = \c,i -> case c of { + Nom => i ; + Gen => glue i "'s" + } ; - nameNounPhrasePl : ProperName -> NounPhrase = \john -> - {s = \\c => john.s ! toCase c ; a = toAgr Pl P3 john.g} ; + nameNounPhrase : ProperName -> NounPhrase = + nameNounPhraseN Sg ; + nameNounPhrasePl : ProperName -> NounPhrase = + nameNounPhraseN Pl ; + nameNounPhraseN : Number -> ProperName -> NounPhrase = \n,john -> + {s = \\c => john.s ! toCase c ; a = toAgr n P3 john.g} ; -- The following construction has to be refined for genitive forms: -- "we two", "us two" are OK, but "our two" is not. @@ -86,6 +92,14 @@ oper pronNounPhrase : Pronoun -> NounPhrase = \pro -> {s = pro.s ; a = toAgr pro.n pro.p pro.g} ; +-- To add a symbol, such as a variable or variable list, to the end of +-- an NP. + + addSymbNounPhrase : NounPhrase -> Str -> NounPhrase = \np,x -> + {s = \\c => np.s ! c ++ x ; + a = np.a + } ; + --2 Determiners -- -- Determiners are inflected according to the nouns they determine. diff --git a/resource/finnish/LangFin.gf b/resource/finnish/LangFin.gf index 3c6d9433f..48a035558 100644 --- a/resource/finnish/LangFin.gf +++ b/resource/finnish/LangFin.gf @@ -4,9 +4,10 @@ concrete LangFin of Lang = RulesFin, ClauseFin, StructuralFin, - BasicFin + BasicFin, ---- TimeEng, ---- CountryEng + MathFin ** open Prelude, ParadigmsFin in { diff --git a/resource/finnish/MathFin.gf b/resource/finnish/MathFin.gf new file mode 100644 index 000000000..3bf2bb9c2 --- /dev/null +++ b/resource/finnish/MathFin.gf @@ -0,0 +1,50 @@ +--# -path=.:../abstract:../../prelude + +concrete MathFin of Math = CategoriesFin ** open Prelude, SyntaxFin, ParadigmsFin in { + +lin + SymbPN i = {s = \\c => i.s} ; --- case endings often needed + IntPN i = {s = \\c => i.s} ; + IntNP cn i = nameNounPhrase { + s = \\c => cn.s ! False ! Sg ! c ++ i.s + } ; + + IndefSymbNumNP nu cn xs = + addSymbNounPhrase (nounPhraseNum False nu cn) xs.s ; + DefSymbNumNP nu cn xs = + addSymbNounPhrase (nounPhraseNum True nu cn) xs.s ; + NDetSymbNP det nu cn xs = + addSymbNounPhrase (numDetNounPhrase det nu cn) xs.s ; + +lincat + SymbList = SS ; + +lin + SymbTwo = infixSS "ja" ; + SymbMore = infixSS "," ; + + + LetCN x cn = { + s = \\_ => "olkoon" ++ x.s ++ (indefNounPhrase singular cn).s ! + NPCase Nom + } ; + LetNumCN x nu cn = { + s = \\_ => "olkoot" ++ x.s ++ (nounPhraseNum False nu cn).s + ! NPCase Part + } ; + + ExistNP np = + sats2clause ( + mkSatsCopula impersNounPhrase ("olemassa" ++ np.s ! NPCase Nom) + ) ; + +-- Moved from $RulesFin$. + + SymbCN cn s = + {s = \\f,n,c => cn.s ! f ! n ! c ++ s.s ; + g = cn.g} ; + IntCN cn s = + {s = \\f,n,c => cn.s ! f ! n ! c ++ s.s ; + g = cn.g} ; + +} diff --git a/resource/finnish/RulesFin.gf b/resource/finnish/RulesFin.gf index 16b53b8da..6f7529fd8 100644 --- a/resource/finnish/RulesFin.gf +++ b/resource/finnish/RulesFin.gf @@ -24,14 +24,6 @@ lin UseN = noun2CommNounPhrase ; UsePN = nameNounPhrase ; - SymbPN i = {s = \\_ => i.s} ; --- case endings often needed - SymbCN cn s = - {s = \\f,n,c => cn.s ! f ! n ! c ++ s.s ; - g = cn.g} ; - IntCN cn s = - {s = \\f,n,c => cn.s ! f ! n ! c ++ s.s ; - g = cn.g} ; - IndefOneNP = indefNounPhrase singular ; IndefNumNP = nounPhraseNum False ; DefOneNP = defNounPhrase singular ; @@ -206,6 +198,8 @@ lin ---- OneNP = nameNounPhrase (nameReg "one" human) ; +--- should be partitive in negative forms: "ei ole olemassa puista autoa" + ExistCN cn = sats2clause ( mkSatsCopula impersNounPhrase ("olemassa" ++ (singularNounPhrase cn).s ! NPCase Nom) diff --git a/resource/finnish/SyntaxFin.gf b/resource/finnish/SyntaxFin.gf index 4840ccd80..bf351b37b 100644 --- a/resource/finnish/SyntaxFin.gf +++ b/resource/finnish/SyntaxFin.gf @@ -157,6 +157,14 @@ oper noNum : Numeral = {s = \\_ => [] ; isNum = False ; n = Pl} ; +-- To add a symbol, such as a variable or variable list, to the end of +-- an NP. + + addSymbNounPhrase : NounPhrase -> Str -> NounPhrase = \np,x -> + {s = \\c => np.s ! c ++ x ; + n = np.n ; + p = np.p + } ; --2 Determiners -- diff --git a/resource/french/MathFre.gf b/resource/french/MathFre.gf new file mode 100644 index 000000000..d38db5dbd --- /dev/null +++ b/resource/french/MathFre.gf @@ -0,0 +1,4 @@ +--# -path=.:../romance:../abstract:../../prelude + +concrete MathFre of Math = CategoriesFre ** + MathRomance with (SyntaxRomance=SyntaxFre) ; diff --git a/resource/italian/MathIta.gf b/resource/italian/MathIta.gf new file mode 100644 index 000000000..02e19a456 --- /dev/null +++ b/resource/italian/MathIta.gf @@ -0,0 +1,4 @@ +--# -path=.:../romance:../abstract:../../prelude + +concrete MathIta of Math = CategoriesIta ** + MathRomance with (SyntaxRomance=SyntaxIta) ; diff --git a/resource/norwegian/MathNor.gf b/resource/norwegian/MathNor.gf new file mode 100644 index 000000000..ddcea878b --- /dev/null +++ b/resource/norwegian/MathNor.gf @@ -0,0 +1,4 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +concrete MathNor of Math = CategoriesNor ** + MathScand with (SyntaxScand=SyntaxNor) ; diff --git a/resource/norwegian/SyntaxNor.gf b/resource/norwegian/SyntaxNor.gf index 1e45f47e0..6b1fb6472 100644 --- a/resource/norwegian/SyntaxNor.gf +++ b/resource/norwegian/SyntaxNor.gf @@ -117,4 +117,7 @@ instance SyntaxNor of SyntaxScand = TypesNor ** (complVerbVerb ({s = verbVara.s ; s1 = "ved" ; isAux = False}) vp) ; + + conjEt = "og" ; + } diff --git a/resource/romance/MathRomance.gf b/resource/romance/MathRomance.gf new file mode 100644 index 000000000..38ccbb21e --- /dev/null +++ b/resource/romance/MathRomance.gf @@ -0,0 +1,51 @@ +--# -path=.:../romance:../abstract:../../prelude + +incomplete concrete MathRomance of Math = CategoriesRomance ** + open Prelude, SyntaxRomance in { + +lin + SymbPN i = {s = i.s ; g = Masc} ; --- cannot know gender + IntPN i = {s = i.s ; g = Masc} ; + IntNP cn i = nameNounPhrase { + s = cn.s ! Sg ++ i.s ; + g = cn.g + } ; + + IndefSymbNumNP nu cn xs = + addSymbNounPhrase (indefNounPhraseNum nu cn) xs.s ; + DefSymbNumNP nu cn xs = + addSymbNounPhrase (defNounPhraseNum nu cn) xs.s ; + NDetSymbNP det nu cn xs = + addSymbNounPhrase (numDetNounPhrase det nu cn) xs.s ; + +lincat + SymbList = SS ; + +lin + SymbTwo = infixSS etConj.s ; + SymbMore = infixSS "," ; + + + LetCN x cn = { + s = \\_,_ => copula.s ! VFin (VPres Con) Sg P3 ++ x.s ++ (indefNounPhrase singular cn).s ! + unstressed nominative + } ; + LetNumCN x nu cn = { + s = \\_,_ => copula.s ! VFin (VPres Con) Pl P3 ++ x.s ++ (indefNounPhraseNum nu cn).s + ! unstressed nominative + } ; + +--- to be replaced by "il existe", "esiste", etc. + + ExistNP np = existNounPhrase np ; + +-- Moved from $RulesRomance$. + + SymbCN cn s = + {s = \\n => cn.s ! n ++ s.s ; + g = cn.g} ; + IntCN cn i = + {s = \\n => cn.s ! n ++ i.s ; + g = cn.g} ; + +} diff --git a/resource/romance/RulesRomance.gf b/resource/romance/RulesRomance.gf index 4d0a20de1..f6381270b 100644 --- a/resource/romance/RulesRomance.gf +++ b/resource/romance/RulesRomance.gf @@ -7,14 +7,6 @@ lin UseN = noun2CommNounPhrase ; UsePN = nameNounPhrase ; - SymbPN i = {s = i.s ; g = Masc} ; --- cannot know gender - SymbCN cn s = - {s = \\n => cn.s ! n ++ s.s ; - g = cn.g} ; - IntCN cn i = - {s = \\n => cn.s ! n ++ i.s ; - g = cn.g} ; - IndefOneNP = indefNounPhrase singular ; IndefNumNP = indefNounPhraseNum ; DefOneNP = defNounPhrase singular ; diff --git a/resource/romance/SyntaxRomance.gf b/resource/romance/SyntaxRomance.gf index 17d8e8d80..e0543125a 100644 --- a/resource/romance/SyntaxRomance.gf +++ b/resource/romance/SyntaxRomance.gf @@ -80,6 +80,17 @@ oper existNounPhrase : NounPhrase -> Clause ; +-- To add a symbol, such as a variable or variable list, to the end of +-- an NP. + + addSymbNounPhrase : NounPhrase -> Str -> NounPhrase = \np,x -> + {s = \\c => np.s ! c ++ x ; + g = np.g ; + n = np.n ; + p = np.p ; + c = np.c + } ; + --2 Determiners -- diff --git a/resource/scandinavian/MathScand.gf b/resource/scandinavian/MathScand.gf new file mode 100644 index 000000000..416a72d03 --- /dev/null +++ b/resource/scandinavian/MathScand.gf @@ -0,0 +1,58 @@ +--# -path=.:../abstract:../../prelude + +incomplete concrete MathScand of Math = CategoriesScand ** + open Prelude, SyntaxScand in { + +lin + SymbPN i = {s = \\_ => i.s ; g = NNeutr} ; --- cannot know gender + IntPN i = {s = \\_ => i.s ; g = NNeutr} ; + IntNP cn i = nameNounPhrase { + s = \\c => cn.s ! Sg ! DefP Def ! Nom ++ i.s ; + g = cn.g + } ; + + IndefSymbNumNP nu cn xs = + addSymbNounPhrase (indefNounPhraseNum plural nu cn) xs.s ; + DefSymbNumNP nu cn xs = + addSymbNounPhrase (defNounPhraseNum plural nu cn) xs.s ; + NDetSymbNP det nu cn xs = + addSymbNounPhrase (numDetNounPhrase det nu cn) xs.s ; + +lincat + SymbList = SS ; + +lin + SymbTwo = infixSS conjEt ; + SymbMore = infixSS "," ; + + + LetCN x cn = { + s = \\_ => letImp ++ x.s ++ verbVara.s ! VI (Inf Act) ++ (indefNounPhrase singular cn).s ! + PNom + } ; + LetNumCN x nu cn = { + s = \\_ => letImp ++ x.s ++ verbVara.s ! VI (Inf Act) ++ + (indefNounPhraseNum plural nu cn).s + ! PNom + } ; + +--- to be replaced by "det existerar", etc. + + ExistNP np = predVerbGroupClause npDet + (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) + np) ; + +-- Moved from $RulesScand$. + + SymbCN cn s = + {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; + g = cn.g ; + p = cn.p + } ; + IntCN cn s = + {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; + g = cn.g ; + p = cn.p + } ; + +} diff --git a/resource/scandinavian/RulesScand.gf b/resource/scandinavian/RulesScand.gf index 452592921..1e4897e23 100644 --- a/resource/scandinavian/RulesScand.gf +++ b/resource/scandinavian/RulesScand.gf @@ -10,16 +10,13 @@ lin UsePN = nameNounPhrase ; SymbPN i = {s = \\_ => i.s ; g = NNeutr} ; + SymbCN cn s = - {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; - g = cn.g ; - p = cn.p - } ; - IntCN cn s = - {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; - g = cn.g ; - p = cn.p - } ; + {s = \\n => cn.s ! n ++ s.s ; + g = cn.g} ; + IntCN cn i = + {s = \\n => cn.s ! n ++ i.s ; + g = cn.g} ; IndefOneNP = indefNounPhrase singular ; IndefNumNP = indefNounPhraseNum plural ; diff --git a/resource/scandinavian/SyntaxScand.gf b/resource/scandinavian/SyntaxScand.gf index 1161b3ffb..6f6886d97 100644 --- a/resource/scandinavian/SyntaxScand.gf +++ b/resource/scandinavian/SyntaxScand.gf @@ -122,6 +122,11 @@ oper npDet : NounPhrase ; + + addSymbNounPhrase : NounPhrase -> Str -> NounPhrase = \np,x -> + {s = \\c => np.s ! c ++ x ; g = np.g ; n = np.n ; p = np.p} ; + + --2 Determiners -- -- Determiners are inflected according to noun in gender and sex. @@ -1710,4 +1715,7 @@ oper pronVars, pronVem, pronVems : Str ; + conjEt : Str ; + + letImp : Str = "låt" ; ---- check for all scand } ; diff --git a/resource/spanish/MathSpa.gf b/resource/spanish/MathSpa.gf new file mode 100644 index 000000000..fd3e7eef0 --- /dev/null +++ b/resource/spanish/MathSpa.gf @@ -0,0 +1,4 @@ +--# -path=.:../romance:../abstract:../../prelude + +concrete MathSpa of Math = CategoriesSpa ** + MathRomance with (SyntaxRomance=SyntaxSpa) ; diff --git a/resource/swedish/MathSwe.gf b/resource/swedish/MathSwe.gf new file mode 100644 index 000000000..98493fbce --- /dev/null +++ b/resource/swedish/MathSwe.gf @@ -0,0 +1,4 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +concrete MathSwe of Math = CategoriesSwe ** + MathScand with (SyntaxScand=SyntaxSwe) ; diff --git a/resource/swedish/SyntaxSwe.gf b/resource/swedish/SyntaxSwe.gf index 4d0aaf8a7..f4de39f1c 100644 --- a/resource/swedish/SyntaxSwe.gf +++ b/resource/swedish/SyntaxSwe.gf @@ -132,4 +132,7 @@ instance SyntaxSwe of SyntaxScand = TypesSwe ** CPpå => "på" ; CPtill => "till" } ; + + conjEt = "och" ; + }