|
@@ -1,6 +1,7 @@
|
1
|
1
|
import java.io.File;
|
2
|
2
|
import java.io.IOException;
|
3
|
3
|
import java.util.Scanner;
|
|
4
|
+import java.util.regex.*;
|
4
|
5
|
|
5
|
6
|
/**
|
6
|
7
|
* Created by thook on 10/7/15.
|
|
@@ -33,7 +34,66 @@ public class HamletParser {
|
33
|
34
|
}
|
34
|
35
|
|
35
|
36
|
public String getHamletData(){
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+ return hamletData;
|
|
40
|
+ }
|
|
41
|
+ //Pattern p.compile(hamletData)
|
|
42
|
+ //Matcher m = p.matcher(input);
|
|
43
|
+ //String output = m.replaceAll(hamlets with leon);
|
|
44
|
+
|
|
45
|
+ public int findName(String input) {
|
|
46
|
+ int count = 0;
|
|
47
|
+ Pattern p = Pattern.compile(input);
|
|
48
|
+ Matcher m = p.matcher(hamletData.toLowerCase());
|
|
49
|
+
|
|
50
|
+ while(m.find()){
|
|
51
|
+ count++;
|
|
52
|
+ }
|
|
53
|
+ return count;
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ public String changeLeon(String input) {
|
|
57
|
+ Pattern p = Pattern.compile(input);
|
|
58
|
+ Matcher m = p.matcher(hamletData.toLowerCase());
|
|
59
|
+ hamletData = m.replaceAll("leon");
|
|
60
|
+
|
36
|
61
|
return hamletData;
|
|
62
|
+
|
|
63
|
+
|
37
|
64
|
}
|
38
|
65
|
|
|
66
|
+ public static void main(String[] args) {
|
|
67
|
+ HamletParser h = new HamletParser();
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ public String changeTariq(String input) {
|
|
71
|
+ String s = "tArIq";
|
|
72
|
+
|
|
73
|
+ Pattern p = Pattern.compile(input);
|
|
74
|
+ Matcher m = p.matcher(hamletData.toLowerCase());
|
|
75
|
+ hamletData = m.replaceAll(s.toLowerCase());
|
|
76
|
+
|
|
77
|
+ return hamletData;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+ }
|
39
|
81
|
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+ /* int max = findName(input);
|
|
85
|
+ final String ham = "hamlet";
|
|
86
|
+ final String hor = "horatio";
|
|
87
|
+ while(max != 0) {
|
|
88
|
+
|
|
89
|
+ switch (hamletData) {
|
|
90
|
+ case ham:
|
|
91
|
+ output = "Leon";
|
|
92
|
+ break;
|
|
93
|
+ case hor:
|
|
94
|
+ output = "Tariq";
|
|
95
|
+ break;
|
|
96
|
+ }
|
|
97
|
+ max--;
|
|
98
|
+ }
|
|
99
|
+ return output;*/
|