/*
 * WITExample2.java
 *
 * Created on March 24, 2006, 9:46 PM
 *
 * @author Sophie Wang
 */

import edu.cmu.cs.readweb.indri.BuildIndexFun;
import edu.cmu.cs.readweb.util.Crawler2;
import edu.cmu.cs.readweb.util.Query;
import java.io.IOException;

public class WITExample2 {
    
    static public void main(String[] args) throws IOException {
        
        String inputURL="http://www.cs.cmu.edu/~tom";
        String startDomain="http://www.cs.cmu.edu/";
        String cacheDir="WITcache";
        String indexDir="INDRIindex";
        int SEARCH_LIMIT = 100; 
        int numOfResult = 10; //return number for retrieval result.
        boolean exactMatch = true;
        boolean isAttachIndex = false; //'false': newly create entire index directory; 'true': attach index to the orignial index file
        int returnTypeCode=0; //'0': url; '1': doc; '2': snippet
        int numTokenBetween=5; //number of tokens between two strings or phases, using for two string exact match. 
        String queryString="Tom mitchell, Machine Learning";
        
        try{
            Crawler2.CrawlDomain(inputURL, startDomain, cacheDir, SEARCH_LIMIT);
            BuildIndexFun bif = new BuildIndexFun(cacheDir, indexDir, isAttachIndex);
            Query.cacheQuery(queryString, numOfResult, returnTypeCode, cacheDir, indexDir, exactMatch, numTokenBetween);
            //Query.webQuery(queryString, numOfResult, returnTypeCode, cacheDir, indexDir, exactMatch);
            
        }catch(Exception e) { e.printStackTrace(); }
        
    }
    
    
}