#include <caml/callback.h>
#include <caml/fail.h>
#include <caml/custom.h>
+
+
+#include <unistd.h>
+#include <sys/times.h>
+#include <time.h>
+#include <sys/stat.h>
+
+ struct tms t1;
+ struct tms t2;
+ double ticks = (double) sysconf(_SC_CLK_TCK)/1000;
+ void start_clock() {
+ times (&t1);
+ }
+
+
+ double stop_clock() {
+ times (&t2);
+ return (t2.tms_utime-t1.tms_utime)/ticks;
+ }
+} //extern C
-} //extern C
//#include "TextCollection/TextCollection.h"
#include "XMLDocShredder.h"
};
}
+
+
+
void traversal_rec(XMLTree* tree, treeNode id){
DocID tid;
if (id == NULLT)
CAMLreturn (str);
}
-extern "C" CAMLprim value caml_text_collection_size(value tree){
- CAMLparam1(tree);
- // CAMLreturn (Val_int( XMLTREE(tree)->CachedText.size()));
- NOT_IMPLEMENTED("text_collection_size");
- CAMLreturn (Val_unit);
-}
-
-
extern "C" CAMLprim value caml_text_collection_empty_text(value tree,value id){
CAMLparam2(tree,id);
}
extern "C" CAMLprim value caml_text_collection_count(value tree,value str){
CAMLparam2(tree,str);
- //uchar * cstr = (uchar *) String_val(str);
- NOT_IMPLEMENTED("text_collection_count");
+ uchar * cstr = (uchar *) String_val(str);
+ CAMLreturn (Val_int((XMLTREE(tree)->Count(cstr))));
CAMLreturn (Val_unit);
}
};
CAMLreturn (resarray);
}
+extern "C" CAMLprim value caml_text_collection_unsorted_contains(value tree,value str){
+ CAMLparam2(tree,str);
+ uchar * cstr = (uchar *) String_val(str);
+ std::vector<DocID> results;
+ start_clock();
+ results = XMLTREE(tree)->Contains(cstr);
+ double d = stop_clock();
+ std::cerr << "Internal timing " << d <<" ms\n";
+ CAMLreturn (Val_unit);
+}
extern "C" CAMLprim value caml_xml_tree_root(value tree){
CAMLreturn(Val_unit);
}
+extern "C" CAMLprim value caml_xml_tree_last_child(value tree, value id){
+ CAMLparam2(tree,id);
+ CAMLreturn(Val_int (XMLTREE(tree)->LastChild(TREENODEVAL(id))));
+}
+
+extern "C" CAMLprim value caml_xml_tree_is_first_child(value tree, value id){
+ CAMLparam2(tree,id);
+ CAMLreturn(Val_bool (XMLTREE(tree)->IsFirstChild(TREENODEVAL(id))));
+}
extern "C" CAMLprim value caml_xml_tree_first_child(value tree, value id){
CAMLparam2(tree,id);
CAMLparam3(tree,id,tag);
CAMLreturn(Val_int (XMLTREE(tree)->TaggedFoll(TREENODEVAL(id),(TagType) Int_val(tag))));
}
+extern "C" CAMLprim value caml_xml_tree_tagged_foll_below(value tree, value id, value tag,value root){
+ CAMLparam4(tree,id,tag,root);
+ CAMLreturn(Val_int (XMLTREE(tree)->TaggedFollBelow(TREENODEVAL(id),(TagType) Int_val(tag),TREENODEVAL(root))));
+}
extern "C" CAMLprim value caml_xml_tree_next_sibling(value tree, value id){
extern "C" CAMLprim value caml_xml_tree_prev_text(value tree, value id){
CAMLparam2(tree,id);
- CAMLlocal1(res);
CAMLreturn(Val_int((XMLTREE(tree)->PrevText(TREENODEVAL(id)))));
- CAMLreturn(res);
}
extern "C" CAMLprim value caml_xml_tree_next_text(value tree, value id){
CAMLparam2(tree,id);
#define VECT(x) ((int*) (x))
-extern "C" CAMLprim value caml_xml_tree_tagged_below(value tree, value node, value ctags, value dtags){
+extern "C" CAMLprim value caml_xml_tree_select_below(value tree, value node, value ctags, value dtags){
CAMLparam4(tree,node,ctags,dtags);
CAMLreturn (Val_int (
VECT(dtags)[0]))));
}
-extern "C" CAMLprim value caml_xml_tree_tagged_next(value tree, value node, value ctags, value ftags,value root){
+extern "C" CAMLprim value caml_xml_tree_select_next(value tree, value node, value ctags, value ftags,value root){
CAMLparam5(tree,node,ctags,ftags,root);
CAMLreturn (Val_int (
(XMLTREE(tree)->TaggedNext(TREENODEVAL(node),
TREENODEVAL(root)))));
}
-extern "C" CAMLprim value caml_xml_tree_tagged_desc_only(value tree, value node,value dtags){
+extern "C" CAMLprim value caml_xml_tree_select_desc_only(value tree, value node,value dtags){
CAMLparam3(tree,node,dtags);
CAMLreturn (Val_int (
VECT(dtags)[0]))));
}
-extern "C" CAMLprim value caml_xml_tree_tagged_foll_only(value tree, value node, value ftags,value root){
+extern "C" CAMLprim value caml_xml_tree_select_foll_only(value tree, value node, value ftags,value root){
CAMLparam4(tree,node,ftags,root);
CAMLreturn (Val_int (
(XMLTREE(tree)->TaggedFollOnly(TREENODEVAL(node),
TREENODEVAL(root)))));
}
-extern "C" CAMLprim value caml_xml_tree_tagged_desc_or_foll_only(value tree, value node, value ftags,value root){
+extern "C" CAMLprim value caml_xml_tree_select_desc_or_foll_only(value tree, value node, value ftags,value root){
CAMLparam4(tree,node,ftags,root);
CAMLreturn (Val_int (
(XMLTREE(tree)->TaggedDescOrFollOnly(TREENODEVAL(node),