-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo_statistics.php
More file actions
121 lines (114 loc) · 3.33 KB
/
Copy pathdo_statistics.php
File metadata and controls
121 lines (114 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/* this program will get the statistics of AOL 24hour timestamp log
* under input condition.
* it alos list the url which clicks is similar with other with same query.
* if two urls clicked by the same query in a specific time t,
* and the clicks count differentis lower than 3, they will be consider as
* similar. If all day the urls are similar, the program will find it out.
* (they should not be ranking in our model)
* input format: php do_statistics.php -TB table_name [-low lower_bound] [-up upper_bound]
*/
include "statistics.php";
$para = ParameterParser($argc, $argv);
//$s = new Statistics($para);
//$s->CountQueryURLPair();
//
//$f = new NavieCluster($para);
//$f->ClusterUrlPairs();
//$f->displaySimilar();
$e = new Entropy($para);
// nonspecific query entropy in day ------------------------------------------
/*
$stdout_flag = false;
if (isset($para["o"])){
$fp = fopen($para["o"].".csv", "w");
}else{
$fp = NULL;
}
if ($fp == NULL){
printf("the output will print to the stdout\n");
$stdout_flag = true;
$fp = STDOUT;
}
$ret = $e->NonSpecificQ_DistributionInDay();
for ($i = 0.00; $i< 3.00; $i += 0.01){
$string_entropy = sprintf("%.2f", $i);
if (!isset($ret["distribution"][$string_entropy])){
fprintf($fp, "%s\t%lf\n", $string_entropy, 0);
}else{
fprintf($fp, "%s\t%lf\n", $string_entropy, $ret["distribution"][$string_entropy]["prob"]);
print_r($ret["distribution"][$string_entropy]);
}
}
if ($stdout_flag == false){
fclose($fp);
}
*/
// ------------------------------------------
// entropy in day ------------------------------------------
/*
$stdout_flag = false;
if (isset($para["o"])){
$fp = fopen($para["o"].".csv", "w");
}else{
$fp = NULL;
}
if ($fp == NULL){
printf("the output will print to the stdout\n");
$stdout_flag = true;
$fp = STDOUT;
}
$ret = $e->DistributionInDay();
for ($i = 0.00; $i< 3.00; $i += 0.01){
$string_entropy = sprintf("%.2f", $i);
if (!isset($ret["distribution"][$string_entropy])){
fprintf($fp, "%s\t%lf\n", $string_entropy, 0);
}else{
fprintf($fp, "%s\t%lf\n", $string_entropy, $ret["distribution"][$string_entropy]["prob"]);
print_r($ret["distribution"][$string_entropy]);
}
}
if ($stdout_flag == false){
fclose($fp);
}
*/
// ------------------------------------------
// entropy in hour ------------------------------------------
for ($t = 0;$t<24;$t++){
$stdout_flag = false;
if (isset($para["o"])){
$fp = fopen($para["o"].".".$t.".csv", "w");
$fp2 = fopen($para["o"].".".$t.".instance.csv", "w");
}else{
$fp = NULL;
$fp2 = NULL;
}
if ($fp == NULL){
printf("the output will print to the stdout\n");
$stdout_flag = true;
$fp = STDOUT;
$fp2 = STDOUT;
}
$ret = $e->DistributionInHour($t);
printf("time = %d\n",$t);
for ($i = 0.00; $i< 3.00; $i += 0.01){
$string_entropy = sprintf("%.2f", $i);
if (!isset($ret["distribution"][$string_entropy])){
fprintf($fp, "%s\t%lf\n", $string_entropy, 0);
}else{
fprintf($fp, "%s\t%lf\n", $string_entropy, $ret["distribution"][$string_entropy]["prob"]);
fprintf($fp2, "entropy about %s\n", $string_entropy);
$value = $ret["distribution"][$string_entropy];
fprintf($fp2, "\tclick = %d\n",$value["click"]);
foreach ($value["Q_URLs"] as $index => $subvalue){
fprintf($fp2, "\t%s\n",$index);
}
}
}
if ($stdout_flag == false){
fclose($fp);
fclose($fp2);
}
}
// ------------------------------------------
?>