-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRankSortReducer.java
More file actions
46 lines (40 loc) · 1.4 KB
/
RankSortReducer.java
File metadata and controls
46 lines (40 loc) · 1.4 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
/*=============================================================================
| Assignment: Final Project - Multiple Document Summarization
| Author: Group7 - (Sampath, Ajay, Visesh)
| Grader: Walid Shalaby
|
| Course: ITCS 6190
| Instructor: Srinivas Akella
|
| Language: Java
| Version : 1.8.0_101
|
| Deficiencies: No logical errors.
*===========================================================================*/
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
/*
* Reducer class to sort topic terms based on term frequency.
* */
public class RankSortReducer extends Reducer<IntWritable, Text, Text, Text> {
private static final long topResults = 15; // To retrieve the top 15
// semantic terms
@Override
public void reduce(IntWritable key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
long count = 1;
// Counter to keep track of the top semantic terms.
if (context.getCounter("topTopicTerms", "topTopicTerms") != null) {
count = context.getCounter("topTopicTerms", "topTopicTerms").getValue();
}
for (Text val : values) {
if (count < topResults) {
count = count + 1;
context.getCounter("topTopicTerms", "topTopicTerms").setValue(count);
context.write(val, new Text(""));
}
}
}
}