re(moved) unused/non-lab files

This commit is contained in:
Arianna Masciolini
2025-03-26 15:10:34 +01:00
parent 125b8a2b0d
commit 1a184f6937
6 changed files with 630 additions and 0 deletions

View File

@@ -0,0 +1,165 @@
abstract MicroLang = {
-- a very minimal version of MiniGrammar + MiniLexicon, helping to get started
-----------------------------------------------------
---------------- Grammar part -----------------------
-----------------------------------------------------
cat
-- Common
Utt ; -- sentence, question, word... e.g. "be quiet"
-- Cat
S ; -- declarative sentence e.g. "she lives here"
VP ; -- verb phrase e.g. "lives here"
Comp ; -- complement of copula e.g. "warm"
AP ; -- adjectival phrase e.g. "warm"
CN ; -- common noun (without determiner) e.g. "red house"
NP ; -- noun phrase (subject or object) e.g. "the red house"
Det ; -- determiner phrase e.g. "those"
Prep ; -- preposition, or just case e.g. "in", dative
V ; -- one-place verb e.g. "sleep"
V2 ; -- two-place verb e.g. "love"
A ; -- one-place adjective e.g. "warm"
N ; -- common noun e.g. "house"
Pron ; -- personal pronoun e.g. "she"
Adv ; -- adverbial phrase e.g. "in the house"
fun
-- Phrase
UttS : S -> Utt ; -- he walks
UttNP : NP -> Utt ; -- he
-- Sentence
PredVPS : NP -> VP -> S ; -- John walks --s shortcut even wrt MiniGrammar
-- Verb
UseV : V -> VP ; -- sleep
ComplV2 : V2 -> NP -> VP ; -- love it ---s
UseComp : Comp -> VP ; -- be small
CompAP : AP -> Comp ; -- small
AdvVP : VP -> Adv -> VP ; -- sleep here
-- Noun
DetCN : Det -> CN -> NP ; -- the man
UsePron : Pron -> NP ; -- she
a_Det : Det ; -- indefinite singular ---s
aPl_Det : Det ; -- indefinite plural ---s
the_Det : Det ; -- definite singular ---s
thePl_Det : Det ; -- definite plural ---s
UseN : N -> CN ; -- house
AdjCN : AP -> CN -> CN ; -- big house
-- Adjective
PositA : A -> AP ; -- warm
-- Adverb
PrepNP : Prep -> NP -> Adv ; -- in the house
-- Structural
in_Prep : Prep ;
on_Prep : Prep ;
with_Prep : Prep ;
he_Pron : Pron ;
she_Pron : Pron ;
they_Pron : Pron ;
-----------------------------------------------------
---------------- Lexicon part -----------------------
-----------------------------------------------------
fun
already_Adv : Adv ;
animal_N : N ;
apple_N : N ;
baby_N : N ;
bad_A : A ;
beer_N : N ;
big_A : A ;
bike_N : N ;
bird_N : N ;
black_A : A ;
blood_N : N ;
blue_A : A ;
boat_N : N ;
book_N : N ;
boy_N : N ;
bread_N : N ;
break_V2 : V2 ;
buy_V2 : V2 ;
car_N : N ;
cat_N : N ;
child_N : N ;
city_N : N ;
clean_A : A ;
clever_A : A ;
cloud_N : N ;
cold_A : A ;
come_V : V ;
computer_N : N ;
cow_N : N ;
dirty_A : A ;
dog_N : N ;
drink_V2 : V2 ;
eat_V2 : V2 ;
find_V2 : V2 ;
fire_N : N ;
fish_N : N ;
flower_N : N ;
friend_N : N ;
girl_N : N ;
good_A : A ;
go_V : V ;
grammar_N : N ;
green_A : A ;
heavy_A : A ;
horse_N : N ;
hot_A : A ;
house_N : N ;
-- john_PN : PN ;
jump_V : V ;
kill_V2 : V2 ;
-- know_VS : VS ;
language_N : N ;
live_V : V ;
love_V2 : V2 ;
man_N : N ;
milk_N : N ;
music_N : N ;
new_A : A ;
now_Adv : Adv ;
old_A : A ;
-- paris_PN : PN ;
play_V : V ;
read_V2 : V2 ;
ready_A : A ;
red_A : A ;
river_N : N ;
run_V : V ;
sea_N : N ;
see_V2 : V2 ;
ship_N : N ;
sleep_V : V ;
small_A : A ;
star_N : N ;
swim_V : V ;
teach_V2 : V2 ;
train_N : N ;
travel_V : V ;
tree_N : N ;
understand_V2 : V2 ;
wait_V2 : V2 ;
walk_V : V ;
warm_A : A ;
water_N : N ;
white_A : A ;
wine_N : N ;
woman_N : N ;
yellow_A : A ;
young_A : A ;
}

View File

@@ -0,0 +1,225 @@
--# -path=.:../abstract
concrete MicroLangEng of MicroLang = open MicroResEng, Prelude in {
-----------------------------------------------------
---------------- Grammar part -----------------------
-----------------------------------------------------
lincat
Utt = {s : Str} ;
S = {s : Str} ;
VP = {verb : Verb ; compl : Str} ; ---s special case of Mini
Comp = {s : Str} ;
AP = Adjective ;
CN = Noun ;
NP = {s : Case => Str ; a : Agreement} ;
Pron = {s : Case => Str ; a : Agreement} ;
Det = {s : Str ; n : Number} ;
Prep = {s : Str} ;
V = Verb ;
V2 = Verb2 ;
A = Adjective ;
N = Noun ;
Adv = {s : Str} ;
lin
UttS s = s ;
UttNP np = {s = np.s ! Acc} ;
PredVPS np vp = {
s = np.s ! Nom ++ vp.verb.s ! agr2vform np.a ++ vp.compl
} ;
UseV v = {
verb = v ;
compl = [] ;
} ;
ComplV2 v2 np = {
verb = v2 ;
compl = v2.c ++ np.s ! Acc -- NP object in the accusative, preposition first
} ;
UseComp comp = {
verb = be_Verb ; -- the verb is the copula "be"
compl = comp.s
} ;
CompAP ap = ap ;
AdvVP vp adv =
vp ** {compl = vp.compl ++ adv.s} ;
DetCN det cn = {
s = \\c => det.s ++ cn.s ! det.n ;
a = Agr det.n ;
} ;
UsePron p = p ;
a_Det = {s = pre {"a"|"e"|"i"|"o" => "an" ; _ => "a"} ; n = Sg} ; --- a/an can get wrong
aPl_Det = {s = "" ; n = Pl} ;
the_Det = {s = "the" ; n = Sg} ;
thePl_Det = {s = "the" ; n = Pl} ;
UseN n = n ;
AdjCN ap cn = {
s = table {n => ap.s ++ cn.s ! n}
} ;
PositA a = a ;
PrepNP prep np = {s = prep.s ++ np.s ! Acc} ;
in_Prep = {s = "in"} ;
on_Prep = {s = "on"} ;
with_Prep = {s = "with"} ;
he_Pron = {
s = table {Nom => "he" ; Acc => "him"} ;
a = Agr Sg ;
} ;
she_Pron = {
s = table {Nom => "she" ; Acc => "her"} ;
a = Agr Sg ;
} ;
they_Pron = {
s = table {Nom => "they" ; Acc => "them"} ;
a = Agr Pl ;
} ;
-----------------------------------------------------
---------------- Lexicon part -----------------------
-----------------------------------------------------
lin already_Adv = mkAdv "already" ;
lin animal_N = mkN "animal" ;
lin apple_N = mkN "apple" ;
lin baby_N = mkN "baby" ;
lin bad_A = mkA "bad" ;
lin beer_N = mkN "beer" ;
lin big_A = mkA "big" ;
lin bike_N = mkN "bike" ;
lin bird_N = mkN "bird" ;
lin black_A = mkA "black" ;
lin blood_N = mkN "blood" ;
lin blue_A = mkA "blue" ;
lin boat_N = mkN "boat" ;
lin book_N = mkN "book" ;
lin boy_N = mkN "boy" ;
lin bread_N = mkN "bread" ;
lin break_V2 = mkV2 (mkV "break" "broke" "broken") ;
lin buy_V2 = mkV2 (mkV "buy" "bought" "bought") ;
lin car_N = mkN "car" ;
lin cat_N = mkN "cat" ;
lin child_N = mkN "child" "children" ;
lin city_N = mkN "city" ;
lin clean_A = mkA "clean" ;
lin clever_A = mkA "clever" ;
lin cloud_N = mkN "cloud" ;
lin cold_A = mkA "cold" ;
lin come_V = mkV "come" "came" "come" ;
lin computer_N = mkN "computer" ;
lin cow_N = mkN "cow" ;
lin dirty_A = mkA "dirty" ;
lin dog_N = mkN "dog" ;
lin drink_V2 = mkV2 (mkV "drink" "drank" "drunk") ;
lin eat_V2 = mkV2 (mkV "eat" "ate" "eaten") ;
lin find_V2 = mkV2 (mkV "find" "found" "found") ;
lin fire_N = mkN "fire" ;
lin fish_N = mkN "fish" "fish" ;
lin flower_N = mkN "flower" ;
lin friend_N = mkN "friend" ;
lin girl_N = mkN "girl" ;
lin good_A = mkA "good" ;
lin go_V = mkV "go" "went" "gone" ;
lin grammar_N = mkN "grammar" ;
lin green_A = mkA "green" ;
lin heavy_A = mkA "heavy" ;
lin horse_N = mkN "horse" ;
lin hot_A = mkA "hot" ;
lin house_N = mkN "house" ;
-- lin john_PN = mkPN "John" ;
lin jump_V = mkV "jump" ;
lin kill_V2 = mkV2 "kill" ;
-- lin know_VS = mkVS (mkV "know" "knew" "known") ;
lin language_N = mkN "language" ;
lin live_V = mkV "live" ;
lin love_V2 = mkV2 (mkV "love") ;
lin man_N = mkN "man" "men" ;
lin milk_N = mkN "milk" ;
lin music_N = mkN "music" ;
lin new_A = mkA "new" ;
lin now_Adv = mkAdv "now" ;
lin old_A = mkA "old" ;
-- lin paris_PN = mkPN "Paris" ;
lin play_V = mkV "play" ;
lin read_V2 = mkV2 (mkV "read" "read" "read") ;
lin ready_A = mkA "ready" ;
lin red_A = mkA "red" ;
lin river_N = mkN "river" ;
lin run_V = mkV "run" "ran" "run" ;
lin sea_N = mkN "sea" ;
lin see_V2 = mkV2 (mkV "see" "saw" "seen") ;
lin ship_N = mkN "ship" ;
lin sleep_V = mkV "sleep" "slept" "slept" ;
lin small_A = mkA "small" ;
lin star_N = mkN "star" ;
lin swim_V = mkV "swim" "swam" "swum" ;
lin teach_V2 = mkV2 (mkV "teach" "taught" "taught") ;
lin train_N = mkN "train" ;
lin travel_V = mkV "travel" ;
lin tree_N = mkN "tree" ;
lin understand_V2 = mkV2 (mkV "understand" "understood" "understood") ;
lin wait_V2 = mkV2 "wait" "for" ;
lin walk_V = mkV "walk" ;
lin warm_A = mkA "warm" ;
lin water_N = mkN "water" ;
lin white_A = mkA "white" ;
lin wine_N = mkN "wine" ;
lin woman_N = mkN "woman" "women" ;
lin yellow_A = mkA "yellow" ;
lin young_A = mkA "young" ;
---------------------------
-- Paradigms part ---------
---------------------------
oper
mkN = overload {
mkN : Str -> Noun -- predictable noun, e.g. car-cars, boy-boys, fly-flies, bush-bushes
= \n -> lin N (smartNoun n) ;
mkN : Str -> Str -> Noun -- irregular noun, e.g. man-men
= \sg,pl -> lin N (mkNoun sg pl) ;
} ;
mkA : Str -> A
= \s -> lin A {s = s} ;
mkV = overload {
mkV : (inf : Str) -> V -- predictable verb, e.g. play-plays, cry-cries, wash-washes
= \s -> lin V (smartVerb s) ;
mkV : (inf,pres,part : Str) -> V -- irregular verb, e.g. drink-drank-drunk
= \inf,pres,part -> lin V (irregVerb inf pres part) ;
} ;
mkV2 = overload {
mkV2 : Str -> V2 -- predictable verb with direct object, e.g. "wash"
= \s -> lin V2 (smartVerb s ** {c = []}) ;
mkV2 : Str -> Str -> V2 -- predictable verb with preposition, e.g. "wait - for"
= \s,p -> lin V2 (smartVerb s ** {c = p}) ;
mkV2 : V -> V2 -- any verb with direct object, e.g. "drink"
= \v -> lin V2 (v ** {c = []}) ;
mkV2 : V -> Str -> V2 -- any verb with preposition
= \v,p -> lin V2 (v ** {c = p}) ;
} ;
mkAdv : Str -> Adv
= \s -> lin Adv {s = s} ;
mkPrep : Str -> Prep
= \s -> lin Prep {s = s} ;
}

View File

@@ -0,0 +1,75 @@
resource MicroResEng = open Prelude in {
param
Number = Sg | Pl ;
Case = Nom | Acc ;
Agreement = Agr Number ; ---s Person to be added
-- all forms of normal Eng verbs, although not yet used in MiniGrammar
VForm = Inf | PresSg3 | Past | PastPart | PresPart ;
oper
Noun : Type = {s : Number => Str} ;
mkNoun : Str -> Str -> Noun = \sg,pl -> {
s = table {Sg => sg ; Pl => pl}
} ;
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
-- smart paradigm
smartNoun : Str -> Noun = \sg -> case sg of {
_ + ("ay"|"ey"|"oy"|"uy") => regNoun sg ;
x + "y" => mkNoun sg (x + "ies") ;
_ + ("ch"|"sh"|"s"|"o") => mkNoun sg (sg + "es") ;
_ => regNoun sg
} ;
Adjective : Type = {s : Str} ;
Verb : Type = {s : VForm => Str} ;
mkVerb : (inf,pres,past,pastpart,prespart : Str) -> Verb
= \inf,pres,past,pastpart,prespart -> {
s = table {
Inf => inf ;
PresSg3 => pres ;
Past => past ;
PastPart => pastpart ;
PresPart => prespart
}
} ;
regVerb : (inf : Str) -> Verb = \inf ->
mkVerb inf (inf + "s") (inf + "ed") (inf + "ed") (inf + "ing") ;
-- regular verbs with predictable variations
smartVerb : Str -> Verb = \inf -> case inf of {
pl + ("a"|"e"|"i"|"o"|"u") + "y" => regVerb inf ;
cr + "y" => mkVerb inf (cr + "ies") (cr + "ied") (cr + "ied") (inf + "ing") ;
lov + "e" => mkVerb inf (inf + "s") (lov + "ed") (lov + "ed") (lov + "ing") ;
kis + ("s"|"sh"|"x"|"o") => mkVerb inf (inf + "es") (inf + "ed") (inf + "ed") (inf + "ing") ;
_ => regVerb inf
} ;
-- normal irregular verbs e.g. drink,drank,drunk
irregVerb : (inf,past,pastpart : Str) -> Verb =
\inf,past,pastpart ->
let verb = smartVerb inf
in mkVerb inf (verb.s ! PresSg3) past pastpart (verb.s ! PresPart) ;
-- two-place verb with "case" as preposition; for transitive verbs, c=[]
Verb2 : Type = Verb ** {c : Str} ;
be_Verb : Verb = mkVerb "are" "is" "was" "been" "being" ; ---s to be generalized
---s a very simplified verb agreement function for Micro
agr2vform : Agreement -> VForm = \a -> case a of {
Agr Sg => PresSg3 ;
Agr Pl => Inf
} ;
}

View File

@@ -0,0 +1,150 @@
incomplete concrete MicroLangFunctor of MicroLang =
open
Grammar,
Syntax,
Lexicon
in {
-- a functor implementation of MicroLang, using Grammar and Lexicon whenever the function is
-- directly from there, Syntax otherwise
-----------------------------------------------------
---------------- Grammar part -----------------------
-----------------------------------------------------
lincat
Utt = Grammar.Utt ;
S = Grammar.S ;
VP = Grammar.VP ;
Comp = Grammar.Comp ;
AP = Grammar.AP ;
CN = Grammar.CN ;
NP = Grammar.NP ;
Det = Grammar.Det ;
Prep = Grammar.Prep ;
V = Grammar.V ;
V2 = Grammar.V2 ;
A = Grammar.A ;
N = Grammar.N ;
Pron = Grammar.Pron ;
Adv = Grammar.Adv ;
lin
UttS = Grammar.UttS ;
UttNP = Grammar.UttNP ;
PredVPS np vp = Syntax.mkS (Syntax.mkCl np vp) ;
UseV = Grammar.UseV ;
ComplV2 v2 np = Syntax.mkVP v2 np ;
UseComp = Grammar.UseComp ;
CompAP = Grammar.CompAP ;
AdvVP = Grammar.AdvVP ;
DetCN = Grammar.DetCN ;
UsePron = Grammar.UsePron ;
a_Det = Syntax.a_Det ;
aPl_Det = Syntax.aPl_Det ;
the_Det = Syntax.the_Det ;
thePl_Det = Syntax.thePl_Det ;
UseN = Grammar.UseN ;
AdjCN = Grammar.AdjCN ;
PositA = Grammar.PositA ;
PrepNP = Grammar.PrepNP ;
in_Prep = Grammar.in_Prep ;
on_Prep = Grammar.on_Prep ;
with_Prep = Grammar.with_Prep ;
he_Pron = Grammar.he_Pron ;
she_Pron = Grammar.she_Pron ;
they_Pron = Grammar.they_Pron ;
-----------------------------------------------------
---------------- Lexicon part -----------------------
-----------------------------------------------------
lin
already_Adv = Lexicon.already_Adv ;
animal_N = Lexicon.animal_N ;
apple_N = Lexicon.apple_N ;
baby_N = Lexicon.baby_N ;
bad_A = Lexicon.bad_A ;
beer_N = Lexicon.beer_N ;
big_A = Lexicon.big_A ;
bike_N = Lexicon.bike_N ;
bird_N = Lexicon.bird_N ;
black_A = Lexicon.black_A ;
blood_N = Lexicon.blood_N ;
blue_A = Lexicon.blue_A ;
boat_N = Lexicon.boat_N ;
book_N = Lexicon.book_N ;
boy_N = Lexicon.boy_N ;
bread_N = Lexicon.bread_N ;
break_V2 = Lexicon.break_V2 ;
buy_V2 = Lexicon.buy_V2 ;
car_N = Lexicon.car_N ;
cat_N = Lexicon.cat_N ;
child_N = Lexicon.child_N ;
city_N = Lexicon.city_N ;
clean_A = Lexicon.clean_A ;
clever_A = Lexicon.clever_A ;
cloud_N = Lexicon.cloud_N ;
cold_A = Lexicon.cold_A ;
come_V = Lexicon.come_V ;
computer_N = Lexicon.computer_N ;
cow_N = Lexicon.cow_N ;
dirty_A = Lexicon.dirty_A ;
dog_N = Lexicon.dog_N ;
drink_V2 = Lexicon.drink_V2 ;
eat_V2 = Lexicon.eat_V2 ;
find_V2 = Lexicon.find_V2 ;
fire_N = Lexicon.fire_N ;
fish_N = Lexicon.fish_N ;
flower_N = Lexicon.flower_N ;
friend_N = Lexicon.friend_N ;
girl_N = Lexicon.girl_N ;
good_A = Lexicon.good_A ;
go_V = Lexicon.go_V ;
grammar_N = Lexicon.grammar_N ;
green_A = Lexicon.green_A ;
heavy_A = Lexicon.heavy_A ;
horse_N = Lexicon.horse_N ;
hot_A = Lexicon.hot_A ;
house_N = Lexicon.house_N ;
jump_V = Lexicon.jump_V ;
kill_V2 = Lexicon.kill_V2 ;
language_N = Lexicon.language_N ;
live_V = Lexicon.live_V ;
love_V2 = Lexicon.love_V2 ;
man_N = Lexicon.man_N ;
milk_N = Lexicon.milk_N ;
music_N = Lexicon.music_N ;
new_A = Lexicon.new_A ;
now_Adv = Lexicon.now_Adv ;
old_A = Lexicon.old_A ;
play_V = Lexicon.play_V ;
read_V2 = Lexicon.read_V2 ;
ready_A = Lexicon.ready_A ;
red_A = Lexicon.red_A ;
river_N = Lexicon.river_N ;
run_V = Lexicon.run_V ;
sea_N = Lexicon.sea_N ;
see_V2 = Lexicon.see_V2 ;
ship_N = Lexicon.ship_N ;
sleep_V = Lexicon.sleep_V ;
small_A = Lexicon.small_A ;
star_N = Lexicon.star_N ;
swim_V = Lexicon.swim_V ;
teach_V2 = Lexicon.teach_V2 ;
train_N = Lexicon.train_N ;
travel_V = Lexicon.travel_V ;
tree_N = Lexicon.tree_N ;
understand_V2 = Lexicon.understand_V2 ;
wait_V2 = Lexicon.wait_V2 ;
walk_V = Lexicon.walk_V ;
warm_A = Lexicon.warm_A ;
water_N = Lexicon.water_N ;
white_A = Lexicon.white_A ;
wine_N = Lexicon.wine_N ;
woman_N = Lexicon.woman_N ;
yellow_A = Lexicon.yellow_A ;
young_A = Lexicon.young_A ;
}

View File

@@ -0,0 +1,8 @@
--# -path=.:../abstract
concrete MicroLangFunctorEng of MicroLang = MicroLangFunctor with
(Grammar = GrammarEng),
(Syntax = SyntaxEng),
(Lexicon = LexiconEng)
;

View File

@@ -0,0 +1,7 @@
--# -path=.:../abstract
concrete MicroLangFunctorSwe of MicroLang = MicroLangFunctor with
(Grammar = GrammarSwe),
(Syntax = SyntaxSwe),
(Lexicon = LexiconSwe)
;