freq_test.ml 509 Bytes

open Xstd

let _ =
  let l = File.load_tab "../resources/NKJP1M/NKJP1M-frequency.tab" (function
      [orth; lemma; interp; freq] -> orth, lemma, interp, int_of_string freq
    | l -> failwith ("load_frequencies: " ^ String.concat "\t" l)) in
  let qmap = Xlist.fold l StringQMap.empty (fun qmap (orth, lemma, interp, freq) ->
    let interp = List.hd (Xstring.split ":" interp) in
    StringQMap.add_val qmap (lemma ^ "\t" ^ interp) freq) in
  StringQMap.iter qmap (fun k v -> Printf.printf "%d\t%s\n" v k)