MCPcopy Create free account
hub / github.com/TIGER-AI-Lab/LongRAG / remove_hyperlink

Function remove_hyperlink

utils/wiki_util.py:40–55  ·  view source on GitHub ↗

Remove the hyperlink from the text. :param text: wikipedia text, with hyperlinks

(text, abstract=False)

Source from the content-addressed store, hash-verified

38
39
40def remove_hyperlink(text, abstract=False):
41 """
42 Remove the hyperlink from the text.
43 :param text: wikipedia text, with hyperlinks
44 """
45 if abstract:
46 text = text.split("\n\n", 1)
47 if len(text) > 1:
48 text = text[1].split('\n')[0]
49 else:
50 text = ""
51 text = _normalize(text)
52 clean_text = re.sub(r'<a href="[^"]+">([^<]+)</a>', r'\1', text)
53 clean_text = re.sub(r'\n\n?', ' ', clean_text)
54 clean_text = clean_text.rstrip()
55 return clean_text

Callers 1

process_wikiFunction · 0.90

Calls 1

_normalizeFunction · 0.85

Tested by

no test coverage detected