<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,25 +3,10 @@ open Inference
 open Builder
 
 let vocabulary =
-    (* define few liguistic variables and register them *)
-    let voc = Vocabulary.create () in
-    let _ = Vocabulary.set
-        voc
-        &quot;BIG&quot;
-        (FuzzySet.create_triangle 5.0 15.0)
-    in
-    let _ = Vocabulary.set
-        voc
-        &quot;FAST&quot;
-        (FuzzySet.create_triangle 90.0 110.0)
-    in
-    voc
-    (* TODO complete the parser for vocabulary
-    Builder.vocabulary_from_string &quot;
+    Builder.voc_from_string &quot;
         DEF BIG  TRIANGLE 5.0 15.0
         DEF FAST TRIANGLE 90 110
     &quot;
-    *)
 
 let create_model voc =
     let rules = Builder.rules_from_string voc &quot;</diff>
      <filename>example/ex2.ml</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,29 @@ let rules_from_string voc s =
     List.map (to_rule voc) (rule_ast_from_string s)
 
 
+let _ = Vocabulary.register_creator
+    &quot;TRIANGLE&quot;
+    (fun l -&gt; match l with
+        | i1::i2::[] -&gt; FuzzySet.create_triangle i1 i2
+        | _ -&gt; failwith &quot;creator TRIANGLE expect 2 float arguments&quot;
+    )
+
+
+let to_var voc t = match t with
+    | DefByFun (Symb s, Symb def, nums) -&gt;
+        let c = Vocabulary.find_creator def in
+        Vocabulary.set voc s (c nums)
+    | DefByPoints (Symb s, points) -&gt;
+        Vocabulary.set voc s (FuzzySet.create points)
+
 let voc_ast_from_string s =
     let lexbuf = Lexing.from_string s in
     Parser.vocabulary Lexer.voc_tokens lexbuf
 
+let voc_from_string s =
+    let voc = Vocabulary.create () in
+    List.iter
+        (to_var voc)
+        (voc_ast_from_string s)
+    ; voc
+</diff>
      <filename>fuzlog/builder.ml</filename>
    </modified>
    <modified>
      <diff>@@ -81,6 +81,15 @@ end (* module Var *)
 
 module Vocabulary = struct
     
+    let creators = Hashtbl.create 5
+
+    let register_creator (name:string) (creator:(float list -&gt; FuzzySet.t)) =
+        Hashtbl.replace creators name creator
+
+    let find_creator name =
+        Hashtbl.find creators name
+
+
     type t = {
         vars: (string, Var.t) Hashtbl.t;
     }
@@ -96,6 +105,9 @@ module Vocabulary = struct
         let var = Var.create symb value in
         Hashtbl.replace voc.vars symb var
 
+    let length voc =
+        Hashtbl.length voc.vars
+
 end (* module Vocabulary *)
 
 </diff>
      <filename>fuzlog/inference.ml</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,14 @@ let _ = Tests.register &quot;Build AST for vocabulary&quot; (fun () -&gt;
     OUnit.assert_bool &quot;Not expected AST for vocabulary&quot; result
 )
 
+let _ = Tests.register &quot;Build voc&quot; (fun () -&gt;
+    let voc = Builder.voc_from_string &quot;
+        DEF BIG  TRIANGLE 5.0 15.0
+        DEF SMURGL [ (1 0.1) (2 0.4) ]
+    &quot; in
+    OUnit.assert_equal 2 (Vocabulary.length voc)
+)
+
 let _ = Tests.register &quot;Build AST for rules&quot; (fun () -&gt;
     let nodes = Builder.rule_ast_from_string &quot;
         IF in10 IS big THEN ou10 IS fast</diff>
      <filename>test/builderTest.ml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3d1d4baea69438d9a9434078da0d2bd74067a9dd</id>
    </parent>
  </parents>
  <author>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </author>
  <url>http://github.com/khigia/ocaml-fuzlog/commit/cf8effd33eb21ef62ed770c03a6f236ba0ee49ef</url>
  <id>cf8effd33eb21ef62ed770c03a6f236ba0ee49ef</id>
  <committed-date>2008-04-10T06:21:55-07:00</committed-date>
  <authored-date>2008-04-10T06:21:55-07:00</authored-date>
  <message>Basic grammar to define vocabulary (named fuzzy set).</message>
  <tree>d8dd4fdfff4e31488f6836b1fe4e24d4e5254ee2</tree>
  <committer>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </committer>
</commit>
