Collect official COLM and NeurIPS abstracts with track-aware coverage
Metadata integrity checks / metadata (push) Successful in 4s
Metadata integrity checks / metadata (push) Successful in 4s
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import unittest
|
||||
import json
|
||||
import runpy
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from collect_proceedings import paper_links,parse_paper
|
||||
|
||||
|
||||
class ProceedingsTests(unittest.TestCase):
|
||||
def test_colm_nested_abstract_and_citation_authors(self):
|
||||
html='''<meta name="citation_title" content="A paper"><meta name="citation_author" content="Doe, Jane"><section><h2>Abstract</h2><p class="paper-abstract"><p>Real <em>abstract</em> text.</p></p></section><h4>Name Change Policy</h4><p>Do not ingest footer.</p>'''
|
||||
row=parse_paper(html,'https://proceedings.colm.cc/paper_files/paper/2024/hash/a-Abstract-Conference.html','colm',2024,'https://proceedings.colm.cc/paper_files/paper/2024')
|
||||
self.assertEqual(row['abstract'],'Real abstract text.')
|
||||
self.assertEqual(row['authors'],['Jane Doe'])
|
||||
self.assertEqual(row['track'],'main')
|
||||
self.assertEqual(row['year'],2024)
|
||||
|
||||
def test_declared_index_count_detects_truncation(self):
|
||||
html='<p>2 papers</p><a href="/paper/2024/hash/a-Abstract.html">Paper</a>'
|
||||
with self.assertRaisesRegex(ValueError,'count differs'):
|
||||
paper_links(html,'https://proceedings.colm.cc/paper/2024')
|
||||
|
||||
def test_missing_abstract_does_not_capture_footer(self):
|
||||
row=parse_paper('<h1>Paper</h1><h4>Name Change Policy</h4><p>Footer</p>','https://example.org/a','colm',2024,'https://example.org/')
|
||||
self.assertIsNone(row['abstract'])
|
||||
|
||||
def test_paper_title_is_not_mistaken_for_index_paper_count(self):
|
||||
html='<li><a href="/paper/2021/hash/a-Abstract.html">Lessons from 1000 papers</a></li>'
|
||||
self.assertEqual(len(paper_links(html,'https://datasets-benchmarks-proceedings.neurips.cc/paper/2021')),1)
|
||||
|
||||
def test_neurips_track_and_legacy_abstract(self):
|
||||
html='<h1>Paper</h1><span class="paper-track">Datasets and Benchmarks Track</span><h4>Abstract</h4><p>Actual abstract.</p><h4>Name Change Policy</h4><p>Footer</p>'
|
||||
row=parse_paper(html,'https://proceedings.neurips.cc/a','neurips',2025,'https://proceedings.neurips.cc/')
|
||||
self.assertEqual(row['abstract'],'Actual abstract.')
|
||||
self.assertEqual(row['track'],'datasets_benchmarks')
|
||||
|
||||
def test_focused_retry_preserves_other_index_status(self):
|
||||
root='https://proceedings.colm.cc/'
|
||||
url=root+'paper_files/paper/2024'
|
||||
other=root+'paper_files/paper/2025'
|
||||
paper=root+'paper_files/paper/2024/hash/a-Abstract-Conference.html'
|
||||
documents={root:f'<a href="{url}">2024</a><a href="{other}">2025</a>',url:f'<p>1 papers</p><a href="{paper}">Paper</a>',paper:'<h1>Paper</h1><p class="paper-abstract">Abstract</p>'}
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
status=Path(tmp)/'colm-index-status.json'
|
||||
status.write_text(json.dumps({other:{'status':'collected','files':[]}}))
|
||||
argv=['collect_proceedings.py','--source','colm','--cache',tmp,'--out',tmp,'--year','2024']
|
||||
with patch('sys.argv',argv),patch('collect_pmlr.fetch',side_effect=lambda u,*a,**kw:documents[u].encode()):
|
||||
runpy.run_path(str(Path(__file__).with_name('collect_proceedings.py')),run_name='__main__')
|
||||
result=json.loads(status.read_text())
|
||||
self.assertEqual(result[other]['status'],'collected')
|
||||
self.assertEqual(result[url]['files'][0]['count'],1)
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in New Issue
Block a user