forked from GrammaticalFramework/gf-wordnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCatAPI.gf
More file actions
49 lines (42 loc) · 2.23 KB
/
Copy pathCatAPI.gf
File metadata and controls
49 lines (42 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
concrete CatAPI of Cat = open Prelude in {
lincat
A, A2, AP, AdA, AdN, AdV, Adv, Ant, CAdv, CN, Card, Cl, ClSlash, Comp, Conj, Det, Digits, Decimal,
IAdv, IComp, IDet, IP, IQuant, Imp, Interj, N, N2, N3, NP, Num, Numeral,
Ord, PConj, GN, SN, PN, Phr, Pol, Predet, Prep, Pron, QCl, QS, Quant, RCl, RP, RS, S, SC, SSlash,
Subj, Temp, Tense, Text, Utt, V, V2, V2A, V2Q, V2S, V2V, V3,
VA, VP, VPSlash, VQ, VS, VV, Voc, ACard, DAP, LN, MU = Term ;
oper Term = {s : Str ; f,x,swap : Str ; par : Str * Str ; flat : Bool} ;
oper mkTerm = overload {
mkTerm : Str -> Term = \f ->
{s = f ; f = f ; x,swap = [] ; par = noPar ; flat = False} ;
mkTerm : Str -> Term -> Term = \f,x ->
appTerm f (fullTerm x) ;
mkTerm : Str -> (_,_ : Term) -> Term = \f,x,y ->
appTerm f (concatTerm x y) ;
mkTerm : Str -> (_,_,_ : Term) -> Term = \f,x,y,z ->
appTerm f (fullTerm x ++ concatTerm y z) ;
mkTerm : Str -> (_,_,_,_ : Term) -> Term = \f,x,y,z,u ->
appTerm f (fullTerm x ++ fullTerm y ++ fullTerm z ++ fullTerm u) ;
mkTerm : {s:Str} -> Term = \s ->
{s = "\""++s.s++"\"" ; f = s.s ; x,swap = [] ; par = noPar ; flat = False} ;
} ;
noPar = <[],[]> ;
yesPar = <"("++SOFT_BIND,SOFT_BIND++")"> ;
appTerm : Str -> Str -> Term = \f,x -> {s = f ++ x ; f = f ; x = x ; swap = [] ; par = yesPar ; flat = False} ;
useTerm : Term -> Str = \t -> t.f ++ t.x ++ t.swap ;
fullTerm : Term -> Str = \t -> t.par.p1 ++ t.f ++ t.x ++ t.swap ++ t.par.p2 ;
flatTerm : Term -> Term = \t -> {s = t.x ; f = [] ; x = t.x ; swap = t.swap ; par = noPar ; flat = False} ;
flatIfTerm : Term -> Term = \t -> case t.flat of {
True => flatTerm t ;
False => t
} ;
mkFlat : Term -> Term = \t -> {s = t.s ; f = t.f ; x = t.x ; swap = t.swap ; par = t.par ; flat = True} ;
mkSwap : Term -> Term = \t -> {s = t.s ; f = t.f ; x = [] ; swap = t.x ; par = t.par ; flat = False} ;
mkSwapTerm : Str -> Term -> Term -> Term = \f,x,y ->
let xs = fullTerm x ; ys = fullTerm y in
{s = f ++ xs ++ ys ; f = f ; x = xs ; swap = ys ; par = yesPar ; flat = False} ;
concatTerm : Term -> Term -> Str = \t,u ->
(t.par.p1 ++ t.f ++ t.x ++ t.par.p2 ++ fullTerm u ++ t.swap) ;
hide : Str -> Str = \f -> [] ;
hideOpt : Str -> Str = \f -> [] | f ;
}