41 lines
2.2 KiB
Python
41 lines
2.2 KiB
Python
import json
|
|
import tempfile
|
|
import unittest
|
|
import xml.etree.ElementTree as ET
|
|
from pathlib import Path
|
|
|
|
from paper_atlas.collectors.acl import paper_id,volume_scope,collect_xml
|
|
|
|
|
|
class AnthologyTests(unittest.TestCase):
|
|
def test_documented_identifier_formats_and_exceptions(self):
|
|
for args,expected in [(('P17','1','1'),'P17-1001'),(('2025.acl','long','1'),'2025.acl-long.1'),(('C69','1','1'),'C69-0101'),(('D19','50','1'),'D19-5001'),(('W17','1','1'),'W17-0101')]:
|
|
self.assertEqual(paper_id(*args),expected)
|
|
|
|
def test_findings_uses_associated_conference_and_separate_track(self):
|
|
meta=ET.fromstring('<meta><venue>findings</venue><booktitle>Findings of ACL: EMNLP 2025</booktitle></meta>')
|
|
self.assertEqual(volume_scope(meta,'emnlp'),('EMNLP',['EMNLP'],'findings'))
|
|
|
|
def test_joint_event_has_one_identity_and_two_aliases(self):
|
|
meta=ET.fromstring('<meta><venue>lrec</venue><venue>coling</venue><booktitle>LREC-COLING 2024</booktitle></meta>')
|
|
self.assertEqual(volume_scope(meta,'main'),('COLING+LREC',['COLING','LREC'],'main'))
|
|
|
|
def test_xml_mixed_text_frontmatter_and_missing_abstract(self):
|
|
xml='<collection id="P17"><volume id="1"><meta><year>2017</year><venue>acl</venue><booktitle>ACL</booktitle></meta><paper id="0"><title>Front matter</title></paper><paper id="1"><title>A <fixed-case>Mixed</fixed-case> Title</title><author><first>Jane</first><last>Doe</last></author><doi>10.18653/v1/P17-1001</doi></paper></volume></collection>'
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
path=Path(tmp)/'P17.xml';path.write_text(xml)
|
|
result=collect_xml(path,tmp,'a'*40)[0]
|
|
row=json.loads(Path(result['file']).read_text())
|
|
self.assertEqual(result['count'],1)
|
|
self.assertEqual(result['excluded_frontmatter'],1)
|
|
self.assertEqual(result['status'],'partial')
|
|
self.assertEqual(row['external_id'],'P17-1001')
|
|
self.assertEqual(row['title'],'A Mixed Title')
|
|
|
|
def test_non_target_workshop_is_not_main_conference(self):
|
|
meta=ET.fromstring('<meta><venue>some-workshop</venue><venue>ws</venue><booktitle>Workshop at ACL</booktitle></meta>')
|
|
self.assertIsNone(volume_scope(meta,'1'))
|
|
|
|
|
|
if __name__=='__main__':unittest.main()
|