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

Function process_wiki

preprocess/process_wiki_page.py:23–47  ·  view source on GitHub ↗
(file_paths)

Source from the content-addressed store, hash-verified

21
22
23def process_wiki(file_paths):
24 data = []
25 for file_path in tqdm(file_paths, desc="Processing wiki files"):
26 with bz2.open(file_path, "rb") as file:
27 for line in file:
28 line_decoded = _normalize(line.decode('utf-8'))
29 page_data = json.loads(line_decoded)
30 title = convert_html(page_data["title"])
31 abs_hyperlink, full_hyperlink = get_hyperlink(page_data["text"])
32
33 new_page_data = {"title": title,
34 "url": page_data["url"],
35 "text": remove_hyperlink(page_data["text"], abstract=False),
36 "abs_hyperlink": abs_hyperlink,
37 "full_hyperlink": full_hyperlink}
38 new_page_data["size"] = len(enc.encode(new_page_data["text"]))
39
40 if title in corpus_title_set:
41 new_page_data["in_corpus"] = True
42 else:
43 new_page_data["in_corpus"] = False
44
45 data.append(new_page_data)
46
47 return data
48
49
50def get_degree_dict():

Callers

nothing calls this directly

Calls 4

_normalizeFunction · 0.90
convert_htmlFunction · 0.90
get_hyperlinkFunction · 0.90
remove_hyperlinkFunction · 0.90

Tested by

no test coverage detected