-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitmailText.java
More file actions
52 lines (42 loc) · 1.2 KB
/
splitmailText.java
File metadata and controls
52 lines (42 loc) · 1.2 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
47
48
49
50
51
52
import java.io.*;
import java.util.*;
import edu.stanford.nlp.io.*;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.util.*;
public class splitmailText {
public static void main(String args[]) throws Exception{
if (args.length != 2){
System.out.println("Usage : splitmailText <input_file_name> <output_file_name> ");
return;
}
BufferedReader input_file = new BufferedReader(new FileReader(new File("./"+args[0])));
BufferedWriter output_file = new BufferedWriter(new FileWriter(new File("./"+args[1])));
String next_line = null;
boolean flag = false;
while((next_line = input_file.readLine())!=null)
{
StringTokenizer st = new StringTokenizer(next_line);
if (st.hasMoreTokens())
{
String first_word = st.nextToken();
if (first_word == ">" && !flag)
{
output_file.write("Separate Structure");
flag = true;
}
while (st.hasMoreTokens())
{
String next_word = st.nextToken();
if (next_word != ">")
output_file.write(next_word+" ");
}
}
output_file.write("\n");
output_file.flush();
}
input_file.close();
output_file.close();
}
}