open Xstd

let prolog_path = "/home/zil/Dokumenty/zasoby/prolog/"

let get_filenames path =
  Xlist.fold (Array.to_list (Sys.readdir path)) []
    (fun acc file -> if Xstring.check_sufix ".xml" file then acc else (path ^ "/" ^file) :: acc)

let parse_fstructure path =
  let sentence, choices, fstructure, form = XTNormalizer.load_fstructure path in
  XTXmlOf.print (path ^ ".xml") sentence choices fstructure form;
  let linear_term = XTLinearTermOf.from_lfg_term fstructure in
  print_endline (ENIAM_LCGstringOf.linear_term 0 linear_term);
  print_endline ""

let _ =
  let files = get_filenames prolog_path in
  Xlist.iter files (fun path ->
    print_endline path;
    try
      parse_fstructure path
    with
    e -> print_endline (Printexc.to_string e ^ "\n"));
  XTLinearTermOf.print_unused ();
