diff --git a/lib/resource-1.4/hindi/CatHin.gf b/lib/resource-1.4/hindi/CatHin.gf index ad50d242c..7a97d4138 100644 --- a/lib/resource-1.4/hindi/CatHin.gf +++ b/lib/resource-1.4/hindi/CatHin.gf @@ -13,7 +13,7 @@ concrete CatHin of Cat = CommonX ** open ResHin, Prelude in { -- ---- Sentence -- --- Cl = {s : ResHin.Tense => Anteriority => CPolarity => Order => Str} ; + Cl = ResHin.Clause ; -- ClSlash = { -- s : ResHin.Tense => Anteriority => CPolarity => Order => Str ; -- c2 : Str @@ -38,7 +38,7 @@ concrete CatHin of Cat = CommonX ** open ResHin, Prelude in { -- ---- Verb -- --- VP = ResHin.VP ; + VP = ResHin.VPH ; -- VPSlash = ResHin.VP ** {c2 : Str} ; -- Comp = {s : Agr => Str} ; -- @@ -48,8 +48,8 @@ concrete CatHin of Cat = CommonX ** open ResHin, Prelude in { -- ---- Noun -- --- CN = {s : Number => Case => Str ; g : Gender} ; --- NP, Pron = {s : Case => Str ; a : Agr} ; + CN = ResHin.Noun ; + NP, Pron = ResHin.NP ; -- Det = {s : Str ; n : Number} ; -- Predet, Ord = {s : Str} ; -- Num = {s : Str; n : Number ; hasCard : Bool} ; @@ -73,7 +73,7 @@ concrete CatHin of Cat = CommonX ** open ResHin, Prelude in { ---- Open lexical classes, e.g. Lexicon -- V, VS, VQ, VA = Verb ; -- = {s : VForm => Str} ; --- V2, V2A, V2Q, V2S = Verb ** {c2 : Str} ; + V2, V2A, V2Q, V2S = Verb ** {c2 : Compl} ; -- V3 = Verb ** {c2, c3 : Str} ; -- VV = {s : VVForm => Str ; isAux : Bool} ; -- V2V = Verb ** {c2 : Str ; isAux : Bool} ; @@ -84,6 +84,6 @@ concrete CatHin of Cat = CommonX ** open ResHin, Prelude in { N = {s : Number => Case => Str ; g : Gender} ; -- N2 = {s : Number => Case => Str ; g : Gender} ** {c2 : Str} ; -- N3 = {s : Number => Case => Str ; g : Gender} ** {c2,c3 : Str} ; --- PN = {s : Case => Str ; g : Gender} ; + PN = {s : Case => Str ; g : Gender} ; -- } diff --git a/lib/resource-1.4/hindi/Deva.hs b/lib/resource-1.4/hindi/Deva.hs new file mode 100644 index 000000000..0c557dc8d --- /dev/null +++ b/lib/resource-1.4/hindi/Deva.hs @@ -0,0 +1,114 @@ +main = interact udeva + +udeva :: String -> String +udeva = encodeUTF8 . str2deva + +str2deva :: String -> String +str2deva s = map toEnum $ case chop s of + c:cs -> encodeInit c : map encode cs + _ -> [] + +chop s = case s of + v:':':cs -> [v,':'] : chop cs + v:'.':cs -> [v,'.'] : chop cs + c:'a':cs -> [c] : chop cs + c :cs -> [c] : chop cs + _ -> [] + +encodeInit :: String -> Int +encodeInit s = case s of + "a" -> 0x0905 + "a:" -> 0x0906 + "i" -> 0x0907 + "i:" -> 0x0908 + "u" -> 0x0909 + "u:" -> 0x090a + "r:" -> 0x090b + "e" -> 0x090f + "E" -> 0x0910 + "o" -> 0x0913 + "O" -> 0x0914 + _ -> encode s + +encode :: String -> Int +encode s = case s of + "k" -> 0x0915 + "K" -> 0x0916 + "g" -> 0x0917 + "G" -> 0x0918 + "N:" -> 0x0919 + + "c" -> 0x091a + "C" -> 0x091b + "j" -> 0x091c + "J" -> 0x091d + "n:" -> 0x091e + + "t." -> 0x091f + "T." -> 0x0920 + "d." -> 0x0921 + "D." -> 0x0922 + "n." -> 0x0923 + + "t" -> 0x0924 + "T" -> 0x0925 + "d" -> 0x0926 + "D" -> 0x0927 + "n" -> 0x0928 + + "p" -> 0x092a + "P" -> 0x092b + "b" -> 0x092c + "B" -> 0x092d + "m" -> 0x092e + + "y" -> 0x092f + "r" -> 0x0930 + "l" -> 0x0932 + "v" -> 0x0935 + + "S" -> 0x0936 + "s." -> 0x0937 + "s" -> 0x0938 + "h" -> 0x0939 + + "R" -> 0x095c + + "a:" -> 0x093e + "i" -> 0x093f + "i:" -> 0x0940 + "u" -> 0x0941 + "u:" -> 0x0942 + "r:" -> 0x0943 + "e" -> 0x0947 + "E" -> 0x0948 + "o" -> 0x094b + "O" -> 0x094c + + "~" -> 0x0901 + "*" -> 0x0902 + + " " -> space + + _ -> 0x093e --- a: + + +space = fromEnum ' ' + + +encodeUTF8 :: String -> String +encodeUTF8 "" = "" +encodeUTF8 (c:cs) = + if c > '\x0000' && c < '\x0080' then + c : encodeUTF8 cs + else if c < toEnum 0x0800 then + let i = fromEnum c + in toEnum (0xc0 + i `div` 0x40) : + toEnum (0x80 + i `mod` 0x40) : + encodeUTF8 cs + else + let i = fromEnum c + in toEnum (0xe0 + i `div` 0x1000) : + toEnum (0x80 + (i `mod` 0x1000) `div` 0x40) : + toEnum (0x80 + i `mod` 0x40) : + encodeUTF8 cs diff --git a/lib/resource-1.4/hindi/LexiconHin.gf b/lib/resource-1.4/hindi/LexiconHin.gf index 50a7045f7..a3948e497 100644 --- a/lib/resource-1.4/hindi/LexiconHin.gf +++ b/lib/resource-1.4/hindi/LexiconHin.gf @@ -2,15 +2,15 @@ concrete LexiconHin of Lexicon = CatHin ** open ParadigmsHin, Prelude in { --- ---flags --- optimize=values ; --- ---lin + + flags + optimize=values ; + + lin -- airplane_N = regN "airplane" ; -- answer_V2S = mkV2S (regV "answer") toP ; -- apartment_N = regN "apartment" ; --- apple_N = regN "apple" ; + apple_N = mkN "seb" ; -- art_N = regN "art" ; -- ask_V2Q = mkV2Q (regV "ask") noPrep ; -- baby_N = regN "baby" ; @@ -29,7 +29,7 @@ concrete LexiconHin of Lexicon = CatHin ** -- book_N = regN "book" ; -- boot_N = regN "boot" ; -- boss_N = mkN human (regN "boss") ; --- boy_N = mkN masculine (regN "boy") ; + boy_N = mkN "laRka:" ; -- bread_N = regN "bread" ; -- break_V2 = dirV2 (irregV "break" "broke" "broken") ; -- broad_A = regADeg "broad" ; @@ -66,7 +66,7 @@ concrete LexiconHin of Lexicon = CatHin ** -- door_N = regN "door" ; -- drink_V2 = dirV2 (irregV "drink" "drank" "drunk") ; -- easy_A2V = mkA2V (regA "easy") forP ; --- eat_V2 = dirV2 (irregV "eat" "ate" "eaten") ; + eat_V2 = mkV2 "Ka:" ; -- empty_A = regADeg "empty" ; -- enemy_N = regN "enemy" ; -- factory_N = regN "factory" ; @@ -81,11 +81,11 @@ concrete LexiconHin of Lexicon = CatHin ** -- fruit_N = regN "fruit" ; -- fun_AV = mkAV (regA "fun") ; -- garden_N = regN "garden" ; --- girl_N = mkN feminine (regN "girl") ; + girl_N = mkN "laRki:" ; -- glove_N = regN "glove" ; -- gold_N = regN "gold" ; -- good_A = mkADeg "good" "better" "best" "well" ; --- go_V = mk5V "go" "goes" "went" "gone" "going" ; + go_V = mkV "cal" ; -- green_A = regADeg "green" ; -- harbour_N = regN "harbour" ; -- hate_V2 = dirV2 (regV "hate") ; diff --git a/lib/resource-1.4/hindi/NounHin.gf b/lib/resource-1.4/hindi/NounHin.gf index a96b844c7..164561afa 100644 --- a/lib/resource-1.4/hindi/NounHin.gf +++ b/lib/resource-1.4/hindi/NounHin.gf @@ -1,15 +1,15 @@ concrete NounHin of Noun = CatHin ** open ResHin, Prelude in { --- --- flags optimize=all_subs ; --- --- lin + + flags optimize=all_subs ; + + lin -- DetCN det cn = { -- s = \\c => det.s ++ cn.s ! det.n ! c ; -- a = agrgP3 det.n cn.g -- } ; -- --- UsePN pn = pn ** {a = agrgP3 Sg pn.g} ; --- UsePron p = p ; + UsePN pn = {s = \\c => toNP pn.s c ; a = agrP3 pn.g Sg} ; + UsePron p = p ; -- -- PredetNP pred np = { -- s = \\c => pred.s ++ np.s ! c ; @@ -72,31 +72,26 @@ concrete NounHin of Noun = CatHin ** open ResHin, Prelude in { -- s = art.s ! True ! card.n ++ card.s ; -- n = card.n -- } ; --- --- DetArtSg art cn = { --- s = \\c => art.s ! False ! Sg ++ cn.s ! Sg ! c ; --- a = agrgP3 Sg cn.g --- } ; --- --- DetArtPl art cn = { --- s = \\c => art.s ! False ! Pl ++ cn.s ! Pl ! c ; --- a = agrgP3 Pl cn.g --- } ; --- --- DefArt = {s = \\c,n => artDef} ; --- --- IndefArt = {s = \\c,n => case of { --- => artIndef ; --- _ => [] --- } --- } ; --- + + DetArtSg art cn = { + s = \\c => art.s ++ toNP (cn.s ! Sg) c ; + a = agrP3 cn.g Sg + } ; + + DetArtPl art cn = { + s = \\c => art.s ++ toNP (cn.s ! Pl) c ; + a = agrP3 cn.g Pl + } ; + + DefArt = {s = []} ; + IndefArt = {s = []} ; + -- MassNP cn = { -- s = cn.s ! Sg ; -- a = agrP3 Sg -- } ; --- --- UseN n = n ; + + UseN n = n ; -- UseN2 n = n ; -- -- Use2N3 f = { diff --git a/lib/resource-1.4/hindi/ParadigmsHin.gf b/lib/resource-1.4/hindi/ParadigmsHin.gf index f64f0793e..659f01143 100644 --- a/lib/resource-1.4/hindi/ParadigmsHin.gf +++ b/lib/resource-1.4/hindi/ParadigmsHin.gf @@ -50,6 +50,16 @@ oper } ; + mkV2 = overload { + mkV2 : Str -> V2 + = \s -> regVerb s ** {c2 = {s = [] ; c = VTrans} ; lock_V2 = <>} ; + mkV2 : V -> V2 + = \v -> v ** {c2 = {s = [] ; c = VTrans} ; lock_V2 = <>} ; + mkV2 : V -> Str -> V2 + = \v,p -> v ** {c2 = {s = p ; c = VIntrans} ; lock_V2 = <>} ; + } ; + + ----3 Compound nouns ---- ---- A compound noun is an uninflected string attached to an inflected noun, diff --git a/lib/resource-1.4/hindi/ResHin.gf b/lib/resource-1.4/hindi/ResHin.gf index 4c5bd25ea..58ded8966 100644 --- a/lib/resource-1.4/hindi/ResHin.gf +++ b/lib/resource-1.4/hindi/ResHin.gf @@ -10,7 +10,7 @@ resource ResHin = ParamX ** open Prelude in { flags optimize=all ; param - Case = Dir | Obj | Voc ; + Case = Dir | Obl | Voc ; Gender = Masc | Fem ; oper @@ -27,10 +27,10 @@ resource ResHin = ParamX ** open Prelude in { } ; regNoun : Str -> Noun = \s -> case s of { - x + "iya:" => mkNoun s s s (x + "iya:~") (x + "iyo~") (x + "iyo") Fem ; - x + "a:" => mkNoun s (x + "e") (x + "e") (x + "e") (x + "o~") (x + "o") Masc ; - x + "i:" => mkNoun s s s (x + "iya:~") (x + "iyo~") (x + "iyo") Fem ; - _ => mkNoun s s s s (s + "o~") (s + "o") Masc + x + "iya:" => mkNoun s s s (x + "iya:~") (x + "iyo*") (x + "iyo") Fem ; + x + "a:" => mkNoun s (x + "e") (x + "e") (x + "e") (x + "o*") (x + "o") Masc ; + x + "i:" => mkNoun s s s (x + "iya:~") (x + "iyo*") (x + "iyo") Fem ; + _ => mkNoun s s s s (s + "o*") (s + "o") Masc } ; @@ -97,8 +97,8 @@ resource ResHin = ParamX ** open Prelude in { regVerb : Str -> Verb = \cal -> mkVerb (cal + "na:") cal (cal + "ta:") (cal + "te") (cal + "ti:") (cal + "ti:") - (cal + "a:") (cal + "e") (cal + "i:") (cal + "i:~") - (cal + "u:~") (cal + "e") (cal + "o") (cal + "e~") + (cal + "a:") (cal + "e") (cal + "i:") (cal + "i:*") + (cal + "u:~") (cal + "e") (cal + "o") (cal + "e*") (cal + "ie") ; param @@ -107,23 +107,23 @@ resource ResHin = ParamX ** open Prelude in { copula : CTense -> Number -> Person -> Gender -> Str = \t,n,p,g -> case of { => "hu:~" ; - => "hai" ; - => "hai" ; - => "hai:~" ; + => "hE" ; + => "hE" ; + => "hE*" ; => "ho" ; - => "hai:~" ; + => "hE*" ; => "Ta:" ; => "Ti:" ; => "Te" ; - => "Ti:~" ; - => "hu:~ga:" ; - => "hu:~gi:" ; + => "Ti:*" ; + => "hu:*ga:" ; + => "hu:*gi:" ; => "hoga:" ; => "hogi:" ; => "hoge" ; - => "ho~ge" ; + => "ho*ge" ; => "hogi:" ; - => "ho~gi:" + => "ho*gi:" } ; param @@ -131,12 +131,12 @@ resource ResHin = ParamX ** open Prelude in { oper personalPronoun : Person -> Number -> {s : PronCase => Str} = \p,n -> case of { - => {s = table PronCase ["mai~" ; "muJ" ; "muJe" ; "mera:"]} ; - => {s = table PronCase ["ham" ; "ham" ; "hame~" ; "hama:ra:"]} ; + => {s = table PronCase ["mE*" ; "muJ" ; "muJe" ; "mera:"]} ; + => {s = table PronCase ["ham" ; "ham" ; "hame*" ; "hama:ra:"]} ; => {s = table PronCase ["tu:" ; "tuJ" ; "tuJe" ; "tera:"]} ; - => {s = table PronCase ["tum" ; "tum" ; "tumhe~" ; "tumha:ra:"]} ; - => {s = table PronCase ["vah" ; "us" ; "use~" ; "uska:"]} ; - => {s = table PronCase ["ve" ; "un" ; "unhe~" ; "unka:"]} + => {s = table PronCase ["tum" ; "tum" ; "tumhe*" ; "tumha:ra:"]} ; + => {s = table PronCase ["vah" ; "us" ; "use" ; "uska:"]} ; + => {s = table PronCase ["ve" ; "un" ; "unhe*" ; "unka:"]} } ; -- the Hindi verb phrase @@ -159,7 +159,7 @@ resource ResHin = ParamX ** open Prelude in { ; VPHForm = - VPTense VPHTense Number Person Gender -- 9 * 12 + VPTense VPHTense Agr -- 9 * 12 | VPReq | VPImp | VPReqFut @@ -167,37 +167,74 @@ resource ResHin = ParamX ** open Prelude in { | VPStem ; + VType = VIntrans | VTrans ; + oper VPH : Type = { s : Bool => VPHForm => {fin, inf, neg : Str} ; obj : Str ; - comp : Gender => Number => Str + subj : VType ; + comp : Agr => Str } ; - mkVPH : Verb -> VPH = \verb -> { + predV : Verb -> VPH = \verb -> { s = \\b,vh => let na = if_then_Str b [] "na" ; nahim = if_then_Str b [] "nahim" ; in case vh of { - VPTense VPGenPres n p g => + VPTense VPGenPres (Ag g n p) => {fin = copula CPresent n p g ; inf = verb.s ! VImpf g n ; neg = nahim} ; - VPTense VPImpPast n p g => + VPTense VPImpPast (Ag g n p) => {fin = copula CPast n p g ; inf = verb.s ! VImpf g n ; neg = nahim} ; - VPTense VPPerf n _ g => + VPTense VPPerf (Ag g n _) => {fin = verb.s ! VPerf g n ; inf = [] ; neg = nahim} ; - VPTense VPPerfPres n p g => + VPTense VPPerfPres (Ag g n p) => {fin = copula CPresent n p g ; inf = verb.s ! VPerf g n ; neg = nahim} ; - VPTense VPPerfPast n p g => + VPTense VPPerfPast (Ag g n p) => {fin = copula CPast n p g ; inf = verb.s ! VPerf g n ; neg = nahim} ; - VPTense VPSubj n p _ => {fin = verb.s ! VSubj n p ; inf = [] ; neg = na} ; - VPTense VPFut n p g => {fin = verb.s ! VFut n p g ; inf = [] ; neg = na} ; + VPTense VPSubj (Ag _ n p) => {fin = verb.s ! VSubj n p ; inf = [] ; neg = na} ; + VPTense VPFut (Ag g n p) => {fin = verb.s ! VFut n p g ; inf = [] ; neg = na} ; VPInf => {fin = verb.s ! VStem ; inf = [] ; neg = na} ; _ => {fin = verb.s ! VStem ; inf = [] ; neg = na} } ; obj = [] ; - comp = \\_,_ => [] + subj = VIntrans ; + comp = \\_ => [] } ; + Clause : Type = {s : VPHTense => Bool => Str} ; + + Compl : Type = {s : Str ; c : VType} ; + + param + Agr = Ag Gender Number Person ; + NPCase = NPC Case | NPErg ; + + oper + agrP3 : Gender -> Number -> Agr = \g,n -> Ag g n P3 ; + + npcase2case : NPCase -> Case = \npc -> case npc of { + NPC c => c ; + NPErg => Obl + } ; + + toNP : (Case => Str) -> NPCase -> Str = \pn, npc -> case npc of { + NPC c => pn ! c ; + NPErg => pn ! Obl ++ "ne" + } ; + + NP : Type = {s : NPCase => Str ; a : Agr} ; + + mkClause : NP -> VPH -> Clause = \np,vp -> { + s = \\vt,b => + let + vps = vp.s ! b ! VPTense vt np.a ; + subj = NPC Dir + in + np.s ! subj ++ vp.obj ++ vp.comp ! np.a ++ vps.neg ++ vps.inf ++ vps.fin + } ; + + } diff --git a/lib/resource-1.4/hindi/SentenceHin.gf b/lib/resource-1.4/hindi/SentenceHin.gf index 4ad3c845a..d4930c9af 100644 --- a/lib/resource-1.4/hindi/SentenceHin.gf +++ b/lib/resource-1.4/hindi/SentenceHin.gf @@ -1,11 +1,11 @@ concrete SentenceHin of Sentence = CatHin ** open Prelude, ResHin in { --- --- flags optimize=all_subs ; --- --- lin --- --- PredVP np vp = mkClause (np.s ! Nom) np.a vp ; --- + + flags optimize=all_subs ; + + lin + + PredVP np vp = mkClause np vp ; + -- PredSCVP sc vp = mkClause sc.s (agrP3 Sg) vp ; -- -- ImpVP vp = { diff --git a/lib/resource-1.4/hindi/VerbHin.gf b/lib/resource-1.4/hindi/VerbHin.gf index ea30e4652..3083d7172 100644 --- a/lib/resource-1.4/hindi/VerbHin.gf +++ b/lib/resource-1.4/hindi/VerbHin.gf @@ -1,10 +1,10 @@ concrete VerbHin of Verb = CatHin ** open ResHin in { --- --- flags optimize=all_subs ; --- --- lin --- UseV = predV ; --- + + flags optimize=all_subs ; + + lin + UseV = predV ; + -- SlashV2a v = predVc v ; -- Slash2V3 v np = -- insertObjc (\\_ => v.c2 ++ np.s ! Acc) (predV v ** {c2 = v.c3}) ;