started a subdir for the book

This commit is contained in:
aarne
2010-11-22 12:55:37 +00:00
parent 0bf4179369
commit 76ba03b545
97 changed files with 2026 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
resource Arabic = {
oper
Root : Type = {F,C,L : Str} ;
Pattern : Type = Root -> Str ;
Filling : Type = {F,FC,CL,L : Str} ;
fill : Filling -> Root -> Str = \p,r ->
p.F + r.F + p.FC + r.C + p.CL + r.L + p.L ;
dfill : Filling -> Root -> Str = \p,r ->
p.F + r.F + p.FC + r.C + r.C + p.CL + r.L + p.L ;
getRoot : Str -> Root = \s -> case s of {
F@? + C@? + L@? => {F = F ; C = C ; L = L} ;
_ => Predef.error ("cannot get root from" ++ s)
} ;
getPattern : Str -> Pattern = \s -> case s of {
F + "F" + FC + "CC" + CL + "L" + L =>
dfill {F = F ; FC = FC ; CL = CL ; L = L} ;
F + "F" + FC + "C" + CL + "L" + L =>
fill {F = F ; FC = FC ; CL = CL ; L = L} ;
_ => Predef.error ("cannot get pattern from" ++ s)
} ;
word : Str -> Str -> Str = \p,r ->
getPattern p (getRoot r) ;
param
Number = Sg | Dl | Pl ;
Gender = Masc | Fem ;
Tense = Perf | Impf ;
VPer = Vp3 Number Gender | Vp2Sg Gender | Vp2Dl | Vp2Pl Gender | Vp1Sg | Vp1Pl ;
oper
Verb : Type = {s : Tense => VPer => Str} ;
pattV_u : Tense -> VPer -> Pattern = \t,v -> getPattern (case t of {
Perf => case v of {
Vp3 Sg Masc => "FaCaLa" ;
Vp3 Sg Fem => "FaCaLat" ;
Vp3 Dl Masc => "FaCaLaA" ;
Vp3 Dl Fem => "FaCaLataA" ;
Vp3 Pl Masc => "FaCaLuwA" ;
Vp3 Pl Fem => "FaCaLona" ;
Vp2Sg Masc => "FaCaLota" ;
Vp2Sg Fem => "FaCaLoti" ;
Vp2Dl => "FaCaLotumaA" ;
Vp2Pl Masc => "FaCaLotum" ;
Vp2Pl Fem => "FaCaLotunv2a" ;
Vp1Sg => "FaCaLotu" ;
Vp1Pl => "FaCaLonaA"
} ;
Impf => case v of {
Vp3 Sg Masc => "yaFoCuLu" ;
Vp3 Sg Fem => "taFoCuLu" ;
Vp3 Dl Masc => "yaFoCuLaAni" ;
Vp3 Dl Fem => "taFoCuLaAni" ;
Vp3 Pl Masc => "yaFoCuLuwna" ;
Vp3 Pl Fem => "yaFoCuLna" ;
Vp2Sg Masc => "taFoCuLu" ;
Vp2Sg Fem => "taFoCuLiyna" ;
Vp2Dl => "taFoCuLaAni" ;
Vp2Pl Masc => "taFoCuLuwna" ;
Vp2Pl Fem => "taFoCuLona" ;
Vp1Sg => "A?aFoCuLu" ;
Vp1Pl => "naFoCuLu"
}
}) ;
u_Verb : Str -> Verb = \s -> {
s = \\t,p => pattV_u t p (getRoot s) ;
} ;
-- for html
tag : Str -> Str = \t -> "<" + t + ">" ;
etag : Str -> Str = \t -> "</" + t + ">" ;
atag : Str -> Str -> Str = \t,a -> "<" + t ++ a + ">" ;
intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ etag t ;
intagAttr : Str -> Str -> Str -> Str = \t,a,s -> atag t a ++ s ++ etag t ;
verbTable : Verb -> Str = \v ->
let
vsp = v.s ! Perf ;
vsi = v.s ! Impf ;
tr : Str -> Str = intag "tr" ;
td : Str -> Str = intag "td" ;
ts : Str -> Str = \s -> td ("\"" ++ s ++ "\"") ;
trs : Str -> Str -> VPer -> Str = \s,n,v ->
tr (td s ++ td n ++ ts (vsp ! v) ++ ts (vsi ! v))
in
intagAttr "table" "border=1" (
tr ((td "Persona") ++ (td "Numerus") ++ (td "Perfectum") ++ (td "Imperfectum")) ++
trs "3. masc." "sing." (Vp3 Sg Masc) ++
trs "3. fem." "sing." (Vp3 Sg Fem) ++
trs "2. masc." "sing." (Vp2Sg Masc) ++
trs "2. fem." "sing." (Vp2Sg Fem) ++
trs "1." "sing." (Vp1Sg) ++
trs "3. masc." "dual." (Vp3 Dl Masc) ++
trs "3. fem." "dual." (Vp3 Dl Fem) ++
trs "2." "dual." (Vp2Dl) ++
trs "3. masc." "plur." (Vp3 Pl Masc) ++
trs "3. fem." "plur." (Vp3 Pl Fem) ++
trs "2. masc." "plur." (Vp2Pl Masc) ++
trs "2. fem." "plur." (Vp2Pl Fem) ++
trs "1." "plur." (Vp1Pl)
) ;
}

View File

@@ -0,0 +1,11 @@
abstract Discont = {
cat
S ; Cl ; NP ; VP ; AP ;
fun
DeclCl : Cl -> S ;
QuestCl : Cl -> S ;
PredVP : NP -> VP -> Cl ;
CompAP : AP -> VP ;
John : NP ;
Old : AP ;
}

View File

@@ -0,0 +1,21 @@
concrete DiscontEng of Discont = {
param
SForm = SDecl | SQuest ;
lincat
S, NP, AP = Str ;
Cl = SForm => Str ;
VP = {verb,comp : Str} ;
lin
DeclCl cl = cl ! SDecl ;
QuestCl cl = cl ! SQuest ;
PredVP np vp = table {
SDecl => np ++ vp.verb ++ vp.comp ;
SQuest => vp.verb ++ np ++ vp.comp
} ;
CompAP ap = {
verb = "is" ;
comp = ap
} ;
John = "John" ;
Old = "old" ;
}

View File

@@ -0,0 +1,13 @@
abstract Foods = {
flags startcat = Comment ;
cat
Comment ; Item ; Kind ; Quality ;
fun
Pred : Item -> Quality -> Comment ;
This, That, These, Those : Kind -> Item ;
Mod : Quality -> Kind -> Kind ;
Wine, Cheese, Fish, Pizza : Kind ;
Very : Quality -> Quality ;
Fresh, Warm, Italian,
Expensive, Delicious, Boring : Quality ;
}

View File

@@ -0,0 +1,40 @@
concrete FoodsEng of Foods = {
lincat
Comment, Quality = {s : Str} ;
Kind = {s : Number => Str} ;
Item = {s : Str ; n : Number} ;
lin
Pred item quality =
{s = item.s ++ copula ! item.n ++ quality.s} ;
This = det Sg "this" ;
That = det Sg "that" ;
These = det Pl "these" ;
Those = det Pl "those" ;
Mod quality kind =
{s = \\n => quality.s ++ kind.s ! n} ;
Wine = regNoun "wine" ;
Cheese = regNoun "cheese" ;
Fish = noun "fish" "fish" ;
Pizza = regNoun "pizza" ;
Very a = {s = "very" ++ a.s} ;
Fresh = adj "fresh" ;
Warm = adj "warm" ;
Italian = adj "Italian" ;
Expensive = adj "expensive" ;
Delicious = adj "delicious" ;
Boring = adj "boring" ;
param
Number = Sg | Pl ;
oper
det : Number -> Str ->
{s : Number => Str} -> {s : Str ; n : Number} =
\n,det,noun -> {s = det ++ noun.s ! n ; n = n} ;
noun : Str -> Str -> {s : Number => Str} =
\man,men -> {s = table {Sg => man ; Pl => men}} ;
regNoun : Str -> {s : Number => Str} =
\car -> noun car (car + "s") ;
adj : Str -> {s : Str} =
\cold -> {s = cold} ;
copula : Number => Str =
table {Sg => "is" ; Pl => "are"} ;
}

View File

@@ -0,0 +1,32 @@
concrete FoodsIta of Foods = open ResIta in {
lincat
Comment = {s : Str} ;
Quality = Adjective ;
Kind = Noun ;
Item = NounPhrase ;
lin
Pred item quality =
{s = item.s ++ copula ! item.n ++
quality.s ! item.g ! item.n} ;
This = det Sg "questo" "questa" ;
That = det Sg "quel" "quella" ;
These = det Pl "questi" "queste" ;
Those = det Pl "quei" "quelle" ;
Mod quality kind = {
s = \\n => kind.s ! n ++ quality.s ! kind.g ! n ;
g = kind.g
} ;
Wine = noun "vino" "vini" Masc ;
Cheese = noun "formaggio" "formaggi" Masc ;
Fish = noun "pesce" "pesci" Masc ;
Pizza = noun "pizza" "pizze" Fem ;
Very qual = {s = \\g,n => "molto" ++ qual.s ! g ! n} ;
Fresh =
adjective "fresco" "fresca" "freschi" "fresche" ;
Warm = regAdj "caldo" ;
Italian = regAdj "italiano" ;
Expensive = regAdj "caro" ;
Delicious = regAdj "delizioso" ;
Boring = regAdj "noioso" ;
}

View File

@@ -0,0 +1,36 @@
resource ResIta = open Prelude in {
param
Number = Sg | Pl ;
Gender = Masc | Fem ;
oper
NounPhrase : Type =
{s : Str ; g : Gender ; n : Number} ;
Noun : Type = {s : Number => Str ; g : Gender} ;
Adjective : Type = {s : Gender => Number => Str} ;
det : Number -> Str -> Str -> Noun -> NounPhrase =
\n,m,f,cn -> {
s = table {Masc => m ; Fem => f} ! cn.g ++
cn.s ! n ;
g = cn.g ;
n = n
} ;
noun : Str -> Str -> Gender -> Noun =
\vino,vini,g -> {
s = table {Sg => vino ; Pl => vini} ;
g = g
} ;
adjective : (nero,nera,neri,nere : Str) -> Adjective =
\nero,nera,neri,nere -> {
s = table {
Masc => table {Sg => nero ; Pl => neri} ;
Fem => table {Sg => nera ; Pl => nere}
}
} ;
regAdj : Str -> Adjective = \nero ->
let ner : Str = init nero
in
adjective nero (ner+"a") (ner+"i") (ner+"e") ;
copula : Number => Str =
table {Sg => "è" ; Pl => "sono"} ;
}