test.ml
1.93 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
let path = "data/NKJP-PodkorpusMilionowy-1.2/"
let version = "1"
(*allows printing messege to a file in results/*)
let rec write_to message file=
try
if Sys.is_directory "results/"
then
let oc = open_out_gen [Open_append; Open_creat] 511 (path^ "/" ^file) in
Printf.fprintf oc "%s\n" message;
close_out oc
with
| Sys_error _ ->
assert(Sys.command ("mkdir "^path) >= 0);
write_to message file
(*returns how much time took proc from beg*)
let time_from_of beg proc =
proc ^ " done in " ^ (string_of_float (Sys.time () -. beg)) ^ " seconds\n"
(*clears directory of current version*)
let clear_version () =
try
if Sys.is_directory ("results" ^ version ^ "/")
then Sys.command ("rm -r results" ^ version)
else 0
with
| Sys_error _ -> Sys.command ("mkdir results" ^ version ^ "/")
(*TESTING IN PROGRESS*)
let _ = clear_version ()
(*Usage of fold_text*)
let beg = Sys.time ()
let x = NKJP.fold_text path ~source:[] ~channel:[] 0 (fun x y -> write_to (NKJP.string_of_text y) "fold_text.txt"; x+1)
let () =
write_to (string_of_int x) "fold_text.txt";
print_endline (time_from_of beg "fold_text")
(*Usage of fold_segm*)
let beg = Sys.time ()
let x = NKJP.fold_segm path ~source:[] ~channel:[] 0 (fun x y -> write_to (NKJP.string_of_text y) "fold_segm.txt"; x+1)
let () =
write_to (string_of_int x) "fold_segm.txt";
print_endline (time_from_of beg "fold_segm")
(*Usage of fold_morph*)
let beg = Sys.time ()
let x = NKJP.fold_morph path ~source:[] ~channel:[] 0 (fun x y -> write_to (NKJP.string_of_text y) "fold_morph.txt"; x+1)
let () =
write_to (string_of_int x) "fold_morph.txt";
print_endline (time_from_of beg "fold_morph")
(*Usage of fold_sense*)
let beg = Sys.time ()
let x = NKJP.fold_sense path ~source:[] ~channel:[] 0 (fun x y -> write_to (NKJP.string_of_text y) "fold_sense.txt"; x+1)
let () =
write_to (string_of_int x) "fold_sense.txt";
print_endline (time_from_of beg "fold_sense")