mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-30 02:58:35 -06:00
copy files over from GF-latin
This commit is contained in:
+98
-54
@@ -3,43 +3,85 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
flags optimize=all_subs ;
|
||||
|
||||
lin
|
||||
DetCN det cn = -- Det -> CN -> NP
|
||||
-- DetCN : Det -> CN -> NP ; -- the man
|
||||
DetCN det cn =
|
||||
{
|
||||
s = \\c => det.s ! cn.g ! c ++ cn.preap.s ! (Ag cn.g det.n c) ++ cn.s ! det.n ! c ++ cn.postap.s ! (Ag cn.g det.n c) ;
|
||||
s = \\c => cn.s ! det.n ! c ;
|
||||
n = det.n ; g = cn.g ; p = P3 ;
|
||||
adv = cn.adv ;
|
||||
preap = cn.preap ;
|
||||
postap = cn.postap ;
|
||||
det = det
|
||||
} ;
|
||||
|
||||
UsePN pn = lin NP { s = pn.s ! Sg ; g = pn.g ; n = Sg ; p = P3 } ;
|
||||
UsePron p = -- Pron -> Np
|
||||
-- UsePN : PN -> NP ; -- John
|
||||
UsePN pn =
|
||||
lin NP
|
||||
{
|
||||
s = pn.s ! Sg ;
|
||||
g = pn.g ;
|
||||
n = Sg ;
|
||||
p = P3 ;
|
||||
adv = "" ;
|
||||
preap, postap = { s = \\_ => "" } ;
|
||||
det = { s,sp = \\_,_ => "" ; n = Sg }
|
||||
} ;
|
||||
|
||||
-- UsePron : Pron -> NP ; -- he
|
||||
UsePron p =
|
||||
{
|
||||
g = p.g ;
|
||||
n = p.n ;
|
||||
g = p.pers.g ;
|
||||
n = p.pers.n ;
|
||||
p = p.p ;
|
||||
s = \\c => case c of {
|
||||
Nom => p.pers ! PronDrop ! PronRefl ; -- Drop pronoun in nominative case
|
||||
_ => p.pers ! PronNonDrop ! PronRefl -- but don't drop it otherwise
|
||||
Nom => p.pers.s ! PronDrop ! PronNonRefl ; -- Drop pronoun in nominative case
|
||||
_ => p.pers.s ! PronNonDrop ! PronNonRefl -- but don't drop it otherwise
|
||||
} ! c ;
|
||||
adv = "" ;
|
||||
preap, postap = { s = \\_ => "" } ;
|
||||
det = { s,sp = \\_,_ => "" ; n = p.pers.n } ;
|
||||
} ;
|
||||
-- PredetNP pred np = {
|
||||
-- s = \\c => pred.s ++ np.s ! c ;
|
||||
-- a = np.a
|
||||
-- } ;
|
||||
--
|
||||
|
||||
-- PredetNP : Predet -> NP -> NP ; -- only the man
|
||||
PredetNP predet np =
|
||||
np ** {
|
||||
det = np.det ** { s = \\g,c => predet.s ++ np.det.s ! g ! c }
|
||||
} ;
|
||||
|
||||
-- PPartNP : NP -> V2 -> NP ; -- the man seen
|
||||
-- PPartNP np v2 = {
|
||||
-- s = \\c => np.s ! c ++ v2.s ! VPPart ;
|
||||
-- a = np.a
|
||||
-- } ;
|
||||
--
|
||||
-- RelNP np rs = {
|
||||
-- s = \\c => np.s ! c ++ "," ++ rs.s ! np.a ;
|
||||
-- a = np.a
|
||||
-- } ;
|
||||
--
|
||||
|
||||
-- AdvNP : NP -> Adv -> NP ; -- Paris today
|
||||
AdvNP np adv = {
|
||||
s = \\c => np.s ! c ++ adv.s ;
|
||||
g = np.g ; n = np.n; p = np.p
|
||||
} ;
|
||||
-- AdvNP : NP -> Adv -> NP ; -- Paris today
|
||||
AdvNP np adv = np ** { adv = np.adv ++ (adv.s ! Posit) } ;
|
||||
-- {
|
||||
-- s = \\c => np.s ! c ;
|
||||
-- g = np.g ; n = np.n; p = np.p ;
|
||||
-- adv = cc2 np.adv adv ;
|
||||
-- preap = np.preap ;
|
||||
-- postap = np.postap ;
|
||||
-- det = np.det;
|
||||
-- } ;
|
||||
|
||||
-- ExtAdvNP: NP -> Adv -> NP ; -- boys, such as ..
|
||||
ExtAdvNP = AdvNP ;
|
||||
|
||||
-- RelNP : NP -> RS -> NP ; -- Paris, which is here
|
||||
RelNP np rs = np ** { adv = rs.s ++ np.adv } ;
|
||||
|
||||
-- DetNP : Det -> NP ; -- these five
|
||||
DetNP det = {
|
||||
s = det.s ! Neutr ;
|
||||
g = Neutr ;
|
||||
n = det.n ;
|
||||
p = P3 ;
|
||||
adv = "" ;
|
||||
preap, postap = { s = \\_ => "" } ;
|
||||
det = { s,sp = \\_,_ => "" ; n = det.n } ;
|
||||
} ;
|
||||
--
|
||||
-- DetQuantOrd quant num ord = {
|
||||
-- s = quant.s ! num.hasCard ! num.n ++ num.s ++ ord.s ;
|
||||
@@ -53,10 +95,7 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
n = num.n
|
||||
} ;
|
||||
|
||||
-- DetNP det = {
|
||||
-- s = det.sp ! Neutr ;
|
||||
-- g = Neutr ; n = det.n ; p = P3
|
||||
-- } ;
|
||||
|
||||
|
||||
-- PossPron p = {
|
||||
-- s = \\_,_ => p.s ! Gen ;
|
||||
@@ -66,13 +105,14 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
NumSg = {s = \\_,_ => [] ; n = Sg} ;
|
||||
NumPl = {s = \\_,_ => [] ; n = Pl} ;
|
||||
|
||||
-- NumCard n = n ** {hasCard = True} ;
|
||||
NumCard n = n ;
|
||||
--
|
||||
-- NumDigits n = {s = n.s ! NCard ; n = n.n} ;
|
||||
-- OrdDigits n = {s = n.s ! NOrd} ;
|
||||
--
|
||||
-- NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;
|
||||
-- OrdNumeral numeral = {s = numeral.s ! NOrd} ;
|
||||
-- OrdDigits n = {s = n.s ! NOrd} ;
|
||||
--
|
||||
lin
|
||||
NumNumeral numeral = numeral.card ;
|
||||
OrdNumeral numeral = numeral.ord ;
|
||||
--
|
||||
-- AdNum adn num = {s = adn.s ++ num.s ; n = num.n} ;
|
||||
--
|
||||
@@ -88,16 +128,24 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
sp = \\_ => [] ;
|
||||
} ;
|
||||
|
||||
-- MassNP cn = {
|
||||
-- s = cn.s ! Sg ;
|
||||
-- a = Ag cn.g Sg
|
||||
-- } ;
|
||||
MassNP cn =
|
||||
{
|
||||
s = cn.s ! Sg ;
|
||||
-- s = case cn.massable of { True => cn.s ! Sg ; False => \\_ => nonExist } ;
|
||||
g = cn.g ;
|
||||
n = Sg ;
|
||||
p = P3 ;
|
||||
adv = cn.adv ;
|
||||
preap = cn.preap ;
|
||||
postap = cn.postap ;
|
||||
det = { s,sp = \\_,_ => "" ; n = Sg } ;
|
||||
};
|
||||
|
||||
UseN n = -- N -> CN
|
||||
lin CN ( n ** {preap, postap = {s = \\_ => "" } } ) ;
|
||||
lin CN ( n ** {preap, postap = {s = \\_ => "" } ; adv = "" }) ; -- massable = n.massable } ) ;
|
||||
|
||||
UseN2 n2 = -- N2 -> CN
|
||||
lin CN ( n2 ** {preap, postap = {s = \\_ => "" } } ) ;
|
||||
lin CN ( n2 ** {preap, postap = {s = \\_ => "" } ; adv = "" }) ; -- massable = n2.massable } ) ;
|
||||
-----b UseN3 n = n ;
|
||||
--
|
||||
-- Use2N3 f = {
|
||||
@@ -119,21 +167,10 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
-- c2 = f.c3
|
||||
-- } ;
|
||||
|
||||
param
|
||||
AdjPos = Pre | Post ;
|
||||
lin
|
||||
-- by default add adjective after the noun, otherwise use AdjCNPre
|
||||
AdjCN ap cn = -- AP -> CN -> CN
|
||||
let pos = variants { Post ; Pre }
|
||||
in
|
||||
{
|
||||
-- s = \\n,c => preOrPost ap.isPre (ap.s ! cn.g ! n ! c) (cn.s ! n ! c) ;
|
||||
-- s = \\n,c => ( cn.s ! n ! c ) ++ ( ap.s ! AdjPhr cn.g n c) ; -- always add adjectives after noun?
|
||||
s = cn.s ;
|
||||
postap = case pos of { Pre => cn.postap ; Post => { s = \\a => ap.s ! a ++ cn.postap.s ! a } } ;
|
||||
preap = case pos of { Pre => { s = \\a => ap.s ! a ++ cn.preap.s ! a } ; Post => cn.preap } ;
|
||||
-- variants { postap = ConsAP postap ap ; preap = ConsAP preap ap } ; -- Nice if that would work
|
||||
g = cn.g
|
||||
} ;
|
||||
addAdjToCN (lin AP ap) (lin CN cn) Post ;
|
||||
|
||||
-- RelCN cn rs = {
|
||||
-- s = \\n,c => cn.s ! n ! c ++ rs.s ! agrgP3 n cn.g ;
|
||||
@@ -143,7 +180,14 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
-- AdvCN cn ad = {s = \\n,c => cn.s ! n ! c ++ ad.s ; g = cn.g} ;
|
||||
|
||||
-- SentCN cn sc = {s = \\n,c => cn.s ! n ! c ++ sc.s ; g = cn.g} ;
|
||||
--
|
||||
-- ApposCN cn np = {s = \\n,c => cn.s ! n ! Nom ++ np.s ! c ; g = cn.g} ;
|
||||
--
|
||||
--
|
||||
-- ApposCN : CN -> NP -> CN
|
||||
ApposCN cn np =
|
||||
{
|
||||
s = \\n,c => cn.s ! n ! c ++ np.det.s ! np.g ! c ++ np.preap.s ! (Ag np.g n c) ++ np.s ! c ++ np.postap .s ! (Ag np.g n c) ++ np.det.sp ! np.g ! c ;
|
||||
g = cn.g ;
|
||||
preap = cn.preap ;
|
||||
postap = cn.postap ;
|
||||
adv = cn.adv
|
||||
} ; -- massable = cn.massable } ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user