public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException{
		
		ObjectInputStream inputStream = new ObjectInputStream(
				new BufferedInputStream(new FileInputStream(
						"D:\\darshan\\temp\\FinalIndexLexicon")));
		Lexicon lexicon = (Lexicon) inputStream
				.readObject();
		inputStream.close();
		
		Map<String,Integer> wordMap = new HashMap<String, Integer>(50000);
		Map<Integer, DocumentInfo> documentMap = new HashMap<Integer, DocumentInfo>(500000);
		
		BufferedReader fileReader = new BufferedReader( new FileReader("D:\\darshan\\temp\\WordRegistrar") );
		BufferedReader fileReader2 = new BufferedReader( new FileReader("D:\\darshan\\temp\\DocumentRegistrar") );
		
		String wordLine;
		while((wordLine = fileReader.readLine() ) != null){
			String[] split = wordLine.split("\\|@\\|");
			wordMap.put(split[0], Integer.valueOf(split[1]));
		}
		
		while((wordLine = fileReader2.readLine() ) != null){
			String[] split = wordLine.split("\\|@\\|");
			documentMap.put(Integer.valueOf(split[1]),new DocumentInfo(split[0],Integer.valueOf(split[2])));
		}
		 
		inputStream = new ObjectInputStream(
				new BufferedInputStream(new FileInputStream(
						"D:\\darshan\\temp\\IndexStatistics")));
		CorpusStatistics corpusStatistics = (CorpusStatistics) inputStream.readObject();
		
		double avgDocumentLength =( (double)corpusStatistics.getTotalPostings())/((double) corpusStatistics.getTotalDocuments());
		
		IndexReader indexReader = new IndexReader(lexicon, 2, "D:\\darshan\\temp\\FinalIndex", true);
		ConjunctiveQuery conjunctiveQuery = new ConjunctiveQuery(indexReader, lexicon, wordMap,documentMap,avgDocumentLength);
		boolean toContinue = true;
		System.out.println("Welcome to DexterV3");
		while(toContinue){
			try{
				System.out.println("Enter You Query : ");
				BufferedReader bufferReader = new BufferedReader(new InputStreamReader(System.in));
			    String string = bufferReader.readLine();
			    String[] tokens = string.split(" ");
			    int[] termIDArray = new int[0];
			    System.out.println("How many pages do you want?");
			    string = bufferReader.readLine();
			    int numberOfResults =Integer.valueOf(string);
				Long startTime = System.currentTimeMillis();
				DocumentScore[] documentScores = conjunctiveQuery.search(tokens, numberOfResults);
				Long stopTime= System.currentTimeMillis();
				
				if(documentScores.length>0){
					for(DocumentScore documentScore: documentScores){
					}
				System.out.println("Found "+documentScores.length+" matching documents in "+(stopTime-startTime)+" milliSeconds");
				System.out.println("**********************************************************************************");
				for(DocumentScore documentScore:documentScores){
					System.out.println(documentMap.get(documentScore.getDocID()).getUrl()+ "     :   "+documentScore.getScore());
				}
				}
				else
					System.out.println("Sorry No Match Found");
				System.out.println("**********************************************************************************");
				System.out.println("Do you want to try some more queries[y]?");
				string = bufferReader.readLine();
			    if(!(string.equalsIgnoreCase("yes")|| string.equalsIgnoreCase("y"))){
			    	System.out.println("Invalid Input or you chose not to query further. We cant loose customers when Google is there. We need a better gui. Where's Stave Jobs?");
			    	toContinue =false;
			    }
			    	
				
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}
		}
		
		
		
		
		
	}