-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource_to_Sentence_Splitter.java
More file actions
83 lines (55 loc) · 1.68 KB
/
Source_to_Sentence_Splitter.java
File metadata and controls
83 lines (55 loc) · 1.68 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class SentenceSpliter {
public static void main(String[] args) throws IOException {
File dir = new File("");
String str = "", text = "";
List<String> enSentences = new ArrayList<String>();
List<String> urSentences = new ArrayList<String>();
List<String> urWords = new ArrayList<String>();
for(File file : dir.listFiles()){
if(file.getName().endsWith("urdu.txt")){
BufferedReader br = new BufferedReader(new FileReader(file));
while((str = br.readLine()) != null){
text = text + " " + str.trim();
}
br.close();
for(String s:text.split("[؟۔!]"))
urSentences.add(s);
System.out.println(file.getName() + " = " + urSentences.size());
for(int i=0;i<enSentences.size();i++)
System.out.println(enSentences.get(i) + "\n" + urSentences.get(i));
FileWriter writer_en = new FileWriter("");
for(String s: enSentences) {
s = s.trim();
writer_en.write(s.trim() + " ." + "\n");
}
writer_en.close();
FileWriter writer_ur = new FileWriter("");
for(String s: urSentences) {
s = s.trim();
writer_ur.write(s.trim() + " ۔" + "\n");
}
writer_ur.close();
System.exit(0);
}
if(file.getName().endsWith("english.txt")){
BufferedReader br = new BufferedReader(new FileReader(file));
while((str = br.readLine()) != null){
text = text + " " + str.trim();
}
br.close();
for(String s:text.split("[.?!]"))
enSentences.add(s);
System.out.println(file.getName() + " = " + enSentences.size());
}
text = "";
}
}
}