mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-04 08:42:50 -06:00
Hindi and Urdu as refactored to Hindustani by Shafqat
This commit is contained in:
400
lib/src/hindustani/ResHindustani.gf
Normal file
400
lib/src/hindustani/ResHindustani.gf
Normal file
@@ -0,0 +1,400 @@
|
||||
--# -path=.:../abstract:../common:../../prelude
|
||||
--
|
||||
--1 Hindustaniu auxiliary operations.
|
||||
--
|
||||
-- This module contains operations that are needed to make the
|
||||
-- resource syntax work.
|
||||
|
||||
--resource ResHindustani = ParamX ** open Prelude,Predef in {
|
||||
interface ResHindustani = DiffHindustani ** open CommonHindustani, Prelude, Predef in {
|
||||
|
||||
|
||||
flags optimize=all ;
|
||||
coding = utf8;
|
||||
|
||||
param
|
||||
|
||||
|
||||
-- Order = ODir | OQuest ;
|
||||
|
||||
--2 For $Relative$
|
||||
|
||||
RAgr = RNoAg | RAg Agr ;
|
||||
RCase = RC Number Case ;
|
||||
|
||||
-- for Numerial
|
||||
|
||||
CardOrd = NCard | NOrd ;
|
||||
|
||||
-----------------------------------------
|
||||
-- Hindustani Pronouns
|
||||
-----------------------------------------
|
||||
|
||||
Pronoun = P Number Gender Case UPerson;
|
||||
PersPronForm = PPF Number UPerson Case;
|
||||
|
||||
-------------------------------------------
|
||||
--Verbs
|
||||
-------------------------------------------
|
||||
|
||||
|
||||
oper
|
||||
Noun = {s : Number => Case => Str ; g : Gender} ;
|
||||
|
||||
Preposition = {s : Gender => Str};
|
||||
DemPronForm = {s : Number => Gender => Case => Str};
|
||||
PossPronForm = {s : Number => Gender => Case => Str};
|
||||
Determiner = {s : Number => Gender => Str ; n : Number};
|
||||
|
||||
-- a useful oper
|
||||
eq : Str -> Str -> Bool = \s1,s2-> (pbool2bool (eqStr s1 s2)) ;
|
||||
|
||||
RefPron : Str;
|
||||
RefPron = "Kwd";
|
||||
|
||||
----------------------------------------------------------
|
||||
-- Grammar part
|
||||
----------------------------------------------------------
|
||||
|
||||
|
||||
toNP : ( Case => Str) -> NPCase -> Str = \pn, npc -> case npc of {
|
||||
NPC c => pn ! c ;
|
||||
NPObj => pn ! Dir ;
|
||||
NPErg => pn ! Obl ++ "nE"
|
||||
} ;
|
||||
detcn2NP : (Determiner) -> Noun -> NPCase -> Number -> Str = \dt,cn,npc,nn -> case npc of {
|
||||
NPC c => dt.s ! Sg ! Masc ++ cn.s ! nn ! c ;
|
||||
NPObj => dt.s ! Sg ! Masc ++ cn.s ! nn ! Dir ;
|
||||
NPErg => dt.s ! Sg ! Masc ++ cn.s ! nn ! Obl ++ "nE"
|
||||
} ;
|
||||
det2NP : (Determiner) -> NPCase -> Str = \dt,npc -> case npc of {
|
||||
NPC c => dt.s ! Sg ! Masc ;
|
||||
NPObj => dt.s ! Sg ! Masc ;
|
||||
NPErg => dt.s ! Sg ! Masc ++ "nE"
|
||||
} ;
|
||||
|
||||
------------------------------------------
|
||||
-- Agreement transformations
|
||||
-----------------------------------------
|
||||
{- toAgr : Number -> UPerson -> Gender -> Agr = \n,p,g ->
|
||||
Ag g n p;
|
||||
|
||||
|
||||
fromAgr : Agr -> {n : Number ; p : UPerson ; g : Gender} = \a -> case a of {
|
||||
Ag g n p => {n = n ; p = p ; g = g}
|
||||
} ;
|
||||
|
||||
conjAgr : Agr -> Agr -> Agr = \a0,b0 ->
|
||||
let a = fromAgr a0 ; b = fromAgr b0
|
||||
in
|
||||
toAgr
|
||||
(conjNumber a.n b.n)
|
||||
b.p a.g;
|
||||
|
||||
giveNumber : Agr -> Number =\a -> case a of {
|
||||
Ag _ n _ => n
|
||||
};
|
||||
giveGender : Agr -> Gender =\a -> case a of {
|
||||
Ag g _ _ => g
|
||||
};
|
||||
-}
|
||||
-- defaultAgr : Agr = agrP3 Masc Sg ;
|
||||
-- agrP3 : Gender -> Number -> Agr = \g,n -> Ag g n Pers3_Distant ;
|
||||
personalAgr : Agr = agrP1 Masc Sg ;
|
||||
agrP1 : Gender -> Number -> Agr = \g,n -> Ag g n Pers1 ;
|
||||
|
||||
param
|
||||
CPolarity =
|
||||
CPos
|
||||
| CNeg Bool ; -- contracted or not
|
||||
|
||||
oper
|
||||
contrNeg : Bool -> Polarity -> CPolarity = \b,p -> case p of {
|
||||
Pos => CPos ;
|
||||
Neg => CNeg b
|
||||
} ;
|
||||
|
||||
-- NP : Type = {s : NPCase => Str ; a : Agr} ;
|
||||
|
||||
oper
|
||||
|
||||
objVType : VType -> NPCase = \vt -> case vt of {
|
||||
VTrans => NPObj ;
|
||||
_ => NPC Obl
|
||||
} ;
|
||||
|
||||
VPHSlash = VPH ** {c2 : Compl} ;
|
||||
|
||||
Compl : Type = {s : Str ; c : VType} ;
|
||||
|
||||
|
||||
predVc : (Verb ** {c2,c1 : Str}) -> VPHSlash = \verb ->
|
||||
predV verb ** {c2 = {s = verb.c1 ; c = VTrans} } ;
|
||||
{-
|
||||
-------------------------
|
||||
-- added for cauitives
|
||||
predVcc : (Verb **{c2:Compl}) -> VPHSlash = \verb ->
|
||||
predV verb ** {c2 = {s = "" ; c = VTrans} } ;
|
||||
------------------------
|
||||
-}
|
||||
predAux : Aux -> VPH = \verb -> {
|
||||
s = \\vh =>
|
||||
let
|
||||
|
||||
inf = verb.inf ;
|
||||
part = verb.ppart ;
|
||||
|
||||
in
|
||||
case vh of {
|
||||
VPTense VPPres (Ag g n p) => {fin = copula CPresent n p g ; inf = part } ;
|
||||
VPTense VPPast (Ag g n p) => {fin = copula CPast n p g ; inf = part } ;
|
||||
VPTense VPFutr (Ag g n p) => {fin = copula CFuture n p g ; inf = part ++ hw p n } ;
|
||||
VPStem => {fin = [] ; inf = "rh" };
|
||||
_ => {fin = part ; inf = [] }
|
||||
};
|
||||
obj = {s = [] ; a = defaultAgr} ;
|
||||
subj = VIntrans ;
|
||||
inf = verb.inf;
|
||||
ad = [];
|
||||
embComp = [];
|
||||
prog = False ;
|
||||
comp = \\_ => []
|
||||
} ;
|
||||
|
||||
Aux = {
|
||||
inf,ppart,prpart : Str
|
||||
} ;
|
||||
|
||||
auxBe : Aux = {
|
||||
inf = "" ;
|
||||
ppart = "" ;
|
||||
prpart = ""
|
||||
} ;
|
||||
|
||||
predProg : VPH -> VPH = \verb -> {
|
||||
s = \\vh =>
|
||||
case vh of {
|
||||
VPTense VPPres (Ag g n p) => {fin = copula CPresent n p g ; inf = (verb.s!VPStem).inf ++ raha g n} ;
|
||||
VPTense VPPast (Ag g n p) => {fin = copula CPast n p g ; inf = (verb.s!VPStem).inf ++ raha g n} ;
|
||||
VPTense VPFutr (Ag g n p) => {fin = copula CFuture n p g ; inf = (verb.s!VPStem).inf ++ raha g n } ;
|
||||
VPTense VPPerf (Ag g n p) => {fin = copula CPast n p g ; inf = (verb.s!VPTense VPPres (Ag g n p)).inf ++ raha g n } ;
|
||||
VPStem => {fin = [] ; inf = (verb.s!VPStem).inf };
|
||||
_ => {fin = [] ; inf = [] }
|
||||
};
|
||||
obj = verb.obj ;
|
||||
subj = VIntrans ;
|
||||
inf = verb.inf;
|
||||
ad = verb.ad;
|
||||
embComp = verb.embComp;
|
||||
prog = True ;
|
||||
comp = verb.comp
|
||||
} ;
|
||||
|
||||
{- Clause : Type = {s : VPHTense => Polarity => Order => Str} ;
|
||||
mkClause : NP -> VPH -> Clause = \np,vp -> {
|
||||
s = \\vt,b,ord =>
|
||||
let
|
||||
subjagr : NPCase * Agr = case vt of {
|
||||
VPImpPast => case vp.subj of {
|
||||
VTrans => <NPErg, vp.obj.a> ;
|
||||
VTransPost => <NPErg, defaultAgr> ;
|
||||
_ => <NPC Dir, np.a>
|
||||
} ;
|
||||
_ => <NPC Dir, np.a>
|
||||
} ;
|
||||
subj = subjagr.p1 ;
|
||||
agr = subjagr.p2 ;
|
||||
n = (fromAgr agr).n;
|
||||
p = (fromAgr agr).p;
|
||||
g = (fromAgr agr).g;
|
||||
vps = case vt of {
|
||||
|
||||
VPGenPres => vp.s ! VPTense VPPres agr ;
|
||||
VPImpPast => vp.s ! VPTense VPPast agr ;
|
||||
VPFut => case vp.prog of { True => {fin = (vp.s ! VPTense VPFutr agr).fin ; inf = (vp.s ! VPTense VPFutr agr).inf ++ hw p n} ;
|
||||
_ => vp.s ! VPTense VPFutr agr } ;
|
||||
VPContPres => {fin = copula CPresent n p g ; inf = (vp.s ! VPStem).inf ++ raha g n } ;
|
||||
VPContPast => {fin = copula CPast n p g ; inf = (vp.s ! VPStem).inf ++ raha g n } ;
|
||||
VPContFut => {fin = copula CFuture n p g ; inf = (vp.s ! VPStem).inf ++ raha g n ++ hw p n} ;
|
||||
VPPerfPres => {fin = copula CPresent n p g ; inf = (vp.s ! VPTense VPPerf agr).inf } ;
|
||||
VPPerfPast => {fin = copula CPast n p g ; inf = (vp.s ! VPTense VPPerf agr).inf } ;
|
||||
VPPerfFut => {fin = copula CFuture n p g ; inf = (vp.s ! VPTense VPPerf agr).inf ++ hw p n } ;
|
||||
VPPerfPresCont => {fin = copula CPresent n p g ; inf = (vp.s ! VPTense VPPres agr).inf ++ raha g n } ;
|
||||
VPPerfPastCont => {fin = copula CPast n p g ; inf = (vp.s ! VPTense VPPres agr).inf ++ raha g n } ;
|
||||
VPPerfFutCont => {fin = copula CFuture n p g ; inf = (vp.s ! VPTense VPPres agr).inf ++ raha g n ++ hw p n } ;
|
||||
VPSubj => case vp.prog of { True => {fin = (vp.s ! VPTense VPFutr agr).inf ++ hw p n ; inf = "Xayd" } ;
|
||||
_ => {fin = (vp.s ! VPTense VPFutr agr).inf ; inf = "Xayd" } }
|
||||
|
||||
};
|
||||
|
||||
|
||||
quest =
|
||||
case ord of
|
||||
{ ODir => [];
|
||||
OQuest => "kya" };
|
||||
na =
|
||||
case b of
|
||||
{ Pos => [];
|
||||
Neg => "na" };
|
||||
nahim =
|
||||
case b of
|
||||
{ Pos => [];
|
||||
Neg => "nhyN" };
|
||||
in
|
||||
case vt of {
|
||||
VPSubj => quest ++ np.s ! subj ++ vp.obj.s ++ vp.ad ++ vp.comp ! np.a ++ na ++ vps.inf ++ vps.fin ++ vp.embComp ;
|
||||
_ => quest ++ np.s ! subj ++ vp.obj.s ++ vp.ad ++ vp.comp ! np.a ++ nahim ++ vps.inf ++ vps.fin ++ vp.embComp};
|
||||
|
||||
} ;
|
||||
|
||||
mkSClause : Str -> Agr -> VPH -> Clause =
|
||||
\subj,agr,vp -> {
|
||||
s = \\t,b,ord =>
|
||||
let
|
||||
n = (fromAgr agr).n;
|
||||
p = (fromAgr agr).p;
|
||||
g = (fromAgr agr).g;
|
||||
vps = case t of {
|
||||
VPGenPres => vp.s ! VPTense VPPres agr ;
|
||||
VPImpPast => vp.s ! VPTense VPPast agr ;
|
||||
VPFut => vp.s ! VPTense VPFutr agr ;
|
||||
VPContPres => {fin = copula CPresent n p g ; inf = (vp.s ! VPStem).inf ++ raha g n } ;
|
||||
VPContPast => {fin = copula CPast n p g ; inf = (vp.s ! VPStem).inf ++ raha g n } ;
|
||||
VPContFut => {fin = copula CFuture n p g ; inf = (vp.s ! VPStem).inf ++ raha g n ++ hw p n } ;
|
||||
VPPerfPres => {fin = copula CPresent n p g ; inf = (vp.s ! VPStem).inf ++ cka g n } ;
|
||||
VPPerfPast => {fin = copula CPast n p g ; inf = (vp.s ! VPStem).inf ++ cka g n } ;
|
||||
VPPerfFut => {fin = copula CFuture n p g ; inf = (vp.s ! VPStem).inf ++ cka g n ++ hw p n } ;
|
||||
VPPerfPresCont => {fin = copula CPresent n p g ; inf = (vp.s ! VPStem).inf ++ raha g n } ;
|
||||
VPPerfPastCont => {fin = copula CPast n p g ; inf = (vp.s ! VPStem).inf ++ raha g n } ;
|
||||
VPPerfFutCont => {fin = copula CFuture n p g ; inf = (vp.s ! VPStem).inf ++ raha g n ++ hw p n } ;
|
||||
VPSubj => {fin = insertSubj p (vp.s ! VPStem).inf ; inf = "xayd" }
|
||||
|
||||
};
|
||||
|
||||
quest =
|
||||
case ord of
|
||||
{ ODir => [];
|
||||
OQuest => "kya" };
|
||||
na =
|
||||
case b of
|
||||
{ Pos => [];
|
||||
Neg => "na" };
|
||||
nahim =
|
||||
case b of
|
||||
{ Pos => [];
|
||||
Neg => "nhyN" };
|
||||
in
|
||||
case t of {
|
||||
VPSubj => quest ++ subj ++ vp.obj.s ++ vp.ad ++ vp.comp ! agr ++ na ++ vps.inf ++ vps.fin ++ vp.embComp;
|
||||
_ => quest ++ subj ++ vp.obj.s ++ vp.ad ++ vp.comp ! agr ++ nahim ++ vps.inf ++ vps.fin ++ vp.embComp};
|
||||
} ;
|
||||
-}
|
||||
-- insertSubj : UPerson -> Str -> Str = \p,s ->
|
||||
-- case p of { Pers1 => s ++ "wN" ; _ => s ++ "E"};
|
||||
|
||||
insertObj : (Agr => Str) -> VPH -> VPH = \obj1,vp -> {
|
||||
s = vp.s ;
|
||||
obj = vp.obj ;
|
||||
subj = vp.subj ;
|
||||
inf = vp.inf;
|
||||
ad = vp.ad;
|
||||
embComp = vp.embComp;
|
||||
prog = vp.prog ;
|
||||
comp = \\a => vp.comp ! a ++ obj1 ! a
|
||||
} ;
|
||||
insertVV : Str -> VPH -> Str -> VPH = \obj1,vp,emb -> {
|
||||
s = vp.s ;
|
||||
obj = vp.obj ;
|
||||
subj = vp.subj ;
|
||||
inf = vp.inf;
|
||||
ad = vp.ad;
|
||||
embComp = vp.embComp ++ emb ;
|
||||
prog = vp.prog ;
|
||||
comp = \\a => vp.comp ! a ++ obj1
|
||||
} ;
|
||||
|
||||
insertObj2 : (Str) -> VPH -> VPH = \obj1,vp -> {
|
||||
s = vp.s;
|
||||
obj = vp.obj ;
|
||||
subj = vp.subj ;
|
||||
inf = vp.inf;
|
||||
ad = vp.ad;
|
||||
embComp = vp.embComp ++ obj1;
|
||||
prog = vp.prog ;
|
||||
comp = vp.comp
|
||||
|
||||
} ;
|
||||
|
||||
insertObjc : (Agr => Str) -> VPHSlash -> VPHSlash = \obj,vp ->
|
||||
insertObj obj vp ** {c2 = vp.c2} ;
|
||||
insertObjc2 : Str -> VPHSlash -> VPHSlash = \obj,vp ->
|
||||
insertObj2 obj vp ** {c2 = vp.c2} ;
|
||||
|
||||
infVP : Bool -> VPH -> Agr -> Str = \isAux,vp,a ->
|
||||
vp.obj.s ++ vp.inf ++ vp.comp ! a ;
|
||||
-- infVV : Bool -> VPH -> Str = \isAux,vp ->
|
||||
-- case isAux of {False => vp.obj.s ++ vp.inf ; True => vp.obj.s ++ (vp.s ! VPImp).fin };
|
||||
infVV : Bool -> VPH -> Str = \isAux,vp ->
|
||||
case isAux of {False => vp.obj.s ++ (vp.comp ! (toAgr Sg Pers1 Masc)) ++ vp.inf ; True => vp.obj.s ++ (vp.comp ! (toAgr Sg Pers1 Masc)) ++ (vp.s ! VPImp).fin } ;
|
||||
infV2V : Bool -> VPH -> Str = \isAux,vp ->
|
||||
case isAux of {False => vp.obj.s ++ (vp.comp ! (toAgr Sg Pers1 Masc)) ++ vp.inf ++ "ky" ; True => vp.obj.s ++ (vp.comp ! (toAgr Sg Pers1 Masc)) ++ (vp.s ! VPImp).fin ++ "ky"};
|
||||
|
||||
|
||||
insertObject : NP -> VPHSlash -> VPH = \np,vps -> {
|
||||
s = vps.s ;
|
||||
obj = {s = vps.obj.s ++ np.s ! objVType vps.c2.c ++ vps.c2.s ; a = np.a} ;
|
||||
subj = vps.c2.c ;
|
||||
inf = vps.inf;
|
||||
ad = vps.ad;
|
||||
embComp = vps.embComp;
|
||||
prog = vps.prog ;
|
||||
comp = vps.comp
|
||||
} ;
|
||||
|
||||
insertObjPre : (Agr => Str) -> VPHSlash -> VPH = \obj,vp -> {
|
||||
s = vp.s ;
|
||||
obj = vp.obj ;
|
||||
inf = vp.inf ;
|
||||
subj = vp.subj ;
|
||||
ad = vp.ad ;
|
||||
embComp = vp.embComp;
|
||||
prog = vp.prog ;
|
||||
comp = \\a => obj ! a ++ vp.c2.s ++ vp.comp ! a
|
||||
} ;
|
||||
|
||||
insertAdV : Str -> VPH -> VPH = \ad,vp -> {
|
||||
s = vp.s ;
|
||||
obj = vp.obj ;
|
||||
inf = vp.inf ;
|
||||
subj = vp.subj;
|
||||
ad = vp.ad ++ ad ;
|
||||
embComp = vp.embComp;
|
||||
prog = vp.prog ;
|
||||
comp = vp.comp
|
||||
} ;
|
||||
|
||||
conjThat : Str = "kh" ;
|
||||
|
||||
insertEmbCompl : VPH -> Str -> VPH = \vp,emb -> {
|
||||
s = vp.s ;
|
||||
obj = vp.obj ;
|
||||
inf = vp.inf ;
|
||||
subj = vp.subj;
|
||||
ad = vp.ad;
|
||||
embComp = vp.embComp ++ emb;
|
||||
prog = vp.prog ;
|
||||
comp = vp.comp
|
||||
} ;
|
||||
insertTrans : VPH -> VType -> VPH = \vp,vtype -> {
|
||||
s = vp.s ;
|
||||
obj = vp.obj ;
|
||||
inf = vp.inf ;
|
||||
subj = vtype;
|
||||
ad = vp.ad;
|
||||
embComp = vp.embComp ;
|
||||
prog = vp.prog ;
|
||||
comp = vp.comp
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user