Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

grew_types.ml 20.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
(**********************************************************************************)
(*    Libcaml-grew - a Graph Rewriting library dedicated to NLP applications      *)
(*                                                                                *)
(*    Copyright 2011-2013 Inria, Université de Lorraine                           *)
(*                                                                                *)
(*    Webpage: http://grew.loria.fr                                               *)
(*    License: CeCILL (see LICENSE folder or "http://www.cecill.info")            *)
(*    Authors: see AUTHORS file                                                   *)
(**********************************************************************************)

open Log
open Printf

open Grew_base

type feature_name = string (* cat, num, ... *)
type feature_atom = string (* V, N, inf, ... *)
type feature_value = string (* V, 4, "free text", ... *)
type suffix = string

bguillaum's avatar
bguillaum committed
21 22 23 24 25 26 27 28 29 30 31
type value = String of string | Float of float

let string_of_value = function
  | String s -> Str.global_replace (Str.regexp "\"") "\\\""
    (Str.global_replace (Str.regexp "\\\\") "\\\\\\\\" s)
  | Float i -> String_.of_float i

let conll_string_of_value = function
  | String s -> s
  | Float i -> String_.of_float i

32 33
type disjunction = value list

bguillaum's avatar
bguillaum committed
34 35 36 37 38 39
let dot_color string =
  match (string.[0], String.length string) with
  | ('#', 4) -> sprintf "\"#%c%c%c%c%c%c\"" string.[1] string.[1] string.[2] string.[2] string.[3] string.[3]
  | ('#', 7) -> sprintf "\"%s\"" string
  | _ -> string

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
(* ================================================================================ *)
module Pid = struct
  (* type t = int *)
  type t = Pos of int | Neg of int

  let compare = Pervasives.compare

  let to_id = function
    | Pos i -> sprintf "p_%d" i
    | Neg i -> sprintf "n_%d" i

  let to_string = function
    | Pos i -> sprintf "Pos %d" i
    | Neg i -> sprintf "Neg %d" i
end (* module Pid *)

(* ================================================================================ *)
module Pid_map =
  struct
    include Map.Make (Pid)

    exception True

    let exists fct map =
      try
        iter
          (fun key value ->
            if fct key value
            then raise True
          ) map;
        false
      with True -> true

    (* union of two maps*)
    let union_map m m' = fold (fun k v m'' -> (add k v m'')) m m'
end (* module Pid_map *)

(* ================================================================================ *)
module Pid_set = Set.Make (Pid)

(* ================================================================================ *)
module Gid = struct
  type t =
    | Old of int
    | New of (int * int) (* identifier for "created nodes" *)
    | Act of (int * string)  (* identifier for "activated nodes" *)

  (* a compare function which ensures that new nodes are at the "end" of the graph *)
  let compare t1 t2 = match (t1,t2) with
    | Old o1, Old o2 -> Pervasives.compare o1 o2

    | Old _ , New _ -> -1
    | New _, Old _ -> 1
    | New n1, New n2 -> Pervasives.compare n1 n2

    | Old _ , Act _ -> -1
    | Act _, Old _ -> 1
    | Act n1, Act n2 -> Pervasives.compare n1 n2

    | Act _ , New _ -> -1
    | New _, Act _ -> 1

  let to_string = function
    | Old i -> sprintf "%d" i
    | New (i,j) -> sprintf"%d__%d" i j
    | Act (i,n) -> sprintf"%d____%s" i n
end (* module Gid *)

(* ================================================================================ *)
module Gid_map = Map.Make (Gid)

(* ================================================================================ *)
module Massoc_gid = Massoc_make (Gid)

(* ================================================================================ *)
module Massoc_pid = Massoc_make (Pid)

(* ================================================================================ *)
bguillaum's avatar
bguillaum committed
118
module Label_domain = struct
119 120 121 122 123 124 125 126 127 128
  (** describe the display style of a label *)
  type line = Solid | Dot | Dash
  type style = {
    text: string;
    bottom: bool;
    color: string option;
    bgcolor: string option;
    line: line;
  }

bguillaum's avatar
bguillaum committed
129 130
  type t = string array * style array
  let empty = ([||],[||])
131 132 133 134

  (** The [default] style value *)
  let default = { text="UNSET"; bottom=false; color=None; bgcolor=None; line=Solid }

bguillaum's avatar
bguillaum committed
135 136
  (** [decl] is the type for a label declaration: the name and a list of display styles *)
  type decl = string * string list
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

  (** Computes the style of a label from its options and maybe its shape (like I:...). *)
  let parse_option string_label options =
    let init_style = match Str.bounded_split (Str.regexp ":") string_label 2 with
      | ["S"; l] -> {default with text=l; color=Some "red"}
      | ["D"; l] -> {default with text=l; color=Some "blue"; bottom=true}
      | ["I"; l] -> {default with text=l; color=Some "grey"}
      | _ -> {default with text=string_label} in
      List.fold_left
        (fun acc_style -> function
            | "@bottom" -> {acc_style with bottom=true}
            | "@dash" -> {acc_style with line=Dash}
            | "@dot" -> {acc_style with line=Dot}
            | s when String.length s > 4 && String.sub s 0 4 = "@bg_" ->
              let color = String.sub s 4 ((String.length s) - 4) in
              {acc_style with bgcolor=Some color}
            | s -> {acc_style with color=Some (String_.rm_first_char s)}
        ) init_style options

156 157
  (* [build decl_list] returns a label_domain *)
  let build decl_list =
158 159 160
    let slist = List.sort (fun (x,_) (y,_) -> compare x y) decl_list in
    let (labels, opts) = List.split slist in
    let labels_array = Array.of_list labels in
161 162 163
    (labels_array, 
      Array.mapi (fun i opt -> parse_option labels_array.(i) opt) (Array.of_list opts)
    )
164

bguillaum's avatar
bguillaum committed
165
  let to_dep ?(deco=false) style =
166 167 168 169 170 171 172 173 174 175 176
    let dep_items =
      (if style.bottom then ["bottom"] else [])
      @ (match style.color with Some c -> ["color="^c; "forecolor="^c] | None -> [])
      @ (match style.bgcolor with Some c -> ["bgcolor="^c] | None -> [])
      @ (match style.line with
        | Dot -> ["style=dot"]
        | Dash -> ["style=dash"]
        | Solid when deco -> ["bgcolor=yellow"]
        | Solid -> []) in
    sprintf "{ label = \"%s\"; %s}" style.text (String.concat "; " dep_items)

bguillaum's avatar
bguillaum committed
177
  let to_dot ?(deco=false) style =
178
    let dot_items =
bguillaum's avatar
bguillaum committed
179
      (match style.color with Some c -> let d = dot_color c in ["color="^d; "fontcolor="^d] | None -> [])
180 181 182 183 184 185 186
      @ (match style.line with
        | Dot -> ["style=dotted"]
        | Dash -> ["style=dashed"]
        | Solid when deco -> ["style=dotted"]
        | Solid -> []) in
    sprintf "[label=\"%s\", %s]" style.text (String.concat ", " dot_items)

bguillaum's avatar
bguillaum committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
end

(* ================================================================================ *)
module Label = struct

  (** Internal representation of labels *)
  type t =
    | Global of int       (* globally defined labels: their names are in the domain *)
    | Local of int        (* locally defined labels: names array should be provided! UNTESTED *)
    | Pattern of string

  let match_ (table,_) p_label g_label = match (p_label, g_label) with
    | (Global p, Global g) when p=g -> true
    | (Pattern p, Global i) when String_.match_star_re p table.(i) -> true
    | _ -> false

  let match_list label_domain p_label_list g_label =
    List.exists (fun p_label -> match_ label_domain p_label g_label) p_label_list

  (** [to_string label_domain t] returns a string for the label *)
  let to_string (table,_) ?(locals=[||]) = function
    | Global i -> table.(i)
    | Local i -> fst locals.(i)
    | Pattern s -> s

  let to_int = function
    | Global i -> Some i
    | _ -> None

  let get_style (_,styles) = function
    | Global i -> styles.(i)
    | Local i -> Log.warning "Style of locally defined labels is not implemented"; Label_domain.default
    | Pattern _ -> Label_domain.default

  let to_dep label_domain ?(deco=false) t =
    let style = get_style label_domain t in
    Label_domain.to_dep ~deco style

  let to_dot label_domain ?(deco=false) t =
    let style = get_style label_domain t in
    Label_domain.to_dot ~deco style

229 230 231
  let from_string ?loc (table, _) ?(locals=[||]) str =
    if String.contains str '*'
    then Pattern str
232
    else
233 234 235 236
      try Global (Id.build ?loc str table)
      with Not_found (* TODO (CANNOT BE RAISED) *) ->
        try Local (Array_.dicho_find_assoc str locals)
        with Not_found -> Error.build "[Label.from_string] unknown edge label '%s'" str
237 238
end (* module Label *)

bguillaum's avatar
bguillaum committed
239 240 241 242 243 244 245
(* ================================================================================ *)
(** The module [Label_cst] defines contraints on label edges *)
module Label_cst = struct
  type t =
  | Pos of Label.t list
  | Neg of Label.t list

246 247 248
  let to_string label_domain = function
    | Pos l -> (List_.to_string (Label.to_string label_domain) "|" l)
    | Neg l -> "^"^(List_.to_string (Label.to_string label_domain) "|" l)
bguillaum's avatar
bguillaum committed
249

bguillaum's avatar
bguillaum committed
250 251
  let all = Neg []

252 253 254
  let match_ label_domain edge = function
    | Pos labels -> Label.match_list label_domain labels edge
    | Neg labels -> not (Label.match_list label_domain labels edge)
bguillaum's avatar
bguillaum committed
255

256 257 258
  let build ?loc label_domain ?locals = function
  | (edge_labels, true) -> Neg (List.sort compare (List.map (Label.from_string ?loc label_domain ?locals) edge_labels))
  | (edge_labels, false) -> Pos (List.sort compare (List.map (Label.from_string ?loc label_domain ?locals) edge_labels))
bguillaum's avatar
bguillaum committed
259 260 261
end (* module Label_cst *)


bguillaum's avatar
bguillaum committed
262
(* ================================================================================ *)
bguillaum's avatar
bguillaum committed
263
module Feature_domain = struct
bguillaum's avatar
bguillaum committed
264 265 266
  type feature_spec =
    | Closed of feature_name * feature_atom list (* cat:V,N *)
    | Open of feature_name (* phon, lemma, ... *)
bguillaum's avatar
bguillaum committed
267
    | Num of feature_name (* position *)
bguillaum's avatar
bguillaum committed
268

bguillaum's avatar
bguillaum committed
269
  type t = feature_spec list
bguillaum's avatar
bguillaum committed
270

271
  let empty = []
272

bguillaum's avatar
bguillaum committed
273 274 275 276
  let is_defined feature_name domain =
    List.exists (function
      | Closed (fn,_) when fn = feature_name -> true
      | Open fn when fn = feature_name -> true
bguillaum's avatar
bguillaum committed
277
      | Num fn when fn = feature_name -> true
bguillaum's avatar
bguillaum committed
278 279 280
      | _ -> false
    ) domain

281 282
  let rec build = function
    | [] -> [Num "position"]
bguillaum's avatar
bguillaum committed
283
    | (Num "position") :: tail -> Log.warning "[Feature_domain] declaration of the feature name \"position\" in useless"; build tail
284 285
    | (Open "position") :: _
    | (Closed ("position",_)) :: _ ->
bguillaum's avatar
bguillaum committed
286
      Error.build "[Feature_domain] The feature named \"position\" is reserved and must be types 'integer', you cannot not redefine it"
287
    | (Num fn) :: tail | (Open fn) :: tail | Closed (fn,_) :: tail when is_defined fn tail ->
bguillaum's avatar
bguillaum committed
288
      Error.build "[Feature_domain] The feature named \"%s\" is defined several times" fn
289 290
    | x :: tail -> x :: (build tail)

291 292 293 294 295 296 297 298
  let get feature_name domain =
    List.find (function
      | Closed (fn,_) when fn = feature_name -> true
      | Open fn when fn = feature_name -> true
      | Num fn when fn = feature_name -> true
      | _ -> false
    ) domain

299 300 301
  let check_feature_name ?loc domain name =
    if not (is_defined name domain)
    then Error.build ?loc "The feature name \"%s\" in not defined in the domain" name
302

303 304
  let is_open domain name =
    List.exists (function Open n when n=name -> true | _ -> false) domain
305

306
  let build_disj ?loc domain name unsorted_values =
bguillaum's avatar
bguillaum committed
307
    let values = List.sort Pervasives.compare unsorted_values in
308 309 310
    match name.[0] with
      | '_' -> List.map (fun s -> String s) values (* no check on feat_name starting with '_' *)
      | _ ->
bguillaum's avatar
bguillaum committed
311 312 313 314
        let rec loop = function
          | [] -> Error.build ?loc "[GRS] Unknown feature name '%s'" name
          | ((Open n)::_) when n = name ->
            List.map (fun s -> String s) values
bguillaum's avatar
bguillaum committed
315
          | ((Num n)::_) when n = name ->
bguillaum's avatar
bguillaum committed
316 317 318 319 320 321 322
            (try List.map (fun s -> Float (String_.to_float s)) values
            with Failure _ -> Error.build ?loc "[GRS] The feature '%s' is of type int" name)
          | ((Closed (n,vs))::_) when n = name ->
            (match List_.sort_diff values vs with
              | [] -> List.map (fun s -> String s) values
              | l when List.for_all (fun x -> x.[0] = '_') l -> List.map (fun s -> String s) values
              | l -> Error.build ?loc "Unknown feature values '%s' for feature name '%s'"
323
                  (List_.to_string (fun x->x) ", " l)
bguillaum's avatar
bguillaum committed
324 325 326
          name
            )
          | _::t -> loop t in
327
        loop domain
bguillaum's avatar
bguillaum committed
328

329 330
  let build_value ?loc domain name value =
    match build_disj ?loc domain name [value] with
bguillaum's avatar
bguillaum committed
331
      | [x] -> x
bguillaum's avatar
bguillaum committed
332
      | _ -> Error.bug ?loc "[Feature_domain.build_value]"
bguillaum's avatar
bguillaum committed
333

334 335
  let check_feature ?loc domain name value =
    ignore (build_disj ?loc domain name [value])
336

337 338
  let feature_names domain =
    Some (List.map (function Closed (fn, _) | Open fn | Num fn -> fn) domain)
339

340 341
  let sub domain name1 name2 =
    match (get name1 domain, get name2 domain) with
342 343 344 345 346
        | (_, Open _) -> true
        | (Closed (_,l1), Closed (_,l2)) -> List_.sort_include l1 l2
        | (Num _, Num _) -> true
        | _ -> false

347 348 349 350 351 352 353 354 355 356 357 358
  let build_closed feature_name feature_values =
    let sorted_list = List.sort Pervasives.compare feature_values in
    let without_duplicate =
      let rec loop = function
        | [] -> []
        | x::y::tail when x=y ->
          Log.fwarning "In the declaration of the feature name \"%s\", the value \"%s\" appears more than once" feature_name x;
          loop (y::tail)
        | x::tail -> x:: (loop tail)
      in loop sorted_list in
    Closed (feature_name, without_duplicate)

bguillaum's avatar
bguillaum committed
359
end (* Feature_domain *)
bguillaum's avatar
bguillaum committed
360

361 362 363 364
(* ================================================================================ *)
module Conll = struct
  type line = {
      line_num: int;
bguillaum's avatar
bguillaum committed
365
      num: int;
366 367 368 369 370
      phon: string;
      lemma: string;
      pos1: string;
      pos2: string;
      morph: (string * string) list;
bguillaum's avatar
bguillaum committed
371
      deps: (int * string ) list;
372 373
    }

bguillaum's avatar
bguillaum committed
374
  let root = { line_num = -1; num=0; phon="ROOT"; lemma="__"; pos1="_X"; pos2=""; morph=[]; deps=[] }
375 376 377

  let line_to_string l =
    let (gov_list, lab_list) = List.split l.deps in
bguillaum's avatar
bguillaum committed
378
    sprintf "%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s"
379 380
      l.num l.phon l.lemma l.pos1 l.pos2
      (match l.morph with [] -> "_" | list -> String.concat "|" (List.map (fun (f,v) -> sprintf "%s=%s" f v) list))
bguillaum's avatar
bguillaum committed
381 382 383 384 385 386 387 388 389 390 391 392 393
      (List_.to_string string_of_int "|" gov_list)
      (String.concat "|" lab_list)

  type range_line = {
    first: int;
    last: int;
    fusion: string;
  }

  let range_line_to_string l =
    sprintf "%d-%d\t%s\t_\t_\t_\t_\t_\t_\t_\t_" l.first l.last l.fusion

  type t = (string * string) list * line list * range_line list
394 395 396 397 398 399 400 401 402

  let parse_morph file_name line_num = function
    | "_" -> []
    | morph ->
      List.map
        (fun feat ->
          match Str.split (Str.regexp "=") feat with
            | [feat_name] -> (feat_name, "true")
            | [feat_name; feat_value] -> (feat_name, feat_value)
bguillaum's avatar
bguillaum committed
403
            | _ -> Error.build ~loc:(Loc.file_line file_name line_num) "[Conll.load] illegal morphology \n>>>>>%s<<<<<<" morph
404 405 406
        ) (Str.split (Str.regexp "|") morph)

  let underscore s = if s = "" then "_" else s
bguillaum's avatar
bguillaum committed
407

bguillaum's avatar
bguillaum committed
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
  let parse file_name lines =
    List.fold_right
      (fun (line_num, line) (acc_meta, acc_basic, acc_fusion) ->
        if line.[0] = '#'
        then
          begin
            match Str.bounded_split (Str.regexp "\\(# *\\)\\|\\( *: *\\)") line 2 with
            | [tag; value] -> ((tag, value) :: acc_meta, acc_basic, acc_fusion)
            | _ -> (acc_meta, acc_basic, acc_fusion)
          end
        else
          match Str.split (Str.regexp "\t") line with
            | [ f1; phon; lemma; pos1; pos2; morph; govs; dep_labs; _; _ ] ->
            begin
              try
                match Str.split (Str.regexp "-") f1 with
                | [f;l] -> (acc_meta, acc_basic, {first=int_of_string f; last=int_of_string l; fusion=phon}:: acc_fusion)
                | [num] ->
                  let gov_list = if govs = "_" then [] else List.map int_of_string (Str.split (Str.regexp "|") govs)
                  and lab_list = if dep_labs = "_" then [] else Str.split (Str.regexp "|") dep_labs in
                  let deps = List.combine gov_list lab_list in
                  (acc_meta, {
                    line_num = line_num;
                    num = int_of_string num;
                    phon = underscore phon;
                    lemma = underscore lemma;
                    pos1 = underscore pos1;
                    pos2 = underscore pos2;
                    morph = parse_morph file_name line_num morph;
                    deps = deps;
                  }::acc_basic, acc_fusion)
                | _ -> Error.build ~loc:(Loc.file_line file_name line_num) "[Conll.load] illegal field one >>>>>%s<<<<<<" f1
              with exc -> Error.build ~loc:(Loc.file_line file_name line_num) "[Conll.load] illegal line, exc=%s\n>>>>>%s<<<<<<" (Printexc.to_string exc) line
            end
            | l -> Error.build ~loc:(Loc.file_line file_name line_num) "[Conll.load] illegal line, %d fields (10 are expected)\n>>>>>%s<<<<<<" (List.length l) line
      ) lines ([], [], [])
444 445 446

  let load file_name =
    let lines = File.read_ln file_name in
bguillaum's avatar
bguillaum committed
447
    parse file_name lines
448

bguillaum's avatar
bguillaum committed
449
  let compare l1 l2 = Pervasives.compare l1.num l2.num
450 451 452 453 454 455 456 457 458 459
end (* module Conll *)

(* ================================================================================ *)
(* This module defines a type for lexical parameter (i.e. one line in a lexical file) *)
module Lex_par = struct

  type item = string list * string list (* first list: pattern parameters $id , second list command parameters @id *)

  type t = item list

bguillaum's avatar
bguillaum committed
460
  let size = List.length
461 462
  let append = List.append

bguillaum's avatar
bguillaum committed
463 464 465 466
  let signature = function
    | [] -> Error.bug "[Lex_par.signature] empty data"
    | (pp,cp)::_ -> (List.length pp,List.length cp)

467 468 469 470 471 472 473 474 475
  let dump t =
    printf "[Lex_par.dump] --> size = %d\n" (List.length t);
    List.iter (fun (pp,cp) ->
      printf "%s##%s\n"
        (String.concat "#" pp)
        (String.concat "#" cp)
    ) t

  let parse_line ?loc nb_p nb_c line =
bguillaum's avatar
bguillaum committed
476
    let line = String_.rm_peripheral_white line in
477 478 479
    if line = "" || line.[0] = '%'
    then None
    else
480
      let line = Str.global_replace (Str.regexp "\\\\%") "%" line in
481 482 483 484
      match Str.split (Str.regexp "##") line with
        | [args] when nb_c = 0 ->
          (match Str.split (Str.regexp "#") args with
            | l when List.length l = nb_p -> Some (l,[])
bguillaum's avatar
bguillaum committed
485
            | _ -> Error.build ?loc
486 487 488 489 490
              "Illegal lexical parameter line: \"%s\" doesn't contain %d args"
              line nb_p)
        | [args; values] ->
          (match (Str.split (Str.regexp "#") args, Str.split (Str.regexp "#") values) with
            | (lp,lc) when List.length lp = nb_p && List.length lc = nb_c -> Some (lp,lc)
bguillaum's avatar
bguillaum committed
491
            | _ -> Error.build ?loc
492 493
              "Illegal lexical parameter line: \"%s\" doesn't contain %d args and %d values"
              line nb_p nb_c)
bguillaum's avatar
bguillaum committed
494
        | _ -> Error.build ?loc "Illegal param line: '%s'" line
495

bguillaum's avatar
bguillaum committed
496 497 498 499
  let from_lines ?loc nb_p nb_c lines =
    match List_.opt_map (parse_line ?loc nb_p nb_c) lines with
    | [] -> Error.build ?loc "Empty lexical parameter list"
    | l -> l
500 501 502 503 504 505 506 507

  let load ?loc dir nb_p nb_c file =
    try
      let full_file =
        if Filename.is_relative file
        then Filename.concat dir file
        else file in
      let lines = File.read full_file in
bguillaum's avatar
bguillaum committed
508 509 510
      match List_.opt_mapi (fun i line -> parse_line ~loc:(Loc.file_line full_file i) nb_p nb_c line) lines with
      | [] -> Error.build ?loc "Empty lexical parameter file '%s'" file
      | l -> l
511 512
    with Sys_error _ -> Error.build ?loc "External lexical file '%s' not found" file

bguillaum's avatar
bguillaum committed
513
  let select index atom t =
514 515 516 517
    match
      List_.opt_map
        (fun (p_par, c_par) ->
          let par = List.nth p_par index in
bguillaum's avatar
bguillaum committed
518
          if atom = par
519
          then Some (p_par, c_par)
bguillaum's avatar
bguillaum committed
520
          else None
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
        ) t
    with
    | [] -> None
    | t -> Some t

  let get_param_value index = function
    | [] -> Error.bug "[Lex_par.get_command_value] empty parameter"
    | (params,_)::_ -> List.nth params index

  let get_command_value index = function
    | [(_,one)] -> List.nth one index
    | [] -> Error.bug "[Lex_par.get_command_value] empty parameter"
    | (_,[sing])::tail when index=0 ->
        Printf.sprintf "%s/%s"
          sing
          (List_.to_string
             (function
               | (_,[s]) -> s
               | _ -> Error.bug "[Lex_par.get_command_value] inconsistent param"
             ) "/" tail
          )
    | l -> Error.run "Lexical parameter are not functionnal"
end (* module Lex_par *)
bguillaum's avatar
bguillaum committed
544 545 546 547 548 549 550 551

(* ================================================================================ *)
module Concat_item = struct
  type t =
    | Feat of (Gid.t * feature_name)
    | String of string
end (* module Concat_item *)