184 lines
11 KiB
Python
184 lines
11 KiB
Python
"""Reviewed AAMAS 2025 publisher TOC; HTML metadata only, never paper PDFs."""
|
|
from collections import Counter, defaultdict
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import re
|
|
import tempfile
|
|
|
|
from paper_atlas.db.submissions import timestamp
|
|
from paper_atlas.io.html import Document, Node, clean
|
|
from paper_atlas.io.http import fetch
|
|
|
|
ROOT = 'https://www.ifaamas.org/Proceedings/aamas2025/'
|
|
URLS = {'index': ROOT, 'contents': ROOT+'forms/contents.htm'}
|
|
TITLE = 'AAMAS 2025: Proceedings of the 2025 International Conference on Autonomous Agents and Multiagent Systems'
|
|
SECTIONS = {
|
|
'1': ('Keynote Talks', 'keynote', 'keynote', 3),
|
|
'2': ('Research Paper Track', 'full_paper', 'proceedings_unspecified', 260),
|
|
'3': ('Extended Abstracts', 'extended_abstract', 'proceedings_unspecified', 148),
|
|
'4': ('Blue Sky Ideas', 'blue_sky_paper', 'blue_sky', 12),
|
|
'5': ('Doctoral Consortium', 'doctoral_abstract', 'doctoral', 25),
|
|
'6': ('Demo Track', 'demo', 'demo', 22),
|
|
'7': ('JAAMAS Track', 'journal_presentation', 'jaamas', 9),
|
|
}
|
|
COMPETITION_TITLE = '[COMP24] The Automated Negotiating Agents Competition (ANAC) 2024 Challenges and Results'
|
|
PAPER = re.compile(r'\.\./pdfs/p([0-9]+)\.pdf')
|
|
|
|
|
|
def one(items, label):
|
|
if len(items) != 1:
|
|
raise ValueError('Expected one '+label)
|
|
return items[0]
|
|
|
|
|
|
def parse_contents(html, evidence):
|
|
doc = Document(html)
|
|
if [clean(n.text()) for n in doc.root.walk() if n.tag == 'title'] != [TITLE]:
|
|
raise ValueError('Unexpected AAMAS proceedings title/year')
|
|
for paragraph in doc.root.walk():
|
|
if paragraph.tag != 'p' or any(n is not paragraph and n.tag == 'p' for n in paragraph.walk()):
|
|
continue
|
|
anchors = [n.attrs['name'] for n in paragraph.walk() if n.tag == 'a' and n.attrs.get('name') in SECTIONS]
|
|
if anchors and (len(anchors) != 1 or clean(paragraph.text()) != SECTIONS[anchors[0]][0]):
|
|
raise ValueError('Publisher section heading differs from reviewed layout')
|
|
section = None
|
|
headers = []
|
|
records, excluded, counts, seen = [], [], Counter(), set()
|
|
for node in doc.root.walk():
|
|
if node.tag == 'a' and node.attrs.get('name') in SECTIONS:
|
|
section = node.attrs['name']
|
|
headers.append(section)
|
|
if node.tag != 'p' or any(n is not node and n.tag == 'p' for n in node.walk()):
|
|
continue
|
|
links = [n for n in node.walk() if n.tag == 'a' and PAPER.fullmatch(n.attrs.get('href', ''))]
|
|
if not links:
|
|
continue
|
|
link = one(links, 'paper link per paragraph')
|
|
if section not in SECTIONS:
|
|
raise ValueError('Paper outside a reviewed publisher section')
|
|
page = int(PAPER.fullmatch(link.attrs['href'])[1])
|
|
if page in seen:
|
|
raise ValueError('Repeated publisher paper/page ID')
|
|
seen.add(page)
|
|
title = clean(link.text())
|
|
if not title:
|
|
raise ValueError('Empty paper title')
|
|
# Names are outside italicized affiliations and separated by explicit BRs.
|
|
font = one([n for n in node.walk() if n.tag == 'font' and n.attrs.get('color', '').lower() == '#222222'], 'ordered author block')
|
|
authors, affiliations = [], []
|
|
name, affiliation = '', ''
|
|
def flush():
|
|
nonlocal name, affiliation
|
|
if clean(name) or clean(affiliation):
|
|
if not clean(name):
|
|
raise ValueError('Affiliation without author')
|
|
authors.append(clean(name)); affiliations.append(clean(affiliation))
|
|
name, affiliation = '', ''
|
|
for child in font.children:
|
|
if isinstance(child, str):
|
|
name += child
|
|
elif child.tag == 'br':
|
|
flush()
|
|
elif child.tag == 'i':
|
|
affiliation += child.text()
|
|
else:
|
|
raise ValueError('Unreviewed author markup: '+child.tag)
|
|
flush()
|
|
if not authors:
|
|
raise ValueError('Empty author list')
|
|
heading, publication_format, track, _ = SECTIONS[section]
|
|
counts[section] += 1
|
|
if section == '1':
|
|
excluded.append({'publisher_page': page, 'title': title, 'authors': authors, 'reason': 'publisher keynote talk, not a research-paper submission'})
|
|
continue
|
|
note = 'Explicit publisher section; section topics are not research types.'
|
|
if track == 'proceedings_unspecified':
|
|
note = 'Published format is known; individual main/special submission track is not provided.'
|
|
if page == 3000:
|
|
if section != '6' or title != COMPETITION_TITLE:
|
|
raise ValueError('Competition report differs from reviewed publisher entry')
|
|
publication_format, track = 'competition_report', 'proceedings_unspecified'
|
|
note = 'Publisher places this competition report in Demo Track; no individual demonstration submission is inferred.'
|
|
records.append({
|
|
'source': 'aamas_proceedings', 'external_id': '2025/p'+str(page),
|
|
'url': URLS['contents']+'#'+section, 'title': title, 'abstract': None,
|
|
'authors': authors, 'identifiers': {}, 'venue': 'AAMAS', 'venue_aliases': [],
|
|
'year': 2025, 'track': track, 'status': 'accepted',
|
|
'observed_at': evidence['observed_at'],
|
|
'raw_decision': 'listed in official AAMAS 2025 published proceedings '+heading,
|
|
'tags': [{'namespace': 'aamas_proceedings:publication_format', 'value': publication_format}],
|
|
'metadata': {'publisher_page': page, 'paper_url': ROOT+'pdfs/p'+str(page)+'.pdf',
|
|
'section_url': URLS['contents'], 'section_anchor': section,
|
|
'section_heading': heading, 'publication_format': publication_format,
|
|
'author_affiliations': affiliations, 'source_evidence': evidence,
|
|
'track_scope_note': note, 'decision_date_precision': 'not_supplied',
|
|
'missing_abstract_reason': 'Publisher HTML supplies no abstract; research PDF not downloaded.',
|
|
'publication_evidence': 'Published proceedings entry, not an original decision note.'}})
|
|
if headers != list(SECTIONS) or dict(counts) != {k: v[3] for k, v in SECTIONS.items()}:
|
|
raise ValueError('Publisher section inventory differs from reviewed 2025 layout')
|
|
if len(records) != 476 or len(excluded) != 3 or sum(r['metadata']['publication_format'] == 'competition_report' for r in records) != 1:
|
|
raise ValueError('Unexpected publication partition')
|
|
return records, excluded
|
|
|
|
|
|
def read_pages(cache, snapshots):
|
|
if bool(cache) == bool(snapshots):
|
|
raise ValueError('Choose exactly one cache or frozen snapshot directory')
|
|
frozen = json.loads((Path(snapshots)/'receipts.json').read_text())['receipts'] if snapshots else []
|
|
pages = {}
|
|
for key, url in URLS.items():
|
|
if snapshots:
|
|
r = one([r for r in frozen if r['url'] == url], 'frozen response receipt')
|
|
filename = Path(r['file']); base = Path(snapshots).resolve()
|
|
if filename.is_absolute() or '..' in filename.parts or not (base/filename).resolve().is_relative_to(base) or r.get('http_status') != 200:
|
|
raise ValueError('Unsafe or unsuccessful publisher response')
|
|
data = (base/filename).read_bytes()
|
|
if len(data) > 8*1024**2 or len(data) != r['bytes'] or hashlib.sha256(data).hexdigest() != r['sha256']:
|
|
raise ValueError('Frozen publisher response checksum/size mismatch')
|
|
observed = r['at']
|
|
else:
|
|
data = fetch(url, cache, 8*1024**2, delay=1)
|
|
r = json.loads((Path(cache)/hashlib.sha256(url.encode()).hexdigest()).with_suffix('.json').read_text())
|
|
observed = r['retrieved_at']
|
|
timestamp(observed)
|
|
pages[key] = data, {'url': url, 'sha256': hashlib.sha256(data).hexdigest(), 'bytes': len(data),
|
|
'file': 'evidence/'+hashlib.sha256(data).hexdigest()+'.html',
|
|
'observed_at': observed, 'http_status': 200, 'response_receipt': r}
|
|
return pages
|
|
|
|
|
|
def collect(out, *, cache=None, snapshots=None):
|
|
pages = read_pages(cache, snapshots)
|
|
if [clean(n.text()) for n in Document(pages['index'][0].decode('utf-8')).root.walk() if n.tag == 'title'] != [TITLE]:
|
|
raise ValueError('Unexpected AAMAS 2025 introduction')
|
|
records, excluded = parse_contents(pages['contents'][0].decode('utf-8'), pages['contents'][1])
|
|
grouped = defaultdict(list)
|
|
for row in records: grouped[row['track']].append(row)
|
|
out = Path(out); out.mkdir(parents=True, exist_ok=True); files = []
|
|
with tempfile.TemporaryDirectory(prefix='.aamas2025-', dir=out) as temporary:
|
|
stage = Path(temporary); (stage/'evidence').mkdir()
|
|
for data, e in pages.values(): (stage/e['file']).write_bytes(data)
|
|
for track, group in sorted(grouped.items()):
|
|
p = stage/f'aamas-proceedings-2025-{track}.jsonl'
|
|
p.write_text(''.join(json.dumps(r, ensure_ascii=False)+'\n' for r in group))
|
|
m = {'source': 'aamas_proceedings', 'parser_version': 2, 'venue': 'AAMAS', 'year': 2025,
|
|
'track': track, 'count': len(group), 'file': str(out/p.name), 'file_sha256': hashlib.sha256(p.read_bytes()).hexdigest(),
|
|
'list_url': URLS['contents'], 'status': 'partial', 'missing_abstract_count': len(group),
|
|
'publication_format_counts': dict(Counter(r['metadata']['publication_format'] for r in group)),
|
|
'note': 'Complete published TOC partition; HTML abstracts absent, identities and submission-track scope require independent review.'}
|
|
p.with_suffix('.manifest.json').write_text(json.dumps(m, ensure_ascii=False, indent=2)+'\n'); files.append(m)
|
|
result = {'source': 'aamas_proceedings', 'year': 2025, 'finished_at': timestamp(),
|
|
'status': 'collected_pending_identity_review', 'records': len(records), 'files': files,
|
|
'excluded_publications': excluded, 'source_receipts': [e for _, e in pages.values()],
|
|
'publication_format_counts': dict(Counter(r['metadata']['publication_format'] for r in records)),
|
|
'database_written': False, 'pdfs_downloaded': False,
|
|
'note': 'Neither absence from proceedings nor aggregate rejection/withdrawal counts identify an individual negative decision.'}
|
|
report = 'aamas-proceedings-2025.json'; (stage/report).write_text(json.dumps(result, ensure_ascii=False, indent=2)+'\n')
|
|
(out/'evidence').mkdir(exist_ok=True)
|
|
for p in (stage/'evidence').iterdir(): p.replace(out/'evidence'/p.name)
|
|
for p in stage.iterdir():
|
|
if p.is_file() and p.name != report: p.replace(out/p.name)
|
|
(stage/report).replace(out/report)
|
|
return result
|