Commit e17dc7b2 authored by Bruno Guillaume's avatar Bruno Guillaume
Browse files

Change json representation for Projection ("freq" is outside the features list)

parent 2083f127
......@@ -244,13 +244,13 @@ module Projection = struct
let to_json keys t =
let rec loop acc keys partial t =
match (keys, t) with
| ([], Leaf n) -> (`Assoc (List.rev (("freq", `Int n) :: partial))) :: acc
| ([], Leaf n) -> (`Assoc ["feats", (`Assoc (List.rev partial)); "freq", `Int n]) :: acc
| (key :: tail, Node map) ->
String_opt_map.fold
(fun value sub_t acc2 ->
let new_partial = (key, match value with Some s -> `String s | _ -> `Null) :: partial in
loop acc2 tail new_partial sub_t
) map acc
| _ -> Error.bug "[Projection.to_json] inconsitent data" in
| _ -> Error.bug "[Projection.to_json] inconsistent data" in
`List (loop [] keys [] t)
end
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment