private void calculateTokenProbabilities(){

		BufferedReader input;
		try{
			input = new BufferedReader(new FileReader("training.txt"));
		
		
			String line = input.readLine();
			String[] toks = line.split("\\s");
			
			nbad = Integer.parseInt(toks[0]);
			//System.out.println("nbad=" + nbad);
			ngood =  Integer.parseInt(toks[1]);
			//System.out.println("ngood=" + ngood);
			
			// calculate token probabilities.
			tokenProb = new HashMap<String,Double>();
			//for(int i = 0; 0 < tokens.size(); i++){
			line = input.readLine();
			while(line != null && line.length() > 0){
				toks = line.split("\\s");
				String token = toks[0];
				//System.out.println("token=" + token);
				double b = Integer.parseInt(toks[1]);
				//System.out.println("b=" + b);
				double g = 2*(Integer.parseInt(toks[2]));
				//System.out.println("g=" + g);
				
				double prob;
				if(b+g < 5){
					prob = defaultTokenProb;
				}else{
					prob = Math.min(1.0,b/nbad) / ( Math.min(1.0, g/ngood) + Math.min(1.0, b/nbad) );
					if (prob < 0.1) prob = 0.1;
					if (prob > 0.99) prob = 0.99;
					tokenProb.put(token,prob);
				}
				line = input.readLine();
			}
			input.close();
		}catch (Exception e) {e.printStackTrace();}
	}