-
Notifications
You must be signed in to change notification settings - Fork 0
/
Summary.rb
64 lines (59 loc) · 1.32 KB
/
Summary.rb
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
module Summary
#Just pull the longest string
def self.simple_summary(clusters)
chosen_points = Array.new
for cluster in clusters
if cluster.points.length <= 2
next
end
max = 0
choice = nil
for point in cluster.points
if point.original_tweet.split.length > max
max = point.original_tweet.split.length
choice = point
end
end
chosen_points << choice
end
return chosen_points
end
def self.center_summary(clusters)
chosen_points = Array.new
for cluster in clusters
next if cluster.points.length <= 2
chosen_points << cluster.center.original_tweet
end
return chosen_points
end
def self.random_summary(input_tweets)
input_points = input_tweets.clone
fraction = 0.15
chosen_points = Array.new
summary_count = ((input_points.length)*0.15).round
summary_count.times do
chosen_points << input_points.delete(input_points.sample)
end
return chosen_points
end
def self.sentiment_summary(clusters)
chosen_points = Array.new
for cluster in clusters
next if cluster.points.length <= 2
max = 0
choice = nil
for point in cluster.points
sum = 0
for word in point.word_array
sum += word.sentiment.abs
end
if max < sum
max = sum
choice = point
end
end
chosen_points << choice
end
return chosen_points
end
end