### Question:
CreateCandidatesMapper implements MapFunction<ParsedWikiDocument, WikiDocumentOutput> { public static List<Integer> identifierPositions(List<Word> sentence, String identifier) { List<Integer> result = Lists.newArrayList(); for (int wordIdx = 0; wordIdx < sentence.size(); wordIdx++) { Word word = sentence.get(wordIdx); if (Objects.equals(identifier, word.getWord())) { result.add(wordIdx); } } return result; } CreateCandidatesMapper(BaseConfig config); @Override WikiDocumentOutput map(ParsedWikiDocument doc); static List<Integer> identifierPositions(List<Word> sentence, String identifier); static int closestIdentifierPosition(List<Integer> positions, int wordIdx); static int calculateMax(Multiset<String> frequencies); static List<Sentence> findSentencesWithIdentifier(List<Sentence> sentences, String identifier);  }### Answer:
@Test public void identifierPositions() { List<Word> sentence = Arrays.asList(w("Ψ", "LNK"), w("is", "VBZ"), w("the", "DT"), w("wave function", "LNK"), w(",", ","), w("i", "FW"), w("is", "VBZ"), w("the", "DT"), w("imaginary unit", "LNK"), w(",", ","), w("ħ", "NN"), w("is", "VBZ"), w("the", "DT"), w("reduced Planck constant", "LNK")); List<Integer> identifierPositions = CreateCandidatesMapper.identifierPositions(sentence, "Ψ"); assertEquals(Arrays.asList(0), identifierPositions); }
@Test public void identifierPositions_several() { List<Word> sentence = Arrays.asList(w("Ψ", "LNK"), w("is", "VBZ"), w("the", "DT"), w("wave function", "LNK"), w(",", ","), w("Ψ", "FW"), w("is", "VBZ"), w("the", "DT"), w("imaginary unit", "LNK"), w(",", ","), w("Ψ", "NN"), w("is", "VBZ"), w("the", "DT"), w("reduced Planck constant", "LNK")); List<Integer> identifierPositions = CreateCandidatesMapper.identifierPositions(sentence, "Ψ"); assertEquals(Arrays.asList(0, 5, 10), identifierPositions); }
@Test public void identifierPositions_none() { List<Word> sentence = Arrays.asList(w("p", "LNK"), w("is", "VBZ"), w("the", "DT"), w("wave function", "LNK"), w(",", ","), w("i", "FW"), w("is", "VBZ"), w("the", "DT"), w("imaginary unit", "LNK"), w(",", ","), w("ħ", "NN"), w("is", "VBZ"), w("the", "DT"), w("reduced Planck constant", "LNK")); List<Integer> identifierPositions = CreateCandidatesMapper.identifierPositions(sentence, "Ψ"); assertEquals(Collections.emptyList(), identifierPositions); }