(file_paths)
| 21 | |
| 22 | |
| 23 | def 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 | |
| 50 | def get_degree_dict(): |
nothing calls this directly
no test coverage detected