-
Notifications
You must be signed in to change notification settings - Fork 0
/
LDAReducer.java
44 lines (38 loc) · 1.29 KB
/
LDAReducer.java
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
/*=============================================================================
| 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.BufferedReader;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
/*
* Reducer to perform LDA Topic Modelling to get a list
* of important topic terms.
* */
public class LDAReducer extends Reducer<Text, Text, Text, Text> {
@Override
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
int termFreq = 0;
StringBuffer sb = new StringBuffer("");
TextSummarizationDriver driverClass = new TextSummarizationDriver();
for (Text value : values) {
sb.append(value.toString());
}
List<String> topicList = driverClass.runLDA(sb.toString());
for (String topic : topicList) {
context.write(new Text(""), new Text(topic));
}
}
}