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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Abel {
public static void main(String args[])
{
String query = "";
String line = " ";
if (args.length == 0) {
try {
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
while(line!=null)
{
line = br.readLine();
query+= line+" isn't it.\n";
// System.out.println(line);
}
} catch (Exception e) {
System.err.println("Error:" + e.getMessage());
System.exit(1);
}
} else {
for (int i = 0; i < args.length; i++) {
query += args[i];
}
}
String[] text = query.split(" ");
String result = "";
int random = 0;
int random2 = 0;
String[] probably = {"is","was","will","did","does","will","can","would","could","might","should","I'll","you'll","he'll","she'll","they'll","it'll","I'd","you'd","he'd","she'd","they'd","it'd","that'd","that's","it's","I'm","you're","he's","she's","they're"};
String[] preProbably = {"isn't","wasn't","won't","didn't","doesn't","can't","wouldn't","shouldn't"};
String[] sounds = {"uh","oh","ah","eugh","ugh"};
String[] maybe = {"I","you","he","she","it","they","that"};
boolean found = false;
for (int i = 0; i < text.length-1; i++)
{
for(int j = 0; j < probably.length; j++)
{
if(text[i].equalsIgnoreCase(probably[j])&&!text[i-1].equals("isn't"))
{
text[i] = text[i]+" probably";
}
}
for(int k = 0; k < preProbably.length; k++)
{
if(text[i].equalsIgnoreCase(preProbably[k])&&!text[i+1].contains("it."))
{
text[i] = "probably "+text[i];
}
}
for(int l = 0; l < maybe.length; l++)
{
found = false;
if(text[i].equalsIgnoreCase(maybe[l]))
{
for(int m = 0; m < probably.length; m++)
{
if(text[i+1].equalsIgnoreCase(probably[m]))
{
found = true;
}
}
for(int n = 0; n < preProbably.length; n++)
{
if(text[i+1].equalsIgnoreCase(preProbably[n])&& found == false)
{
found = true;
}
}
if(!found)
{
text[i] = text[i]+" probably";
}
}
}
random = (int)(Math.random()*10);
random2 = (int)(Math.random()*5);
if(random==5)
{
text[i] = text[i]+", "+sounds[random2]+",";
}
if(text[i].length()>0)
{
if(text[i].charAt(text[i].length()-1)=='.'&&text[i].length()>2&&!text[i].equals("it"))
{
text[i] = text[i].substring(0,text[i].length()-3)+", isn't it.";
}
}
if(text[i].equalsIgnoreCase("text"))
{
text[i] = "texty";
}
result = result+" "+text[i];
}
if(!text[text.length-1].equals("it."))
{
text[text.length-1] = text[text.length-1].replace('.',',')+ " isn't it.";
}
result = result + " " + text[text.length-1];
System.out.println(result);
}
}
|