mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-14 07:19:31 -06:00
resource for OCL
This commit is contained in:
20
lib/resource-0.6/abstract/Atom.gf
Normal file
20
lib/resource-0.6/abstract/Atom.gf
Normal file
@@ -0,0 +1,20 @@
|
||||
interface Atom = ResourceExt ** open Resource in {
|
||||
param
|
||||
Polarity = Pos | Neg ;
|
||||
|
||||
oper
|
||||
AS : Type = {s : Polarity => SBranch} ;
|
||||
SBranch : Type ;
|
||||
|
||||
mkPred : NP -> VG -> {s : Polarity => SBranch} = \x,F -> {s =
|
||||
table {
|
||||
Pos => (PredVP x (PosVG F)).s ;
|
||||
Neg => (PredVP x (NegVG F)).s
|
||||
}
|
||||
} ;
|
||||
|
||||
posAS, negAS : AS -> S ;
|
||||
|
||||
posAS p = {s = p.s ! Pos ; lock_S =<>} ;
|
||||
negAS p = {s = p.s ! Neg ; lock_S =<>} ;
|
||||
} ;
|
||||
91
lib/resource-0.6/abstract/Logic.gf
Normal file
91
lib/resource-0.6/abstract/Logic.gf
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
--1 A Small Predication Library
|
||||
--
|
||||
-- (c) Aarne Ranta 2003 under Gnu GPL.
|
||||
--
|
||||
-- This library is built on a language-independent API of
|
||||
-- resource grammars. It has a common part, the type signatures
|
||||
-- (defined here), and language-dependent parts. The user of
|
||||
-- the library should only have to look at the type signatures.
|
||||
|
||||
incomplete resource Logic = open Atom in {
|
||||
|
||||
-- We first define a set of predication patterns.
|
||||
|
||||
oper
|
||||
|
||||
predV1 : V -> NP -> AS ; -- one-place verb: "John walks"
|
||||
predV2 : TV -> NP -> NP -> AS ; -- two-place verb: "John loves Mary"
|
||||
predV3 : V3 -> NP -> NP -> NP -> AS ;-- three-place verb: "John prefers Mary to Jane"
|
||||
predVColl : V -> NP -> NP -> AS ; -- collective verb: "John and Mary fight"
|
||||
predA1 : Adj1 -> NP -> AS ; -- one-place adjective: "John is old"
|
||||
predA2 : Adj2 -> NP -> NP -> AS ; -- two-place adj: "John is married to Mary"
|
||||
predAComp : AdjDeg -> NP -> NP -> AS ; -- compar adj: "John is older than Mary"
|
||||
predAColl : Adj1 -> NP -> NP -> AS ; -- collective adj: "John and Mary are married"
|
||||
predN1 : N -> NP -> AS ; -- one-place noun: "John is a man"
|
||||
predN2 : Fun -> NP -> NP -> AS ; -- two-place noun: "John is a lover of Mary"
|
||||
predNColl : N -> NP -> NP -> AS ; -- collective noun: "John and Mary are lovers"
|
||||
predAdv : AdV -> NP -> AS ; -- adverb: "Joh is outside"
|
||||
|
||||
-- Individual-valued function applications.
|
||||
|
||||
appFun1 : Fun -> NP -> NP ; -- one-place function: "the successor of x"
|
||||
appFun2 : Fun2 -> NP -> NP -> NP ; -- two-place function: "the distance from x to y"
|
||||
appFunColl : Fun -> NP -> NP -> NP ; -- collective function: "the sum of x and y"
|
||||
|
||||
-- Families of types, expressed by common nouns depending on arguments.
|
||||
|
||||
appFam1 : Fun -> NP -> CN ; -- one-place family: "divisor of x"
|
||||
appFamColl : Fun -> NP -> NP -> CN ; -- collective family: "path between x and y"
|
||||
|
||||
-- Type constructor, similar to a family except that the argument is a type.
|
||||
|
||||
constrTyp1 : Fun -> CN -> CN ;
|
||||
|
||||
-- Logical connectives on two sentences.
|
||||
|
||||
conjS : S -> S -> S ;
|
||||
disjS : S -> S -> S ;
|
||||
implS : S -> S -> S ;
|
||||
|
||||
-- As an auxiliary, we need two-place conjunction of names ("John and Mary"),
|
||||
-- used in collective predication.
|
||||
|
||||
conjNP : NP -> NP -> NP ;
|
||||
|
||||
-----------------------------
|
||||
|
||||
---- what follows should be an implementation of the preceding
|
||||
|
||||
oper
|
||||
|
||||
predV1 = \F, x -> mkPred x (PredV F) ;
|
||||
predV2 = \F, x, y -> mkPred x (PredTV F y) ;
|
||||
predV3 = \F, x, y, z -> mkPred x (PredV3 F y z) ;
|
||||
predVColl = \F, x, y -> mkPred (conjNP x y) (PredV F) ;
|
||||
predA1 = \F, x -> mkPred x (PredAP (AdjP1 F)) ;
|
||||
predA2 = \F, x, y -> mkPred x (PredAP (ComplAdj F y)) ;
|
||||
predAComp = \F, x, y -> mkPred x (PredAP (ComparAdjP F y)) ;
|
||||
predAColl = \F, x, y -> mkPred (conjNP x y) (PredAP (AdjP1 F)) ;
|
||||
predN1 = \F, x -> mkPred x (PredCN (UseN F)) ;
|
||||
predN2 = \F, x, y -> mkPred x (PredCN (AppFun F y)) ;
|
||||
predNColl = \F, x, y -> mkPred (conjNP x y) (PredCN (UseN F)) ;
|
||||
predAdv = \F, x -> mkPred x (PredAdV F) ;
|
||||
|
||||
|
||||
appFun1 = \f, x -> DefOneNP (AppFun f x) ;
|
||||
appFun2 = \f, x, y -> DefOneNP (AppFun (AppFun2 f y) x) ;
|
||||
appFunColl = \f, x, y -> DefOneNP (AppFun f (conjNP x y)) ;
|
||||
|
||||
appFam1 = \F, x -> AppFun F x ;
|
||||
appFamColl = \F, x, y -> AppFun F (conjNP x y) ;
|
||||
|
||||
conjS = \A, B -> ConjS AndConj (TwoS A B) ;
|
||||
disjS = \A, B -> ConjS OrConj (TwoS A B) ;
|
||||
implS = \A, B -> SubjS IfSubj A B ;
|
||||
|
||||
constrTyp1 = \F, A -> AppFun F (IndefManyNP A) ;
|
||||
|
||||
conjNP = \x, y -> ConjNP AndConj (TwoNP x y) ;
|
||||
|
||||
} ;
|
||||
3
lib/resource-0.6/english/AtomEng.gf
Normal file
3
lib/resource-0.6/english/AtomEng.gf
Normal file
@@ -0,0 +1,3 @@
|
||||
instance AtomEng of Atom = ResourceExtEng ** open ResourceEng in {
|
||||
oper SBranch = Str ;
|
||||
}
|
||||
6
lib/resource-0.6/english/LogicEng.gf
Normal file
6
lib/resource-0.6/english/LogicEng.gf
Normal file
@@ -0,0 +1,6 @@
|
||||
--# -path=.:../abstract:../../prelude
|
||||
|
||||
resource LogicEng = Logic with
|
||||
(Atom = AtomEng), (Resource = ResourceEng) ;
|
||||
|
||||
-- this is the standard form of a derived resource. AR 12/1/2004
|
||||
@@ -261,7 +261,7 @@ oper
|
||||
vPart = \go, goes, went, gone, up ->
|
||||
verbPart (mkVerbP3 go goes went gone) up ** {lock_V = <>} ;
|
||||
vPartReg = \get, up ->
|
||||
verbPart (regVerbP3 get) up ** {lock_V = <>} ;
|
||||
verbPart (vGen get) up ** {lock_V = <>} ;
|
||||
|
||||
mkTV = \v,p -> v ** {lock_TV = <> ; s3 = p} ;
|
||||
tvPartReg = \get, along, to -> mkTV (vPartReg get along) to ;
|
||||
|
||||
Reference in New Issue
Block a user