-
Notifications
You must be signed in to change notification settings - Fork 0
/
workFlow.php
61 lines (48 loc) · 1.42 KB
/
workFlow.php
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
<?PHP
ini_set("memory_limit","80M");
include($_SERVER['DOCUMENT_ROOT'] . '/IOlab-project-03/search.php');//includes searchResults() function
include($_SERVER['DOCUMENT_ROOT'] . '/IOlab-project-03/sentiment.php');//includes other necesary functions
//assignSentiment(), binData, usort() {for sorting by time},
//get_data_from_file(), write_to_file()
$hash = array(/*"#ModernFamily", "#NewGirl", "#30Rock", "#HIMYM", "#TheWalkingDead", "#bones", "#CriminalMinds", "#DWTS", "#TheVoice", "#MythBusters",*/ "#familyguy", "#SouthPark");
foreach($hash as $item)
{
$count = 0;
$query = $item;
$date = strftime("%F");
$date = strftime("%F", strtotime("-1 day", strtotime($date)));
$tweets = 1;
$data_file = $query .".txt";
$json_file = $query .".json";
var_dump($date);
echo "<br><br>";
while(!empty($tweets) && $count < 10)
{
$tweets = searchResults($query, $date);
echo count($tweets);
echo "<br><br>";
if(!empty($tweets))
{
$sentimentized = assignSentiment($tweets);
echo count($sentimentized);
echo "<br><br>";
write_to_file($data_file, $sentimentized);
//break;
}
sleep(0.5);
$date = strftime("%F", strtotime("-1 day", strtotime($date)));
echo $date;
echo "<br><br>";
$count++;
}
$data = get_data_from_file($data_file);
echo count($data);
$result = binData($data);
convert2Json($json_file, $result);
foreach($result as $row)
{
print_r($row);
echo "<br>";
}
}
?>