-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStopwordsAsDiseaseSynonyms.java
72 lines (58 loc) · 1.96 KB
/
StopwordsAsDiseaseSynonyms.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
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
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
/**
* The StopwordsAsDiseaseSynonyms program identifies the disease concepts
* matching with English stopwords
*
*
* @author Kalpana Raja
*
*/
public class StopwordsAsDiseaseSynonyms {
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
String line="";
int count=0;
String arg1 = args[0]; //input_file -- stopwords
String arg2 = args[1]; //input_file -- disease lexicon
String arg3 = args[2]; //output_file
ArrayList<String> stopwords = new ArrayList<String>();
try {
FileInputStream fis = new FileInputStream(arg1);
InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
BufferedReader br = new BufferedReader(isr);
while((line = br.readLine()) != null) {
stopwords.add(line.toLowerCase().trim());
}
FileInputStream fis0 = new FileInputStream(arg2);
InputStreamReader isr0 = new InputStreamReader(fis0,"UTF-8");
BufferedReader br0 = new BufferedReader(isr0);
FileOutputStream fos = new FileOutputStream(arg3);
OutputStreamWriter osr = new OutputStreamWriter(fos, "UTF-8");
BufferedWriter bw = new BufferedWriter(osr);
while((line = br0.readLine()) != null) {
String[] arrLine = line.split("\t");
if(!stopwords.contains(arrLine[0].toLowerCase().trim())) continue;
bw.append(line);
bw.append("\n");
count++;
//if(count==10) break;
//if(count%1000==0) System.out.println(count);
}
br0.close();
br.close();
bw.close();
} catch(IOException e) {
System.err.println(e);
}
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
System.out.println("Execution time in milliseconds: " + elapsedTime);
}
}