cleaned up in lab2 grammars ; added myproject/ from the lecture

This commit is contained in:
aarneranta
2021-04-28 12:16:07 +02:00
parent 4da15031d1
commit 3faf1f2265
14 changed files with 85 additions and 635 deletions

View File

@@ -1,118 +0,0 @@
--# -path=.:../abstract:../english:../api
-- model implementation using Mini RGL
concrete DoctorFraMerle of Doctor =
open
SyntaxFre,
ParadigmsFre,
Prelude,
StructuralFre
in {
-- application using your own Mini* modules
lincat
Phrase = Utt ;
Fact = Cl ;
Action = VP ;
Property = VP ;
Profession = CN ;
Person = NP ;
Place = {at,to : Adv} ;
Substance = NP ;
Illness = NP ;
lin
presPosPhrase fact = mkUtt (mkS fact) ;
presNegPhrase fact = mkUtt (mkS negativePol fact) ;
pastPosPhrase fact = mkUtt (mkS anteriorAnt fact) ;
pastNegPhrase fact = mkUtt (mkS anteriorAnt negativePol fact) ;
presQuestionPhrase fact = let p : Utt = mkUtt (mkQS (mkQCl fact)) in p ** {s = p.s ++ SOFT_BIND ++ "?"} ;
pastQuestionPhrase fact = let p : Utt = mkUtt (mkQS anteriorAnt (mkQCl fact)) in p ** {s = p.s ++ SOFT_BIND ++ "?"} ;
impPosPhrase action = mkUtt (mkImp action) ;
impNegPhrase action = mkUtt negativePol (mkImp action) ;
actionFact person action = mkCl person action ;
propertyFact person property = mkCl person property ;
isProfessionProperty profession = mkVP (mkNP a_Det profession) ;
needProfessionProperty profession = mkVP need_V2 (mkNP a_Det profession) ;
isAtPlaceProperty place = mkVP place.at ;
haveIllnessProperty illness = mkVP have_V2 illness ;
theProfessionPerson profession = mkNP the_Det profession ;
iMascPerson = i_NP ;
iFemPerson = i_NP ;
youMascPerson = youPol_NP ;
youFemPerson = youPol_NP ;
hePerson = he_NP ;
shePerson = she_NP ;
goToAction place = mkVP (mkVP go_V) place.to ;
stayAtAction place = mkVP (mkVP stay_V) place.at ;
vaccinateAction person = mkVP vaccinate_V2 person ;
examineAction person = mkVP examine_V2 person ;
takeSubstanceAction substance = mkVP take_V2 substance ;
-- end of what could be a functor
--------------------------------
coughAction = mkVP (mkV "tousser") ;
breatheAction = mkVP (mkV "respirer") ;
vomitAction = mkVP (mkV "vomir") ;
sleepAction = mkVP (mkV "dormir" "dors" "dormons" "dorment" "dormit" "dormira" "dormi") ;
undressAction = mkVP (reflV (mkV "déshabiller")) ;
dressAction = mkVP (reflV (mkV "habiller")) ;
eatAction = mkVP (mkV "manger") ;
drinkAction = mkVP (mkV "boire" "bois" "buvons" "boivent" "but" "boira" "bu") ;
smokeAction = mkVP (mkV "fumer") ;
measureTemperatureAction = mkVP (mkV2 (mkV "mesurer")) (mkNP the_Det (mkN "temperatur du corps" feminine)) ;
measureBloodPressureAction = mkVP (mkV2 (mkV "mesurer")) (mkNP the_Det (mkN "tension artérielle")) ;
--these are identical for 'at' and 'to' in French
hospitalPlace = {at = pAdv "à l'hôpital" ; to = pAdv "à l'hôpital"} ;
homePlace = {at = pAdv "à la maison" ; to = pAdv "à la maison"} ;
schoolPlace = {at = pAdv "à l'école" ; to = pAdv "à l'école"} ;
workPlace = {at = pAdv "au travail" ; to = pAdv "au travail"} ;
doctorProfession = mkCN (mkN "médecin") ;
nurseProfession = mkCN ((mkN "infirmière") | (mkN "infermier")) ;
interpreterProfession = mkCN (mkN "interprète") ;
bePregnantProperty = mkVP (mkA "enceinte") ;
beIllProperty = mkVP (mkA "malade") ;
beWellProperty = mkVP (mkA "bien" "bien" "bien" "bien") ;
beDeadProperty = mkVP (mkA "mort") ;
haveAllergiesProperty = mkVP have_V2 (mkNP aPl_Det (mkN "allergie")) ;
havePainsProperty = mkVP have_V2 (mkNP aPl_Det (mkN "douleur")) ;
haveChildrenProperty = mkVP have_V2 (mkNP aPl_Det (mkN "enfant")) ;
feverIllness = mkNP (mkN "fièvre") ;
fluIllness = mkNP a_Det (mkN "grippe") ;
headacheIllness = mkNP a_Det (mkN "mal de crâne") ;
diarrheaIllness = mkNP (mkN "diarrhée") ;
heartDiseaseIllness = mkNP a_Det (mkN "cardiopathie") ;
lungDiseaseIllness = mkNP a_Det (mkN "maladie pulmonaire") ;
hypertensionIllness = mkNP (mkN "hypertension") ;
alcoholSubstance = mkNP (mkN "alcool") ;
medicineSubstance = mkNP a_Det (mkN "médicament") ;
drugsSubstance = mkNP aPl_Det (mkN "drogue") ;
oper
pAdv : Str -> Adv = ParadigmsFre.mkAdv ;
go_V = etreV (mkV "aller" "vais" "allons" "vont" "alla" "ira" "allé") ;
stay_V = etreV (mkV "rester") ;
need_V2 = mkV2 (mkV (mkV have_V2) "besoin d'") ;
--need_V2 = mkV2 (mkV "nécessiter") ;
take_V2 = mkV2 (mkV "prendre" "prends" "prenons" "prennent" "prit" "prendra" "pris") ;
put_V2 = mkV2 (mkV "mettre" "mets" "mettons" "mettent" "mit" "mettra" "mis") ;
vaccinate_V2 = mkV2 (mkV "vacciner") ;
examine_V2 = mkV2 (mkV "examiner") ;
}

View File

@@ -1,112 +0,0 @@
concrete DoctorSweBritta of Doctor =
open
SyntaxSwe,
ParadigmsSwe,
Prelude
in {
-- application using standard RGL
lincat
Phrase = Utt ;
Fact = Cl ;
Action = VP ;
Property = VP ;
Profession = CN ;
Person = NP ;
Place = {at,to : Adv} ;
Substance = NP ;
Illness = NP ;
lin
presPosPhrase fact = mkUtt (mkS fact) ;
presNegPhrase fact = mkUtt (mkS negativePol fact) ;
pastPosPhrase fact = mkUtt (mkS anteriorAnt fact) ;
pastNegPhrase fact = mkUtt (mkS anteriorAnt negativePol fact) ;
-- presQuestionPhrase fact = mkUtt (mkQS (mkQCl fact)) ;
-- pastQuestionPhrase fact = mkUtt (mkQS anteriorAnt (mkQCl fact)) ;
presQuestionPhrase fact = let p : Utt = mkUtt (mkQS (mkQCl fact)) in p ** {s = p.s ++ SOFT_BIND ++ "?"} ;
pastQuestionPhrase fact = let p : Utt = mkUtt (mkQS anteriorAnt (mkQCl fact)) in p ** {s = p.s ++ SOFT_BIND ++ "?"} ;
impPosPhrase action = mkUtt (mkImp action) ;
impNegPhrase action = mkUtt negativePol (mkImp action) ;
actionFact person action = mkCl person action ;
propertyFact person property = mkCl person property ;
isProfessionProperty profession = mkVP (mkNP profession) ;
needProfessionProperty profession = mkVP need_V2 (mkNP a_Det profession) ;
isAtPlaceProperty place = mkVP place.at ;
haveIllnessProperty illness = mkVP have_V2 illness ;
theProfessionPerson profession = mkNP the_Det profession ;
iMascPerson = i_NP ;
iFemPerson = i_NP ;
youMascPerson = you_NP ;
youFemPerson = you_NP ;
hePerson = he_NP ;
shePerson = she_NP ;
goToAction place = mkVP (mkVP go_V) place.to ;
stayAtAction place = mkVP (mkVP stay_V) place.at ;
vaccinateAction person = mkVP vaccinate_V2 person ;
examineAction person = mkVP examine_V2 person ;
takeSubstanceAction substance = mkVP use_V2 substance ;
-- end of what could be a functor
--------------------------------
coughAction = mkVP (mkV "hostar") ;
breatheAction = mkVP (mkV "andas" "andas" "andas" "andades" "andats" "andad") ;
vomitAction = mkVP (mkV "kräkas" "kräks" "kräks" "kräktes" "kräkts" "kräkt") ;
sleepAction = mkVP (mkV "sova" "sov" "sovit") ;
undressAction = mkVP (mkV2 (take_V "av" )) (mkNP thePl_Det (mkN "kläd" "kläder")) ;
dressAction = mkVP (mkV2 (take_V "på")) (mkNP thePl_Det (mkN "kläd" "kläder")) ;
eatAction = mkVP (mkV "äta" "åt" "ätit") ;
drinkAction = mkVP (mkV "dricka" "drack" "druckit") ;
smokeAction = mkVP (mkV "röker") ;
measureTemperatureAction = mkVP (mkV2 (mkV "mäter")) (mkNP the_Det (mkN "kroppstemperatur")) ;
measureBloodPressureAction = mkVP (mkV2 (mkV "mäter")) (mkNP the_Det (mkN "blodtryck" "blodtrycket" "blodtryck" "blodtrycken")) ;
hospitalPlace = {at = pAdv "på sjukhuset" ; to = pAdv "till sjukhuset"} ;
homePlace = {at = pAdv "hemma" ; to = pAdv "hem"} ;
schoolPlace = {at = pAdv "i skolan" ; to = pAdv "till skolan"} ;
workPlace = {at = pAdv "på jobbet" ; to = pAdv "till jobbet"} ;
doctorProfession = mkCN (mkN "läkare" "läkare") ;
nurseProfession = mkCN (mkN "sköterska") ;
interpreterProfession = mkCN (mkN "tolk") ;
bePregnantProperty = mkVP (mkA "gravid") ;
beIllProperty = mkVP (mkA "sjuk") ;
beWellProperty = mkVP (mkA "frisk") ;
beDeadProperty = mkVP (mkA "död") ;
haveAllergiesProperty = mkVP have_V2 (mkNP aPl_Det (mkN "allergi" "allergier")) ;
havePainsProperty = mkVP have_V2 (mkNP aPl_Det (mkN "smärta")) ;
haveChildrenProperty = mkVP have_V2 (mkNP aPl_Det (mkN "barn" "barn")) ;
feverIllness = mkNP (mkN "feber") ;
fluIllness = mkNP (mkN "influensa") ;
headacheIllness = mkNP (mkN "huvudvärk") ;
diarrheaIllness = mkNP (mkN "diarré") ;
heartDiseaseIllness = mkNP a_Det (mkN "hjärtsjukdom") ;
lungDiseaseIllness = mkNP a_Det (mkN "lungsjukdom") ;
hypertensionIllness = mkNP (mkN "hypertoni") ;
alcoholSubstance = mkNP (mkN "alkohol") ;
medicineSubstance = mkNP a_Det (mkN "medicin") ;
drugsSubstance = mkNP aPl_Det (mkN "drog" "droger") ;
oper
pAdv : Str -> Adv = ParadigmsSwe.mkAdv ;
go_V = mkV "gå" "gick" "gått" ;
stay_V = mkV "stannar" ;
take_V = mkV (mkV "ta" "tar" "ta" "tog" "tagit" "tagen") ;
need_V2 = mkV2 (mkV "behöver") ;
use_V2 = mkV2 (mkV "använda" "använde" "använt") ;
vaccinate_V2 = mkV2 (mkV "vaccinerar") ;
examine_V2 = mkV2 (mkV "undersöker") ;
}

View File

@@ -1,5 +1,5 @@
--# -path=.:../abstract
concrete MicroLangEn of MicroLang = open MicroResEn, Prelude in {
concrete MicroLangEng of MicroLang = open MicroResEng, Prelude in {
-----------------------------------------------------
---------------- Grammar part -----------------------

View File

@@ -1,241 +0,0 @@
--# -path=.:../abstract
concrete MicroLangFr of MicroLang = open MicroResFr, Prelude in {
-----------------------------------------------------
---------------- Grammar part -----------------------
-----------------------------------------------------
lincat
Utt = {s : Str} ;
S = {s : Str} ;
VP = {verb : Verb ; compl : Number => Gender => Str} ;
Comp = Adjective ;
AP = Adjective ;
CN = Noun ;
NP = {s : Case => Str ; gen : Gender ; num : Number } ;
Pron = {s : Case => Str ; gen : Gender ; num: Number } ;
Det = {s : Str ; num : Number ; gen : Gender } ;
Prep = {s : Str} ;
V = Verb ;
V2 = Verb2 ;
A = Adjective ;
N = Noun ;
Adv = {s : Str} ;
lin
UttS s = s ;
UttNP np = {s = np.s ! Acc} ;
-- PredVP : NP -> VP -> Cl
PredVPS np vp = {
s = np.s ! Nom ++ vp.verb.s ! agr2vform np.num ++ vp.compl ! np.num ! np.gen
} ;
-- V -> VP
UseV v = {
verb = v ;
compl = \\num,gen => [] ;
} ;
-- V2 -> NP -> VP
ComplV2 v2 np = {
verb = v2 ;
compl = \\num,gen => v2.c ! num ! gen ++ np.s ! Acc -- NP object in the accusative
} ;
UseComp comp = {
verb = be_Verb ; -- the verb is the copula "être"
compl = \\num,gen => comp.s ! num ! gen
} ;
CompAP ap = ap ;
AdvVP vp adv =
vp ** {compl = \\num,gen => vp.compl ! num ! gen ++ adv.s} ; --update complement by + adv
-- Det -> CN -> NP
DetCN det cn = {
s = \\c => det.s ++ cn.s ! det.num ;
gen = cn.gen ;
num = det.num ;
} ;
a_Det = {s = pre {"a"|"e"|"i"|"o" => "l'" ; _ => "le"} ; num = Sg ; gen = M | F} ;
aPl_Det = {s = "la" ; num = Sg ; gen = F} ;
the_Det = {s = "les" ; num = Pl ; gen = M | F} ;
thePl_Det = {s = "des" ; num = Pl ; gen = M | F} ;
UsePron p = p ;
-- N -> CN
UseN noun = noun ;
-- AP -> CN -> CN
AdjCN ap cn = {
s = \\num => ap.s ! num ! cn.gen ++ cn.s ! num ; --table from number to gender to string
gen = cn.gen ;
} ;
PositA a = a ;
PrepNP prep np = {s = prep.s ++ np.s ! Acc} ;
in_Prep = {s = "dans"} ;
on_Prep = {s = "sur"} ;
with_Prep = {s = "avec"} ;
he_Pron = {
s = table {Nom => "il" ; Acc => "le"} ;
num = Sg ;
pers = P3 ;
gen = M ;
} ;
she_Pron = {
s = table {Nom => "elle" ; Acc => "la"} ;
num = Sg ;
pers = P3 ;
gen = F ;
} ;
they_Pron = {
s = table {Nom => "ils" ; Acc => "les"} ;
num = Pl ;
pers = P3 ;
gen = M | F ;
} ;
-----------------------------------------------------
---------------- Lexicon part -----------------------
-----------------------------------------------------
lin already_Adv = mkAdv "déja" ;
lin animal_N = mkN "animal" ;
lin apple_N = mkN "pomme" ;
lin baby_N = mkN "bébé" ;
lin bad_A = mkA "mauvais" ;
lin beer_N = mkN "bière" ;
lin big_A = mkA "grand" ;
lin bike_N = mkN "vélo" ;
lin bird_N = mkN "oiseau" ;
lin black_A = mkA "noir" ;
lin blood_N = mkN "sang" "sang";
lin blue_A = mkA "bleu" ;
lin boat_N = mkN "bâteau" ;
lin book_N = mkN "livre" ;
lin boy_N = mkN "garçon" ;
lin bread_N = mkN "pain" ;
lin break_V2 = mkV2 (mkV "casser") ;
lin buy_V2 = mkV2 (mkV "acheter" "achète" "achetons" "achètes" "achetez" "achète" "achetent") ;
lin car_N = mkN "voiture" ;
lin cat_N = mkN "chat" ;
lin child_N = mkN "enfant" ;
lin city_N = mkN "ville" ;
lin clean_A = mkA "propre" ;
lin clever_A = mkA "intelligent" ;
lin cloud_N = mkN "nuage" ;
lin cold_A = mkA "froid" ;
lin come_V = mkV "venir" "viens" "venons" "viens" "venez" "vient" "viennent" ;
lin computer_N = mkN "ordinateur" ;
lin cow_N = mkN "vache" ;
lin dirty_A = mkA "sale" ;
lin dog_N = mkN "chien" ;
lin drink_V2 = mkV2 (mkV "boire" "bois" "buvons" "bois" "buvez" "boit" "boivent") ;
lin eat_V2 = mkV2 (mkV "manger") ;
lin find_V2 = mkV2 (mkV "trouver") ;
lin fire_N = mkN "feu" ;
lin fish_N = mkN "poisson" ;
lin flower_N = mkN "fleur" ;
lin friend_N = mkN "ami" ;
lin girl_N = mkN "fille" ;
lin good_A = mkA "bon" ;
lin go_V = mkV "aller" "vais" "allons" "vas" "allez" "va" "vont" ;
lin grammar_N = mkN "grammaire" ;
lin green_A = mkA "vert" ;
lin heavy_A = mkA "lourd" ;
lin horse_N = mkN "cheval" ;
lin hot_A = mkA "chaud" ;
lin house_N = mkN "maison" ;
-- lin john_PN = mkPN "John" ;
lin jump_V = mkV "sauter" ;
lin kill_V2 = mkV2 "tuer" ;
-- lin know_VS = mkVS (mkV "savoir" "sais" "savons" "sais" "savez" "sait" "savent") ;
lin language_N = mkN "langue" ;
lin live_V = mkV "vivre" ;
lin love_V2 = mkV2 (mkV "aimer") ;
lin man_N = mkN "homme" ;
lin milk_N = mkN "lait" "lait" ;
lin music_N = mkN "musique" ;
lin new_A = mkA "nouveau" ;
lin now_Adv = mkAdv "maintenant" ;
lin old_A = mkA "ancien" ;
-- lin paris_PN = mkPN "Paris" ;
lin play_V = mkV "jouer" ;
lin read_V2 = mkV2 (mkV "lire" "lis" "lisons" "lis" "lisez" "lit" "lisent") ;
lin ready_A = mkA "prêt" ;
lin red_A = mkA "rouge" ;
lin river_N = mkN "rivière" ;
lin run_V = mkV "courir" ;
lin sea_N = mkN "mer" ;
lin see_V2 = mkV2 (mkV "voir") ;
lin ship_N = mkN "navire" ;
lin sleep_V = mkV "acheter" "achète" "achètes" "achete" "achètons" "achetez" "achetent" ;
lin small_A = mkA "petit" ;
lin star_N = mkN "etoile" ;
lin swim_V = mkV "nager" ;
lin teach_V2 = mkV2 (mkV "enseigner") ;
lin train_N = mkN "train" ;
lin travel_V = mkV "voyager" ;
lin tree_N = mkN "arbre" ;
lin understand_V2 = mkV2 (mkV "comprendre") ;
lin wait_V2 = mkV2 "attendre" ;
lin walk_V = mkV "marcher" ;
lin warm_A = mkA "chaud" ;
lin water_N = mkN "eau" ;
lin white_A = mkA "blanc" ;
lin wine_N = mkN "vin" ;
lin woman_N = mkN "femme" ;
lin yellow_A = mkA "jaune" ;
lin young_A = mkA "jeune" ;
---------------------------
-- Paradigms part ---------
---------------------------
oper
mkN = overload {
mkN : Str -> Noun -- predictable nouns according to the pattern matching
= \n -> lin N (smartNoun n) ;
mkN : Str -> Str -> Noun -- irregular nouns
= \sg,pl -> lin N (mkNoun sg pl) ;
} ;
mkA : Str -> A = \s -> lin A (smartA s) ;
mkV = overload {
mkV : (inf : Str) -> V
= \s -> lin V (smartVerb s) ;
mkV : (inf,p1sg,p2sg,p3sg,p1pl,p2pl,p3pl : Str) -> V
= \inf,p1sg,p2sg,p3sg,p1pl,p2pl,p3pl -> lin V (irregVerb inf p1sg p2sg p3sg p1pl p2pl p3pl) ;
} ;
mkV2 = overload {
mkV2 : Str -> V2
= \s -> lin V2 (smartVerb s ** {c =\\num,gen => []}) ;
mkV2 : Str -> Str -> V2 -- predictable verb with preposition
= \s,p -> lin V2 (smartVerb s ** {c =\\num,gen => p}) ;
mkV2 : V -> V2 -- any verb with direct object
= \v -> lin V2 (v ** {c =\\num,gen => []}) ;
mkV2 : V -> Str -> V2 -- any verb with preposition
= \v,p -> lin V2 (v ** {c =\\num,gen => p}) ;
} ;
mkAdv : Str -> Adv
= \s -> lin Adv {s = s} ;
mkPrep : Str -> Prep
= \s -> lin Prep {s = s} ;
}

View File

@@ -1,4 +1,4 @@
resource MicroResEn = open Prelude in {
resource MicroResEng = open Prelude in {
param
Number = Sg | Pl ;

View File

@@ -1,162 +0,0 @@
resource MicroResFr = open Prelude in {
param
Number = Sg | Pl ;
Case = Nom | Acc ;
Gender = F | M ;
Person = P1 | P2 | P3 ;
-- infinitive | present forms of French verbs
VForm = VInf | VPres Person Number;
oper
--------------------- NOUNS --------------------------
------------------------------------------------------
Noun : Type = {s : Number => Str ; gen : Gender} ;
mkNoun : Str -> Str -> Noun = \sg,pl -> {
s = table {Sg => sg ; Pl => pl} ;
gen = mkGen sg
} ;
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
smartNoun : Str -> Noun = \sg -> case sg of {
_ + ("é"|"o"|"e"|"n"|"t"|"r"|"i"|"il"|"ol"|"el") => regNoun sg ;
_ + ("au"|"eu"|"eau") => mkNoun sg (sg + "x") ;
noun + "al" => mkNoun sg (noun + "aux") ;
noun + ("z"|"s"|"x") => mkNoun sg sg ; --plural defective nouns
("sang"|"lait") => mkNoun sg sg --attempt in
} ;
mkGen: Str -> Gender = \sg -> case sg of {
root + ("au"|"isson"|"eu"|"t"|"o"|"age"|"é"|"ire"|"al"|"i"|"g"|"in"|"at"|"nt"|"en") => M ; -- some general rules for M nouns
("garçon"|"livre"|"arbre") => M ; -- exceptions for M
root + ("té"|"ion"|"elle"|"me"|"ère"|"eur"|"ure"|"che"|"le"|"aire"|"ue"|"er") => F ; -- some general rules for F nouns
("maison" | "eau") => F -- exceptions for F
} ;
----------------------- ADJ inflection tables ----------------------
--------------------------------------------------------------------
Adjective : Type = {s : Number => Gender => Str} ;
mkAdjective : (msg,fsg,mpl,fpl : Str) -> Adjective = \msg,fsg,mpl,fpl ->
{s = table { Sg => table { M => msg ; F => fsg } ; Pl => table { M => mpl ; F => fpl }
} ;
} ;
regA : (msg : Str) -> Adjective = \grand ->
mkAdjective grand (grand + "e") (grand + "s") (grand + "es") ;
irA_anc : (msg : Str) -> Adjective = \blanc ->
mkAdjective blanc (blanc+"he") (blanc + "s") (blanc+"hes" ) ;
irA_eau : (msg : Str) -> Adjective = \nouv ->
mkAdjective (nouv + "eau") (nouv + "elle") (nouv + "eaux") (nouv + "elles") ;
-- adj that are gender invariable - have the same form for both genders in Sg | Pl: e.g. "calme" "calme" "calmes" "calmes"
invar_gen : (msg : Str) -> Adjective = \propre ->
mkAdjective propre propre (propre + "s") (propre + "s") ;
-- adj that are number invariable - have the same form for both genders in Sg: e.g."anglais" "anglaise" "anglais" "anglaises"
invar_num : (msg : Str) -> Adjective = \mauvais ->
mkAdjective mauvais (mauvais + "e") mauvais (mauvais + "es") ;
dupl_n : (msg : Str) -> Adjective = \bon ->
let bonn = bon + last bon
in
mkAdjective bon (bonn + "e") (bon + "s") (bonn + "es") ;
smartA : (msg : Str) -> Adjective = \adj -> case adj of {
_ + ("d"|"t"|"eu"|"r") => regA adj ;
_ + "anc" => irA_anc adj ;
adj + "eau" => irA_eau adj ;
_ + "e" => invar_gen adj ;
_ + ("ien"|"on"|"en") => dupl_n adj ;
_ + "s" => invar_num adj
} ;
------------------- VERB Paradigms------------------------
----------------------------------------------------------
Verb : Type = {s : VForm => Str} ;
mkVerb : (vinf,p1sg,p1pl,p2sg,p2pl,p3sg,p3pl : Str) -> Verb
= \vinf,p1sg,p1pl,p2sg,p2pl,p3sg,p3pl -> {
s = table {
VInf => vinf ;
VPres P1 Sg => p1sg ;
VPres P2 Sg => p2sg ;
VPres P3 Sg => p3sg ;
VPres P1 Pl => p1pl ;
VPres P2 Pl => p2pl ;
VPres P3 Pl => p3pl
} ;
} ;
-- verbs ending in -ger that need an extra "e" for the 1st Person pl
ger_Verb : Str -> Verb = \manger ->
let mange = init manger
in
mkVerb manger mange (mange + "ons") (mange + "s") (mange + "z") mange (mange + "nt") ;
er_Verb : Str -> Verb = \aimer ->
let aim = init aimer
in
mkVerb aimer aim (aim + "ons") (aim + "s") (aim + "z") aim (aim + "nt") ;
ir_Verb : Str -> Verb = \cour ->
mkVerb cour (cour + "s") (cour + "ons") (cour + "s") (cour + "ez") (cour + "t") (cour + "ent") ;
re_Verb : Str -> Verb = \attendre ->
let attend = init attendre
in
mkVerb attendre (attend + "ds") (attend + "dons") (attend + "ds") (attend + "dez") (attend + "d") (attend + "dent") ;
-- regular verbs with predictable variations
smartVerb : Str -> Verb = \v -> case v of {
v + "re" => re_Verb v ;
v + "ir" => ir_Verb v ;
v + "er" => er_Verb v ;
_ + "g" + "er" => ger_Verb v
} ;
-- some irregular verbs e.g. acheter achète achètes
irregVerb : (vinf,p1sg,p2sg,p3sg,p1pl,p2pl,p3pl : Str) -> Verb =
\vinf,p1sg,p2sg,p3sg,p1pl,p2pl,p3pl ->
mkVerb vinf p1sg p2sg p3sg p1pl p2pl p3pl ;
-- two-place verb with "case" as preposition; for transitive verbs, c=[]
Verb2 : Type = Verb ** {c : Number => Gender => Str} ;
be_Verb : Verb = mkVerb "être" "suis" "es" "est" "sommes" "êtes" "sont" ; ---s to be generalized
Determiner : Type = {s : Str ; n : Number ; gen : Gender} ;
mkDet : Str -> Number -> Gender -> Determiner ;
mkDet str num gen = {s=str ; n = num ; gen = gen} ;
---s a very simplified verb agreement function for Micro
agr2vform : Number -> VForm = \a -> case a of {
Sg => VPres P3 Sg ;
Pl => VPres P3 Pl
} ;
}

View File

@@ -0,0 +1,15 @@
--# -path=.:../abstract
concrete MicroLangEng of MicroLang = open MicroResEng in {
lincat N = MicroResEng.N ;
lin baby_N = mkN "baby" ;
lin dog_N = mkN "dog" ;
lin man_N = mkN "man" "men" ;
lin car_N = mkN "car" ;
lin city_N = mkN "city" ;
lin boy_N = mkN "boy" ;
}

Binary file not shown.

View File

@@ -0,0 +1,15 @@
--# -path=.:../abstract
concrete MicroLangSwe of MicroLang = open MicroResSwe in {
lincat N = MicroResSwe.N ;
lin baby_N = decl2 "bebis" ;
lin dog_N = decl2 "hund" ;
lin man_N = worstN "man" "mannen" "män" "männen" Utr ;
lin car_N = decl2 "bil" ;
--lin city_N = mkN "stad" ;
lin boy_N = decl2 "pojke" ;
}

Binary file not shown.

View File

@@ -0,0 +1,30 @@
resource MicroResEng = {
param Number = Sg | Pl ;
oper
N = {s : Number => Str} ;
worstN : Str -> Str -> N
= \x,y -> {s = table {Sg => x ; Pl => y}} ;
regN : Str -> N
= \x -> worstN x (x + "s") ;
smartN : Str -> N
= \x -> case x of
{
b + ("ay"|"oy"|"uy") => regN x ;
bab + "y" => worstN x (bab + "ies") ;
_ => regN x
} ;
mkN = overload {
mkN : (dog : Str) -> N
= smartN ;
mkN : (man,men : Str) -> N
= worstN
} ;
}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
resource MicroResSwe = {
param
Number = Sg | Pl ;
Species = Indef | Def ;
Gender = Utr | Neutr ;
oper
N = {s : Number => Species => Str ; g : Gender} ;
worstN : Str -> Str -> Str -> Str -> Gender -> N
= \man,mannen,män,männen,gen -> {
s = table {
Sg => table {Indef => man ; Def => mannen} ;
Pl => table {Indef => män ; Def => männen}
} ;
g = gen
} ;
decl2 : Str -> N
= \bil -> worstN bil (bil + "en") (bil + "ar") (bil + "arna") Utr ;
}

Binary file not shown.