@Override
	public Alignment alignSentencePair(SentencePair sentencePair) {
		Alignment alignment = new Alignment();
		int enLength = sentencePair.getEnglishWords().size();
		int frLength = sentencePair.getFrenchWords().size();
		double[] enProbobality = new double[enLength];
		double[] frProbobality = new double[frLength];
		int[] best_e2f_index = new int[enLength];
		// e2f alignment
		for (int i = 0; i < enLength; i++) {
			String en = sentencePair.getEnglishWords().get(i);
			for (int j = 0; j < frLength; j++) {
				String fr = sentencePair.getFrenchWords().get(j);
				frProbobality[j] = f2e.getCount(fr, en)
						* getPositionProbability(i, j, enLength, frLength);
			}
			int frPosition = DoubleArrays.argMax(frProbobality);
			if (frProbobality[frPosition] < f2e.getCount(nullString, en)
					* NullPositionProbabiliy) {
				frPosition = -1;
			}
			best_e2f_index[i] = frPosition;
		}

		for (int i = 0; i < frLength; i++) {
			String fr = sentencePair.getFrenchWords().get(i);
			for (int j = 0; j < enLength; j++) {
				String en = sentencePair.getEnglishWords().get(j);
				enProbobality[j] = e2f.getCount(en, fr)
						* getPositionProbability(j, i, enLength, frLength);
			}
			int englishPosition = DoubleArrays.argMax(enProbobality);
			if (enProbobality[englishPosition] < e2f.getCount(nullString, fr)
					* NullPositionProbabiliy) {
				englishPosition = -1;
			} else if (best_e2f_index[englishPosition] != i) { // intersection
				englishPosition = -1;
			}
			alignment.addAlignment(englishPosition, i, true);
		}
		return alignment;
	}