summaryrefslogtreecommitdiff
path: root/next-lib/src/common
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-09-22 11:49:15 +0000
committeraarne <aarne@cs.chalmers.se>2008-09-22 11:49:15 +0000
commit98665df78b8018af30051cb4a9a31f845e0ba19d (patch)
tree67ba30b09e2b9590a00a4b193bf7611caa935af8 /next-lib/src/common
parent4862018f140a1bdcc7961d445ed9aa92facd742f (diff)
moved lib/next-resource to next-lib/src, to enable linking with next-lib as value of GF_LIB_PATH
Diffstat (limited to 'next-lib/src/common')
-rw-r--r--next-lib/src/common/CommonX.gf34
-rw-r--r--next-lib/src/common/ConstructX.gf19
-rw-r--r--next-lib/src/common/Overload.gf101
-rw-r--r--next-lib/src/common/ParamX.gf65
-rw-r--r--next-lib/src/common/TenseX.gf18
-rw-r--r--next-lib/src/common/TextX.gf11
6 files changed, 248 insertions, 0 deletions
diff --git a/next-lib/src/common/CommonX.gf b/next-lib/src/common/CommonX.gf
new file mode 100644
index 000000000..9401e1ea5
--- /dev/null
+++ b/next-lib/src/common/CommonX.gf
@@ -0,0 +1,34 @@
+concrete CommonX of Common = open (R = ParamX) in {
+
+ lincat
+ Text = {s : Str} ; --lock_Text : {}} ;
+ Phr = {s : Str} ; --lock_Phr : {}} ;
+ Utt = {s : Str} ; --lock_Utt : {}} ;
+ Voc = {s : Str} ; --lock_Voc : {}} ;
+ SC = {s : Str} ; --lock_SC : {}} ;
+ Adv = {s : Str} ; --lock_Adv : {}} ;
+ AdV = {s : Str} ; --lock_AdV : {}} ;
+ AdA = {s : Str} ; --lock_AdA : {}} ;
+ AdN = {s : Str} ; --lock_AdN : {}} ;
+ IAdv = {s : Str} ; --lock_IAdv : {}} ;
+ CAdv = {s : Str} ; --lock_CAdv : {}} ;
+ PConj = {s : Str} ; --lock_PConj : {}} ;
+
+ Temp = {s : Str ; t : R.Tense ; a : R.Anteriority} ;
+ Tense = {s : Str ; t : R.Tense} ;
+ Ant = {s : Str ; a : R.Anteriority} ;
+ Pol = {s : Str ; p : R.Polarity} ;
+
+ lin
+ TTAnt t a = {s = t.s ++ a.s ; t = t.t ; a = a.a} ;
+
+ PPos = {s = []} ** {p = R.Pos} ;
+ PNeg = {s = []} ** {p = R.Neg} ;
+ TPres = {s = []} ** {t = R.Pres} ;
+ TPast = {s = []} ** {t = R.Past} ; --# notpresent
+ TFut = {s = []} ** {t = R.Fut} ; --# notpresent
+ TCond = {s = []} ** {t = R.Cond} ; --# notpresent
+ ASimul = {s = []} ** {a = R.Simul} ;
+ AAnter = {s = []} ** {a = R.Anter} ; --# notpresent
+
+}
diff --git a/next-lib/src/common/ConstructX.gf b/next-lib/src/common/ConstructX.gf
new file mode 100644
index 000000000..ee4decf00
--- /dev/null
+++ b/next-lib/src/common/ConstructX.gf
@@ -0,0 +1,19 @@
+--# -path=.:../abstract:prelude
+
+resource ConstructX = open CommonX in {
+
+ oper
+ mkText : Str -> Text = \s -> {s = s ; lock_Text = <>} ;
+ mkPhr : Str -> Phr = \s -> {s = s ; lock_Phr = <>} ;
+ mkUtt : Str -> Utt = \s -> {s = s ; lock_Utt = <>} ;
+ mkVoc : Str -> Voc = \s -> {s = s ; lock_Voc = <>} ;
+ mkSC : Str -> SC = \s -> {s = s ; lock_SC = <>} ;
+ mkAdv : Str -> Adv = \s -> {s = s ; lock_Adv = <>} ;
+ mkAdV : Str -> AdV = \s -> {s = s ; lock_AdV = <>} ;
+ mkAdA : Str -> AdA = \s -> {s = s ; lock_AdA = <>} ;
+ mkAdN : Str -> AdN = \s -> {s = s ; lock_AdN = <>} ;
+ mkIAdv : Str -> IAdv = \s -> {s = s ; lock_IAdv = <>} ;
+ mkCAdv : Str -> CAdv = \s -> {s = s ; lock_CAdv = <>} ;
+ mkPConj : Str -> PConj = \s -> {s = s ; lock_PConj = <>} ;
+
+}
diff --git a/next-lib/src/common/Overload.gf b/next-lib/src/common/Overload.gf
new file mode 100644
index 000000000..df7baeab9
--- /dev/null
+++ b/next-lib/src/common/Overload.gf
@@ -0,0 +1,101 @@
+incomplete resource Overload = open Grammar in {
+
+ oper
+
+ pred = overload {
+ pred : NP -> V -> Cl
+ = \v,np -> PredVP np (UseV v) ;
+ pred : NP -> V2 -> NP -> Cl
+ = \v,np,ob -> PredVP np (ComplV2 v ob) ;
+ pred : NP -> V3 -> NP -> NP -> Cl
+ = \v,np,ob,ob2 ->
+ PredVP np (ComplV3 v ob ob2) ;
+ pred : NP -> A -> Cl
+ = \a,np ->
+ PredVP np (UseComp (CompAP (PositA a)))
+ } ;
+
+ mod = overload {
+ mod : A -> N -> CN
+ = \a,n -> AdjCN (PositA a) (UseN n) ;
+ mod : AP -> N -> CN
+ = \a,n -> AdjCN a (UseN n) ;
+ mod : AP -> CN -> CN
+ = \a,n -> AdjCN a n ;
+ mod : AdA -> A -> AP
+ = \m,a -> AdAP m (PositA a) ;
+ mod : Quant -> N -> NP
+ = \q,n -> DetCN (DetSg (SgQuant q)
+ NoOrd) (UseN n) ;
+ mod : Quant -> CN -> NP
+ = \q,n -> DetCN (DetSg
+ (SgQuant q) NoOrd) n ;
+ mod : Predet -> N -> NP
+ = \q,n -> PredetNP q (DetCN (DetPl
+ (PlQuant IndefArt) NoNum NoOrd) (UseN n)) ;
+ mod : Num -> N -> NP
+ = \nu,n -> DetCN (DetPl (PlQuant
+ IndefArt) nu NoOrd) (UseN n)
+
+ } ;
+
+ coord = overload {
+ coord : Conj -> Adv -> Adv -> Adv
+ = \c,x,y -> ConjAdv c (BaseAdv x y) ;
+ coord : Conj -> AP -> AP -> AP
+ = \c,x,y -> ConjAP c (BaseAP x y) ;
+ coord : Conj -> NP -> NP -> NP
+ = \c,x,y -> ConjNP c (BaseNP x y) ;
+ coord : Conj -> S -> S -> S
+ = \c,x,y -> ConjS c (BaseS x y) ;
+ coord : DConj -> Adv -> Adv -> Adv
+ = \c,x,y -> DConjAdv c (BaseAdv x y) ;
+ coord : DConj -> AP -> AP -> AP
+ = \c,x,y -> DConjAP c (BaseAP x y) ;
+ coord : DConj -> NP -> NP -> NP
+ = \c,x,y -> DConjNP c (BaseNP x y) ;
+ coord : DConj -> S -> S -> S
+ = \c,x,y -> DConjS c (BaseS x y) ;
+ coord : Conj -> ListAdv -> Adv
+ = \c,xy -> ConjAdv c xy ;
+ coord : Conj -> ListAP -> AP
+ = \c,xy -> ConjAP c xy ;
+ coord : Conj -> ListNP -> NP
+ = \c,xy -> ConjNP c xy ;
+ coord : Conj -> ListS -> S
+ = \c,xy -> ConjS c xy ;
+ coord : DConj -> ListAdv -> Adv
+ = \c,xy -> DConjAdv c xy ;
+ coord : DConj -> ListAP -> AP
+ = \c,xy -> DConjAP c xy ;
+ coord : DConj -> ListNP -> NP
+ = \c,xy -> DConjNP c xy ;
+ coord : DConj -> ListS -> S
+ = \c,xy -> DConjS c xy
+ } ;
+
+ mkCN = overload {
+ mkCN : N -> CN
+ = UseN ;
+ mkCN : A -> N -> CN
+ = \a,n -> AdjCN (PositA a) (UseN n) ;
+ mkCN : AP -> N -> CN
+ = \a,n -> AdjCN a (UseN n) ;
+ mkCN : AP -> CN -> CN
+ = \a,n -> AdjCN a n ;
+ } ;
+
+ mkNP = overload {
+ mkNP : NP
+ = this_NP ;
+ mkNP : Pron -> NP
+ = UsePron ;
+ mkNP : PN -> NP
+ = UsePN ;
+ mkNP : Quant -> N -> NP
+ = \q,n -> DetCN (DetSg (SgQuant q) NoOrd) (UseN n) ;
+ mkNP : Predet -> N -> NP
+ = \q,n -> PredetNP q (DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) (UseN n))
+ } ;
+
+}
diff --git a/next-lib/src/common/ParamX.gf b/next-lib/src/common/ParamX.gf
new file mode 100644
index 000000000..65901de66
--- /dev/null
+++ b/next-lib/src/common/ParamX.gf
@@ -0,0 +1,65 @@
+resource ParamX = open Prelude in {
+
+---- flags optimize=noexpand ;
+
+ param
+ Number = Sg | Pl ;
+ Person = P1 | P2 | P3 ;
+ Degree = Posit | Compar | Superl ;
+
+ Anteriority =
+ Simul
+ | Anter --# notpresent
+ ;
+ Tense =
+ Pres
+ | Past --# notpresent
+ | Fut --# notpresent
+ | Cond --# notpresent
+ ;
+
+ param
+
+ Polarity = Pos | Neg ;
+
+ QForm = QDir | QIndir ;
+
+-- Imperatives: True = polite, False = familiar.
+
+ ImpForm = ImpF Number Bool ;
+
+ oper
+ numImp : ImpForm -> Number = \i ->
+ case i of {
+ ImpF n _ => n
+ } ;
+
+ conjNumber : Number -> Number -> Number = \m,n ->
+ case m of {
+ Sg => n ;
+ _ => Pl
+ } ;
+
+-- For persons, we let the latter argument win ("either you or I am absent"
+-- but "either I or you are absent"). This is not quite clear.
+
+ conjPerson : Person -> Person -> Person = \_,p ->
+ p ;
+
+-- To construct a record with a polarity-dependent table.
+
+ polCases : SS -> SS -> {s : Polarity => Str} = \true,false -> {
+ s = table {
+ Pos => true.s ;
+ Neg => false.s
+ }
+ } ;
+
+-- To count the length of a tail in a sequence of digits, e.g. to put commas
+-- as in 1,000,000.
+
+ param
+ DTail = T1 | T2 | T3 ;
+
+
+}
diff --git a/next-lib/src/common/TenseX.gf b/next-lib/src/common/TenseX.gf
new file mode 100644
index 000000000..665bb146d
--- /dev/null
+++ b/next-lib/src/common/TenseX.gf
@@ -0,0 +1,18 @@
+concrete TenseX of Tense = open (R = ParamX) in {
+
+ lincat
+ Tense = {s : Str ; t : R.Tense} ;
+ Ant = {s : Str ; a : R.Anteriority} ;
+ Pol = {s : Str ; p : R.Polarity} ;
+
+ lin
+ PPos = {s = []} ** {p = R.Pos} ;
+ PNeg = {s = []} ** {p = R.Neg} ;
+ TPres = {s = []} ** {t = R.Pres} ;
+ TPast = {s = []} ** {t = R.Past} ;
+ TFut = {s = []} ** {t = R.Fut} ;
+ TCond = {s = []} ** {t = R.Cond} ;
+ ASimul = {s = []} ** {a = R.Simul} ;
+ AAnter = {s = []} ** {a = R.Anter} ;
+
+}
diff --git a/next-lib/src/common/TextX.gf b/next-lib/src/common/TextX.gf
new file mode 100644
index 000000000..a5ddebc54
--- /dev/null
+++ b/next-lib/src/common/TextX.gf
@@ -0,0 +1,11 @@
+concrete TextX of Text = CommonX ** {
+
+-- This will work for almost all languages except Spanish.
+
+ lin
+ TEmpty = {s = []} ;
+ TFullStop x xs = {s = x.s ++ "." ++ xs.s} ;
+ TQuestMark x xs = {s = x.s ++ "?" ++ xs.s} ;
+ TExclMark x xs = {s = x.s ++ "!" ++ xs.s} ;
+
+}