forked from GitHub/gf-core
Added transfer example: constructing reflexives.
This commit is contained in:
15
transfer/examples/reflexive/Abstract.gf
Normal file
15
transfer/examples/reflexive/Abstract.gf
Normal file
@@ -0,0 +1,15 @@
|
||||
abstract Abstract = {
|
||||
|
||||
cat
|
||||
S ; NP ; V2 ; Conj ;
|
||||
|
||||
fun
|
||||
PredV2 : V2 -> NP -> NP -> S ;
|
||||
ReflV2 : V2 -> NP -> S ;
|
||||
ConjNP : Conj -> NP -> NP -> NP ;
|
||||
|
||||
And, Or : Conj ;
|
||||
John, Mary, Bill : NP ;
|
||||
See, Whip : V2 ;
|
||||
|
||||
}
|
||||
54
transfer/examples/reflexive/English.gf
Normal file
54
transfer/examples/reflexive/English.gf
Normal file
@@ -0,0 +1,54 @@
|
||||
concrete English of Abstract = {
|
||||
|
||||
lincat
|
||||
S = { s : Str } ;
|
||||
V2 = {s : Num => Str} ;
|
||||
Conj = {s : Str ; n : Num} ;
|
||||
NP = {s : Str ; n : Num; g : Gender} ;
|
||||
|
||||
lin
|
||||
PredV2 v s o = ss (s.s ++ v.s ! s.n ++ o.s) ;
|
||||
ReflV2 v s = ss (s.s ++ v.s ! s.n ++ self ! s.n ! s.g) ;
|
||||
-- FIXME: what is the gender of "Mary or Bill"?
|
||||
ConjNP c A B = {s = A.s ++ c.s ++ B.s ; n = c.n; g = A.g } ;
|
||||
|
||||
John = pn Masc "John" ;
|
||||
Mary = pn Fem "Mary" ;
|
||||
Bill = pn Masc "Bill" ;
|
||||
See = regV2 "see" ;
|
||||
Whip = regV2 "whip" ;
|
||||
|
||||
And = {s = "and" ; n = Pl } ;
|
||||
Or = { s = "or"; n = Sg } ;
|
||||
|
||||
param
|
||||
Num = Sg | Pl ;
|
||||
Gender = Neutr | Masc | Fem ;
|
||||
|
||||
oper
|
||||
regV2 : Str -> {s : Num => Str} = \run -> {
|
||||
s = table {
|
||||
Sg => run + "s" ;
|
||||
Pl => run
|
||||
}
|
||||
} ;
|
||||
|
||||
self : Num => Gender => Str =
|
||||
table {
|
||||
Sg => table {
|
||||
Neutr => "itself";
|
||||
Masc => "himself";
|
||||
Fem => "herself"
|
||||
};
|
||||
Pl => \\g => "themselves"
|
||||
};
|
||||
|
||||
pn : Gender -> Str -> {s : Str ; n : Num; g : Gender} = \gen -> \bob -> {
|
||||
s = bob ;
|
||||
n = Sg ;
|
||||
g = gen
|
||||
} ;
|
||||
|
||||
ss : Str -> {s : Str} = \s -> {s = s} ;
|
||||
|
||||
}
|
||||
31
transfer/examples/reflexive/reflexive.tra
Normal file
31
transfer/examples/reflexive/reflexive.tra
Normal file
@@ -0,0 +1,31 @@
|
||||
{-
|
||||
|
||||
$ ../../transferc -i../../lib reflexive.tra
|
||||
|
||||
$ gf English.gf reflexive.trc
|
||||
|
||||
> p -tr "John sees John" | at -tr reflexivize_S | l
|
||||
PredV2 See John John
|
||||
ReflV2 See John
|
||||
John sees himself
|
||||
|
||||
> p -tr "John and Bill see John and Bill" | at -tr reflexivize_S | l
|
||||
PredV2 See (ConjNP And John Bill) (ConjNP And John Bill)
|
||||
ReflV2 See (ConjNP And John Bill)
|
||||
John and Bill see themselves
|
||||
|
||||
> p -tr "John sees Mary" | at -tr reflexivize_S | l
|
||||
PredV2 See John Mary
|
||||
PredV2 See John Mary
|
||||
John sees Mary
|
||||
|
||||
-}
|
||||
|
||||
import tree
|
||||
|
||||
reflexivize : (C : Cat) -> Tree C -> Tree C
|
||||
reflexivize _ (PredV2 v s o) | eq ? (eq_Tree ?) s o = ReflV2 v s
|
||||
reflexivize _ t = composOp ? ? compos_Tree ? reflexivize t
|
||||
|
||||
reflexivize_S : Tree S -> Tree S
|
||||
reflexivize_S = reflexivize S
|
||||
21
transfer/examples/reflexive/tree.tra
Normal file
21
transfer/examples/reflexive/tree.tra
Normal file
@@ -0,0 +1,21 @@
|
||||
import prelude ;
|
||||
data Cat : Type where {
|
||||
Conj : Cat ;
|
||||
NP : Cat ;
|
||||
S : Cat ;
|
||||
V2 : Cat
|
||||
} ;
|
||||
data Tree : Cat -> Type where {
|
||||
And : Tree Conj ;
|
||||
Bill : Tree NP ;
|
||||
ConjNP : Tree Conj -> Tree NP -> Tree NP -> Tree NP ;
|
||||
John : Tree NP ;
|
||||
Mary : Tree NP ;
|
||||
Or : Tree Conj ;
|
||||
PredV2 : Tree V2 -> Tree NP -> Tree NP -> Tree S ;
|
||||
ReflV2 : Tree V2 -> Tree NP -> Tree S ;
|
||||
See : Tree V2 ;
|
||||
Whip : Tree V2
|
||||
} ;
|
||||
derive Eq Tree ;
|
||||
derive Compos Tree ;
|
||||
Reference in New Issue
Block a user