-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicDocumentGrader.java
48 lines (44 loc) · 1.6 KB
/
BasicDocumentGrader.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
package document;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import document.BasicDocument;
public class BasicDocumentGrader {
public static void main(String[] args) {
try
{
System.out.println("Sentences, words, and syllables:");
BufferedReader br = new BufferedReader(new FileReader("test_cases/mod1TestCases.txt"));
String line;
PrintWriter out = new PrintWriter("grader_output/module1.part1.out", "utf-8");
while ((line = br.readLine()) != null)
{
BasicDocument doc = new BasicDocument(line);
String result = doc.getNumSentences() + " " + doc.getNumWords() + " " + doc.getNumSyllables() + " ";
System.out.print(result);
out.print(result);
}
out.print("\n");
out.close();
System.out.println("\nFlesch scores:");
br.close();
br = new BufferedReader(new FileReader("test_cases/mod1TestCases.txt"));
out = new PrintWriter("grader_output/module1.part2.out", "utf-8");
while ((line = br.readLine()) != null)
{
BasicDocument doc = new BasicDocument(line);
String result = doc.getFleschScore() + " ";
System.out.print(result);
out.print(result);
}
out.print("\n");
out.close();
System.out.print('\n');
br.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}