public void run(){
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try{
			String textQuery = in.readLine();
					
			while( !textQuery.equals("exit") ){
				QueryResult result;
				
				if( textQuery.contains("!") ||
					textQuery.contains("AND") ||
					textQuery.contains("OR") ){
					result = index.booleanQuery(textQuery);
				}else{
					result = index.rankedQuery(new Query(tokenProcessor.process(tokenizer.tokenize(textQuery))));
				}
				
				if( result.size() == 0 ){
					System.out.println("No results");
				}else{
					int[] ids = result.getIDs();
					double[] scores = result.getScores();
					
					for( int i = 0; i < scores.length; i++ ){
						if( id2doc != null ){
							System.out.println(id2doc.get(ids[i]));
						}else if( id2web != null ){
							WebResultData data = id2web.get(ids[i]);
							
							System.out.println(data.getTitle());
							System.out.println(data.getUrl());
							System.out.println();
						}
						else{
							System.out.print(ids[i] + ":" + scores[i] + " ");
						}
					}
				
					System.out.println();
				}
				
				
				textQuery = in.readLine();
			}
		}catch(IOException e){
			throw new RuntimeException(e.toString());
		}
	}