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

Function get_hyperlink

utils/wiki_util.py:21–37  ·  view source on GitHub ↗

Get abstract of each page and hyperplinks within the whole page. :param text: wikipedia text, with hyperlinks

(text, abstract=None)

Source from the content-addressed store, hash-verified

19
20
21def get_hyperlink(text, abstract=None):
22 """
23 Get abstract of each page and hyperplinks within the whole page.
24 :param text: wikipedia text, with hyperlinks
25 """
26 if abstract is None:
27 parts = text.split("\n\n", 1)
28 if len(parts) > 1:
29 abstract = parts[1].split('\n')[0]
30 else:
31 abstract = ""
32
33 abs_hyperlink = re.findall(r'<a href="([^"]+)">', abstract)
34 full_hyperlink = re.findall(r'<a href="([^"]+)">', text)
35 abs_hyperlink = [_normalize(unquote(link)) for link in abs_hyperlink]
36 full_hyperlink = [_normalize(unquote(link)) for link in full_hyperlink]
37 return abs_hyperlink, full_hyperlink
38
39
40def remove_hyperlink(text, abstract=False):

Callers 2

process_wikiFunction · 0.90
process_wikiFunction · 0.90

Calls 1

_normalizeFunction · 0.85

Tested by

no test coverage detected