mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-23 01:52:50 -06:00
a dialogue resource started
This commit is contained in:
41
lib/dialogue/Dialogue.gf
Normal file
41
lib/dialogue/Dialogue.gf
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
abstract Dialogue = {
|
||||||
|
|
||||||
|
cat
|
||||||
|
Phrase ;
|
||||||
|
Sentence ;
|
||||||
|
Command ;
|
||||||
|
|
||||||
|
NP ; V ; V2 ; VV ; A ; PP ; IP ;
|
||||||
|
|
||||||
|
fun
|
||||||
|
PhrasePos : Sentence -> Phrase ;
|
||||||
|
PhraseNeg : Sentence -> Phrase ;
|
||||||
|
PhraseQuest : Sentence -> Phrase ;
|
||||||
|
|
||||||
|
SentV : V -> NP -> Sentence ;
|
||||||
|
SentV2 : V2 -> NP -> NP -> Sentence ;
|
||||||
|
SentA : A -> NP -> Sentence ;
|
||||||
|
SentPP : PP -> NP -> Sentence ;
|
||||||
|
|
||||||
|
ModSentV : VV -> V -> NP -> Sentence ;
|
||||||
|
ModSentV2 : VV -> V2 -> NP -> NP -> Sentence ;
|
||||||
|
ModSentA : VV -> A -> NP -> Sentence ;
|
||||||
|
ModSentPP : VV -> PP -> NP -> Sentence ;
|
||||||
|
|
||||||
|
WhQuestV : V -> IP -> Phrase ;
|
||||||
|
WhQuestSubjV2 : V2 -> IP -> NP -> Phrase ;
|
||||||
|
WhQuestObjV2 : V2 -> NP -> IP -> Phrase ;
|
||||||
|
WhQuestA : A -> IP -> Phrase ;
|
||||||
|
WhQuestPP : PP -> IP -> Phrase ;
|
||||||
|
|
||||||
|
CommV : V -> Phrase ;
|
||||||
|
CommV2 : V2 -> NP -> Phrase ;
|
||||||
|
CommA : A -> Phrase ;
|
||||||
|
CommPP : PP -> Phrase ;
|
||||||
|
|
||||||
|
-- to test
|
||||||
|
|
||||||
|
testNP : NP ; testV : V ; testV2 : V2 ; testVV : VV ; testA : A ;
|
||||||
|
testPP : PP ; testIP : IP ;
|
||||||
|
|
||||||
|
}
|
||||||
6
lib/dialogue/DialogueEng.gf
Normal file
6
lib/dialogue/DialogueEng.gf
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
--# -path=dialogue:resource/*:prelude
|
||||||
|
|
||||||
|
concrete DialogueEng of Dialogue = DialogueI with
|
||||||
|
(Resource = ResourceEng),
|
||||||
|
(Basic = BasicEng),
|
||||||
|
(DialogueParam = DialogueParamEng) ;
|
||||||
42
lib/dialogue/DialogueI.gf
Normal file
42
lib/dialogue/DialogueI.gf
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
incomplete concrete DialogueI of Dialogue = open Prelude, Resource, Basic, DialogueParam in {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
Phrase = {s : Str} ;
|
||||||
|
Sentence = {s : PhraseForm => Str} ;
|
||||||
|
Command = {s : Str} ;
|
||||||
|
|
||||||
|
NP = NP ; V = V ; V2 = V2 ; VV = VV ; A = A ; PP = PP ; IP = IP ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
PhrasePos s = ss (s.s ! PPos) ;
|
||||||
|
PhraseNeg s = ss (s.s ! PNeg) ;
|
||||||
|
PhraseQuest s = ss (s.s ! PQuest) ;
|
||||||
|
|
||||||
|
SentV v np = mkPhrase (SPredV np v) ;
|
||||||
|
SentV2 v np obj = mkPhrase (SPredV2 np v obj) ;
|
||||||
|
SentA v np = mkPhrase (SPredAP np (UseA v)) ;
|
||||||
|
SentPP pp np = mkPhrase (SPredAdv np (AdvPP pp)) ;
|
||||||
|
|
||||||
|
ModSentV m v np = mkPhrase (SPredVV np m (IPredV ASimul v)) ;
|
||||||
|
ModSentV2 m v np obj = mkPhrase (SPredVV np m (IPredV2 ASimul v obj)) ;
|
||||||
|
|
||||||
|
CommV v = ImperOne (PosImpVP (IPredV ASimul v)) ;
|
||||||
|
CommV2 v obj = ImperOne (PosImpVP (IPredV2 ASimul v obj)) ;
|
||||||
|
|
||||||
|
WhQuestV v ip = mkQuestion (QPredV ip v) ;
|
||||||
|
WhQuestSubjV2 v ip np = mkQuestion (QPredV2 ip v np) ;
|
||||||
|
WhQuestObjV2 v np ip = mkQuestion (IntSlash ip (SlashV2 np v)) ;
|
||||||
|
WhQuestA v ip = mkQuestion (QPredAP ip (UseA v)) ;
|
||||||
|
WhQuestPP pp ip = mkQuestion (QPredAdv ip (AdvPP pp)) ;
|
||||||
|
|
||||||
|
|
||||||
|
-- test
|
||||||
|
|
||||||
|
testNP = she_NP ; testV = walk_V ; testV2 = love_V2 ; testVV =
|
||||||
|
want_VV ;
|
||||||
|
--- testA = PositADeg blue_A ;
|
||||||
|
testPP = PrepNP in_Prep (DefOneNP (UseN city_N)) ;
|
||||||
|
testIP = who8one_IP ;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
24
lib/dialogue/DialogueParam.gf
Normal file
24
lib/dialogue/DialogueParam.gf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
interface DialogueParam = open Resource, Predef, Prelude in {
|
||||||
|
|
||||||
|
param
|
||||||
|
PhraseForm = PPos | PNeg | PQuest ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
mkPhraseStr : (p,n,q : Str) -> {s : PhraseForm => Str} = \p,n,q ->
|
||||||
|
{s = table {
|
||||||
|
PPos => p ;
|
||||||
|
PNeg => n ;
|
||||||
|
PQuest => q
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
mkPhrase : Cl -> {s : PhraseForm => Str} = \p ->
|
||||||
|
mkPhraseStr
|
||||||
|
((IndicPhrase (UseCl (PosTP TPresent ASimul) p)).s)
|
||||||
|
((IndicPhrase (UseCl (NegTP TPresent ASimul) p)).s)
|
||||||
|
((QuestPhrase (UseQCl (PosTP TPresent ASimul) (QuestCl p))).s) ;
|
||||||
|
|
||||||
|
mkQuestion : QCl -> {s : Str} = \q ->
|
||||||
|
(QuestPhrase (UseQCl (PosTP TPresent ASimul) q)) ;
|
||||||
|
|
||||||
|
}
|
||||||
3
lib/dialogue/DialogueParamEng.gf
Normal file
3
lib/dialogue/DialogueParamEng.gf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
instance DialogueParamEng of DialogueParam = open ResourceEng, Predef, Prelude in {
|
||||||
|
|
||||||
|
} ;
|
||||||
@@ -347,7 +347,6 @@ instance Print Exp where
|
|||||||
EProj exp label -> prPrec i 3 (concatD [prt 3 exp , doc (showString ".") , prt 0 label])
|
EProj exp label -> prPrec i 3 (concatD [prt 3 exp , doc (showString ".") , prt 0 label])
|
||||||
EQConstr id0 id -> prPrec i 3 (concatD [doc (showString "{0") , prt 0 id0 , doc (showString ".") , prt 0 id , doc (showString "}0")]) -- H
|
EQConstr id0 id -> prPrec i 3 (concatD [doc (showString "{0") , prt 0 id0 , doc (showString ".") , prt 0 id , doc (showString "}0")]) -- H
|
||||||
EQCons id0 id -> prPrec i 3 (concatD [doc (showString "%") , prt 0 id0 , doc (showString ".") , prt 0 id])
|
EQCons id0 id -> prPrec i 3 (concatD [doc (showString "%") , prt 0 id0 , doc (showString ".") , prt 0 id])
|
||||||
EQCons id0 id -> prPrec i 3 (concatD [doc (showString "%") , prt 0 id0 , doc (showString ".") , prt 0 id , doc (showString "%")])
|
|
||||||
EApp exp0 exp -> prPrec i 2 (concatD [prt 2 exp0 , prt 3 exp])
|
EApp exp0 exp -> prPrec i 2 (concatD [prt 2 exp0 , prt 3 exp])
|
||||||
ETable cases -> prPrec i 2 (concatD [doc (showString "table") , doc (showString "{") , prt 0 cases , doc (showString "}")])
|
ETable cases -> prPrec i 2 (concatD [doc (showString "table") , doc (showString "{") , prt 0 cases , doc (showString "}")])
|
||||||
ETTable exp cases -> prPrec i 2 (concatD [doc (showString "table") , prt 4 exp , doc (showString "{") , prt 0 cases , doc (showString "}")])
|
ETTable exp cases -> prPrec i 2 (concatD [doc (showString "table") , prt 4 exp , doc (showString "{") , prt 0 cases , doc (showString "}")])
|
||||||
|
|||||||
Reference in New Issue
Block a user