|
@@ -1,13 +1,19 @@
|
|
1
|
+import com.sun.tools.doclets.formats.html.SourceToHTMLConverter;
|
|
2
|
+
|
1
|
3
|
import java.io.File;
|
2
|
4
|
import java.io.IOException;
|
3
|
5
|
import java.util.Scanner;
|
|
6
|
+import java.util.regex.Matcher;
|
|
7
|
+import java.util.regex.Pattern;
|
4
|
8
|
|
5
|
9
|
/**
|
6
|
10
|
* Created by thook on 10/7/15.
|
7
|
11
|
*/
|
8
|
12
|
public class HamletParser {
|
9
|
13
|
|
|
14
|
+ private HamletParser hamletParser;
|
10
|
15
|
private String hamletData;
|
|
16
|
+ private String inputText;
|
11
|
17
|
|
12
|
18
|
public HamletParser(){
|
13
|
19
|
this.hamletData = loadFile();
|
|
@@ -32,8 +38,71 @@ public class HamletParser {
|
32
|
38
|
return result.toString();
|
33
|
39
|
}
|
34
|
40
|
|
|
41
|
+ public boolean findHoratio(String inputText){
|
|
42
|
+ if (inputText.contains("HORATIO") || inputText.contains("Horatio"));
|
|
43
|
+ return true;
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ public boolean findHamlet(String inputText){
|
|
47
|
+ if (inputText.contains("HAMLET") || inputText.contains("Hamlet"));
|
|
48
|
+ return true;
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ public String changeHoratioToTariq(String inputText){
|
|
52
|
+
|
|
53
|
+ String str = inputText;
|
|
54
|
+ Pattern p = Pattern.compile("\\bHoratio\\b");
|
|
55
|
+ Matcher m = p.matcher(str);
|
|
56
|
+ String capital = m.replaceAll("Tariq");
|
|
57
|
+
|
|
58
|
+ String lower = capital;
|
|
59
|
+ Pattern p2 = Pattern.compile("\\bHORATIO\\b");
|
|
60
|
+ Matcher m2 = p2.matcher(lower);
|
|
61
|
+ String result = m2.replaceAll("TARIQ");
|
|
62
|
+ return result;
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ public String changeHamletToLeon(String inputText){
|
|
66
|
+
|
|
67
|
+ String str = inputText;
|
|
68
|
+ Pattern p = Pattern.compile("\\bHamlet\\b");
|
|
69
|
+ Matcher m = p.matcher(str);
|
|
70
|
+ String capital = m.replaceAll("Leon");
|
|
71
|
+
|
|
72
|
+ String lower = capital;
|
|
73
|
+ Pattern p2 = Pattern.compile("\\bHAMLET\\b");
|
|
74
|
+ Matcher m2 = p2.matcher(lower);
|
|
75
|
+ String result = m2.replaceAll("LEON");
|
|
76
|
+ return result;
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ public String changeBothNames(String inputText){
|
|
80
|
+ String str = inputText;
|
|
81
|
+ Pattern p = Pattern.compile("\\bHoratio\\b");
|
|
82
|
+ Matcher m = p.matcher(str);
|
|
83
|
+ String capital = m.replaceAll("Tariq");
|
|
84
|
+
|
|
85
|
+ String lower = capital;
|
|
86
|
+ Pattern p2 = Pattern.compile("\\bHORATIO\\b");
|
|
87
|
+ Matcher m2 = p2.matcher(lower);
|
|
88
|
+ String resultOne = m2.replaceAll("TARIQ");
|
|
89
|
+
|
|
90
|
+ String hamBoy = resultOne;
|
|
91
|
+ Pattern p3 = Pattern.compile("\\bHamlet\\b");
|
|
92
|
+ Matcher m3 = p3.matcher(hamBoy);
|
|
93
|
+ String ham1 = m3.replaceAll("Leon");
|
|
94
|
+
|
|
95
|
+ String ham2 = ham1;
|
|
96
|
+ Pattern p4 = Pattern.compile("\\bHAMLET\\b");
|
|
97
|
+ Matcher m4 = p4.matcher(ham2);
|
|
98
|
+ String result = m4.replaceAll("LEON");
|
|
99
|
+ return result;
|
|
100
|
+
|
|
101
|
+ }
|
|
102
|
+
|
35
|
103
|
public String getHamletData(){
|
36
|
104
|
return hamletData;
|
37
|
105
|
}
|
38
|
106
|
|
39
|
|
-}
|
|
107
|
+
|
|
108
|
+ }
|