-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.java
executable file
·36 lines (27 loc) · 911 Bytes
/
main.java
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
import java.io.File;
import java.io.FileReader;
import java.util.Scanner;
class main{
public static void main(String[] args) throws Exception {
new main();
}
public main() throws Exception{
Scanner c = new Scanner(new FileReader(new File("google10k.txt")));
// 10 000 words in file therefore N = 10k, prob of false pos = 1%
BloomFilter bloom = new BloomFilter(10000, 0.01);
while(c.hasNext()){
bloom.add(c.next());
}
Scanner input = new Scanner(System.in);
System.out.print("Enter a word to check: ");
String in = input.nextLine();
while(!in.equalsIgnoreCase("q")){
if (bloom.contains(in))
System.out.println("Most probably contains " +in+ "!");
else
System.out.println("Does not contain");
System.out.print("\nEnter a word to check: ");
in = input.nextLine();
}
}
}