ajout d'un compteur pour compter le nombre de noeuds évalués
authorHuibo SHI <shihuibo19@gmail.com>
Tue, 11 Mar 2014 21:48:11 +0000 (22:48 +0100)
committerHuibo SHI <shihuibo19@gmail.com>
Tue, 11 Mar 2014 21:48:11 +0000 (22:48 +0100)
ajout une variable boolean 'count' dans le fichier table_options.ml

src/query_tree.ml
src/query_tree.mli
src/table_driver.ml
src/table_options.ml

index c513bdb..79aee48 100644 (file)
@@ -1,6 +1,6 @@
 open Table
 
-
+let compteur = ref 0
 
 let all_nodes tree = let root = Naive_tree.root tree in
                     eval_axis tree [root] (Descendant true)
@@ -144,5 +144,6 @@ let rec eval_query_tree tree start q =
       end
   in
   debug tree q resultat;
+  compteur := !compteur + (List.length resultat);
   resultat
   
index 9afa1ad..2369eff 100644 (file)
@@ -1,3 +1,5 @@
+val compteur : int ref
+
 val all_nodes : Naive_tree.t -> Naive_tree.node list
 (** [all_nodes t] returns all the nodes in the tree [t].
     Returns an empty list if there are no nodes in the tree.
index 1f04028..d75c5df 100644 (file)
@@ -32,7 +32,11 @@ let main () =
       print_node_list doc res;
       print_string "</xml_result>\n"
     ) query_tree_list ;
-
+  
+  let _ = if !Table_options.count then 
+       Format.fprintf Format.std_formatter "there are %i nodes\n" !Query_tree.compteur;
+  in
+  
  (* let output =
     match !Options.output_file with
       | None | Some "-" | Some "/dev/stdout" -> stdout
index 22122b3..f2b0016 100644 (file)
@@ -1,15 +1,18 @@
 open Arg
 
-
+let count = ref false
 let input_file : string option ref = ref None
 let output_file : string option ref = ref None
 let queries = ref []
 
 
+
 let set_string_option r s = r := Some s 
 
 let specs = align [
+   "-c", Set count,
+        " write the number of results only";
+  "--count", Set count, " ";
   "-d", String (set_string_option input_file),
         " specify the input document file [default stdin]";
   "--doc", String (set_string_option input_file), " ";