ENIAMplWordnetAnalyze.ml
2.79 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(*
* ENIAMplWordnet, a converter for Polish Wordnet "Słowosieć".
* Copyright (C) 2016-2017 Wojciech Jaworski <wjaworski atSPAMfree mimuw dot edu dot pl>
* Copyright (C) 2016-2017 Institute of Computer Science Polish Academy of Sciences
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
open ENIAMplWordnetTypes
open Xstd
(* let print_stringqmap file qmap =
StringQMap.iter qmap (fun k v ->
Printf.fprintf file "%6d %s\n" v k) *)
let print_lexical_units_field path name selector lumap =
File.file_out (path ^ name ^ ".tab") (fun file ->
let qmap = IntMap.fold lumap StringQMap.empty (fun qmap _ lu ->
StringQMap.add qmap (selector lu)) in
StringQMap.iter qmap (fun k v ->
Printf.fprintf file "%6d %s\n" v k))
let print_lexical_units_fields path lumap =
print_lexical_units_field path "pos" (fun lu -> lu.lu_pos) lumap;
print_lexical_units_field path "tagcount " (fun lu -> lu.lu_tagcount) lumap;
print_lexical_units_field path "domain" (fun lu -> lu.lu_domain) lumap;
print_lexical_units_field path "desc" (fun lu -> lu.lu_desc) lumap;
print_lexical_units_field path "workstate" (fun lu -> lu.lu_workstate) lumap;
print_lexical_units_field path "source" (fun lu -> lu.lu_source) lumap;
()
let print_lexical_units_full path lumap =
let map = IntMap.fold lumap StringMap.empty (fun map _ lu ->
StringMap.add_inc map lu.lu_pos [lu] (fun l -> lu :: l)) in
StringMap.iter map (fun pos l ->
File.file_out (path ^ pos ^ ".tab") (fun file ->
Xlist.iter l (fun lu ->
Printf.fprintf file "%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" lu.lu_id lu.lu_name lu.lu_variant lu.lu_tagcount lu.lu_domain lu.lu_desc lu.lu_workstate lu.lu_source)))
let _ =
if Array.length Sys.argv < 2 then print_endline "missing argument" else (
let lumap,synmap,lr,sr,rtmap = ENIAMplWordnet.load_data Sys.argv.(1) in
print_endline "data loaded";
(*print_lexical_units_fields "results/lufield_" lumap;*)
print_lexical_units_full "results/lu_" lumap;
ENIAMplWordnet.check_lu_syn_consistency lumap synmap;
let synmap = ENIAMplWordnet.merge_lu_syn lumap synmap in
let lumap = ENIAMplWordnet.set_lu_syn lumap synmap in
let lu_syn = PlWordnet.make_lu_syn_map synmap in
())