forked from ekaf/wordnet-prolog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwn2csv.pl
40 lines (33 loc) · 745 Bytes
/
wn2csv.pl
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
/*
# https://github.com/ekaf/wordnet-prolog/raw/master/wn2csv.pl
(c) 2020 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/
SWI-prolog program to convert all WordNet databases to comma-separated CSV files
*/
:-consult('wn_load.pl').
pred2file(P):-
atom_concat('csv/wn_',P,C1),
atom_concat(C1,'.csv',C),
writef('Writing %w\n',[C]),
tell(C).
list2csv([A],S0,S2):-
swritef(S2,'%w%q',[S0,A]).
list2csv([A,B|T],S0,S2):-
swritef(S1,'%w%q,',[S0,A]),
list2csv([B|T],S1,S2).
out2csv(P):-
wnpred_arity(P,A), length(L,A),
apply(P,L),
list2csv(L,'',S),
write(S), nl,
false.
out2csv(_):-
told.
convert_wn:-
allwn(L),
member(P,L),
pred2file(P),
out2csv(P),
false.
convert_wn:-
nl.
:-convert_wn.