-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConnectNGramWithSenseRelate.java
executable file
·57 lines (46 loc) · 1.97 KB
/
ConnectNGramWithSenseRelate.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
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
public class ConnectNGramWithSenseRelate {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new FileReader(args[0]));
int tIndex = 0;
int pIndex = 0;
// This will probably change soon (name and implementation)
NgramParser tnp = new NgramParser(args[1]);
ArrayList<String> triplet = tnp.getTriplet();
ArrayList<String> polarity = tnp.getPolarity();
FileWriter sw = new FileWriter(args[2]);
String line = null;
while(((line = br.readLine()) != null) && (tIndex < triplet.size()) && (pIndex < polarity.size())) {
if (line.matches("^[\\d]*:")) {
//System.out.println(line);
sw.write(line + "\n");
} else {
Scanner sc = new Scanner(line);
String trip = sc.findInLine(Pattern.compile("[a-zA-Z]+#[a-z]+[#]?[0-9]*"));
//if (trip != null && trip.equals(triplet.get(tIndex))) {
System.out.println(trip);
if (trip != null && !trip.toLowerCase().contains("no#cl")) {
//System.out.println(triplet.get(tIndex) + ":" +polarity.get(pIndex));
String pol = polarity.get(pIndex);
sw.write(line + " " + pol + "\n");
sc.close();
tIndex++;
pIndex++;
} else {
String pol = "neg";
sw.write("no#a#1" + " " + pol + "\n");
sc.close();
}
}
//sw.flush();
}
sw.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}