temporary transcription; first clauses generated in Hindi

This commit is contained in:
aarne
2008-05-06 15:15:16 +00:00
parent 830358e5ca
commit aefb6fcc23
8 changed files with 244 additions and 88 deletions

View File

@@ -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} ;
--
}

View File

@@ -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

View File

@@ -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") ;

View File

@@ -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 <n,c> of {
-- <Sg,False> => 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 = {

View File

@@ -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,

View File

@@ -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 <t,n,p,g> of {
<CPresent,Sg,P1,_ > => "hu:~" ;
<CPresent,Sg,P2,_ > => "hai" ;
<CPresent,Sg,P3,_ > => "hai" ;
<CPresent,Pl,P1,_ > => "hai:~" ;
<CPresent,Sg,P2,_ > => "hE" ;
<CPresent,Sg,P3,_ > => "hE" ;
<CPresent,Pl,P1,_ > => "hE*" ;
<CPresent,Pl,P2,_ > => "ho" ;
<CPresent,Pl,P3,_ > => "hai:~" ;
<CPresent,Pl,P3,_ > => "hE*" ;
<CPast, Sg,_ ,Masc> => "Ta:" ;
<CPast, Sg,_ ,Fem > => "Ti:" ;
<CPast, Pl,_ ,Masc> => "Te" ;
<CPast, Pl,_ ,Fem > => "Ti:~" ;
<CFuture, Sg,P1,Masc> => "hu:~ga:" ;
<CFuture, Sg,P1,Fem > => "hu:~gi:" ;
<CPast, Pl,_ ,Fem > => "Ti:*" ;
<CFuture, Sg,P1,Masc> => "hu:*ga:" ;
<CFuture, Sg,P1,Fem > => "hu:*gi:" ;
<CFuture, Sg,_ ,Masc> => "hoga:" ;
<CFuture, Sg,_ ,Fem > => "hogi:" ;
<CFuture, Pl,P2,Masc> => "hoge" ;
<CFuture, Pl,_ ,Masc> => "ho~ge" ;
<CFuture, Pl,_ ,Masc> => "ho*ge" ;
<CFuture, Pl,P2,Fem > => "hogi:" ;
<CFuture, Pl,_ ,Fem > => "ho~gi:"
<CFuture, Pl,_ ,Fem > => "ho*gi:"
} ;
param
@@ -131,12 +131,12 @@ resource ResHin = ParamX ** open Prelude in {
oper
personalPronoun : Person -> Number -> {s : PronCase => Str} = \p,n ->
case <p,n> of {
<P1,Sg> => {s = table PronCase ["mai~" ; "muJ" ; "muJe" ; "mera:"]} ;
<P1,Pl> => {s = table PronCase ["ham" ; "ham" ; "hame~" ; "hama:ra:"]} ;
<P1,Sg> => {s = table PronCase ["mE*" ; "muJ" ; "muJe" ; "mera:"]} ;
<P1,Pl> => {s = table PronCase ["ham" ; "ham" ; "hame*" ; "hama:ra:"]} ;
<P2,Sg> => {s = table PronCase ["tu:" ; "tuJ" ; "tuJe" ; "tera:"]} ;
<P2,Pl> => {s = table PronCase ["tum" ; "tum" ; "tumhe~" ; "tumha:ra:"]} ;
<P3,Sg> => {s = table PronCase ["vah" ; "us" ; "use~" ; "uska:"]} ;
<P3,Pl> => {s = table PronCase ["ve" ; "un" ; "unhe~" ; "unka:"]}
<P2,Pl> => {s = table PronCase ["tum" ; "tum" ; "tumhe*" ; "tumha:ra:"]} ;
<P3,Sg> => {s = table PronCase ["vah" ; "us" ; "use" ; "uska:"]} ;
<P3,Pl> => {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
} ;
}

View File

@@ -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 = {

View File

@@ -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}) ;