From 3c27eea68bbeca6a21845df57e5cd96e6f0ced69 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. --- src/thai/NounTha.gf | 10 +++++----- src/thai/PhraseTha.gf | 10 +++++----- src/thai/QuestionTha.gf | 2 +- src/thai/ResTha.gf | 11 ++++++----- src/thai/SentenceTha.gf | 13 ++++++++----- src/translator/DictionaryTha.gf | 2 +- src/translator/ExtensionsTha.gf | 4 ++-- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/thai/NounTha.gf b/src/thai/NounTha.gf index bda5cc41..6cc9c232 100644 --- a/src/thai/NounTha.gf +++ b/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/src/thai/PhraseTha.gf b/src/thai/PhraseTha.gf index 32b8e81b..aeec4216 100644 --- a/src/thai/PhraseTha.gf +++ b/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/src/thai/QuestionTha.gf b/src/thai/QuestionTha.gf index fd4f64f9..33168758 100644 --- a/src/thai/QuestionTha.gf +++ b/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/src/thai/ResTha.gf b/src/thai/ResTha.gf index d635c36a..ffab0d23 100644 --- a/src/thai/ResTha.gf +++ b/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/src/thai/SentenceTha.gf b/src/thai/SentenceTha.gf index 6c932c9e..56ccb1d4 100644 --- a/src/thai/SentenceTha.gf +++ b/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/src/translator/DictionaryTha.gf b/src/translator/DictionaryTha.gf index 7931b5e6..300eaff5 100644 --- a/src/translator/DictionaryTha.gf +++ b/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/src/translator/ExtensionsTha.gf b/src/translator/ExtensionsTha.gf index b2eaa49e..555e4281 100644 --- a/src/translator/ExtensionsTha.gf +++ b/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 ;