Skip to content

Instantly share code, notes, and snippets.

@ZacBlanco
Last active March 31, 2017 18:21
Show Gist options
  • Save ZacBlanco/dfc2c037678b76ae0a516a1ce276ea6f to your computer and use it in GitHub Desktop.
Save ZacBlanco/dfc2c037678b76ae0a516a1ce276ea6f to your computer and use it in GitHub Desktop.
Driver for Little Search Engine
Hey Jude don't let me down,
You have found her now go and get her,
Remember to let her into your heart,
Then you can start to make it better.
So let it out and let it in
Hey Jude begin,
You're waiting for someone to perform with.
And don't you know that it's just you.
Hey Jude, you'll do,
The movement you need is on your shoulder.
Hey Jude, don't make it bad,
Take a sad song and make it better,
Remember to let her under your skin,
Then you'll begin to make it all better, better, better, better,
better, better, better, ah!
Na, na, na, na, na, na, na, na, na, na, na.
Hey Jude, Jude, Jude, Jude, Jude, yeah, yeah!
Na, na, na, na, na, na, na, na, na, na, na.
Hey Jude.
package search;
import java.io.*;
import java.util.*;
public class LSETester {
public static void main(String[] args) throws FileNotFoundException {
LittleSearchEngine lse = new LittleSearchEngine();
String docFile = "docs.txt"; //file containing references to all txt documents
// AliceCh1.txt
// WowCh1.txt
// books/mice.txt
// books/oedip10.txt
// books/scrlt11.txt
// books/sleep10.txt
// books/stoker-dracula-168.txt
// books/swift-gullivers-728.txt
// books/wizrd_oz.txt
// books/zenda10.txt
lse.makeIndex(docFile, "noisewords.txt"); //Index all of our documents
Scanner words = new Scanner(System.in);
lse.loadKeyWords("pohlx.txt");
lse.loadKeyWords("Tyger.txt");
lse.loadKeyWords("jude.txt");
String k1 = "", k2 = "";
while (true) {
System.out.println("Enter two keywords now. Type \":q\" for either keyword to quit");
System.out.print("Keyword 1:");
k1 = words.nextLine();
if(k1.equals(":q")) {
break;
}
System.out.print("Keyword 2:");
k2 = words.nextLine();
if(k2.equals(":q")) {
break;
}
long pre = System.nanoTime();
ArrayList<String> results = lse.top5search(k1, k2);
long post = System.nanoTime();
float seconds = (post - pre) / 1000000000f;
if(results != null){
System.out.println(results.size() + " results in " + seconds + " seconds.");
for (String s : results) {
System.out.print(s + ", ");
}
} else {
System.out.println("0 results in " + seconds + " seconds.");
}
System.out.println();
}
System.out.println("Thank you for using the Little Search Engine!");
}
}
I even tipped the bellboy a hundred and fifty dollars. I said: Do me
a favor. I've got my baggage booby-trapped.
Natch, he said, only mildly impressed by the bill and a half, even
less impressed by me.
I mean really booby-trapped. Not just a burglar alarm. Besides the
alarm, there's a little surprise on a short fuse. So what I want you
to do, if you hear the alarm go off, is come running. Right?
And get my head blown off? He slammed my bags onto the floor.
Mister, you can take your damn money and~~~
Wait a minute, friend. I passed over another hundred. Please? It's
only a shaped charge. It won't hurt anything except anybody who messes
around, see? But I don't want it to go off. So you come running when
you hear the alarm and scare him away and~~~
No! But he was less positive. I gave him two hundred more and he
said grudgingly: All right. If I hear it. Say, what's in there that's
worth all that trouble?
Tyger! Tyger! burning bright,
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?
In what distant deeps or skies
Burnt the fire in thine eyes?
On what wings dare he aspire?
What the hand dare seize the fire?
And what shoulder, and what art?
Could twist the sinews of thy heart?
And when thy heart began to beat,
What dread hand, and what dread feet?
What the hammer? What the chain?
In what furnace was thy brain?
What the anvil? What dread grasp
Dare its deadly terrors clasp?
When the stars threw down their spears,
And watered heaven with their tears,
Did he smile his work to see?
Did he who made the Lamb, make thee?
Tyger! Tyger! burning bright,
In the forests of the night,
What immortal hand or eye
Dare frame thy fearful symmetry?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment