Skip to content

Commit

Permalink
Add contents of contrib and examples from core repo (some of which ma…
Browse files Browse the repository at this point in the history
…y be removed)
  • Loading branch information
johnjcamilleri committed Sep 3, 2013
1 parent be9ea22 commit d769dac
Show file tree
Hide file tree
Showing 938 changed files with 425,804 additions and 0 deletions.
77 changes: 77 additions & 0 deletions RDF/RDF.gf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-------------------------------------------------------------------------
--
-- Abstract Syntax for RDF according to the RDF and RDFS specifications
--
-- (c) Krasimir Angelov
--
-------------------------------------------------------------------------

abstract RDF = {

cat Value (class : Class) ;

cat Resource (class : Class) ;
fun res : (c : Class) -> Resource c -> Value c ;

cat [Resource (class : Class)] ;

cat URI ;
fun uri : (c : Class) -> URI -> Resource c ;

cat BNode ;
fun bnode : (c : Class) -> BNode -> Resource c ;
nodeId : String -> BNode ;

cat DataType ;
fun datatype : DataType -> URI ;

cat Literal ;
fun lit : Literal -> Value literal_C ;
int : Int -> Literal ;
float : Float -> Literal ;
string : String -> DataType -> Literal ;

cat Property (domain, range : Class) ;
fun property : (d, r : Class) -> Property d r -> URI ;

cat Container (class : Class) ;
fun container : (c : Class) -> Container c -> Resource c ;
bag : Resource bag_C -> [Resource resource_C] -> Container bag_C ;
seq : Resource seq_C -> [Resource resource_C] -> Container seq_C ;
alt : Resource alt_C -> [Resource resource_C] -> Container alt_C ;

cat Statement ;
fun statement : Statement -> Resource statement_C ;
assert : (d,r : Class) -> Resource d -> Property d r -> Value r -> Statement ;
r_assert : (d,r : Class) -> Resource statement_C -> Resource d -> Property d r -> Value r -> Statement ;

cat Attribute (class : Class) (subject : Resource class) ;
fun assign : (d,r : Class) -> (s : Resource d) -> Property d r -> Value r -> Attribute d s ;
r_assign : (d,r : Class) -> Resource statement_C -> (s : Resource d) -> Property d r -> Value r -> Attribute d s ;

cat [Attribute (class : Class) (subject : Resource class)] ;

cat Description ;
fun description : Description -> Resource bag_C ;
describe : (c : Class) -> (s : Resource c) -> [Attribute c s] -> Description ;
r_describe : Resource bag_C -> (c : Class) -> (s : Resource c) -> [Attribute c s] -> Description ;

cat Class ;
fun class : Class -> Resource class_C ;

fun resource_C : Class ;
class_C : Class ;
property_C : Class ;
constraintResource_C : Class ;
constraintProperty_C : Class ;
literal_C : Class ;
statement_C : Class ;
bag_C : Class ;
seq_C : Class ;
alt_C : Class ;

cat Inheritance (c1,c2 : Class) ;
fun inheritance : (c1,c2 : Class) -> Inheritance c1 c2 -> Statement ;
upcast : (c1,c2 : Class) -> Inheritance c1 c2 -> Resource c1 -> Resource c2 ;

}
98 changes: 98 additions & 0 deletions SUMO/Basic.gf
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
--# -path=.:englishExtended:common:prelude:abstract
abstract Basic = {

cat
Class;
El Class;
Ind Class;
SubClass (c1,c2 : Class);
Inherits Class Class ;
[El Class];
[Class];
Formula;
Desc Class;
Var Class;
Stmt ;


-- class-forming operations
data
both : Class -> Class -> Class ;
either : Class -> Class -> Class ;

KappaFn : (c : Class) -> (Var c -> Formula) -> Class ;


-- inheritance between classes
data
-- simple sub-class relations
inhz : (c : Class) -> Inherits c c;
inhs : (c1, c2, c3 : Class) -> SubClass c1 c2 -> Inherits c2 c3 -> Inherits c1 c3;

-- (both c1 c2) is subclass of c1 and of c2
bothL : (c1, c2 : Class) -> SubClass (both c1 c2) c1 ;
bothR : (c1, c2 : Class) -> SubClass (both c1 c2) c2 ;

-- relationship with other subclasses
bothC : (c1, c2, c3 : Class) -> Inherits c3 c1 -> Inherits c3 c2 -> Inherits c3 (both c1 c2);

-- (either c1 c2) is superclass of c1 and of c2
eitherL : (c1, c2 : Class) -> Inherits c1 (either c1 c2);
eitherR : (c1, c2 : Class) -> Inherits c2 (either c1 c2);

-- relationship with other subclasses
eitherC : (c1,c2,c3 : Class) -> SubClass c1 c3 -> SubClass c2 c3 -> SubClass (either c1 c2) c3 ;

-- sub-class axiom for KappaFn
kappa : (c : Class) -> (p : Var c -> Formula) -> Inherits (KappaFn c p) c ;


-- coercion from Var to El
data
var : (c1 , c2 : Class) -> Inherits c1 c2 -> Var c1 -> El c2 ;


-- coercion from Ind to El
data
el : (c1, c2 : Class) -> Inherits c1 c2 -> Ind c1 -> El c2;


-- first-order logic operations for Formula
data
not : Formula -> Formula;
and : Formula -> Formula -> Formula;
or : Formula -> Formula -> Formula;
impl : Formula -> Formula -> Formula;
equiv : Formula -> Formula -> Formula;

-- quantification over instances of a Class
data
exists : (c : Class) -> (Var c -> Formula) -> Formula;
forall : (c : Class) -> (Var c -> Formula) -> Formula;


-- Desc category
data
desc : (c1,c2 : Class) -> Inherits c1 c2 -> Desc c2 ;

fun descClass : (c : Class) -> Desc c -> Class ;
def descClass _ (desc c _ _) = c ;

fun descInh : (c : Class) -> (p : Desc c) -> Inherits (descClass c p) c ;
--def descInh c1 (desc c2 c1 i) = i ;

fun desc2desc : (c1,c2 : Class) -> Inherits c1 c2 -> Desc c1 -> Desc c2 ;
--def desc2desc _ _ inh dsc = desc ? ? (plusInh ? ? ? inh (descInh ? dsc)) ;

--fun plusInh : (c1,c2,c3 : Class) -> Inherits c1 c2 -> Inherits c2 c3 -> Inherits c1 c3 ;
--def plusInh _ _ _ inhz inh2 = inh2 ;
-- plusInh _ _ _ (inhs _ _ _ sc inh1) inh2 = inhs ? ? ? sc (plusInh ? ? ? inh1 inh2) ;


-- statements
data
subClassStm : (c1,c2 : Class) -> SubClass c1 c2 -> Stmt ;
instStm : (c : Class) -> Ind c -> Stmt ;
formStm : Formula -> Stmt ;

};
6 changes: 6 additions & 0 deletions SUMO/BasicBul.gf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
concrete BasicBul of Basic = open SyntaxBul in {

lincat
Class = CN ;

};
99 changes: 99 additions & 0 deletions SUMO/BasicEng.gf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
--# -path=.:englishExtended:abstract:common:
concrete BasicEng of Basic = open CatEng, ExtensionEng, DictLangEng, DictEng, ParadigmsEng, ResEng, Coordination, Prelude, ParamBasic, ConjunctionEng, NounEng in {

lincat
Class = CatEng.CN ;
El = CatEng.NP ;
Ind = CatEng.NP ;
Var = CatEng.PN ;
SubClass = {} ;
Inherits = {} ;
Desc = CatEng.CN ;
Formula = ExtensionEng.PolSentence;
[El] = ConjunctionEng.ListNP;
[Class] =ExtensionEng.ListCN ;
Stmt = ExtensionEng.StmtS ;

lin
BaseClass = {s1,s2 = \\_,_ => "";
g = Neutr;
lock_ListCN=<>};
ConsClass xs x = ExtensionEng.ConsCN xs x ;

BaseEl c = {s1,s2 = \\_ => "";
a = agrP3 Sg;
lock_ListNP=<>};

ConsEl c xs x = ConjunctionEng.ConsNP xs x ;

and f1 f2 = {s = \\f,c => f1.s ! Indep ! c ++ "and" ++ f2.s ! Indep ! c; flag = NothingS; lock_PolSentence = <>};
or f1 f2 = {s = \\f,c => f1.s ! Indep ! c ++ "or" ++ f2.s ! Indep ! c; flag = NothingS; lock_PolSentence = <>};
not f1 = {s = \\f => table {
CNeg _ => "it is not true that" ++ f1.s ! f ! CPos ;
CPos => f1.s ! Indep ! CNeg False
};
flag = f1.flag;
lock_PolSentence = <>
};
impl f1 f2 = {s = \\f,c => "if" ++ f1.s ! Indep ! c ++ "then" ++ f2.s ! Indep ! c; flag = NothingS; lock_PolSentence = <>};

equiv f1 f2 = {s = \\f,c => f1.s ! Indep ! c ++ "is" ++ "equivalent" ++ "to" ++ f2.s ! Indep ! c; flag = NothingS;
lock_PolSentence = <>};

el c1 c2 i e = e;
var c1 c2 i e = UsePN e;

exists C f = let np = DetCN (DetQuant IndefArt NumSg) C
in { s = \\form,c => case <form, f.flag> of {
<Indep, ExistS _> => "there" ++ "exists" ++ np.s ! npNom ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib, ExistS One> => "and" ++ np.s ! npNom ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib, ExistS _> => "," ++ np.s ! npNom ++ f.$0 ++ f.s ! Attrib ! c ;
<Indep,_> => "there" ++ "exists" ++ np.s ! npNom ++ f.$0 ++ "such" ++ "that" ++ f.s ! Indep ! c ;
_ => "and" ++ np.s ! npNom ++ f.$0 ++ "such" ++ "that" ++ f.s ! Indep ! c
};
flag = case f.flag of {
ExistS _ => ExistS Many;
_ => ExistS One
};
lock_PolSentence=<>
};

forall C f = { s = \\form, c => case <form,f.flag> of {
<Indep,ForallS _> => "for" ++ "every" ++ C.s ! Sg ! Nom ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib,ForallS One> => "," ++ "every" ++ C.s ! Sg ! Nom ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib, ForallS _> => "," ++ "every" ++ C.s ! Sg ! Nom ++ f.$0 ++ f.s ! Attrib ! c ;
<Indep,ExistS _> => "for" ++"every"++ C.s ! Sg ! Nom ++ f.$0 ++ f.s ! Indep ! c ;
<Indep,_> => "for" ++"every"++ C.s ! Sg ! Nom ++ f.$0 ++ "we"++"have" ++ "that" ++ f.s ! Indep ! c ;
<Attrib,ExistS _> => "and" ++ "every" ++ C.s ! Sg ! Nom ++ f.$0 ++ f.s ! Indep ! c;
_ => "and" ++ "every" ++ C.s ! Sg ! Nom ++ f.$0 ++ "we" ++ "have" ++ "that" ++f.s ! Indep ! c };
flag = case f.flag of {
ForallS _ => ForallS Many;
_ => ForallS One
};
lock_PolSentence=<>
};

both c1 c2 = { s = \\c,n => c1.s ! c ! n ++ "and" ++ c2.s ! c ! n;
g = c2.g; lock_CN = <>
};

either c1 c2 = { s = \\c,n => c1.s ! c ! n ++ "or" ++ c2.s ! c ! n;
g = c2.g; lock_CN = <>
};

KappaFn c ob2 = ApposCN (AdvCN (AdvCN (UseN class_N) (PrepNP part_Prep (DetCN (DetQuant IndefArt NumPl) c))) where_Adv) (sentToNoun ob2) ;

desc c1 c2 i = c2 ;
descClass c dc = c;
desc2desc c1 c2 i d = d;

subClassStm c1 c2 sc = lin StmtS (ss (c1. s ! Sg ! Nom ++ "is a subclass of" ++ c2.s ! Sg ! Nom)) ;
instStm c i = lin StmtS (ss (i.s ! npNom ++ "is an instance of" ++ c.s ! Sg ! Nom)) ;
formStm f = lin StmtS (ss (f.s ! Indep ! CPos)) ;

lindef
Ind = \x -> {s = \\_ => x; a = agrP3 Sg; lock_NP = <>} ;
El = \x -> {s = \\_ => x; a = agrP3 Sg; lock_NP = <>} ;
Class = \x -> {s = \\_,_ => x; g = Neutr; lock_CN =<>};

};
107 changes: 107 additions & 0 deletions SUMO/BasicFre.gf
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
--# -path=.:french:romance:abstract:prelude:common
concrete BasicFre of Basic = CatFre - [Text] ** open DictLangFre, CommonRomance, Prelude, ParamBasic,Coordination, ParamX, ResFre,ParadigmsFre in{

lincat
Class = CN ;
El = NP ;
Ind = NP ;
Var = PN ;
SubClass = {} ;
Inherits = {} ;
Desc = CN ;
Formula = PolSentence;
[El] = {s1,s2 : Case => Str ; a : Agr};
[Class] = {s1,s2 : Number => Str ; g : Gender};
Stmt = StmtS;

lin
BaseClass = {s1,s2 = \\_ => "";
g = Masc} ;

ConsClass xs x = consrTable Number comma xs x ** {g = x.g} ;

BaseEl c = {s1,s2 = \\_ => "";
a = agrP3 Masc Sg};

ConsEl cl x xs = {
s1 = \\c => (x.s ! c).comp ++ comma ++ xs.s1 ! c ;
s2 = \\c => xs.s2 ! c ;
a = conjAgr x.a xs.a
} ;

and f1 f2 = {s = \\f,c => f1.s ! Indep ! c ++ "et" ++ f2.s ! Indep ! c; flag = NothingS; lock_PolSentence = <>};
or f1 f2 = {s = \\f,c => f1.s ! Indep ! c ++ "ou" ++ f2.s ! Indep ! c; flag = NothingS; lock_PolSentence = <>};
not f1 = {s = \\f,c => case c of
{Pos => f1.s ! Indep ! Neg ;
_ => f1.s ! Indep ! Pos };
flag = NothingS; lock_PolSentence = <>};
impl f1 f2 = {s = \\f,c => "si" ++ f1.s ! Indep ! c ++ "alors" ++ f2.s ! Indep ! c; flag = NothingS; lock_PolSentence = <>};
equiv f1 f2 = {s = \\f,c => f1.s ! Indep ! c ++ "est" ++ "equivalent" ++ "à" ++ f2.s ! Indep ! c; flag = NothingS;
lock_PolSentence = <>};


var c1 c2 i e = let np = UsePN e in
{s = np.s;
a = agrP3 c1.g Sg; isPol = False;
hasClit = False; lock_NP = <>};

el c1 c2 i e = e ;

exists C f = let np = DetCN (DetQuant IndefArt NumSg) C ;
tel = case C.g of
{Masc => "tel";
_ => "telle"
}
in
{s = \\form,c => case <form, f.flag> of
{ <Indep, ExistS _> => "il" ++ "existe" ++ (np.s ! Nom).comp ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib, ExistS One> => "et" ++ (np.s ! Nom).comp ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib, ExistS _> => "," ++ (np.s ! Nom).comp ++ f.$0 ++ f.s ! Attrib ! c ;
<Indep,_> => "il" ++ "existe" ++ (np.s ! Nom).comp ++ f.$0 ++ tel ++ "que" ++ f.s ! Indep ! c ;
_ => "et" ++ (np.s ! Nom).comp ++ f.$0 ++ tel ++ "que" ++ f.s ! Indep ! c };
flag = case f.flag of
{ExistS _ => ExistS Many;
_ => ExistS One };
lock_PolSentence=<>};

forall C f = {s = \\form, c => case <form,f.flag> of
{<Indep,ForallS _> => "pour" ++ "chaque" ++ C.s ! Sg ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib,ForallS One> => "," ++ "chaque" ++ C.s ! Sg ++ f.$0 ++ f.s ! Attrib ! c ;
<Attrib, ForallS _> => "," ++ "chaque" ++ C.s ! Sg ++ f.$0 ++ f.s ! Attrib ! c ;
<Indep,ExistS _> => "pour" ++"chaque"++ C.s ! Sg ++ f.$0 ++ f.s ! Indep ! c ;
<Indep,_> => "pour" ++"chaque"++ C.s ! Sg ++ f.$0 ++ "il"++ "y" ++ "a" ++ "que" ++ f.s ! Indep ! c ;
<Attrib,ExistS _> => "et" ++ "chaque" ++ C.s ! Sg ++ f.$0 ++ f.s ! Indep ! c;
_ => "and" ++ "every" ++ C.s ! Sg ++ f.$0 ++ "il" ++ "y" ++ "a" ++ "que" ++f.s ! Indep ! c };
flag = case f.flag of
{ForallS _ => ForallS Many;
_ => ForallS One };
lock_PolSentence=<>};



both c1 c2 = {s = \\n => c1.s ! n ++ "et" ++ c2.s ! n;
g = c2.g; lock_CN = <>};


either c1 c2 = {s = \\n => c1.s ! n ++ "ou" ++ c2.s ! n;
g = c2.g; lock_CN = <>};

desc c1 c2 i = c2 ;
descClass c dc = c;
desc2desc c1 c2 i d = d;

subClassStm c1 c2 sc = ss (c1. s ! Sg ++ "est" ++ "une" ++ "sous-classe" ++ "de" ++ c2.s ! Sg) ;
instStm c i = ss ((i.s ! Nom).comp ++ "est" ++ "une" ++ "instance" ++ "de" ++ c.s ! Sg) ;
formStm f = ss (f.s ! Indep ! Pos) ;


-- lindef

lindef Ind = \x -> heavyNP {s = \\_ => x ; a = agrP3 Masc Sg} ;

lindef El = \x -> heavyNP {s = \\_ => x ; a = agrP3 Masc Sg} ;

lindef Class = \x -> {s = \\n => x;
g = Masc; lock_CN =<>};

};
Loading

0 comments on commit d769dac

Please sign in to comment.