Implementation:AGI Edgerunners LLM Agents Papers parse paper
| Knowledge Sources | |
|---|---|
| Domains | Data_Collection, Data_Labeling, Configuration |
| Last Updated | 2026-10-10 14:30 GMT |
Overview
Concrete orchestration function for loading seed URLs, crawling arXiv pages, interactively labeling categories, and persisting parsed paper metadata, provided by the LLM-Agents-Papers repository.
Description
The parse_paper function is the main entry point of script_v5_step1.py. It performs the complete data collection pipeline:
- Loads the category taxonomy from config_v5.json and builds a flat list of categories with an index-to-category mapping
- Loads existing parsed data from all parsed_v5/*.json files into all_parsed_datas (keyed by MD5 hash of URL)
- Iterates the seed URL list from papers_v5.json, skipping URLs already parsed
- For new arXiv URLs, calls parse_by_crawl() to extract metadata
- Prompts the user for interactive category assignment using the pretty_category() display helper
- Persists all accumulated data to parsed_v5/<year>.json files
The function uses module-level globals stored_datas and all_parsed_datas to accumulate state. On any exception, it attempts an emergency save of accumulated data.
Helper: pretty_category
The pretty_category function (script_v5_step1.py:L86-99) formats the flat category list into a two-column display string for the interactive prompt. It calculates column widths and rows, then builds numbered lines like 0.Survey 5.Planning. It is only called by parse_paper and is not intended for standalone use.
def pretty_category(all_categories):
"""Format categories into a 2-column numbered display string."""
columns = 2
max_len = max(len(cate.split(".")[0]) for cate in all_categories)
rows = (len(all_categories) + 1) // columns
lines = []
for i in range(rows):
left = f'{i}.{all_categories[i].split(".")[0]}'.ljust(max_len + 4)
right_idx = i + rows
right = f'{right_idx}.{all_categories[right_idx].split(".")[0]}' if right_idx < len(all_categories) else ''
lines.append(left + right)
return '\n'.join(lines)
Usage
Run this function as the main entry point of the data collection pipeline:
- First-time crawling of all seed URLs in papers_v5.json
- Incremental crawling: re-run to process only new URLs not yet in parsed_v5/*.json
- Interactive category labeling for newly crawled papers
Code Reference
Source Location
- Repository: LLM-Agents-Papers
- File: script_v5_step1.py:L102-177 (parse_paper), L86-99 (pretty_category)
Signature
# Module-level globals used as accumulators
stored_datas = {} # keyed by year -> {md5_id: parsed_data}
all_parsed_datas = {} # keyed by md5_id -> parsed_data
CONFIG_FILE = "config_v5.json"
URL_FILE = "papers_v5.json"
PARSED_FOLDER = "parsed_v5"
def parse_paper() -> None:
"""
Main orchestration: load config, load existing parsed data, crawl new URLs,
interactively label categories, and persist results.
Uses module-level globals stored_datas and all_parsed_datas.
"""
Import
from script_v5_step1 import parse_paper
# Or run directly:
# python script_v5_step1.py
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config_v5.json | File | Yes | Category taxonomy, sort order, description text |
| papers_v5.json | File | Yes | Seed list of arXiv URLs with optional code links |
| parsed_v5/*.json | Files | Yes | Existing parsed metadata (for incremental crawling) |
| stdin | Stream | Yes | User enters space-separated category index numbers |
Outputs
| Name | Type | Description |
|---|---|---|
| return | None | No return value |
| parsed_v5/<year>.json | Files | Updated metadata files on disk, keyed by MD5 hash |
| stored_datas | dict (global) | Accumulated data keyed by year |
| all_parsed_datas | dict (global) | Accumulated data keyed by MD5 hash |
Usage Examples
Running the Full Pipeline
# Run the complete data collection pipeline
# This will:
# 1. Load config_v5.json for category taxonomy
# 2. Load existing parsed_v5/*.json files
# 3. Crawl new URLs from papers_v5.json
# 4. Prompt for category labels on new papers
# 5. Save to parsed_v5/<year>.json
from script_v5_step1 import parse_paper
parse_paper()
Incremental Crawling
# Re-running parse_paper only processes NEW URLs
# URLs already in parsed_v5/*.json (matched by MD5 hash) are skipped
# Just add new URLs to papers_v5.json and re-run:
# python script_v5_step1.py
# Output example:
# parse data: {"url": "https://arxiv.org/abs/2501.12345", "code": ""}
# 1/500
# --------------------
# title: New Paper Title link: https://arxiv.org/abs/2501.12345
# Please label the category of this paper:
# 0.Survey 5.Planning
# 1.Technique 6.Memory
# ...
# Input the numbers with blank: 0 5
Emergency Save Pattern
# The __main__ block wraps parse_paper in a try/except
# so accumulated data is saved even on interruption:
# if __name__ == '__main__':
# try:
# parse_paper()
# except Exception as e:
# for year, datas in stored_datas.items():
# write_json(f'{PARSED_FOLDER}/{year}.json', datas)
Related Pages
Implements Principle
- Principle:AGI_Edgerunners_LLM_Agents_Papers_Human_in_the_Loop_Labeling
- Principle:AGI_Edgerunners_LLM_Agents_Papers_Configuration_Driven_Categorization
- Principle:AGI_Edgerunners_LLM_Agents_Papers_Structured_Data_Persistence