Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for m in ms:
if urllib.quote("#") not in m.group(1) or keep_anchors:
annotations.append({
"u" : m.group(1),
"s" : m.group(2),
"o" : m.start() - deltaStringLength
})
deltaStringLength += len(m.group(0)) - len(m.group(2))
#As a second step, replace all links in the article by their label
wiki_document.text = re.sub('<a href="([^">([^>]+)</a>', lambda m: m.group(2), wiki_document.text)
#Create a new AnnotatedWikiDocument
annotated_wiki_document = AnnotatedWikiDocument(wiki_document)
annotated_wiki_document.setAnnotations(annotations)
#Return the AnnotatedWikiDocument
return annotated_wiki_document