Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package simulator2;
- import java.util.*;
- public class SpiderTest{
- public static void main(String[] args){
- Spider spider = new Spider();
- SpiderLeg leg = new SpiderLeg();
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the URL to search (Start with http://): "); // Sorts the 30 urls and asks the user if he wants to search more words or not or not
- do{
- String s = in.nextLine();
- System.out.println("Enter the keyword to search: ");
- String s1 = in.nextLine();
- spider.search(s, s1);
- spider.theUrls.clear();
- spider.pagesToVisit.clear();
- spider.pagesVisited.clear();
- System.out.println("\n\nEnter any number to proceed or enter another URL to search a keyword from: ");
- }
- while (!(in.hasNextInt()));
- spider.uniqueKeywords();
- String s3 = spider.keywords.get(0); // gets the most searched word
- Scanner in2 = new Scanner(System.in);
- spider.search("https://en.wikipedia.org/wiki/Dog", s3); // searches the keyword again to perform the BST operations
- BinarySearchTree bst = new BinarySearchTree();
- spider.createTree(); // creates the tree
- System.out.println("\n\nSearching by the Page Rank: ");// Searching method of a URL by its Page Rank
- System.out.println("Enter the Page Rank of the URL to search: ");
- int s2;
- do{
- s2 = in2.nextInt();
- System.out.println("\nThe URL with the entered Page Rank: ");
- spider.SearchPageRank(s2);
- System.out.println("\nEnter any number to proceed: ");
- }
- while (!(in2.hasNextInt()));
- Scanner in3 = new Scanner(System.in); // testing insertion of a url
- System.out.println("\n\nInserting a node to the BST: ");
- System.out.println("Enter the URL to add (Start with http://): ");
- String s4;
- do {
- s4 = in3.nextLine();
- System.out.println("Enter the score: ");
- s2 = in3.nextInt();
- System.out.println("Inserting... ");
- spider.insertNode(s4, s2);
- System.out.println("Enter the next URL to insert or Press any number to proceed: ");
- }while (!(in3.hasNextInt()));
- Scanner in5 = new Scanner(System.in); // tests deletion of a url
- System.out.println("finished inserting");
- System.out.println("\n\n Deleting a node from the BST: ");
- System.out.println("Enter the URL to delete (Start with http://): ");
- do {
- s4 = in5.nextLine();
- spider.deleteNode(s4);
- System.out.println("Enter the next URL to delete or Press any number to proceed:");
- } while (!(in5.hasNextInt()));
- System.out.println("Finished deleting");
- BucketSort b = new BucketSort();
- b.domainify(spider.theUrls);
- System.out.println("\n\n Starting bucket sort on the URLs with the most searched keyword: ");
- b.bucketSort(b.bucketList);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement