From: Luca Padovani Date: Mon, 8 Nov 2004 22:07:09 +0000 (+0000) Subject: * added a few calculations X-Git-Tag: v_0_6_4_1~19 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=679063958752a96a8c63b983ea1ecf3a9074d4de;p=helm.git * added a few calculations --- diff --git a/helm/papers/use_case/stats/stats.cc b/helm/papers/use_case/stats/stats.cc index 9892e12b6..85ef8ba06 100644 --- a/helm/papers/use_case/stats/stats.cc +++ b/helm/papers/use_case/stats/stats.cc @@ -1,4 +1,5 @@ +#include #include #include @@ -12,6 +13,8 @@ unsigned n_attributes; unsigned max_attributes; unsigned max_depth; unsigned max_children; +std::vector depths; +std::vector widths; bool is_blank(const std::string& s) @@ -54,13 +57,33 @@ visit(DOM::Node node, unsigned depth) n_children++; } max_children = std::max(max_children, n_children); + + if (!node.get_firstChild()) + depths.push_back(depth); + else + widths.push_back(n_children); } void print_results(const std::string& URI) { + unsigned tot_depth = 0; + for (std::vector::const_iterator p = depths.begin(); p != depths.end(); p++) + tot_depth += *p; + + unsigned tot_width = 0; + for (std::vector::const_iterator p = widths.begin(); p != widths.end(); p++) + tot_width += *p; + std::cout << "" << std::endl; - std::cout << " " << max_depth << "" << std::endl; + std::cout << " " << std::endl; + std::cout << " " << max_depth << "" << std::endl; + std::cout << " " << tot_depth / ((double) depths.size()) << "" << std::endl; + std::cout << " " << std::endl; + std::cout << " " << std::endl; + std::cout << " " << max_children << "" << std::endl; + std::cout << " " << tot_width / ((double) widths.size()) << "" << std::endl; + std::cout << " " << std::endl; std::cout << " " << std::endl; std::cout << " " << n_elements << "" << std::endl; std::cout << " " << n_leaf_elements << "" << std::endl; @@ -73,15 +96,17 @@ print_results(const std::string& URI) std::cout << " " << n_attributes << "" << std::endl; std::cout << " " << max_attributes << "" << std::endl; std::cout << " " << std::endl; - std::cout << " " << std::endl; - std::cout << " " << max_children << "" << std::endl; - std::cout << " " << std::endl; std::cout << "" << std::endl; } int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Usage: stats " << std::endl; + return -1; + } + DOM::DOMImplementation di; DOM::Document doc = di.createDocumentFromURI(argv[1]); visit(doc, 0);