}
/* See Javadoc for LexicalProbabilities#getSourceGivenTargetAlignments(Pattern,Pattern). */
public AlignmentGrid getSourceGivenTargetAlignments(Pattern sourcePattern, Pattern targetPattern) {
SymbolTable sourceVocab = getSourceVocab();
SymbolTable targetVocab = getTargetVocab();
StringBuilder alignmentPoints = new StringBuilder();
for (IndexedInt indexedSource : Lists.eachWithIndex(sourcePattern.getWordIDs())) {
int sourceWord = indexedSource.getValue();
int sourceIndex = indexedSource.getIndex();
if (sourceVocab.isNonterminal(sourceWord)) {
//TODO Do something special here
} else {
float max = sourceGivenTarget(sourceWord, null);
Integer bestTargetIndex = null;
for (IndexedInt indexedTarget : Lists.eachWithIndex(targetPattern.getWordIDs())) {
int targetWord = indexedTarget.getValue();
int targetIndex = indexedTarget.getIndex();
if (! targetVocab.isNonterminal(targetWord)) {
float score = this.sourceGivenTarget(sourceWord, targetWord);
if (score > max) {
max = score;
bestTargetIndex = targetIndex;
}