public void trainBernoulli() {		
		Map<String, Cluster> trainingDataSet = readFile(trainLabelPath, trainDataPath, "training");
		Map<String, Cluster> testingDataSet = readFile(testLabelPath, testDataPath, "testing");

		// do testing, if the predicted class and the gold class is not equal, increment one
		double error = 0;

		double documentSize = 0;

		System.out.println("evaluate the performance");
		for (int testKey = 1; testKey <= 20; testKey++) {
			Cluster testingCluster = testingDataSet.get(Integer.toString(testKey));
			System.out.println("Cluster: "+testingCluster.toString());

			for (Document document : testingCluster.getDocuments()) {
				documentSize += 1; 
				List<Double> classprobability = new ArrayList<Double>();
				Map<String, Integer> testDocumentWordCounts = document.getWordCount();

				for (int classindex = 1; classindex <= 20; classindex++) {
					// used for calculating the probability
					Cluster trainCluster = trainingDataSet.get(Integer.toString(classindex));
					// System.out.println(classindex + " " + trainCluster.mClassId);
					Map<String, Double> bernoulliProbability = trainCluster.bernoulliProbabilities;
					double probability = Math.log(trainCluster.getDocumentSize()/trainDocSize);
					for(int index = 1; index <= voc.size(); index++ ){

						// judge whether this word is stop word 
						boolean isStopwords = englishStopPosition.contains(index);
						if (isStopwords) continue;

						boolean contain = testDocumentWordCounts.containsKey(Integer.toString(index));						
						if (contain) {
							probability += Math.log(bernoulliProbability.get(Integer.toString(index)));
						} else {
							probability += Math.log(1 - bernoulliProbability.get(Integer.toString(index)));
						}

					}

					// put the probability into the map for the specific class
					classprobability.add(probability);
				}
				Object obj = Collections.max(classprobability);
				// System.out.println(classprobability);
				String predicte_class1 = obj.toString();
				// System.out.println(predicte_class1);
				// System.out.println(Double.parseDouble(predicte_class1));
				int index = classprobability.indexOf(Double.parseDouble(predicte_class1));
				// System.out.println(index);
				String predicte_class = Integer.toString(index + 1);


				confusion_matrix[testKey - 1][index] += 1;

				// System.out.println(document.docId + ": G, " + testKey + "; P: " + predicte_class);
				if (!predicte_class.equals(Integer.toString(testKey))) {
					error += 1;
				}

			}

			System.out.println("the error is " + error + "; the document size : " + documentSize);
		}

		System.out.println("the error is " + error + "; the document size : " + documentSize + " precision rate : " + (1 - error/documentSize));

		// print confusion matrix
		printConfusionMatrix(confusion_matrix);
	}