public static void main(String[] args) throws IOException {
		Map<String, URL> trainingFiles = new HashMap<>();
		
		
            File folder = new File("/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/actor/train/");
            String path = "/Users/ericzheng/Google Drive/web_app/test2/src";
            String category = "actor";
            
            String mergeNamed = category.concat("Meraged.txt");
            String mergePath = "/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/merged/";
            mergePath = mergePath.concat(mergeNamed);
            mergeFiles(folder.listFiles(),new File(mergePath));
            trainingFiles.put(category, NaiveBayesExample.class.getResource(mergePath.replace(path, "")));
            
            category = "book";
            folder = new File("/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/book/train/");
            mergeNamed = category.concat("Meraged.txt");
            mergePath = "/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/merged/";
            mergePath = mergePath.concat(mergeNamed);
            mergeFiles(folder.listFiles(),new File(mergePath));
            trainingFiles.put(category, NaiveBayesExample.class.getResource(mergePath.replace(path, "")));
            
            category = "company";
            folder = new File("/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/company/train/");
            mergeNamed = category.concat("Meraged.txt");
            mergePath = "/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/merged/";
            mergePath = mergePath.concat(mergeNamed);
            mergeFiles(folder.listFiles(),new File(mergePath));
            trainingFiles.put(category, NaiveBayesExample.class.getResource(mergePath.replace(path, "")));
            
            category = "stadium";
            folder = new File("/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/stadium/train/");
            mergeNamed = category.concat("Meraged.txt");
            mergePath = "/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/merged/";
            mergePath = mergePath.concat(mergeNamed);
            mergeFiles(folder.listFiles(),new File(mergePath));
            trainingFiles.put(category, NaiveBayesExample.class.getResource(mergePath.replace(path, "")));
            
            category = "university";
            folder = new File("/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/university/train/");
            mergeNamed = category.concat("Meraged.txt");
            mergePath = "/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/merged/";
            mergePath = mergePath.concat(mergeNamed);
            mergeFiles(folder.listFiles(),new File(mergePath));
            trainingFiles.put(category, NaiveBayesExample.class.getResource(mergePath.replace(path, "")));
            
            category = "writer";
            folder = new File("/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/writer/train/");
            mergeNamed = category.concat("Meraged.txt");
            mergePath = "/Users/ericzheng/Google Drive/web_app/test2/src/trainingdata/a/merged/";
            mergePath = mergePath.concat(mergeNamed);
            mergeFiles(folder.listFiles(),new File(mergePath));
            trainingFiles.put(category, NaiveBayesExample.class.getResource(mergePath.replace(path, "")));
            
            
            //loading examples in memory
	        Map<String, String[]> trainingExamples = new HashMap<>();
	        for(Map.Entry<String, URL> entry : trainingFiles.entrySet()) {
	            trainingExamples.put(entry.getKey(), readLines(entry.getValue()));
	        }
	        
	        //train classifier
	        NaiveBayes nb = new NaiveBayes();
	        nb.setChisquareCriticalValue(6.63); //0.01 pvalue
	        //at this point, trainingExamples as (category,one_file_content)
	        nb.train(trainingExamples);
	        
	        //get trained classifier knowledgeBase
	        NaiveBayesKnowledgeBase knowledgeBase = nb.getKnowledgeBase();
	        
	        nb = null;
	        trainingExamples = null;
	        
	        
	        //Use classifier
	        nb = new NaiveBayes(knowledgeBase);
	        
	        
	        // Start testing
	        String testPath = "/Users/ericzheng/Google Drive/web_app/test2/src/testingdata/";
	        File testedfolder = new File(testPath);
            //TODO in the future, one will be store on DB.
            LinkedList<String> testedFiles = new LinkedList<String>();
            
            //only for testing cases
            int actor = 0;
            int book = 0;
            int company = 0;
            int stadium = 0;
            int university = 0;
            int writer = 0;
            for (File fileEntry : testedfolder.listFiles()) {
            	String fileName =  fileEntry.getName();
            	//if already read before, just skip.
            	if(testedFiles.contains(fileName))
            	{
            		continue;
            	}
            	String testInput = readFile(testPath.concat(fileEntry.getName()));
            	//test file get rid of all special char but space
            	testInput = testInput.replaceAll("[^\\w\\s]+", "");
            	String testOutput= nb.predict(testInput);
            	//System.out.println(testInput);
            	//System.out.format("The sentense \"%s\" was classified as \"%s\".%n", fileName, testOutput);
            	if(testOutput.equals("actor"))
            	{
            		actor++;
            	}
            	if(testOutput.equals("book"))
            	{
            		book++;
            	}
            	if(testOutput.equals("company"))
            	{
            		company++;
            	}
            	if(testOutput.equals("stadium"))
            	{
            		stadium++;
            	}
            	if(testOutput.equals("university"))
            	{
            		university++;
            	}
            	
            	if(testOutput.equals("writer"))
            	{
            		writer++;
            	}
            	
            	//add this fileName to DB.
            	testedFiles.add(fileName);        	
            }
            System.out.println("actor is "+actor);
            System.out.println("book is "+book);
            System.out.println("company is "+company);
            System.out.println("stadium is "+stadium);
            System.out.println("university is "+university);
            System.out.println("writer is "+writer);
            
        }