### Question:
PatternMatcherMapper implements MapFunction<ParsedWikiDocument, WikiDocumentOutput> { @Override public WikiDocumentOutput map(ParsedWikiDocument doc) throws Exception { List<Relation> foundRelations = Lists.newArrayList(); List<Sentence> sentences = doc.getSentences(); for (Sentence sentence : sentences) { if (!sentence.getIdentifiers().isEmpty()) { LOGGER.debug("sentence {}", sentence); } Set<String> identifiers = sentence.getIdentifiers(); PatternMatcher matcher = PatternMatcher.generatePatterns(identifiers); List<IdentifierMatch> foundMatches = matcher.match(sentence.getWords(), doc); for (IdentifierMatch match : foundMatches) { if (!DefinitionUtils.isValid(match.getDefinition())) { continue; } Relation relation = new Relation(); relation.setIdentifier(match.getIdentifier()); relation.setDefinition(match.getDefinition()); relation.setSentence(sentence); relation.setScore(1.0d); relation.setIdentifierPosition(match.getPosition()); if (!relationWasFoundBefore(foundRelations, relation)) { LOGGER.debug("found match {}", relation); foundRelations.add(relation); } } } LOGGER.info("extracted {} relations from {}", foundRelations.size(), doc.getTitle()); return new WikiDocumentOutput(doc.getTitle(), foundRelations, doc.getIdentifiers()); }  @Override WikiDocumentOutput map(ParsedWikiDocument doc);  }### Answer:
@Test public void testShodingerFull() throws Exception { ParsedWikiDocument doc = CreateCandidatesMapperTest.read("com/formulasearchengine/mathosphere/mlp/augmentendwikitext.xml", 1); PatternMatcherMapper patternMatcher = new PatternMatcherMapper(); WikiDocumentOutput identifiers = patternMatcher.map(doc); for (Relation relation : identifiers.getRelations()) { LOGGER.debug("relation: {}", relation); } }
@Test public void testShrodingerPart() throws Exception { InputStream input = PatternMatchingRelationFinder.class.getResourceAsStream("escaped.txt"); String text = IOUtils.toString(input,"UTF-8"); RawWikiDocument documentText = new RawWikiDocument("Document", 0, text); TextAnnotatorMapper textAnnotator = TextAnnotatorMapperTest.TEST_INSTANCE; ParsedWikiDocument doc = textAnnotator.map(documentText); PatternMatcherMapper patternMatcher = new PatternMatcherMapper(); WikiDocumentOutput identifiers = patternMatcher.map(doc); for (Relation relation : identifiers.getRelations()) { LOGGER.debug("relation: {}, sentence: {}", relation, relation.getSentence()); } }