diff --git a/VERSION b/VERSION index f8e233b27332b4712304d3226a791d32bdd967c5..9ab8337f3962b9b8665360bffed84c5f605c2ce0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.0 +1.9.1 diff --git a/src_ocaml/grewpy.ml b/src_ocaml/grewpy.ml index eed93c12b9a4e0d2eef8b4994bd0b47643f9f55b..1c9fadb84a0129164127999e4ae3d4e036755396 100644 --- a/src_ocaml/grewpy.ml +++ b/src_ocaml/grewpy.ml @@ -24,13 +24,29 @@ let json_error msg = (* ==================================================================================================== *) let run_command request = + let config = !Global.config in let _ = Debug.log "run request >>>>%s<<<<" request in try let json = Yojson.Basic.from_string request in match json |> member "command" |> to_string_option with | None -> failwith "no 'command' in request" - (* ======================= load_graph ======================= *) + (* ======================= set_config ======================= *) + | Some "set_config" -> + begin + match json |> member "config" |> to_string_option with + | Some c -> + begin + try + Global.config := Conllx_config.build c; + Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", `Null)]) + with Conllx_error js -> + Yojson.Basic.to_string (`Assoc [("status", `String "ERROR"); ("message", js)]) + end + | None -> json_error "no 'config' in 'set_config' command" + end + + (* ======================= load_graph ======================= *) | Some "load_graph" -> begin match json |> member "filename" |> to_string_option with @@ -38,7 +54,7 @@ let run_command request = let graph = Graph.load ~config filename in let data = Graph.to_json_python ~config graph in Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", data)]) - | None -> json_error "no 'filename' in 'load_grs' command" + | None -> json_error "no 'filename' in 'load_graph' command" end (* ======================= save_graph ======================= *) diff --git a/src_ocaml/grewpy_utils.ml b/src_ocaml/grewpy_utils.ml index 407d4425f30539ee1c0700dd873a4630f2c9057b..f62562bb4dccb76cade90c0d68ecbd8809344844 100644 --- a/src_ocaml/grewpy_utils.ml +++ b/src_ocaml/grewpy_utils.ml @@ -5,7 +5,6 @@ open Libgrew module Int_map = Map.Make (struct type t=int let compare=Stdlib.compare end) -let config = Conllx_config.build "ud" exception Error of string @@ -38,6 +37,9 @@ end (* ==================================================================================================== *) module Global = struct + + let config = ref (Conllx_config.build "ud") + let debug = ref false let (caller_pid: string option ref) = ref None