public String spellCheckConfusionMatrices(String wrong, DataSet testSet)
	{
		String correct;  
		double probability = 0.0;
	    //System.out.println("Calculating probabilites with all possible words...");
		double max = 0.0;
		// Set<String> candidates = new HashSet<String>();
		String candidate = "";
		
		//iterate over all correct words in test set
	    for (int i = 0 ; i < testSet.correctWords.size() ; i++)
		{   
			correct = testSet.correctWords.get(i); //get the ith correct word
			//probability  = bigrams.getProbability(correct);
			probability = bigWordCounts.getProbability(correct); //find probability of the correct word itself 
				
			int result[] = errorMatrices.findError(wrong, correct); //detect the type of error and the characters involved in the error
			
			//System.out.println("type of error: "+result[0]);
			
			switch(result[0])
			{
			
			case ErrorMatrices.NO_ERROR: 
			
				probability = 1; //p=1 since we have found a dictionary word 
			
			case ErrorMatrices.INSERTION: 
				//System.out.println("Candidate Word: "+correct);
				//System.out.println("p(c): "+probability);
				probability *= errorMatrices.getIProbability(result[1], result[2]);  //so far probability contained P(C),  now we mult it by P(W/C) wrt insertion
				//System.out.println("p(w/c): "+errorMatrices.getIProbability(result[1], result[2]));
				//System.out.println("p(c/w): "+probability);
				break;
			
			case ErrorMatrices.DELETION:
				//System.out.println("Candidate Word: "+correct);
				//System.out.println("p(c): "+probability);
				probability *= errorMatrices.getDProbability(result[1], result[2]); 
				//System.out.println("p(w/c): "+errorMatrices.getDProbability(result[1], result[2]));
				//System.out.println("p(c/w): "+probability);
				break;
			
			case ErrorMatrices.SUBSTITUTION:
				//System.out.println("Candidate Word: "+correct);
				//System.out.println("p(c): "+probability);
				probability *= errorMatrices.getSProbability(result[1], result[2]); 
				//System.out.println("p(w/c): "+errorMatrices.getSProbability(result[1], result[2]));
				//System.out.println("p(c/w): "+probability);
				break;
			
			case ErrorMatrices.TRANSPOSITION:
				//System.out.println("Candidate Word: "+correct);
				//System.out.println("p(c): "+probability);
				probability *= errorMatrices.getXProbability(result[1], result[2]); 
				//System.out.println("p(w/c): "+errorMatrices.getXProbability(result[1], result[2]));
				//System.out.println("p(c/w): "+probability);
				break;
			
			case ErrorMatrices.UNKNOWN_ERROR: 
				
				probability = 0; //not a single error hence should not be part of candidate set
				break;
				
			}
			
			//at this point correct is a candidate word and probability is P(C/W)
			
			if ( max < probability ) //word with probability > max found
			{
				max = probability;
				//candidates.clear();
				//candidates.add(correct);
				candidate = correct;
			}
			/* else if ( max == probability )
			{
				if(max != 0.0)
					candidates.add(correct);
			} */
			else //probability < max so can't be a candidate
			{	/*do nothing*/		}
			
		}
	    System.out.println("\nmax probability: "+max);
	    System.out.println("-----------------\nCorrect Word:\n------------------");
	    
	    /* Iterator<String> iterator = candidates.iterator();
	    while(iterator.hasNext())
	    {
	    	String candidateWord = iterator.next();
	    	System.out.println(candidateWord);
	    } */
		
	    System.out.println(candidate);
	    System.out.println("------------------");
	   	
		return candidate;
	}