-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestStringContains.java
executable file
·50 lines (41 loc) · 1.73 KB
/
TestStringContains.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
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
public class TestStringContains {
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)
TestNgramParser tnp = new TestNgramParser(args[1]);
ArrayList<String> triplet = tnp.getTriplet();
ArrayList<String> polarity = tnp.getPolarity();
FileWriter sw = new FileWriter("test_result.txt");
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))) {
if (trip != null) {
System.out.println(triplet.get(tIndex));
String pol = polarity.get(pIndex);
sw.write(line + " " + pol + "\n");
sc.close();
}
}
tIndex++;
pIndex++;
}
sw.flush();
sw.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}