function wordDistance(words, text, pos) {
        return getWordIndex(pos).then(function(prefixPos) {
            var wordScores = new Map();
            var currentWord = words[prefixPos];

            words.forEach(function(word, idx) {
                if (!word || word === currentWord) {
                    return;
                }

                var distance = Math.abs(prefixPos - idx);
                var score = words.length - distance;
                if (wordScores.contains(word)) {
                    wordScores.set(word, Math.max(score, wordScores.get(word)));
                } else {
                    wordScores.set(word, score);
                }
            });

            return wordScores;
        });
    }
Does a distance analysis of the word `prefix` at position `pos` in `doc`.
@return Map