add first changes

This commit is contained in:
odanoburu
2018-03-14 18:59:42 -03:00
parent 23f27a9dab
commit 22187afd1f
6 changed files with 1169 additions and 1144 deletions
+181 -122
View File
@@ -1,130 +1,186 @@
--# -path=.:../romance:../common:../../prelude
--1 A Simple Pornish Resource Morphology
--1 A Simple Portuguese Resource Morphology
--
-- Aarne Ranta 2002 -- 2005
--
-- This resource morphology contains definitions needed in the resource
-- syntax. To build a lexicon, it is better to use $ParadigmsPor$, which
-- gives a higher-level access to this module.
-- This resource morphology contains definitions needed in the
-- resource syntax. To build a lexicon, it is better to use
-- $ParadigmsPor$, which gives a higher-level access to this module.
resource MorphoPor = CommonRomance, ResPor **
resource MorphoPor = CommonRomance, ResPor **
open PhonoPor, Prelude, Predef,
CatPor in {
flags optimize=all ;
coding=utf8 ;
--2 Nouns
--
-- The following macro is useful for creating the forms of number-dependent
-- tables, such as common nouns.
-- The following macro is useful for creating the forms of
-- number-dependent tables, such as common nouns.
oper
numForms : (_,_ : Str) -> Number => Str = \vino, vini ->
table {Sg => vino ; Pl => vini} ;
numForms : (_,_ : Str) -> Number => Str = \campus, campi ->
table {Sg => campus ; Pl => campi} ;
-- For example:
nomVinho : Str -> Number => Str = \vinho ->
numForms vinho (vinho + "s") ;
nomVino : Str -> Number => Str = \vino ->
numForms vino (vino + "s") ;
nomAreia : Str -> Number => Str = \areia ->
numForms areia areia ;
nomPilar : Str -> Number => Str = \pilar ->
numForms pilar (pilar + "es") ;
nomAlemao : Str -> Number => Str = \alemao ->
numForms alemao (init alemao + "es") ;
nomTram : Str -> Number => Str = \tram ->
numForms tram tram ;
nomFalcao : Str -> Number => Str = \falcao ->
numForms falcao (tk 2 falcao + "ões") ;
nomCidadao : Str -> Number => Str = -- for completeness
nomVinho ;
nomNuvem : Str -> Number => Str = \nuvem ->
numForms nuvem (init nuvem + "ns") ;
nomRapaz : Str -> Number => Str = \rapaz ->
numForms rapaz (rapaz + "es") ;
nomCanal : Str -> Number => Str = \canal ->
numForms canal (init canal + "is") ;
acuteVowel : Str -> Str = \v ->
case v of {
"a" => "á" ;
"e" => "é" ;
"i" => "í" ;
"o" => "ó" ;
"u" => "ú" ;
_ => error "input must be vowel character."
} ;
nomFenol : Str -> Number => Str = \fenol ->
case fenol of {
fen + v@("a"|"e"|"i"|"o"|"u") + "l" => numForms fenol (fen + acuteVowel v + "is")
};
nomVowelL : Str -> Number => Str = \nom ->
-- papel -> papéis, móvel -> móveis
case occurs "áéíúó" nom of {
PTrue => nomCanal nom ;
PFalse => nomFenol nom
} ;
-- Common nouns are inflected in number and have an inherent gender.
mkNoun : (Number => Str) -> Gender -> Noun = \mecmecs,gen ->
mkNoun : (Number => Str) -> Gender -> Noun = \mecmecs,gen ->
{s = mecmecs ; g = gen} ;
mkNounIrreg : Str -> Str -> Gender -> Noun = \mec,mecs ->
mkNounIrreg : Str -> Str -> Gender -> Noun = \mec,mecs ->
mkNoun (numForms mec mecs) ;
mkNomReg : Str -> Noun = \mec ->
case mec of {
_ + ("o" | "e" | "é" | "á") => mkNoun (nomVino mec) Masc ; --bebé, papá; how about other accented vocal endings? champú champúes
_ + "a" => mkNoun (nomVino mec) Fem ;
_ + "z" => mkNounIrreg mec (init mec + "ces") Fem ;
_ + "ión" => mkNounIrreg mec (tk 2 mec + "ones") Fem ;
_ + "tud" => mkNounIrreg mec (mec + "es") Fem ;
_ + "án" => mkNounIrreg mec (tk 2 mec + "anes") Masc ;
_ + "én" => mkNounIrreg mec (tk 2 mec + "enes") Masc ;
_ + "ín" => mkNounIrreg mec (tk 2 mec + "ines") Masc ;
_ + "ón" => mkNounIrreg mec (tk 2 mec + "ones") Masc ;
_ + "ún" => mkNounIrreg mec (tk 2 mec + "unes") Masc ;
_ => mkNoun (nomPilar mec) Masc
} ;
smartGenNoun : Str -> Gender -> Noun = \vinho,g -> case vinho of {
rapa + ("z"|"s") => -- capataz/Masc, flor/Fem, obus/Masc
mkNoun (nomRapaz vinho) g ;
can + "al" => -- canal/Masc, vogal/Fem
mkNoun (nomCanal vinho) g ;
pap + "el" => -- cascavel/Fem, infiel/Masc
mkNoun (nomVowelL vinho) g ;
home + "m" => -- homem/Masc, nuvem/nuvens
mkNoun (nomNuvem vinho) g ;
tóra + "x" => -- tórax/Masc, xerox/Fem
mkNoun (nomAreia vinho) g ;
_ =>
mkNoun (nomVinho vinho) g
} ;
mkNomReg : Str -> Noun = \vinho -> case vinho of {
cas + ("a" | "ã" | "dade" | "tude" | "ise" | "ite") =>
-- casa, artesã, saudade, juventude, marquise, artrite
mkNoun (nomVinho vinho) Fem ;
va + "gem" =>
mkNoun (nomNuvem vinho) Fem ;
certid + "ão" => -- other rules depend on stress, can this be built with gf?
mkNoun (nomFalcao vinho) Fem ;
proble + ("ma" | "n" | "o" | "á") => -- problema, líquen, carro, maracujá
mkNoun (nomVinho vinho) Masc ;
can + "r" => -- feminine words ending with 'r' usually are also masculine
mkNoun (nomRapaz vinho) Masc ;
can + ("i" | "u") + "l" => -- canil, azul | what about fóssil?
mkNoun (nomCanal vinho) Masc ;
fen + "ol" => mkNoun (nomVowelL vinho) Masc ;
urub + "u" => mkNoun (nomVinho vinho) Masc ;
_ => smartGenNoun vinho Masc
} ;
--2 Adjectives
--
-- Adjectives are conveniently seen as gender-dependent nouns.
-- Here are some patterns. First one that describes the worst case.
-- Adjectives are conveniently seen as gender-dependent nouns. Here
-- are some patterns. First one that describes the worst case.
mkAdj : (_,_,_,_,_ : Str) -> Adj = \solo,sola,soli,sole,solamente ->
mkAdj : (_,_,_,_,_ : Str) -> Adj =
\burro,burra,burros,burras,burramente ->
{s = table {
AF Masc n => numForms solo soli ! n ;
AF Fem n => numForms sola sole ! n ;
AA => solamente
AF Masc n => numForms burro burros ! n ;
AF Fem n => numForms burra burras ! n ;
AA => burramente
}
} ;
-- Then the regular and invariant patterns.
adjSolo : Str -> Adj = \solo ->
let
sol = Predef.tk 1 solo
adjPreto : Str -> Adj = \preto ->
let
pret = Predef.tk 1 preto
in
mkAdj solo (sol + "a") (sol + "os") (sol + "as") (sol + "amente") ;
mkAdj preto (pret + "a") (pret + "os") (pret + "as") (pret + "amente") ;
-- masculine and feminine are identical:
-- adjectives ending with -e, -a and many but not all that end in a consonant
adjUtil : Str -> Str -> Adj = \util,utiles ->
mkAdj util util utiles utiles (util + "mente") ;
-- masculine and feminine are identical:
-- adjectives ending with -e, -a and many but not all that end in a
-- consonant
adjUtil : Str -> Str -> Adj = \útil,úteis ->
mkAdj útil útil úteis úteis (útil + "mente") ;
-- adjectives that end in consonant but have different masc and fem forms
-- español, hablador ...
adjEspanol : Str -> Str -> Adj = \espanol,espanola ->
mkAdj espanol espanola (espanol + "es") (espanol + "as") (espanola + "mente") ;
-- adjectives that end in consonant but have different masc and fem
-- forms español, hablador ...
adjOuvidor : Str -> Str -> Adj = \ouvidor,ouvidora ->
mkAdj ouvidor ouvidora (ouvidor + "es") (ouvidor + "as") (ouvidora + "mente") ;
adjBlu : Str -> Adj = \blu ->
mkAdj blu blu blu blu blu ; ---
adjBlu : Str -> Adj = \blu ->
mkAdj blu blu blu blu blu ; --- blasé
-- francés francesa franceses francesas
adjEs : Str -> Adj = \francEs ->
let franc : Str = Predef.tk 2 francEs ;
-- francês francesa franceses francesas
adjEs : Str -> Adj = \francês ->
let franc : Str = Predef.tk 2 francês ;
frances : Str = franc + "es" ;
in mkAdj francEs (frances + "a") (frances + "es") (frances + "as") (frances + "amente") ;
in mkAdj francês (frances + "a") (frances + "es") (frances + "as") (frances + "amente") ;
-- alemán alemana alemanes alemanas
adjVn : Str -> Adj = \alemAn ->
let alemA : Str = init alemAn ;
alem : Str = init alemA ;
A : Str = last alemA ;
V : Str = case A of {
"á" => "a" ;
"é" => "e" ;
"í" => "i" ;
"ó" => "o" ;
"ú" => "u"
-- alemão alemã alemães alemãs
-- is there really a need for this? is it as useful as the spanish
-- one?
adjVo : Str -> Adj = \alemão ->
let alemã : Str = init alemão ;
alem : Str = init alemã ;
ã : Str = last alemã ;
v : Str = case ã of {
"ã" => "a"
} ;
alemVn : Str = alem + V + "n" ;
in mkAdj alemAn (alemVn + "a") (alemVn + "es")
(alemVn + "as") (alemVn + "amente") ;
alemvo : Str = alem + v + "o" ;
in mkAdj alemão alemã (alemã + "s") (alemã + "es") (alemã + "amente") ;
mkAdjReg : Str -> Adj = \solo ->
case solo of {
_ + "o" => adjSolo solo ;
_ + ("e" | "a") => adjUtil solo (solo + "s") ;
_ + "és" => adjEs solo ;
_ + ("á" | "é" | "í" | "ó" | "ú") + "n" => adjVn solo ;
_ => adjUtil solo (solo + "es")
} ;
adjEuropeu : Str -> Adj = \europeu -> let europe = init europeu in
mkAdj europeu (europe + "ia") (europeu + "s") (europe + "ias")
(europe + "iamente") ;
mkAdjReg : Str -> Adj = \a ->
case a of {
pret + "o" => adjPreto a ;
anarquist + v@("e" | "a") => adjUtil (anarquist + v) (anarquist + v + "s") ;
ouvido + "r" => adjOuvidor a (ouvido + "ra") ;
chin + "ês" => adjEs a ;
europ + "eu" => adjEuropeu a ;
alem + "ão" => adjVo a ;
_ => adjUtil a (a + "s")
} ;
--2 Personal pronouns
--
@@ -132,73 +188,76 @@ oper
-- The use of "ne" as atonic genitive is debatable.
-- We follow the rule that the atonic nominative is empty.
mkPronoun : (_,_,_,_,_,_,_,_ : Str) ->
Gender -> Number -> Person -> Pronoun =
\il,le,lui,Lui,son,sa,ses,see,g,n,p ->
let
alui : Case -> Str = \x -> prepCase x ++ Lui ;
in {
s = table {
Nom => {c1 = [] ; c2 = [] ; comp = il ; ton = Lui} ;
Acc => {c1 = le ; c2 = [] ; comp = [] ; ton = Lui} ;
CPrep P_a => {c1 = [] ; c2 = lui ; comp = [] ; ton = alui (CPrep P_a)} ;
c => {c1 = [] ; c2 = [] ; comp, ton = alui c}
} ;
poss = \\n,g => case <n,g> of {
<Sg,Masc> => son ;
<Sg,Fem> => sa ;
<Pl,Masc> => ses ;
<Pl,Fem> => see
mkPronoun : (_,_,_,_,_,_,_,_ : Str) -> Gender -> Number -> Person
-> Pronoun = \ele,o,lhe,Ele,seu,sua,seus,suas,g,n,p ->
{poss = \\n,g => case <n,g> of {
<Sg,Masc> => seu ;
<Sg,Fem> => sua ;
<Pl,Masc> => seus ;
<Pl,Fem> => suas
} ;
a = Ag g n p ;
hasClit = True ; isPol = False
} ** pronLin ele o lhe Ele ;
a = Ag g n p ;
hasClit = True ; isPol = False
pronLin : (_,_,_,_ : Str) -> {s : Case => {c1,c2,comp,ton : Str}}
= \você, o, lhe, Você ->
let
aVocê : Case -> Str = \x -> prepCase x ++ Você ;
in
{s = table {
Nom => {c1 = [] ; c2 = [] ; comp = você ; ton = Você} ;
Acc => {c1 = o ; c2 = [] ; comp = [] ; ton = Você} ;
CPrep P_a => {c1 = [] ; c2 = lhe ; comp = [] ; ton = aVocê (CPrep P_a)} ;
c => {c1 = [] ; c2 = [] ; comp, ton = aVocê c}
}
} ;
pronAgr : Pronoun -> Gender -> Number -> Person -> Pronoun
= \pron, g, n, p -> pron ** {a = Ag g n p} ;
mkPronFrom : Pronoun -> (_,_,_,_ : Str) -> Gender -> Number -> Person
-> Pronoun = \pron, você, o, lhe, Você, g, n, p ->
(pronAgr pron g n p) ** pronLin você o lhe Você ;
--2 Determiners
--
-- Determiners, traditionally called indefinite pronouns, are inflected
-- in gender and number, like adjectives.
-- Determiners, traditionally called indefinite pronouns, are
-- inflected in gender and number, like adjectives.
pronForms : Adj -> Gender -> Number -> Str = \tale,g,n -> tale.s ! AF g n ;
pronForms : Adj -> Gender -> Number -> Str =
\tale,g,n -> tale.s ! AF g n ;
mkOrdinal : A -> Ord = \adj->
mkOrdinal : A -> Ord = \adj ->
lin Ord {
s = \\ag => adj.s ! Posit ! AF ag.g ag.n ;
} ;
mkQuantifier : (ese,esa,esos,esas : Str) -> Quant = \ese,esa,esos,esas->
let
se : Str = Predef.drop 1 ese ;
sa : Str = Predef.drop 1 esa ;
sos : Str = Predef.drop 1 esos ;
sas : Str = Predef.drop 1 esas ;
E : Str = "é" ;
mkQuantifier : (esse,essa,esses,essas : Str) -> Quant = \esse,essa,esses,essas->
let
attrforms : Number => Gender => Case => Str = table {
Sg => \\g,c => prepCase c ++ genForms ese esa ! g ;
Pl => \\g,c => prepCase c ++ genForms esos esas ! g ----
Sg => \\g,c => prepCase c ++ genForms esse essa ! g ;
Pl => \\g,c => prepCase c ++ genForms esses essas ! g
} ;
npforms : Number => Gender => Case => Str = table {
Sg => \\g,c => prepCase c ++ genForms (E + se) (E + sa) ! g ;
Pl => \\g,c => prepCase c ++ genForms (E + sos) (E + sas) ! g }
in lin Quant {
s = \\_ => attrforms ;
s2 = [] ;
sp = npforms ; isNeg = False
sp = attrforms ; -- in spanish it was different
isNeg = False
} ;
mkDeterminer : (mucho,mucha : Str) -> Number -> Bool -> Det = \mucho,mucha,number,neg ->
mkDeterminer : (muito,muita : Str) -> Number -> Bool -> Det = \muito,muita,number,neg ->
lin Det {
s,sp = \\g,c => prepCase c ++ genForms mucho mucha ! g ;
s,sp = \\g,c => prepCase c ++ genForms muito muita ! g ;
n = number;
s2 = [] ;
isNeg = neg
} ;
mkIDet : (cuantos, cuantas : Str) -> Number -> IDet = \cuantos,cuantas,number ->
mkIDet : (quantos, quantas : Str) -> Number -> IDet = \quantos,quantas,number ->
lin IDet {
s = \\g,c => prepCase c ++ genForms cuantos cuantas ! g ;
s = \\g,c => prepCase c ++ genForms quantos quantas ! g ;
n = number
} ;
}