lexicon.ml 1.15 KB
Newer Older
huet's avatar
huet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
(**************************************************************************)
(*                                                                        *)
(*                 The Zen Computational Linguistics Toolkit              *)
(*                                                                        *)
(*                              Grard Huet                               *)
(*                                                                        *)
(* 2002 Institut National de Recherche en Informatique et en Automatique *)
(**************************************************************************)

(*i Trie lexicon building for ascii words. i*)

(*i module Lexicon = struct i*)

(* [make_lex] raises [Redundancy] if duplicate elements in its argument. *)

(* [make_lex : list string -> trie] *)
value make_lex = 
  List.fold_left (fun lex c -> Trie.enter lex (Ascii.encode c)) Trie.empty
;

(* [strings_of : trie -> list string] *)
value strings_of t = List.map Ascii.decode (Trie.contents t)
;

(* [strings_of (make_lex l)] gives [l] in lexicographic order. *)
   
assert (strings_of (make_lex [ "a"; "b"; "ab" ]) = [ "a"; "ab"; "b" ])
;

(*i end; i*)