1
0
forked from GitHub/gf-core

Added transfer example: constructing reflexives.

This commit is contained in:
bringert
2006-03-13 10:53:44 +00:00
parent 1814761d36
commit 6779c45f5d
4 changed files with 121 additions and 0 deletions

View 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 ;
}

View 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} ;
}

View 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

View 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 ;