### Question:
TextAnnotatorMapper extends RichMapFunction<RawWikiDocument, ParsedWikiDocument> { @Override public ParsedWikiDocument map(RawWikiDocument doc) { LOGGER.info("processing \"{}\"...", doc.title); final ParsedWikiDocument parse = parse(doc.text, doc.title); LOGGER.debug("identifiers in \"{}\" from {} formulas: {}", doc.title, parse.getFormulas().size(), parse.getIdentifiers()); return parse; } TextAnnotatorMapper(BaseConfig config); @Override void open(Configuration cfg); @Override ParsedWikiDocument map(RawWikiDocument doc); ParsedWikiDocument parse(String wikitext, String title); ParsedWikiDocument parse(String wikitext);  }### Answer:
@Test public void test() throws Exception { final String mathMLExtract = WikiTextUtilsTest.getTestResource("com/formulasearchengine/mathosphere/mlp/schrödinger_eq.xml").trim(); List<RawWikiDocument> docs = readWikiTextDocuments("com/formulasearchengine/mathosphere/mlp/augmentendwikitext.xml"); RawWikiDocument schroedingerIn = docs.get(0); assertTrue("the seed math tag was not found", schroedingerIn.text.contains(mathMLExtract)); MathTag tag = new MathTag(0, mathMLExtract, WikiTextUtils.MathMarkUpType.MATHML); String placeholder = tag.placeholder(); ParsedWikiDocument shroedingerOut = TEST_INSTANCE.map(schroedingerIn); Set<String> identifiers = shroedingerOut.getIdentifiers().elementSet(); assertTrue(identifiers.containsAll(Arrays.asList("Ψ", "V", "h", "λ", "ρ", "τ"))); List<MathTag> formulas = shroedingerOut.getFormulas(); MathTag formula = null; for (MathTag f : formulas) { if (placeholder.equals(f.getKey())) { formula = f; break; } } assertNotNull("the placeholder was not found", formula); assertTrue("the placeholder was not part of the sentence", contains(formula, shroedingerOut.getSentences())); }
@Test public void tokenization_formulaSuffexed() throws Exception { String text = "The <math>x</math>-axis shows..."; RawWikiDocument doc = new RawWikiDocument("some doc", 1, text); ParsedWikiDocument result = TEST_INSTANCE.map(doc); List<MathTag> formulas = result.getFormulas(); assertEquals(1, formulas.size()); Sentence sentence = result.getSentences().get(0); List<Word> expected = Arrays.asList(new Word("The", "DT"), new Word("x", "ID"), new Word("-axis", "-SUF"), new Word("shows", "VBZ"), new Word("...", ":")); assertEquals(expected, sentence.getWords()); }