mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-15 06:02:55 -06:00
godis tram grammars, augmented with Fin
This commit is contained in:
399
examples/godis-tram/Common/GodisLang.gf
Normal file
399
examples/godis-tram/Common/GodisLang.gf
Normal file
@@ -0,0 +1,399 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common
|
||||
|
||||
interface GodisLang = open Grammar, Prelude, PredefAbs in {
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- different clause forms
|
||||
|
||||
param ClForm = HasDone | IsDoing;
|
||||
|
||||
oper
|
||||
|
||||
ClauseForm : Type;
|
||||
clauseForm : ClauseForm -> ClauseForm;
|
||||
|
||||
hasDone : ClauseForm;
|
||||
isDoing : ClauseForm;
|
||||
|
||||
anter : ClauseForm -> Ant;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- punctuation on system utterances
|
||||
|
||||
param Punctn = FullStop | QuestMark;
|
||||
|
||||
oper
|
||||
|
||||
Punctuation : Type;
|
||||
fullStop,
|
||||
questMark : Punctuation;
|
||||
|
||||
consText : Punctuation -> Utt -> Text -> Text;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- focus
|
||||
|
||||
emphasize : NP -> NP;
|
||||
embed_NP : Str -> Str -> NP -> NP;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- user utterances
|
||||
|
||||
UserQuestion,
|
||||
UserAction,
|
||||
UserAnswer,
|
||||
UserShortAns,
|
||||
UserProposition : Type;
|
||||
|
||||
askQS : QCl -> UserQuestion;
|
||||
ansCl : Cl -> UserAnswer;
|
||||
ansNP : NP -> UserShortAns;
|
||||
|
||||
reqVP : VP -> UserAction;
|
||||
req1 : Str -> UserAction;
|
||||
req1x : Str -> Str -> UserAction;
|
||||
req2x : Str -> Str -> Str -> UserAction;
|
||||
|
||||
not_user_prop : UserProposition -> SS;
|
||||
not_user_short : UserShortAns -> SS;
|
||||
|
||||
userGreet,
|
||||
userQuit,
|
||||
userYes,
|
||||
userNo,
|
||||
userOkay : SS;
|
||||
|
||||
userCoordinate : SS -> SS -> SS;
|
||||
|
||||
thank_you_Str,
|
||||
i_want_to_Str,
|
||||
please_Str,
|
||||
this_that_Str : Str;
|
||||
|
||||
use_QCl : QCl -> SS;
|
||||
use_Cl : Cl -> SS;
|
||||
use_NP : NP -> SS;
|
||||
use_VP : VP -> SS;
|
||||
use_Adv : Adv -> SS;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- system utterances
|
||||
|
||||
hello,
|
||||
goodbye,
|
||||
yes,
|
||||
no,
|
||||
|
||||
is_that_correct_Post,
|
||||
returning_to_Pre,
|
||||
returning_to_act_Pre,
|
||||
returning_to_issue_Pre,
|
||||
i_dont_understand,
|
||||
cant_answer_que_Pre,
|
||||
not_valid_Post,
|
||||
|
||||
icm_acc_pos,
|
||||
icm_con_neg,
|
||||
icm_reraise,
|
||||
icm_loadplan,
|
||||
icm_accommodate : Utt;
|
||||
|
||||
icm_per_pos : String -> Utt;
|
||||
|
||||
cncUtt : Utt -> Utt -> Utt;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- interrogative phrases
|
||||
|
||||
which_N_sg : N -> IP;
|
||||
which_N_pl : N -> IP;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- noun phrases
|
||||
|
||||
sing_NP,
|
||||
plur_NP : Str -> NP;
|
||||
|
||||
the_CN_sg : CN -> NP;
|
||||
|
||||
the_N_sg,
|
||||
the_N_pl,
|
||||
indef_N_sg,
|
||||
indef_N_pl,
|
||||
this_N_sg,
|
||||
these_N_pl,
|
||||
no_N_sg,
|
||||
no_N_pl,
|
||||
all_N_pl : N -> NP;
|
||||
|
||||
the_A_super_N_sg,
|
||||
indef_A_posit_N_sg,
|
||||
no_A_posit_N_sg : A -> N -> NP;
|
||||
|
||||
NP_Adv : NP -> Adv -> NP;
|
||||
NP_Prep_NP : Prep -> NP -> NP -> NP;
|
||||
NP_in_NP,
|
||||
NP_of_NP,
|
||||
NPgen_NP : NP -> NP -> NP;
|
||||
NP_Cl : NP -> Cl;
|
||||
|
||||
prefix_N : N -> N -> N;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- questions, q-clauses
|
||||
|
||||
useQCl : (QCl ** ClauseForm) -> QS;
|
||||
|
||||
which_N_are_AP,
|
||||
which_N_is_AP : N -> AP -> QCl;
|
||||
what_is_NP : NP -> QCl;
|
||||
who_VP : VP -> QCl;
|
||||
|
||||
which_N_do_you_want_to_V2 : N -> V2 -> QCl;
|
||||
which_N_has_NP_V2 : N -> NP -> V2 -> QCl;
|
||||
which_N_are_AP_Adv : N -> AP -> Adv -> QCl;
|
||||
|
||||
is_the_N_AP : N -> AP -> QCl;
|
||||
is_the_N_AP_Adv : N -> AP -> Adv -> QCl;
|
||||
|
||||
which_N_are_Adv : N -> Adv -> QCl;
|
||||
which_N_are_Adv_Adv : N -> Adv -> Adv -> QCl;
|
||||
|
||||
is_the_N_Adv : N -> Adv -> QCl;
|
||||
is_the_N_Adv_Adv : N -> Adv -> Adv -> QCl;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- adverbials
|
||||
|
||||
Prep_NP : Prep -> NP -> Adv;
|
||||
in_NP : NP -> Adv;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- clauses, sentences, answers, propositions
|
||||
|
||||
useCl : (Cl ** ClauseForm) -> S;
|
||||
|
||||
--generic_VP,
|
||||
you_want_to_VP,
|
||||
you_are_VPing : VP -> Cl;
|
||||
you_VV_to_VP : VV -> VP -> Cl;
|
||||
it_is_NP_who_VP : NP -> (VP ** ClauseForm) -> Cl;
|
||||
NP_is_AP : NP -> AP -> Cl;
|
||||
NP_is_AP_Adv : NP -> AP -> Adv -> Cl;
|
||||
NP_is_Adv : NP -> Adv -> Cl;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- relative clauses
|
||||
|
||||
useRCl : (RCl ** ClauseForm) -> RS;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verb phrases, actions
|
||||
|
||||
use_V : V -> VP;
|
||||
V2_NP : V2 -> NP -> VP;
|
||||
V2_the_N : V2 -> N -> VP;
|
||||
V2_a_N : V2 -> N -> VP;
|
||||
VPing : (VP ** ClauseForm) -> VP;
|
||||
vp2Utt : VP -> Utt;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- general syntactical operations
|
||||
|
||||
disjunct_QCl : QCl -> QCl -> QCl;
|
||||
negate_Cl : Cl -> Cl;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verbs
|
||||
|
||||
see_V : V;
|
||||
|
||||
do_V2,
|
||||
have_V2,
|
||||
understand_V2 : V2;
|
||||
|
||||
know_VQ,
|
||||
wonder_VQ : VQ;
|
||||
|
||||
say_VS : VS;
|
||||
|
||||
fail_VV,
|
||||
like_VV : VV;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- nouns, proper nouns, common nouns and noun phrases
|
||||
|
||||
information_N : N;
|
||||
|
||||
you_NP : NP;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- closed word categories
|
||||
|
||||
of_på_Prep,
|
||||
for_Prep : Prep;
|
||||
|
||||
not_Predet : Predet;
|
||||
no_Quant : Quant;
|
||||
all_Quant : QuantPl;
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- language independent implementations
|
||||
----------------------------------------------------------------------
|
||||
|
||||
oper
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- different clause forms
|
||||
|
||||
ClauseForm = {clform : ClForm};
|
||||
clauseForm c = c;
|
||||
|
||||
hasDone = {clform = HasDone};
|
||||
isDoing = {clform = IsDoing};
|
||||
|
||||
anter c = case c.clform of {HasDone => AAnter; IsDoing => ASimul};
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- punctuation on system utterances
|
||||
|
||||
Punctuation = {punctuation : Punctn};
|
||||
fullStop = {punctuation = FullStop};
|
||||
questMark = {punctuation = QuestMark};
|
||||
|
||||
consText punct utt = let txt = PhrUtt NoPConj utt NoVoc in
|
||||
case punct.punctuation of
|
||||
{ FullStop => TFullStop txt; QuestMark => TQuestMark txt };
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- focus
|
||||
|
||||
emphasize = embed_NP "<emphasize>" "</emphasize>";
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- user utterances
|
||||
|
||||
UserAction,
|
||||
UserQuestion,
|
||||
UserAnswer,
|
||||
UserShortAns,
|
||||
UserProposition = SS;
|
||||
|
||||
askQS q = UttQS (UseQCl TPres ASimul PPos q);
|
||||
ansCl c = UttS (UseCl TPres ASimul PPos c);
|
||||
ansNP a = UttNP a;
|
||||
|
||||
reqVP vp =
|
||||
PhrUtt NoPConj
|
||||
(variants{ UttImpSg PPos (ImpVP vp);
|
||||
UttS (UseCl TPres ASimul PPos
|
||||
(PredVP (UsePron i_Pron) (ComplVV want_VV vp)));
|
||||
UttS (UseCl TCond ASimul PPos
|
||||
(PredVP (UsePron i_Pron) (ComplVV like_VV vp))) })
|
||||
(variants{ NoVoc; please_Voc });
|
||||
req1 act = req1x act [];
|
||||
req1x act = req2x act act;
|
||||
req2x imp inf extra = variants {
|
||||
ss ( variants { imp; i_want_to_Str ++ inf } ++ extra ++ optStr please_Str);
|
||||
ss ( variants { please_Str; userOkay.s } ++ imp ++ extra )};
|
||||
|
||||
use_QCl = askQS;
|
||||
use_Cl = ansCl;
|
||||
use_NP = ansNP;
|
||||
use_VP = reqVP;
|
||||
use_Adv = UttAdv;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- system utterances
|
||||
|
||||
cncUtt x y = mkUtt (x.s ++ y.s);
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- interrogative phrases
|
||||
|
||||
which_N_sg n = IDetCN whichSg_IDet NoNum NoOrd (UseN n);
|
||||
which_N_pl n = IDetCN whichPl_IDet NoNum NoOrd (UseN n);
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- noun phrases
|
||||
|
||||
the_CN_sg cn = DetCN (DetSg (SgQuant DefArt) NoOrd) cn;
|
||||
|
||||
the_N_sg n = the_CN_sg (UseN n);
|
||||
the_N_pl n = DetCN (DetPl (PlQuant DefArt) NoNum NoOrd) (UseN n);
|
||||
indef_N_sg n = DetCN (DetSg (SgQuant IndefArt) NoOrd) (UseN n);
|
||||
indef_N_pl n = DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) (UseN n);
|
||||
this_N_sg n = DetCN (DetSg (SgQuant this_Quant) NoOrd) (UseN n);
|
||||
these_N_pl n = DetCN (DetPl (PlQuant this_Quant) NoNum NoOrd) (UseN n);
|
||||
no_N_sg n = DetCN (DetSg (SgQuant no_Quant) NoOrd) (UseN n);
|
||||
no_N_pl n = DetCN (DetPl (PlQuant no_Quant) NoNum NoOrd) (UseN n);
|
||||
all_N_pl n = DetCN (DetPl all_Quant NoNum NoOrd) (UseN n);
|
||||
|
||||
the_A_super_N_sg a n = DetCN (DetSg (SgQuant DefArt) (OrdSuperl a)) (UseN n);
|
||||
indef_A_posit_N_sg a n = DetCN (DetSg (SgQuant IndefArt) NoOrd) (AdjCN (PositA a) (UseN n));
|
||||
no_A_posit_N_sg a n = DetCN (DetSg (SgQuant no_Quant) NoOrd) (AdjCN (PositA a) (UseN n));
|
||||
|
||||
NP_Adv = AdvNP;
|
||||
NP_Prep_NP prep np np' = AdvNP np (PrepNP prep np');
|
||||
|
||||
NP_in_NP = NP_Prep_NP in_Prep;
|
||||
NP_of_NP = NP_Prep_NP of_på_Prep;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- questions
|
||||
|
||||
useQCl q = UseQCl TPres (anter q) PPos q;
|
||||
|
||||
which_N_are_AP n ap = QuestVP (which_N_pl n) (UseComp (CompAP ap));
|
||||
which_N_is_AP n ap = QuestVP (which_N_sg n) (UseComp (CompAP ap));
|
||||
what_is_NP np = QuestVP whatSg_IP (UseComp (CompNP np));
|
||||
who_VP vp = QuestVP whoSg_IP vp;
|
||||
|
||||
which_N_do_you_want_to_V2 n v2 = QuestSlash (which_N_sg n) (SlashVVV2 you_NP want_VV v2);
|
||||
which_N_has_NP_V2 n np v2 = QuestSlash (which_N_pl n) (SlashV2 np v2);
|
||||
which_N_are_AP_Adv n ap adv= QuestVP (which_N_pl n) (AdvVP (UseComp (CompAP ap)) adv);
|
||||
|
||||
is_the_N_AP n ap = QuestCl (NP_is_AP (the_N_sg n) ap);
|
||||
is_the_N_AP_Adv n ap adv = QuestCl (NP_is_AP_Adv (the_N_sg n) ap adv);
|
||||
|
||||
which_N_are_Adv n a = QuestVP (which_N_pl n) (UseComp (CompAdv a));
|
||||
which_N_are_Adv_Adv n a aa = QuestVP (which_N_pl n) (AdvVP (UseComp (CompAdv a)) aa);
|
||||
|
||||
is_the_N_Adv n a = QuestCl (PredVP (the_N_sg n) (UseComp (CompAdv a)));
|
||||
is_the_N_Adv_Adv n a aa = QuestCl (PredVP (the_N_sg n) (AdvVP (UseComp (CompAdv a)) aa));
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- adverbials
|
||||
|
||||
Prep_NP = PrepNP;
|
||||
in_NP = PrepNP in_Prep;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- clauses, sentences, answers, propositions
|
||||
|
||||
useCl c = UseCl TPres (anter c) PPos c;
|
||||
|
||||
--generic_VP = GenericCl;
|
||||
you_want_to_VP vp = PredVP you_NP (ComplVV want_VV vp);
|
||||
you_are_VPing vp = PredVP you_NP (VPing (isDoing ** vp));
|
||||
you_VV_to_VP vv vp = PredVP you_NP (ComplVV vv vp);
|
||||
it_is_NP_who_VP np vp = CleftNP np (UseRCl TPres (anter vp) PPos (RelVP IdRP vp));
|
||||
NP_is_AP np ap = PredVP np (UseComp (CompAP ap));
|
||||
NP_is_AP_Adv np ap adv= PredVP np (AdvVP (UseComp (CompAP ap)) adv);
|
||||
NP_is_Adv np adv= PredVP np (UseComp (CompAdv adv));
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- relative clauses
|
||||
|
||||
useRCl r = UseRCl TPres (anter r) PPos r;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verb phrases, actions
|
||||
|
||||
use_V = UseV;
|
||||
V2_NP = ComplV2;
|
||||
V2_the_N v2 n = ComplV2 v2 (the_N_sg n);
|
||||
V2_a_N v2 n = ComplV2 v2 (indef_N_sg n);
|
||||
|
||||
}
|
||||
134
examples/godis-tram/Common/GodisLangEng.gf
Normal file
134
examples/godis-tram/Common/GodisLangEng.gf
Normal file
@@ -0,0 +1,134 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common:resource-1.0/english
|
||||
|
||||
instance GodisLangEng of GodisLang =
|
||||
open Prelude, PredefCnc, GrammarEng, ParadigmsEng, (ResEng=ResEng), ParamX, ConstructX,
|
||||
(Lex=LangEng), (Irreg=IrregEng) in {
|
||||
|
||||
oper
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- focus
|
||||
|
||||
embed_NP a b x = {s = \\c => a ++ (x.s ! c) ++ b; a = x.a; lock_NP = <>};
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- user utterances
|
||||
|
||||
userGreet = ss ["hello"];
|
||||
userQuit = ss (variants{ ["goodbye"]; ["quit"] });
|
||||
userNo = ss ["no"];
|
||||
userYes = ss ["yes"];
|
||||
userOkay = variants { ss ["okay"]; ss ["ok"] };
|
||||
|
||||
userCoordinate x y = ss (x.s ++ "and" ++ optStr "then" ++ y.s);
|
||||
|
||||
thank_you_Str = variants {["thank you"]; "great"; ["thanks"]};
|
||||
i_want_to_Str = variants{"i" ++ variants{"want"; ["would like"]} ++ "to";
|
||||
["can you"]};
|
||||
please_Str = "please";
|
||||
this_that_Str = variants{"this"; "that"};
|
||||
|
||||
not_user_prop p = ss ( not_Predet.s ++ p.s );
|
||||
not_user_short a = ss ( not_Predet.s ++ a.s );
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- system utterances
|
||||
|
||||
hello = mkUtt ["The mp3 player is ready to use"];
|
||||
goodbye = mkUtt ["Goodbye"];
|
||||
yes = mkUtt ["Yes"];
|
||||
no = mkUtt ["No"];
|
||||
|
||||
is_that_correct_Post = mkUtt [", is that correct"];
|
||||
returning_to_Pre = mkUtt ["Returning to"];
|
||||
returning_to_act_Pre = mkUtt ["Returning to"];
|
||||
returning_to_issue_Pre = mkUtt ["Returning to the issue of"];
|
||||
what_did_you_say = mkUtt ["What did you say"];
|
||||
what_do_you_mean = mkUtt ["What do you mean"];
|
||||
i_dont_understand = mkUtt ["Sorry, I don't quite understand"];
|
||||
cant_answer_que_Pre = mkUtt ["Sorry, I can't answer questions about"];
|
||||
not_valid_Post = mkUtt ["is not a valid option"];
|
||||
|
||||
icm_acc_pos = variants { mkUtt ["Okay"]; mkUtt thank_you_Str };
|
||||
icm_con_neg = mkUtt ["Hello?"];
|
||||
icm_reraise = mkUtt ["So, "];
|
||||
icm_loadplan = mkUtt ["Let's see"];
|
||||
icm_accommodate = mkUtt ["Alright "];
|
||||
|
||||
icm_per_pos x = mkUtt (["I thought you said"] ++ x.s);
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- noun phrases
|
||||
|
||||
sing_NP s = ResEng.regNP s Sg ** {lock_NP = <>};
|
||||
plur_NP s = ResEng.regNP s Pl ** {lock_NP = <>};
|
||||
|
||||
NPgen_NP = NP_of_NP;
|
||||
|
||||
NP_Cl np = {s = \\t,a,b,o => np.s ! ResEng.Nom; lock_Cl = <>};
|
||||
|
||||
prefix_N n = compoundN (UttNP (DetCN (DetSg MassDet NoOrd) (UseN n))).s;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verb phrases, actions
|
||||
|
||||
VPing vp = case vp.clform of {HasDone => vp; IsDoing => ProgrVP vp};
|
||||
vp2Utt vp = mkUtt (ResEng.infVP True vp (ResEng.agrP3 Sg));
|
||||
-- vp2Utt vp = mkUtt (vp.s2 ! (ResEng.agrP3 Sg));i_want_to_Str ++
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- general syntactical operations
|
||||
|
||||
disjunct_QCl q q' =
|
||||
{s = \\t,a,p,x => q.s!t!a!p!x ++ "or" ++ q'.s!t!a!p!x;
|
||||
lock_QCl = <>};
|
||||
|
||||
negate_Cl c =
|
||||
{s = \\t,a,p,o => c.s!t!a!(case p of {ResEng.CNeg _ => ResEng.CPos; ResEng.CPos => ResEng.CNeg Prelude.True})!o;
|
||||
lock_Cl = <>};
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verbs
|
||||
|
||||
see_V = Irreg.see_V;
|
||||
|
||||
do_V2 = Lex.do_V2;
|
||||
have_V2 = Lex.have_V2;
|
||||
understand_V2 = Lex.understand_V2;
|
||||
|
||||
know_VQ = mkVQ Irreg.know_V;
|
||||
wonder_VQ = Lex.wonder_VQ;
|
||||
|
||||
say_VS = Lex.say_VS;
|
||||
|
||||
fail_VV = mkVV (regV "fail");
|
||||
like_VV = mkVV (regV "like");
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- nouns, proper nouns, common nouns and noun phrases
|
||||
|
||||
information_N = regN "information";
|
||||
|
||||
you_NP = UsePron Lex.youSg_Pron;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- closed word categories
|
||||
|
||||
of_på_Prep = mkPrep "of";
|
||||
for_Prep = mkPrep "for";
|
||||
|
||||
not_Predet = ss "not" ** {lock_Predet = <>};
|
||||
|
||||
no_Quant = {s = \\_ => "no"; lock_Quant = <>};
|
||||
all_Quant = {s = "all"; lock_QuantPl = <>};
|
||||
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
i_dont_want_to = variants { ["i do not want to"];
|
||||
["i don't want to"] };
|
||||
|
||||
}
|
||||
154
examples/godis-tram/Common/GodisLangFin.gf
Normal file
154
examples/godis-tram/Common/GodisLangFin.gf
Normal file
@@ -0,0 +1,154 @@
|
||||
--# -path=.:prelude:alltenses
|
||||
|
||||
instance GodisLangFin of GodisLang =
|
||||
open Prelude, PredefCnc, GrammarFin,
|
||||
ParadigmsFin, (ResFin=ResFin), ParamX, ConstructX,
|
||||
(Lex=LangFin) in {
|
||||
|
||||
--flags optimize = noexpand ;
|
||||
|
||||
oper
|
||||
|
||||
TODO : (a : Type) -> a = Predef.error "TODO" ;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- focus
|
||||
|
||||
embed_NP a b x = TODO NP ;
|
||||
----{s = \\c => a ++ (x.s ! c) ++ b; a = x.a; lock_NP = <>};
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- user utterances
|
||||
|
||||
userGreet = ss ["hei"];
|
||||
userQuit = ss (variants{ ["näkemiin"]; ["lopetetaan"] });
|
||||
userNo = ss ["ei"];
|
||||
userYes = ss ["kyllä"];
|
||||
userOkay = variants { ss ["okei"]; ss ["selvä"] };
|
||||
|
||||
userCoordinate x y = ss (x.s ++ "ja" ++ optStr "sitten" ++ y.s);
|
||||
|
||||
thank_you_Str = variants {"kiitos"; "loistavaa"; "kiitti"};
|
||||
i_want_to_Str = variants {"haluan"; "haluaisin"} ;
|
||||
|
||||
please_Str = ["ole hyvä"] ;
|
||||
this_that_Str = variants{"tämä"; "tuo"};
|
||||
|
||||
not_user_prop p = ss ( Predef.toStr Predet not_Predet ++ p.s );
|
||||
not_user_short a = ss ( Predef.toStr Predet not_Predet ++ a.s );
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- system utterances
|
||||
|
||||
hello = mkUtt ["Valmis"];
|
||||
goodbye = mkUtt ["Näkemiin"];
|
||||
yes = mkUtt ["Kyllä"];
|
||||
no = mkUtt ["Ei"];
|
||||
|
||||
is_that_correct_Post = mkUtt [", pitääkö paikkansa"];
|
||||
returning_to_Pre = mkUtt ["Takaisin kohtaan"];
|
||||
returning_to_act_Pre = mkUtt ["Takaisin kohtaan"];
|
||||
returning_to_issue_Pre = mkUtt ["Takaisin aiheeseen"];
|
||||
what_did_you_say = mkUtt ["Mitä sanoit"];
|
||||
what_do_you_mean = mkUtt ["Mitä tarkoitat"];
|
||||
i_dont_understand = mkUtt ["Anteeksi, en ymmärrä"];
|
||||
cant_answer_que_Pre = mkUtt ["Anteeksi, en tiedä mitään aiheesta"];
|
||||
not_valid_Post = mkUtt ["ei ole mahdollinen vaihtoehto"];
|
||||
|
||||
icm_acc_pos = variants { mkUtt ["Okei"]; mkUtt thank_you_Str };
|
||||
icm_con_neg = mkUtt ["No?"];
|
||||
icm_reraise = mkUtt ["No niin, "];
|
||||
icm_loadplan = mkUtt ["Katsotaan"];
|
||||
icm_accommodate = mkUtt ["Selvä"];
|
||||
|
||||
icm_per_pos x = mkUtt (["Luulin että sanoit että"] ++ x.s);
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- noun phrases
|
||||
|
||||
sing_NP s = mkNP (nLinux s) singular ; ----
|
||||
plur_NP s = mkNP (nLinux s) plural ;
|
||||
|
||||
NPgen_NP np1 np2 = AdvNP np2 (PrepNP possess_Prep np1) ; ----
|
||||
|
||||
NP_Cl np = TODO Cl ;
|
||||
|
||||
prefix_N n1 n2 = n2 ; ----
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verb phrases, actions
|
||||
|
||||
VPing vp = case vp.clform of {
|
||||
HasDone => vp;
|
||||
IsDoing => ProgrVP vp
|
||||
};
|
||||
|
||||
vp2Utt vp = UttVP vp ;
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- general syntactical operations
|
||||
|
||||
disjunct_QCl q q' =
|
||||
{s = \\t,a,p => q.s!t!a!p ++ "vai" ++ q'.s!t!a!p;
|
||||
lock_QCl = <>};
|
||||
|
||||
negate_Cl c =
|
||||
{s = \\t,a,p,o => c.s!t!a!(case p of {
|
||||
Neg => Pos;
|
||||
Pos => Neg
|
||||
})!o;
|
||||
lock_Cl = <>};
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verbs
|
||||
|
||||
see_V = Lex.see_V2 ** {lock_V = <>}; ----
|
||||
|
||||
do_V2 = Lex.do_V2;
|
||||
have_V2 = Lex.have_V2;
|
||||
understand_V2 = Lex.understand_V2;
|
||||
|
||||
know_VQ = mkVQ (reg2V "tietää" "tiesi") ;
|
||||
wonder_VQ = Lex.wonder_VQ;
|
||||
|
||||
say_VS = Lex.say_VS;
|
||||
|
||||
fail_VV = mkVV (regV "epäonnistua");
|
||||
like_VV = mkVV (regV "haluta"); ----
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- nouns, proper nouns, common nouns and noun phrases
|
||||
|
||||
information_N = regN "informaatio";
|
||||
|
||||
you_NP = UsePron Lex.youSg_Pron;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- closed word categories
|
||||
|
||||
of_på_Prep = casePrep genitive ;
|
||||
for_Prep = casePrep allative ;
|
||||
|
||||
not_Predet = {s = \\n,c => "ei" ; lock_Predet = <>} ; ----
|
||||
|
||||
no_Quant = TODO Quant ;
|
||||
all_Quant = TODO QuantPl ;
|
||||
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
i_dont_want_to = variants { ["en halua"];
|
||||
["en tahdo"] };
|
||||
|
||||
-- Finnish-specific
|
||||
|
||||
-- local cases in free variation
|
||||
|
||||
in_Case : Case = variants {adessive ; inessive} ;
|
||||
to_Case : Case = variants {allative ; illative} ;
|
||||
from_Case : Case = variants {ablative ; elative} ;
|
||||
|
||||
}
|
||||
150
examples/godis-tram/Common/GodisLangSwe.gf
Normal file
150
examples/godis-tram/Common/GodisLangSwe.gf
Normal file
@@ -0,0 +1,150 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common:resource-1.0/scandinavian:resource-1.0/swedish
|
||||
|
||||
instance GodisLangSwe of GodisLang =
|
||||
open Prelude, PredefCnc, GrammarSwe, ParadigmsSwe, ConstructX,
|
||||
MorphoSwe, CommonScand, (Lex=LexiconSwe), (Irreg=IrregSwe) in {
|
||||
|
||||
oper
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- focus
|
||||
|
||||
embed_NP a b x = {s = \\c => a ++ (x.s ! c) ++ b; a = x.a; lock_NP = <>};
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- user utterances
|
||||
|
||||
userGreet = ss ["hej"];
|
||||
userQuit = ss ["hejdå"];
|
||||
userNo = ss ["nej"];
|
||||
userYes = ss ["ja"];
|
||||
userOkay = variants { ss ["okej"]; ss ["ok"]; ss ["okay"] };
|
||||
|
||||
userCoordinate x y = ss (x.s ++ "och" ++ optStr "sedan" ++ y.s);
|
||||
|
||||
thank_you_Str = variants{ "schysst"; "tack"; userOkay.s };
|
||||
i_want_to_Str = variants{ "jag" ++ variants{ "vill"; ["skulle vilja"] };
|
||||
["kan du"] };
|
||||
please_Str = "tack";
|
||||
this_that_Str = variants{ variants{"den";"det"} ++ optStr "här";
|
||||
"denna"; "detta" };
|
||||
|
||||
not_user_prop p = ss ( "inte" ++ p.s );
|
||||
not_user_short a = ss ( "inte" ++ a.s );
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- system utterances
|
||||
|
||||
hello = mkUtt ["MP3 spelaren är redo"];
|
||||
goodbye = mkUtt ["Hejdå"];
|
||||
yes = mkUtt ["Ja"];
|
||||
no = mkUtt ["Nej"];
|
||||
|
||||
is_that_correct_Post = mkUtt [", är det korrekt"];
|
||||
returning_to_Pre = mkUtt ["Återgår till"];
|
||||
returning_to_act_Pre = mkUtt ["Återgår till att"];
|
||||
returning_to_issue_Pre = mkUtt ["Återgår till frågan om"];
|
||||
what_did_you_say = mkUtt ["Vad sa du"];
|
||||
what_do_you_mean = mkUtt ["Vad menar du"];
|
||||
i_dont_understand = mkUtt ["Jag förstår inte riktigt"];
|
||||
cant_answer_que_Pre = mkUtt ["Ledsen , jag kan inte svara på frågor om"];
|
||||
not_valid_Post = mkUtt ["går inte att välja"];
|
||||
|
||||
icm_acc_pos = mkUtt thank_you_Str;
|
||||
icm_con_neg = mkUtt ["Hallå?"];
|
||||
icm_reraise = mkUtt ["Så ,"];
|
||||
icm_loadplan = mkUtt ["Få se"];
|
||||
icm_accommodate = mkUtt ["Visst"];
|
||||
|
||||
icm_per_pos x = mkUtt (["Jag tyckte du sa"] ++ x.s);
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- noun phrases
|
||||
|
||||
sing_NP s = regNP s (s+"s") SgUtr ** {lock_NP = <>};
|
||||
plur_NP s = regNP s (s+"s") Plg ** {lock_NP = <>};
|
||||
|
||||
NPgen_NP = NP_of_NP;
|
||||
|
||||
NP_Cl np = {s = \\t,a,b,o => np.s ! nominative; lock_Cl = <>};
|
||||
|
||||
prefix_N n1 n2 = {s = \\n,s,c => n1.s!Sg!Indef!Gen ++ n2.s!n!s!c;
|
||||
g = n2.g;
|
||||
lock_N = <>};
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- actions/verb phrases
|
||||
|
||||
VPing act = act;
|
||||
vp2Utt vp = mkUtt (infVP vp (agrP3 utrum Sg));
|
||||
-- UttVP vp;
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- general syntactical operations
|
||||
|
||||
disjunct_QCl q q' =
|
||||
{s = \\t,a,p,x => q.s!t!a!p!x ++ "eller" ++ q'.s!t!a!p!x;
|
||||
lock_QCl = <>};
|
||||
|
||||
negate_Cl c =
|
||||
{s = \\t,a,p,o => c.s!t!a!(case p of {Neg=>Pos; Pos=>Neg})!o;
|
||||
lock_Cl = <>};
|
||||
|
||||
-- disjunct_Utt u u' = ss (u.s ++ "eller" ++ u'.s);
|
||||
-- disjunct_VP vp vp' =
|
||||
-- insertObj (\\agr => "eller" ++ (ImpVP vp').s!Pos!(agr.gn)) vp;
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- verbs
|
||||
|
||||
see_V = Irreg.se_V;
|
||||
|
||||
do_V2 = Lex.do_V2;
|
||||
have_V2 = Lex.have_V2;
|
||||
understand_V2 = Lex.understand_V2;
|
||||
|
||||
know_VQ = mkVQ Irreg.veta_V;
|
||||
wonder_VQ = Lex.wonder_VQ;
|
||||
|
||||
say_VS = Lex.say_VS;
|
||||
|
||||
fail_VV = mkVV (mkV "misslyckas" "misslyckas" "misslyckas" "misslyckades" "misslyckats" "misslyckad");
|
||||
like_VV = want_VV;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- nouns, proper nouns, common nouns and noun phrases
|
||||
|
||||
information_N = mk2N "information" "informationer";
|
||||
|
||||
you_NP = UsePron youSg_Pron;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- closed word categories
|
||||
|
||||
of_på_Prep = mkPrep "på";
|
||||
for_Prep = mkPrep "för";
|
||||
|
||||
not_Predet = {s = \\_ => "inte"; lock_Predet = <>};
|
||||
|
||||
no_Quant = {s = table {Sg => \\_ => table {Utr => "ingen";
|
||||
Neutr => "inget"};
|
||||
Pl => \\_,_ => "inga"};
|
||||
det = DIndef;
|
||||
lock_Quant = <>};
|
||||
|
||||
all_Quant = {s = \\_,_ => "alla";
|
||||
det = DIndef;
|
||||
lock_QuantPl = <>};
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
i_dont_want_to = ["jag vill inte"];
|
||||
|
||||
}
|
||||
135
examples/godis-tram/Common/GodisSystem.gf
Normal file
135
examples/godis-tram/Common/GodisSystem.gf
Normal file
@@ -0,0 +1,135 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
abstract GodisSystem = PredefAbs ** {
|
||||
|
||||
cat
|
||||
|
||||
-- Participant;
|
||||
|
||||
Move;
|
||||
[Move]{1};
|
||||
S;
|
||||
|
||||
ShortAns;
|
||||
|
||||
Proposition;
|
||||
|
||||
-- NOTE: Question means only WhQ
|
||||
-- this division is for Multimodality to work
|
||||
Question;
|
||||
YNQ; AltQ;
|
||||
[Proposition]{2};
|
||||
|
||||
-- special kind of proposition best linearized as a VP,
|
||||
-- only used in Y/N and Alt questions starting with "do you want to ..."
|
||||
-- this is for VP aggregation to work
|
||||
VPProposition; -- issue(X^p(X)) and action(a)
|
||||
[VPProposition]{2};
|
||||
|
||||
Action;
|
||||
Reason;
|
||||
|
||||
|
||||
fun
|
||||
|
||||
-- usr, sys : Participant;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- forming Questions
|
||||
|
||||
action_Q,
|
||||
issue_Q : Question;
|
||||
|
||||
ynq : Proposition -> YNQ;
|
||||
altq : [Proposition] -> AltQ;
|
||||
-- BaseProposition : Proposition -> Proposition -> [Proposition];
|
||||
-- ConsProposition : Proposition -> [Proposition] -> [Proposition];
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- forming Propositions
|
||||
|
||||
not : Proposition -> Proposition;
|
||||
-- done : Action -> Proposition;
|
||||
fail : Question -> Reason -> Proposition;
|
||||
-- und : Participant -> Proposition -> Proposition;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- forming VPPropositions, and associated questions
|
||||
|
||||
action : Action -> VPProposition;
|
||||
issue : Question -> VPProposition;
|
||||
|
||||
vp_ynq : VPProposition -> YNQ;
|
||||
vp_altq : [VPProposition] -> AltQ;
|
||||
-- BaseVPProposition : VPProposition -> VPProposition -> [VPProposition];
|
||||
-- ConsVPProposition : VPProposition -> [VPProposition] -> [VPProposition];
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- short answers
|
||||
|
||||
notS : ShortAns -> ShortAns;
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- dialogue moves
|
||||
|
||||
answer_yes,
|
||||
answer_no : Move;
|
||||
|
||||
greet,
|
||||
quit : Move;
|
||||
ask : Question -> Move;
|
||||
askYNQ : YNQ -> Move;
|
||||
askAltQ : AltQ -> Move;
|
||||
answer : Proposition -> Move;
|
||||
answerVP : VPProposition -> Move;
|
||||
shortAns : ShortAns -> Move;
|
||||
|
||||
request,
|
||||
confirm : Action -> Move;
|
||||
reportFailure : Action -> Reason -> Move;
|
||||
|
||||
answerFailure : Question -> Reason -> Move;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- ICM
|
||||
|
||||
icm_acc_pos,
|
||||
icm_con_neg,
|
||||
icm_per_neg,
|
||||
icm_per_int,
|
||||
icm_sem_neg,
|
||||
icm_sem_int,
|
||||
icm_und_neg,
|
||||
icm_reraise,
|
||||
icm_loadplan,
|
||||
icm_accommodate : Move;
|
||||
|
||||
icm_per_pos : String -> Move;
|
||||
icm_und_int_prop,
|
||||
icm_und_pos_prop,
|
||||
icm_acc_neg_prop : Proposition -> Move;
|
||||
icm_acc_neg_que : Question -> Move;
|
||||
icm_sem_pos_move : Move -> Move;
|
||||
icm_sem_pos_shortAns : ShortAns -> Move;
|
||||
icm_und_pos_vp,
|
||||
icm_und_int_vp : {- Participant -> -} VPProposition -> Move;
|
||||
icm_reraise_act : Action -> Move;
|
||||
|
||||
icm_reraise_whq,
|
||||
icm_accommodate_whq,
|
||||
icm_reaccommodate_whq : Question -> Move;
|
||||
icm_reraise_ynq,
|
||||
icm_accommodate_ynq,
|
||||
icm_reaccommodate_ynq : YNQ -> Move;
|
||||
icm_und_int_altq,
|
||||
icm_reraise_altq,
|
||||
icm_accommodate_altq,
|
||||
icm_reaccommodate_altq: AltQ -> Move;
|
||||
|
||||
-- BaseMove : Move -> [Move];
|
||||
-- ConsMove : Move -> [Move] -> [Move];
|
||||
|
||||
godis_utterance : [Move] -> S;
|
||||
|
||||
}
|
||||
4
examples/godis-tram/Common/GodisSystemEng.gf
Normal file
4
examples/godis-tram/Common/GodisSystemEng.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common:resource-1.0/english
|
||||
|
||||
concrete GodisSystemEng of GodisSystem = GodisSystemI with
|
||||
(Grammar=GrammarEng), (Extra=ExtraEng), (GodisLang=GodisLangEng);
|
||||
4
examples/godis-tram/Common/GodisSystemFin.gf
Normal file
4
examples/godis-tram/Common/GodisSystemFin.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
--# -path=.:prelude:alltenses
|
||||
|
||||
concrete GodisSystemFin of GodisSystem = GodisSystemI with
|
||||
(Grammar=GrammarFin), (Extra=ExtraFin), (GodisLang=GodisLangFin);
|
||||
152
examples/godis-tram/Common/GodisSystemI.gf
Normal file
152
examples/godis-tram/Common/GodisSystemI.gf
Normal file
@@ -0,0 +1,152 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common
|
||||
|
||||
incomplete concrete GodisSystemI of GodisSystem = PredefCnc **
|
||||
open Prelude, Grammar, Extra, GodisLang, ConstructX, ParamX in {
|
||||
|
||||
lincat
|
||||
|
||||
Move = Utt ** Punctuation;
|
||||
[Move],
|
||||
S = Text;
|
||||
|
||||
ShortAns = NP;
|
||||
|
||||
Proposition = Cl ** ClauseForm;
|
||||
[Proposition],
|
||||
Question,
|
||||
YNQ, AltQ = QCl ** ClauseForm;
|
||||
|
||||
VPProposition = VP;
|
||||
[VPProposition] = [VPI];
|
||||
|
||||
Action = VP ** ClauseForm;
|
||||
|
||||
Reason = S;
|
||||
|
||||
lin
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- questions
|
||||
|
||||
action_Q = isDoing **
|
||||
QuestSlash whatSg_IP (AdvSlash (SlashVVV2 (UsePron i_Pron) can_VV do_V2)
|
||||
(PrepNP for_Prep you_NP));
|
||||
issue_Q = isDoing **
|
||||
QuestCl (PredVP you_NP (ComplVV want_VV
|
||||
(ComplV2 have_V2 (DetCN someSg_Det (UseN information_N)))));
|
||||
|
||||
ynq p = clauseForm p ** QuestCl p;
|
||||
altq qs = qs;
|
||||
BaseProposition p q = clauseForm p ** disjunct_QCl (QuestCl p) (QuestCl q);
|
||||
ConsProposition p qs = clauseForm p ** disjunct_QCl (QuestCl p) qs;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- propositions
|
||||
|
||||
not p = p ** negate_Cl p;
|
||||
-- done a = clauseForm a ** PredVP (UsePron i_Pron) (VPing a);
|
||||
{-
|
||||
fail q r = hasDone **
|
||||
negate_Cl (PredVP (UsePron i_Pron)
|
||||
(AdvVP (ComplVQ know_VQ (UseQCl TPres (anter q) PPos q))
|
||||
(SubjS because_Subj r)));
|
||||
-}
|
||||
----------------------------------------------------------------------
|
||||
-- vp-propositions
|
||||
|
||||
action a = a;
|
||||
{-
|
||||
issue q = ComplVQ know_VQ (useQCl q);
|
||||
-}
|
||||
|
||||
vp_ynq p = isDoing ** QuestCl (PredVP you_NP (ComplVV want_VV p));
|
||||
vp_altq qs = isDoing ** QuestCl (PredVP you_NP (ComplVPIVV want_VV (ConjVPI or_Conj qs)));
|
||||
|
||||
|
||||
BaseVPProposition p q = BaseVPI (MkVPI p) (MkVPI q);
|
||||
ConsVPProposition p qs = ConsVPI (MkVPI p) qs;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- short answers
|
||||
|
||||
notS a = PredetNP not_Predet a;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- dialogue moves
|
||||
|
||||
answer_yes = fullStop ** yes;
|
||||
answer_no = fullStop ** no;
|
||||
|
||||
greet = fullStop ** hello;
|
||||
quit = fullStop ** goodbye;
|
||||
shortAns a = fullStop ** UttNP a;
|
||||
request a = fullStop ** UttImpSg PPos (ImpVP a);
|
||||
|
||||
ask q = questMark ** UttQS (useQCl q);
|
||||
askYNQ q = questMark ** UttQS (useQCl q);
|
||||
askAltQ q = questMark ** UttQS (useQCl q);
|
||||
|
||||
answer p = fullStop ** UttS (useCl p);
|
||||
answerVP p = fullStop ** vp2Utt p;
|
||||
|
||||
confirm a = fullStop ** UttS (useCl (clauseForm a ** PredVP (UsePron i_Pron) (VPing a)));
|
||||
|
||||
reportFailure a r = fullStop **
|
||||
UttS (UseCl TPast ASimul PPos
|
||||
(PredVP (UsePron i_Pron)
|
||||
(AdvVP (ComplVV fail_VV a) (SubjS because_Subj r))));
|
||||
|
||||
answerFailure q r = fullStop ** UttS r;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- ICM
|
||||
|
||||
icm_acc_pos = fullStop ** icm_acc_pos;
|
||||
icm_con_neg = fullStop ** icm_con_neg;
|
||||
icm_per_neg = fullStop **
|
||||
UttQS (UseQCl TPast ASimul PPos (QuestSlash whatSg_IP
|
||||
(SlashV2 you_NP (UseVS say_VS))));
|
||||
icm_per_int = questMark ** what_did_you_say;
|
||||
icm_sem_neg = fullStop ** i_dont_understand;
|
||||
icm_sem_int = questMark ** what_do_you_mean;
|
||||
icm_und_neg = fullStop ** i_dont_understand;
|
||||
|
||||
icm_reraise = fullStop ** icm_reraise;
|
||||
icm_loadplan = fullStop ** icm_loadplan;
|
||||
icm_accommodate = fullStop ** icm_accommodate;
|
||||
|
||||
icm_per_pos x = fullStop ** icm_per_pos x;
|
||||
icm_und_int_prop p = questMark ** (UttS (useCl p));
|
||||
icm_und_pos_prop p = questMark ** (UttS (useCl p));
|
||||
icm_acc_neg_prop p = fullStop ** cncUtt (UttS (useCl p)) not_valid_Post;
|
||||
icm_acc_neg_que q = fullStop **
|
||||
cncUtt cant_answer_que_Pre (UttAdv (AdvSC (EmbedQS (useQCl q))));
|
||||
icm_sem_pos_move m = fullStop ** m;
|
||||
icm_sem_pos_shortAns a = fullStop ** UttNP a;
|
||||
icm_und_pos_vp p = questMark ** (UttS (useCl (you_want_to_VP p ** isDoing)));
|
||||
icm_und_int_vp p = questMark ** cncUtt (UttS (useCl (you_want_to_VP p ** isDoing))) is_that_correct_Post;
|
||||
icm_reraise_act a = fullStop **
|
||||
cncUtt returning_to_act_Pre (vp2Utt a); -- (VPing a));
|
||||
|
||||
icm_und_int_altq q = questMark ** UttAdv (AdvSC (EmbedQS (useQCl q)));
|
||||
icm_reraise_whq q = fullStop ** requestion q returning_to_Pre;
|
||||
icm_reraise_ynq q = fullStop ** requestion q returning_to_Pre;
|
||||
icm_reraise_altq q = fullStop ** requestion q returning_to_issue_Pre;
|
||||
icm_accommodate_whq q = questMark ** icm_accommodate;
|
||||
icm_accommodate_ynq q = questMark ** icm_accommodate;
|
||||
icm_accommodate_altq q = questMark ** icm_accommodate;
|
||||
icm_reaccommodate_whq q = questMark ** requestion q returning_to_issue_Pre;
|
||||
icm_reaccommodate_ynq q = questMark ** requestion q returning_to_issue_Pre;
|
||||
icm_reaccommodate_altq q = questMark ** requestion q returning_to_issue_Pre;
|
||||
|
||||
oper requestion : (QCl ** ClauseForm) -> Utt -> Utt
|
||||
= \q,s -> cncUtt s (UttAdv (AdvSC (EmbedQS (useQCl q))));
|
||||
|
||||
lin
|
||||
|
||||
BaseMove m = consText m m TEmpty;
|
||||
ConsMove m = consText m m;
|
||||
|
||||
godis_utterance x = x;
|
||||
|
||||
}
|
||||
134
examples/godis-tram/Common/GodisSystemSem.gf
Normal file
134
examples/godis-tram/Common/GodisSystemSem.gf
Normal file
@@ -0,0 +1,134 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete GodisSystemSem of GodisSystem = PredefCnc ** open Prolog in {
|
||||
|
||||
lincat
|
||||
|
||||
Move,
|
||||
[Move],
|
||||
S,
|
||||
ShortAns,
|
||||
Proposition,
|
||||
Question,
|
||||
YNQ, AltQ,
|
||||
[Proposition],
|
||||
VPProposition,
|
||||
[VPProposition],
|
||||
Action,
|
||||
Reason = PStr;
|
||||
|
||||
|
||||
lin
|
||||
|
||||
-- usr = ss "usr";
|
||||
-- sys = ss "sys";
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- questions
|
||||
|
||||
action_Q = pWhQ "action";
|
||||
issue_Q = pWhQ "issue";
|
||||
|
||||
ynq q = q;
|
||||
altq qs = pp1 "set" (pBrackets qs);
|
||||
BaseProposition = pSeq;
|
||||
ConsProposition = pSeq;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- propositions
|
||||
|
||||
not = pp1 "not";
|
||||
-- done = pp1 "done";
|
||||
fail = pp2 "fail";
|
||||
-- und = pp2 "und";
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- vp-propositions
|
||||
|
||||
action = pp1 "action";
|
||||
issue = pp1 "issue";
|
||||
|
||||
vp_ynq p = p;
|
||||
vp_altq qs = pp1 "set" (pBrackets qs);
|
||||
BaseVPProposition = pSeq;
|
||||
ConsVPProposition = pSeq;
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- short answers
|
||||
|
||||
notS = pp1 "not";
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- dialogue moves
|
||||
|
||||
answer_yes = pp1 "answer" (pp0 "yes");
|
||||
answer_no = pp1 "answer" (pp0 "no");
|
||||
|
||||
greet = pp0 "greet";
|
||||
quit = pp0 "quit";
|
||||
ask = pp1 "ask";
|
||||
askYNQ = pp1 "ask";
|
||||
askAltQ = pp1 "ask";
|
||||
answer = pp1 "answer";
|
||||
answerVP = pp1 "answer";
|
||||
shortAns = pp1 "answer";
|
||||
|
||||
request = pp1 "request";
|
||||
confirm a = variants{ pp1 "confirm" a;
|
||||
pp2 "report" a (pp0 "done") };
|
||||
reportFailure a r = pp2 "report" a (pp1 "failed" r);
|
||||
|
||||
answerFailure q r = pp1 "answer" (pp2 "fail" q r);
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- ICM
|
||||
|
||||
icm_acc_pos = icmFeedback0 "acc" "pos";
|
||||
icm_con_neg = icmFeedback0 "con" "neg";
|
||||
icm_per_neg = icmFeedback0 "per" "neg";
|
||||
icm_per_int = icmFeedback0 "per" "int";
|
||||
icm_sem_neg = icmFeedback0 "sem" "neg";
|
||||
icm_sem_int = icmFeedback0 "sem" "int";
|
||||
icm_und_neg = icmFeedback0 "und" "neg";
|
||||
icm_reraise = icmSingle0 "reraise";
|
||||
icm_loadplan = icmSingle0 "loadplan";
|
||||
icm_accommodate = icmSingle0 "accomodate";
|
||||
|
||||
icm_per_pos = icmFeedback1 "per" "pos";
|
||||
icm_und_int_prop p = icmFeedback1 "und" "int" (pOper "*" (pp0 "usr") p);
|
||||
icm_und_pos_prop p = icmFeedback1 "und" "pos" (pOper "*" (pp0 "usr") p);
|
||||
icm_acc_neg_prop = icmFeedback1 "acc" "neg";
|
||||
icm_acc_neg_que q = icmFeedback1 "acc" "neg" (pp1 "issue" q);
|
||||
icm_sem_pos_move = icmFeedback1 "sem" "pos";
|
||||
icm_sem_pos_shortAns = icmFeedback1 "sem" "pos";
|
||||
icm_und_pos_vp p = icmFeedback1 "und" "pos" (pOper "*" (pp0 "usr") p);
|
||||
icm_und_int_vp p = icmFeedback1 "und" "int" (pOper "*" (pp0 "usr") p);
|
||||
icm_reraise_act = icmSingle1 "reraise";
|
||||
|
||||
icm_und_int_altq q = icmFeedback1 "und" "int"(pOper "*" (pp0 "usr") q);
|
||||
icm_reraise_whq = icmSingle1 "reraise";
|
||||
icm_reraise_ynq = icmSingle1 "reraise";
|
||||
icm_reraise_altq = icmSingle1 "reraise";
|
||||
icm_accommodate_whq = icmSingle1 "accomodate";
|
||||
icm_accommodate_ynq = icmSingle1 "accomodate";
|
||||
icm_accommodate_altq = icmSingle1 "accomodate";
|
||||
icm_reaccommodate_whq = icmSingle1 "reaccomodate";
|
||||
icm_reaccommodate_ynq = icmSingle1 "reaccomodate";
|
||||
icm_reaccommodate_altq = icmSingle1 "reaccomodate";
|
||||
|
||||
BaseMove m = m;
|
||||
ConsMove m = pSeq m;
|
||||
|
||||
godis_utterance = pBrackets;
|
||||
|
||||
|
||||
oper
|
||||
|
||||
icmSingle0 : Str -> PStr = \icm -> pStr ("icm" ++ ":" ++ icm);
|
||||
icmSingle1 : Str -> PPStr = \icm -> pOper ":" (icmSingle0 icm);
|
||||
|
||||
icmFeedback0 : Str -> Str -> PStr = \lvl,pol -> icmSingle0 (lvl ++ "*" ++ pol);
|
||||
icmFeedback1 : Str -> Str -> PPStr = \lvl,pol -> icmSingle1 (lvl ++ "*" ++ pol);
|
||||
|
||||
|
||||
}
|
||||
4
examples/godis-tram/Common/GodisSystemSwe.gf
Normal file
4
examples/godis-tram/Common/GodisSystemSwe.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common:resource-1.0/scandinavian:resource-1.0/swedish
|
||||
|
||||
concrete GodisSystemSwe of GodisSystem = GodisSystemI with
|
||||
(Grammar=GrammarSwe), (Extra=ExtraSwe), (GodisLang=GodisLangSwe);
|
||||
33
examples/godis-tram/Common/GodisUser.gf
Normal file
33
examples/godis-tram/Common/GodisUser.gf
Normal file
@@ -0,0 +1,33 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
abstract GodisUser = {
|
||||
|
||||
cat
|
||||
|
||||
S;
|
||||
Question;
|
||||
Action;
|
||||
Answer;
|
||||
ShortAns;
|
||||
Proposition;
|
||||
|
||||
|
||||
fun
|
||||
|
||||
greet_S,
|
||||
quit_S : S;
|
||||
|
||||
no_S,
|
||||
yes_S : Answer;
|
||||
|
||||
request_S : Action -> S;
|
||||
answer_S : Answer -> S;
|
||||
ask_S : Question -> S;
|
||||
|
||||
shortans_S,
|
||||
not_shortans_S : ShortAns -> S;
|
||||
not_prop_S : Proposition -> S;
|
||||
|
||||
request_request_S : Action -> Action -> S;
|
||||
|
||||
}
|
||||
32
examples/godis-tram/Common/GodisUserEng.gf
Normal file
32
examples/godis-tram/Common/GodisUserEng.gf
Normal file
@@ -0,0 +1,32 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common:resource-1.0/english
|
||||
|
||||
concrete GodisUserEng of GodisUser =
|
||||
GodisUserI with (GodisLang = GodisLangEng);
|
||||
|
||||
|
||||
-- open Prelude, GodisLangEng in {
|
||||
|
||||
-- lincat
|
||||
|
||||
-- S = SS;
|
||||
|
||||
-- Question = UserQuestion;
|
||||
-- Action = UserAction;
|
||||
-- Answer = UserAnswer;
|
||||
-- ShortAns = UserShortAns;
|
||||
|
||||
|
||||
-- lin
|
||||
|
||||
-- greet_S = ss ["hello"];
|
||||
-- quit_S = variants{ ss ["goodbye"]; ss ["quit"] };
|
||||
|
||||
-- no_S = ss ["no"];
|
||||
-- yes_S = ss ["yes"];
|
||||
|
||||
-- request_S x = x;
|
||||
-- answer_S x = x;
|
||||
-- ask_S x = x;
|
||||
-- shortans_S x = x;
|
||||
|
||||
-- }
|
||||
5
examples/godis-tram/Common/GodisUserFin.gf
Normal file
5
examples/godis-tram/Common/GodisUserFin.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
--# -path=.:prelude:alltenses
|
||||
|
||||
concrete GodisUserFin of GodisUser =
|
||||
GodisUserI with (GodisLang = GodisLangFin);
|
||||
|
||||
34
examples/godis-tram/Common/GodisUserI.gf
Normal file
34
examples/godis-tram/Common/GodisUserI.gf
Normal file
@@ -0,0 +1,34 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common
|
||||
|
||||
incomplete concrete GodisUserI of GodisUser =
|
||||
open Prelude, GodisLang in {
|
||||
|
||||
lincat
|
||||
|
||||
S = SS;
|
||||
|
||||
Question = UserQuestion;
|
||||
Action = UserAction;
|
||||
Answer = UserAnswer;
|
||||
ShortAns = UserShortAns;
|
||||
Proposition = UserProposition;
|
||||
|
||||
lin
|
||||
|
||||
greet_S = {s = "hei"} ;
|
||||
quit_S = userQuit;
|
||||
|
||||
no_S = userNo;
|
||||
yes_S = userYes;
|
||||
|
||||
request_S x = x;
|
||||
answer_S x = x;
|
||||
ask_S x = x;
|
||||
shortans_S x = x;
|
||||
|
||||
not_prop_S = not_user_prop;
|
||||
not_shortans_S = not_user_short;
|
||||
|
||||
request_request_S = userCoordinate;
|
||||
|
||||
}
|
||||
33
examples/godis-tram/Common/GodisUserSem.gf
Normal file
33
examples/godis-tram/Common/GodisUserSem.gf
Normal file
@@ -0,0 +1,33 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete GodisUserSem of GodisUser =
|
||||
open Prolog, GodisSystemSem in {
|
||||
|
||||
lincat
|
||||
|
||||
S,
|
||||
Question,
|
||||
Answer,
|
||||
ShortAns,
|
||||
Action,
|
||||
Proposition = PStr;
|
||||
|
||||
lin
|
||||
|
||||
greet_S = pList1 (pp0 "greet");
|
||||
quit_S = pList1 (pp0 "quit");
|
||||
|
||||
no_S = pm1 (answer (pp0 "no"));
|
||||
yes_S = pm1 (answer (pp0 "yes"));
|
||||
|
||||
answer_S = pBrackets;
|
||||
ask_S = pBrackets;
|
||||
request_S = pBrackets;
|
||||
shortans_S = pBrackets;
|
||||
|
||||
not_prop_S = \x -> pBrackets (pp1 "not" x);
|
||||
not_shortans_S = \x -> pBrackets (pp1 "not" x);
|
||||
|
||||
request_request_S = pList2;
|
||||
|
||||
}
|
||||
31
examples/godis-tram/Common/GodisUserSwe.gf
Normal file
31
examples/godis-tram/Common/GodisUserSwe.gf
Normal file
@@ -0,0 +1,31 @@
|
||||
--# -path=.:prelude:resource-1.0/abstract:resource-1.0/common:resource-1.0/scandinavian:resource-1.0/swedish
|
||||
|
||||
concrete GodisUserSwe of GodisUser =
|
||||
GodisUserI with (GodisLang = GodisLangSwe);
|
||||
|
||||
|
||||
-- open Prelude, GodisLangSwe in {
|
||||
|
||||
-- lincat
|
||||
|
||||
-- S = SS;
|
||||
|
||||
-- Question = UserQuestion;
|
||||
-- Answer = UserAnswer;
|
||||
-- ShortAns = UserShortAns;
|
||||
-- Action = UserAction;
|
||||
|
||||
-- lin
|
||||
|
||||
-- greet_S = ss ["hej"];
|
||||
-- quit_S = ss ["hejdå"];
|
||||
|
||||
-- no_S = ss ["nej"];
|
||||
-- yes_S = ss ["ja"];
|
||||
|
||||
-- answer_S x = x;
|
||||
-- ask_S x = x;
|
||||
-- shortans_S x = x;
|
||||
-- request_S x = x;
|
||||
|
||||
-- }
|
||||
60
examples/godis-tram/Common/Prolog.gf
Normal file
60
examples/godis-tram/Common/Prolog.gf
Normal file
@@ -0,0 +1,60 @@
|
||||
resource Prolog = {
|
||||
|
||||
oper
|
||||
|
||||
PStr : Type = {s : Str};
|
||||
PPStr : Type = PStr -> PStr;
|
||||
PPPStr : Type = PStr -> PStr -> PStr;
|
||||
PPPPStr : Type = PStr -> PStr -> PStr -> PStr;
|
||||
PPPPPStr : Type = PStr -> PStr -> PStr -> PStr -> PStr;
|
||||
PPPPPPStr : Type = PStr -> PStr -> PStr -> PStr -> PStr -> PStr;
|
||||
PPPPPPPStr : Type = PStr -> PStr -> PStr -> PStr -> PStr -> PStr -> PStr;
|
||||
|
||||
pStr : Str -> PStr = \str -> {s = str};
|
||||
pOper : Str -> PPPStr = \f,x,y -> pStr (x.s ++ f ++ y.s);
|
||||
pPrefix : Str -> PPStr = \f,x -> pStr (f ++ x.s);
|
||||
pPostfix : Str -> PPStr = \f,x -> pStr (x.s ++ f);
|
||||
pEmbed : Str -> Str -> PPStr = \f,g,x -> pStr (f ++ x.s ++ g);
|
||||
pParen : PPStr = pEmbed "(" ")";
|
||||
pBrackets: PPStr = pEmbed "[" "]";
|
||||
|
||||
pAtom : PPStr = \x -> pStr ("'" + x.s + "'");
|
||||
pQuote : PPStr = pEmbed "'" "'";
|
||||
pDQuote : PPStr = pEmbed "\"" "\"";
|
||||
|
||||
pNil : PStr = pStr "''";
|
||||
pEmpty : PStr = pStr [];
|
||||
|
||||
pp0 : Str -> PStr = pStr;
|
||||
pp1 : Str -> PPStr = \pred,arg -> pPrefix pred (pParen arg);
|
||||
pp2 : Str -> PPPStr = \pred,arg1,arg2 -> pp1 pred (pSeq arg1 arg2);
|
||||
pp3 : Str -> PPPPStr = \pred,arg1,arg2 -> pp2 pred (pSeq arg1 arg2);
|
||||
pp4 : Str -> PPPPPStr = \pred,arg1,arg2 -> pp3 pred (pSeq arg1 arg2);
|
||||
pp5 : Str -> PPPPPPStr = \pred,arg1,arg2 -> pp4 pred (pSeq arg1 arg2);
|
||||
pp6 : Str -> PPPPPPPStr = \pred,arg1,arg2 -> pp5 pred (pSeq arg1 arg2);
|
||||
|
||||
pList0 : PStr = pBrackets pEmpty;
|
||||
pList1 : PPStr = \x -> pBrackets x;
|
||||
pList2 : PPPStr = \x,y -> pList1 (pSeq x y);
|
||||
pList3 : PPPPStr = \x,y -> pList2 (pSeq x y);
|
||||
pList4 : PPPPPStr = \x,y -> pList3 (pSeq x y);
|
||||
pList5 : PPPPPPStr = \x,y -> pList4 (pSeq x y);
|
||||
pList6 : PPPPPPPStr = \x,y -> pList5 (pSeq x y);
|
||||
|
||||
pSeq : PPPStr = pOper ",";
|
||||
|
||||
pConcat : PPPStr = \x,y -> pStr (x.s ++ y.s);
|
||||
|
||||
-- the following operations are Godis-specific
|
||||
|
||||
pWhQ : Str -> PStr = \pred -> pOper "^" pVar (pp1 pred pVar);
|
||||
pVar : PStr = pStr "X";
|
||||
|
||||
pm1 : PPStr = \x -> x;
|
||||
pm2 : PPPStr = \x,y -> pm1 (pSeq x y);
|
||||
pm3 : PPPPStr = \x,y -> pm2 (pSeq x y);
|
||||
pm4 : PPPPPStr = \x,y -> pm3 (pSeq x y);
|
||||
pm5 : PPPPPPStr = \x,y -> pm4 (pSeq x y);
|
||||
pm6 : PPPPPPPStr = \x,y -> pm5 (pSeq x y);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user