From 845687462f7ad95e597739794d6c89f3548df769 Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 16 Mar 2015 14:53:53 +0000 Subject: [PATCH] refactored Thai so that it can now be compiled producing BIND tokens instead of spaces, by just changing the definition of ResTha.bIND. This is not to be exploited yet, because it produces consecutive BIND tokens, which are not supported at runtime. --- lib/src/thai/NounTha.gf | 10 +++++----- lib/src/thai/PhraseTha.gf | 10 +++++----- lib/src/thai/QuestionTha.gf | 2 +- lib/src/thai/ResTha.gf | 11 ++++++----- lib/src/thai/SentenceTha.gf | 13 ++++++++----- lib/src/translator/DictionaryTha.gf | 2 +- lib/src/translator/ExtensionsTha.gf | 4 ++-- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/src/thai/NounTha.gf b/lib/src/thai/NounTha.gf index bda5cc417..6cc9c2323 100644 --- a/lib/src/thai/NounTha.gf +++ b/lib/src/thai/NounTha.gf @@ -18,18 +18,18 @@ concrete NounTha of Noun = CatTha ** open StringsTha, ResTha, Prelude in { AdvNP np adv = thbind np adv ; DetQuant quant num = { - s1 = num.s ++ quant.s1 ; --- can there be quant.s1 ?? + s1 = num.s ++bIND++ quant.s1 ; --- can there be quant.s1 ?? s2 = quant.s2 ; hasC = orB num.hasC quant.hasC ; } ; DetQuantOrd quant num ord = { - s1 = num.s ++ quant.s1 ; --- can there be quant.s1 ?? - s2 = ord.s ++ quant.s2 ; + s1 = num.s ++bIND++ quant.s1 ; --- can there be quant.s1 ?? + s2 = ord.s ++bIND++ quant.s2 ; hasC = True ; } ; PossPron p = { - s1 = khoog_s ++ p.s ; + s1 = khoog_s ++bIND++ p.s ; s2 = [] ; hasC = False } ; @@ -60,7 +60,7 @@ concrete NounTha of Noun = CatTha ** open StringsTha, ResTha, Prelude in { ComplN2 f x = {s = thbind f.s f.c2 x.s ; c = f.c} ; ComplN3 f x = {s = thbind f.s f.c2 x.s ; c = f.c ; c2 = f.c3} ; - AdjCN ap cn = {s = cn.s ++ ap.s ; c = cn.c} ; + AdjCN ap cn = {s = cn.s ++bIND++ ap.s ; c = cn.c} ; RelCN cn rs = {s = thbind cn.s rs.s ; c = cn.s} ; AdvCN cn ad = {s = thbind cn.s ad.s ; c = cn.s} ; diff --git a/lib/src/thai/PhraseTha.gf b/lib/src/thai/PhraseTha.gf index 32b8e81b2..aeec42165 100644 --- a/lib/src/thai/PhraseTha.gf +++ b/lib/src/thai/PhraseTha.gf @@ -1,13 +1,13 @@ concrete PhraseTha of Phrase = CatTha ** open Prelude, ResTha in { lin - PhrUtt pconj utt voc = {s = pconj.s ++ utt.s ++ voc.s} ; + PhrUtt pconj utt voc = {s = pconj.s ++bIND++ utt.s ++bIND++ voc.s} ; UttS s = s ; UttQS qs = {s = qs.s ! QDir} ; - UttImpSg pol imp = {s = pol.s ++ imp.s ! pol.p} ; - UttImpPl pol imp = {s = pol.s ++ imp.s ! pol.p} ; - UttImpPol pol imp = {s = pol.s ++ imp.s ! pol.p} ; --- add politeness here? + UttImpSg pol imp = {s = pol.s ++bIND++ imp.s ! pol.p} ; + UttImpPl pol imp = {s = pol.s ++bIND++ imp.s ! pol.p} ; + UttImpPol pol imp = {s = pol.s ++bIND++ imp.s ! pol.p} ; --- add politeness here? UttIP ip = ip ; UttIAdv iadv = iadv ; @@ -15,7 +15,7 @@ concrete PhraseTha of Phrase = CatTha ** open Prelude, ResTha in { UttCN cn = cn ; UttAP ap = ap ; UttCard x = x ; - UttVP vp = {s = vp.s ! Pos ++ vp.e} ; + UttVP vp = {s = vp.s ! Pos ++bIND++ vp.e} ; UttAdv adv = adv ; NoPConj = {s = []} ; diff --git a/lib/src/thai/QuestionTha.gf b/lib/src/thai/QuestionTha.gf index fd4f64f9d..331687585 100644 --- a/lib/src/thai/QuestionTha.gf +++ b/lib/src/thai/QuestionTha.gf @@ -30,7 +30,7 @@ concrete QuestionTha of Question = CatTha ** IdetIP idet = mkNP (thbind idet.s1 idet.s2) ; IdetQuant iquant num = { - s1 = num.s ++ iquant.s1 ; --- is num even possible ?? + s1 = num.s ++bIND++ iquant.s1 ; --- is num even possible ?? s2 = iquant.s2 ; hasC = iquant.hasC } ; diff --git a/lib/src/thai/ResTha.gf b/lib/src/thai/ResTha.gf index d635c36ae..ffab0d23b 100644 --- a/lib/src/thai/ResTha.gf +++ b/lib/src/thai/ResTha.gf @@ -11,9 +11,10 @@ resource ResTha = ParamX, StringsTha ** open Prelude in { oper --- binding words together - if you want. But better do it with the unlexer -unchars. +-- binding words together +-- will be activated when the parser supports consecutive BINDs AR 16/3/2015 - bIND = [] ; + bIND = [] ; ---- Predef.BIND ; thbind = overload { thbind : Str -> Str = \s -> s ; @@ -99,8 +100,8 @@ resource ResTha = ParamX, StringsTha ** open Prelude in { predV : Verb -> VP = \v -> { s = \\p => if_then_Str v.isCompl - (thbind v.s1 (polStr may_s p ++ v.s2)) - (v.s1 ++ (polStr may_s p ++ v.s2)) ; --- v.s1 = [] ; + (thbind v.s1 (polStr may_s p ++bIND++ v.s2)) + (v.s1 ++bIND++ (polStr may_s p ++bIND++ v.s2)) ; --- v.s1 = [] ; e = [] } ; @@ -111,7 +112,7 @@ resource ResTha = ParamX, StringsTha ** open Prelude in { insertExtra : Str -> VP -> VP = \o,vp -> { s = vp.s ; - e = vp.e ++ o + e = vp.e ++bIND++ o } ; adjVP : Adj -> VP = \a -> { diff --git a/lib/src/thai/SentenceTha.gf b/lib/src/thai/SentenceTha.gf index 6c932c9ea..56ccb1d40 100644 --- a/lib/src/thai/SentenceTha.gf +++ b/lib/src/thai/SentenceTha.gf @@ -32,17 +32,20 @@ concrete SentenceTha of Sentence = CatTha ** EmbedQS qs = {s = qs.s ! QIndir} ; EmbedVP vp = {s = infVP vp} ; - UseCl t p cl = {s = thbind t.s p.s (cl.s ! ClDecl ! p.p)} ; + UseCl t p cl = {s = t.s ++ p.s ++ (cl.s ! ClDecl ! p.p)} ; --- no bIND here, to prevent spurious &+ tokens UseQCl t p cl = { - s = \\q => thbind t.s p.s - (case q of {QIndir => waa_s ; _ => []}) (cl.s ! p.p) + s = \\q => t.s ++ p.s ++ + (case q of {QIndir => waa_s ; _ => []}) ++bIND++ (cl.s ! p.p) } ; UseRCl t p cl = { - s = thbind t.s p.s (cl.s ! p.p) ; + s = t.s ++ p.s ++ (cl.s ! p.p) ; } ; - UseSlash t p cl = {s = thbind t.s p.s (cl.s ! p.p) ; c2 = cl.c2} ; + UseSlash t p cl = {s = t.s ++ p.s ++ (cl.s ! p.p) ; c2 = cl.c2} ; AdvS a s = thbind a s ; RelS s r = thbind s r ; + + ExtAdvS a s = thbind a s ; + SSubjS a c b = thbind a c b ; } diff --git a/lib/src/translator/DictionaryTha.gf b/lib/src/translator/DictionaryTha.gf index 7931b5e68..300eaff51 100644 --- a/lib/src/translator/DictionaryTha.gf +++ b/lib/src/translator/DictionaryTha.gf @@ -17,7 +17,7 @@ oper mmkV2V : Str -> V2V = \s -> mkV2V (mkV s) [] [] ; oper mmkV2A : Str -> V2A = \s -> mkV2A (mkV s) [] [] ; oper mmkV2S : Str -> V2S = \s -> mkV2S (mkV s) [] ; oper prepV2 : V -> Prep -> V2 = \v,p -> mkV2 v p.s ; -oper advV : V -> Adv -> V = \v,a -> mkV v.s1 (v.s2 ++ a.s) ; ---- +oper advV : V -> Adv -> V = \v,a -> mkV v.s1 (thbind v.s2 a.s) ; ---- lin aardvark_N = mkN "ตัวกินมด" ; -- src=panlex diff --git a/lib/src/translator/ExtensionsTha.gf b/lib/src/translator/ExtensionsTha.gf index b2eaa49ec..555e42816 100644 --- a/lib/src/translator/ExtensionsTha.gf +++ b/lib/src/translator/ExtensionsTha.gf @@ -14,9 +14,9 @@ lin ---- ConjVPI = E.ConjVPI ; ---- ComplVPIVV = E.ComplVPIVV ; - MkVPS _ p vp = {s = vp.s ! p.p} ; ---- + MkVPS t p vp = {s = t.s ++ p.s ++ vp.s ! p.p} ; ---- ---- ConjVPS = E.ConjVPS ; - PredVPS np vp = cc2 np vp ; + PredVPS np vp = thbind np vp ; {- BaseVPI = E.BaseVPI ; ConsVPI = E.ConsVPI ;