From cb10072a53278e0f5c6f6ddf9679dbd9643c7f7e Mon Sep 17 00:00:00 2001 From: Huibo SHI Date: Mon, 7 Apr 2014 14:14:43 +0200 Subject: [PATCH] 1) Supprimer le module Tas car il sert a rien 2) recrire la fonction all_nodes par appeler la fonction get_descendant --- src/query_tree.ml | 1 + src/table.ml | 72 ----------------------------------------------- tests/exemple.xml | 12 ++++++++ tests/tiny3.xml | 5 +--- 4 files changed, 14 insertions(+), 76 deletions(-) create mode 100644 tests/exemple.xml diff --git a/src/query_tree.ml b/src/query_tree.ml index a818047..69f17b3 100644 --- a/src/query_tree.ml +++ b/src/query_tree.ml @@ -7,6 +7,7 @@ let table_qtree = QTreeHash.create 97 let all_nodes tree = let root = Naive_tree.root tree in let acc1 = get_descendant tree [root] in root::acc1 + let element_by_tag tree tagset kind = let dom = all_nodes tree in List.filter (fun c -> diff --git a/src/table.ml b/src/table.ml index 5876e7e..7a49b75 100644 --- a/src/table.ml +++ b/src/table.ml @@ -59,78 +59,6 @@ module QTreeHash = Hashtbl.Make(QTree) let compare_node tree a b = compare (Naive_tree.preorder tree a ) (Naive_tree.preorder tree b ) -module Tas = struct -type 'a tas = - | Vide - | Noeud of 'a tas * 'a * 'a tas - -let comp_node tree a b = (Naive_tree.preorder tree a )< (Naive_tree.preorder tree b ) - -let rec size t = - match t with - Vide -> 0 - | Noeud (t1,racine,t2) -> 1+ size t1 + size t2 - -let rec height t = - match t with - Vide -> 0 - | Noeud (t1,racine,t2) -> 1 + max (height t1) (height t2) - -let equilibre t = - let rec aux t = - match t with - Vide -> 0 - | Noeud (t1,racine,t2) -> 1 + min (aux t1) (aux t2) - in - let max_h = height t in - let min_h = aux t in - if max_h- min_h >1 then false - else true - -let is_tas t = - if not (equilibre t) then false - else - let rec aux n t = - match t with - Vide -> true - | Noeud (Vide,racine,Vide) -> racine >= n - | Noeud (t1,racine, t2) -> (aux racine t1) && (aux racine t2) - in - aux 0 t - -let rec pop tree t = - match t with - Vide -> failwith "Tas vide" - | Noeud (t1, racine, t2) -> begin - match t1,t2 with - Vide,t2 -> t2 - | t1,Vide -> t1 - | Noeud (t3,r1,t4),Noeud (t5,r2,t6) -> if comp_node tree r1 r2 then Noeud (pop tree t1, r1,t2) - else Noeud (pop tree t2, r2, t1) - end - -let rec push tree t a = - match t with - Vide -> Noeud(Vide,a,Vide) - | Noeud (t1,r,t2) -> if comp_node tree a r then Noeud (t2,a,push tree t1 r) - else Noeud(t2,r, push tree t1 a) - -let tas_of_list tree l = - List.fold_left (push tree) Vide l - -let is_empty t = (size t )== 0 - -let rec list_of_tas tree t = - match t with - Vide -> [] - | Noeud(t1,r,t2) -> r::(list_of_tas tree (pop tree t)) - -let sort_of_list tree l = - let t = tas_of_list tree l in - list_of_tas tree t - -end - let comp_node t n1 n2 = (Naive_tree.preorder t n1) < (Naive_tree.preorder t n2) diff --git a/tests/exemple.xml b/tests/exemple.xml new file mode 100644 index 0000000..d599d06 --- /dev/null +++ b/tests/exemple.xml @@ -0,0 +1,12 @@ + + +China + Beijing + + +Japan + Tokyo + + + + diff --git a/tests/tiny3.xml b/tests/tiny3.xml index 49a5ae0..641e27e 100644 --- a/tests/tiny3.xml +++ b/tests/tiny3.xml @@ -1,6 +1,3 @@ - -united states1duteous nine eighteen - -dispatch reported dotard holofernes + \ No newline at end of file -- 2.17.1