public static void main(String[] args) throws Exception{
        String filepath = "query_test.txt";
        String dictFile = "words.txt";
        BufferedReader reader = new BufferedReader((new FileReader(filepath)));
        String line;

        ArrayList<String> topQueue1;
        ArrayList<String> topQueue2;
        ArrayList<String> topQueue3;
        ArrayList<String> sameSet;
        int i = 0;

        double precision1=0;
        double precision2=0;
        double precision3=0;
        double recall1=0;
        double recall2=0;
        double recall3=0;
        double average1=0;
        double average2=0;
        double average3=0;

        int[] positions;
        int[] counts = new int[2];

        if(args.length == 2) {
            dictFile = args[0];
            filepath = args[1];
        }
        else if(args.length == 0) {
            System.out.println("The system will using the default setting.");
            System.out.println("java Pooling words.txt query_test.txt");
        }
        else {
            System.out.println("usage: java Pooling [dictionary] [query]");
            return;
        }


        while((line = reader.readLine()) != null){
            // records the number of queries
            i++;

            // found out the same set of answers from three
            // different approximate matching techniques
            topQueue1 = N_Gram.search(line, dictFile).getCollection();
            topQueue2 = Editex.search(line, dictFile).getCollection();
            sameSet = findSameSet(topQueue1, topQueue2);
            topQueue3 = Edit_distance.search(line,dictFile).getCollection();
            sameSet = findSameSet(sameSet, topQueue3);

            // output the position of words in answers of 2-gram from same set
            positions = outputWordsPosition(topQueue1,sameSet,counts);

            // compute precision, recall, average precision
            precision1 += (double)counts[0]/12;
            recall1 += (double)counts[0]/counts[1];
            average1 += computeAP(positions,counts[1]);

            // output the position of words in answers of Editex from same set
            positions = outputWordsPosition(topQueue2,sameSet,counts);

            // compute precision, recall, average precision
            precision2 += (double)counts[0]/12;
            recall2 += (double)counts[0]/counts[1];
            average2 += computeAP(positions,counts[1]);

            // output the position of words in answers of edit-distance from same set
            positions = outputWordsPosition(topQueue3,sameSet,counts);

            // compute precision, recall, average precision
            precision3 += (double)counts[0]/12;
            recall3 += (double)counts[0]/counts[1];
            average3 += computeAP(positions,counts[1]);

        }
        System.out.println("Number of line: " + i);
        System.out.println("2-gram:");
        System.out.println("Precision: " + precision1/i);
        System.out.println("Recall: " + recall1/i);
        System.out.println("Average precision: " + average1/i);

        System.out.println();

        System.out.println("Editex:");
        System.out.println("Precision: " + precision2/i);
        System.out.println("Recall: " + recall2/i);
        System.out.println("Average precision: " + average2/i);

        System.out.println();

        System.out.println("Edit-distance:");
        System.out.println("Precision: " + precision3/i);
        System.out.println("Recall: " + recall3/i);
        System.out.println("Average precision: " + average3/i);

        reader.close();
    }