This repository was archived by the owner on Jul 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTester.java
More file actions
65 lines (52 loc) · 1.92 KB
/
Tester.java
File metadata and controls
65 lines (52 loc) · 1.92 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
import javax.swing.*;
import java.awt.Font;
public class Tester {
private JFrame frame;
private JTable table;
private JScrollPane sp;
private Font font;
public Tester() {
for (String fileName : new String[] {"Gettysburg.txt", "test-6th-grader.txt", "test-college-grad.txt"}) {
System.out.println("\n" + (new TextAnalyzer("test_files\\" + fileName)).toString());
}
font = new Font("Tahome", Font.PLAIN, 18);
frame = new JFrame();
frame.setSize(1250, 500);
frame.setTitle("Text Analyzer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object data[][] = new Object[17][3 + ScoringIndex.values().length];
int shift = 0;
for (String fileName : new String[] {"Gettysburg.txt", "test-6th-grader.txt", "test-college-grad.txt"}) {
TextAnalyzer analyze = new TextAnalyzer("test_files\\" + fileName);
data[shift][0] = fileName;
data[shift + 1][0] = "# of Characters:";
data[shift + 2][0] = "# of Syllables:";
data[shift + 3][0] = "# of Words:";
data[shift + 4][0] = "# of Sentences:";
data[shift + 1][1] = analyze.countCharacters();
data[shift + 2][1] = analyze.countSyllables();
data[shift + 3][1] = analyze.countWords();
data[shift + 4][1] = analyze.countSentences();
data[shift + 1][2] = "Score:";
data[shift + 2][2] = "Level:";
int shiftScorer = 3;
for (ScoringIndex v : ScoringIndex.values()) {
ReadabilityScorer scorer = analyze.getReadabilityScorer(v);
data[shift + 1][shiftScorer] = (int) scorer.getReadabilityScore();
data[shift + 2][shiftScorer] = scorer.getReadingLevel();
++shiftScorer;
}
shift += 6;
}
table = new JTable(data, new Object[] {"", "Stats", "", "Flesch", "Smog", "Gunning Fog", "Automated"});
table.setFont(font);
table.getTableHeader().setFont(font);
table.setRowHeight(30);
sp = new JScrollPane(table);
frame.add(sp);
frame.setVisible(true);
}
public static void main(String[] args) {
new Tester();
}
}