Skip to content

Commit 5e16dac

Browse files
committed
Add missing csv header
1 parent 6a6eb5b commit 5e16dac

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/smtml/feature_extraction.ml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ let cmd directory output_csv =
467467
let res : ((unit, [> Rresult.R.msg ]) result, [> Rresult.R.msg ]) result =
468468
Bos.OS.File.with_oc output_csv
469469
(fun oc entries ->
470+
Out_channel.output_string oc
471+
(String.cat (String.concat "," final_names) "\n");
470472
List.iter
471473
(fun (solver_name, exprs, model, t) ->
472474
if not (List.is_empty exprs) then
@@ -490,3 +492,34 @@ let cmd directory output_csv =
490492
match Rresult.R.join res with
491493
| Error (`Msg m) -> Fmt.failwith "%s" m
492494
| Ok () -> Fmt.pr "Done writing to %a\n%!" Fpath.pp output_csv
495+
496+
(* let cmd directory output_csv =
497+
let directory = Fpath.to_string directory in
498+
let output_csv = Fpath.to_string output_csv in
499+
let entries = read_marshalled_file directory in
500+
let oc = open_out output_csv in
501+
502+
(* en-tête CSV *)
503+
output_string oc (String.concat "," final_names ^ "\n");
504+
505+
List.iter
506+
(fun (solver_name, exprs, model, t) ->
507+
if not (List.is_empty exprs) then
508+
let feats = extract_feats_wtime exprs t in
509+
let row =
510+
List.map
511+
(fun name ->
512+
if String.equal name "solver" then solver_name
513+
else if String.equal name "model" then Bool.to_string model
514+
else
515+
let count = StringMap.find_def0 name feats in
516+
string_of_int count )
517+
final_names
518+
in
519+
let row = String.concat "," row ^ "\n" in
520+
(* Fmt.epr "pp row: %s@." row; *)
521+
output_string oc row )
522+
entries;
523+
524+
close_out oc;
525+
Fmt.pr "Done writing to %s\n%!" output_csv *)

0 commit comments

Comments
 (0)