summaryrefslogtreecommitdiff
path: root/Abel.java
diff options
context:
space:
mode:
Diffstat (limited to 'Abel.java')
-rwxr-xr-xAbel.java112
1 files changed, 112 insertions, 0 deletions
diff --git a/Abel.java b/Abel.java
new file mode 100755
index 0000000..2f1e1ff
--- /dev/null
+++ b/Abel.java
@@ -0,0 +1,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);
+ }
+}
+
+