-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemantic-clusters.html
101 lines (91 loc) · 4.91 KB
/
semantic-clusters.html
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="js/semantic-cluster.js"></script>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<link rel="stylesheet" href="css/semantic-cluster.css" type="text/css">
</head>
<body>
<a href="#" class="button" id = "expand">Expand All Nodes</a><br>
<a href="#" class="button" id = "collapse">Collapse All Nodes</a>
<div id = "main"></div>
<script type="text/javascript">
var items = [];
var treeIds = [];
var tweetsPath = "data/relevant-chrono-sort-tweets/json/";
var clustersUrl = "data/semantic-clusters-ids/json/clusters-ids.json";
//var topics = ["09", "22", "23", "36", "55", "75", "79", "88", "95", "98"];
var topics = ["003", "021", "022", "026", "042", "051", "057", "066", "068", "088"];
for (var topicNum = 0; topicNum < topics.length; topicNum ++) {
var treeId = "tree" + topicNum;
treeIds.push(treeId);
items.push("<ul class='mktree' id=" + treeId + ">");
var tweets = {};
var tweetsUrl = tweetsPath + "tweet_topic" + topics[topicNum] + ".json";
$.ajax({
url: tweetsUrl,
dataType: "text",
async: false,
success: function(json) {
var data = $.parseJSON(json);
items.push("<li class='liClosed' style='border: solid 1px; background-color:#E0E0E0'; margin-bottom: 10px><b>" + data.topicid + ":" + data.topic + "</b><ul>");
for (var i = 0, tweet; i < data.tweets.length; i++) {
tweet = data.tweets[i];
tweets[tweet.id] = tweet.text;
}
}
});
$.ajax({
url: clustersUrl,
dataType: "text",
async: false,
success: function(json) {
var data = $.parseJSON(json);
var clusters = data.topics["MB" + topics[topicNum]].clusters;
for (var i = 0; i < clusters.length; i ++) {
items.push("<div style='border: solid 1px; background-color:#99FFCC'>")
for (var j = 0; j < clusters[i].length; j ++) {
items.push("<li>" + clusters[i][j] + "\t" + tweets[clusters[i][j]] + "</li>");
}
items.push("</div>")
}
}
});
items.push("</ul></li></ul>");
}
//$.ajax({
// url: "data.json",
// dataType: "text",
// async: false,
// success: function(json) {
// var data = $.parseJSON(json);
// $.each(data.topics, function(in1, topic) {
// var treeId = "tree" + in1;
// treeIds.push(treeId);
// items.push("<ul class='mktree' id=" + treeId +">");
// items.push("<li class='liClosed' style='border: solid 1px; background-color:#E0E0E0'; margin-bottom: 10px><b>Topic: " + topic.name + "</b><ul>");
// $.each(topic.clusters.semantic, function(in2, seman) {
// items.push("<li class='liOpen' style='border: solid 1px; background-color:#99FFCC'>Semantic cluster<ul>");
// $.each(seman.jaccard, function(in3, jac) {
// items.push("<li class='liOpen' style='border: solid 1px; background-color:#FFFF99'>Jaccard cluster<ul>");
// $.each(jac.tweet, function(in4, tweet) {
// items.push("<li>" + tweet + "</li>");
// });
// items.push("</ul></li>");
// });
// items.push("</ul></li>");
// });
// $.each(topic.clusters.singleton, function(in5, single) {
// items.push("<li>" + single + "</li>");
// });
// items.push("</ul></li></ul>");
// });
// }
//});
$("#main").html(items.join(""));
$("#expand").click(function() {expandTrees(treeIds); return false;});
$("#collapse").click(function() {collapseTrees(treeIds); return false;});
</script>
</body>
</html>