41
41
from typing import List , Optional , Tuple
42
42
43
43
from acl_anthology import Anthology
44
+ from acl_anthology .collections import VolumeType
45
+ from acl_anthology .text import MarkupText
44
46
45
47
# from anthology.utils import make_simple_element, indent, compute_hash_from_file
46
48
@@ -303,16 +305,7 @@ def main(args):
303
305
304
306
collection_id = str (year ) + "." + venue
305
307
if (collection := anthology .collections .get (collection_id )) is None :
306
- # TODO: Should provide convenience function for instantiating new collections
307
- from acl_anthology .collections import Collection
308
-
309
- collection = Collection (
310
- id = collection_id ,
311
- parent = anthology .collections ,
312
- path = os .path .join (args .anthology_dir , "data" , "xml" , f"{ collection_id } .xml" ),
313
- )
314
- collection .is_data_loaded = True
315
- # ------
308
+ collection = anthology .collections .create (collection_id )
316
309
317
310
papers = []
318
311
for xml in sorted (args .root_dir .glob ("*.xml" )):
@@ -350,24 +343,18 @@ def sort_papers_by_page(paper_tuple):
350
343
else :
351
344
month = None
352
345
353
- # TODO: encapsulate
354
- from acl_anthology .collections import Volume , VolumeType
355
- from acl_anthology .text import MarkupText
356
-
357
- volume = Volume (
358
- id = issue ,
359
- parent = collection ,
346
+ volume = collection .create_volume (
347
+ issue ,
348
+ title = MarkupText .from_string (issue_info ), # TODO: from LaTeX?
360
349
type = VolumeType .JOURNAL ,
361
350
year = str (year ),
362
351
month = month ,
363
- booktitle = MarkupText .from_string (issue_info ), # TODO: from LaTeX?
364
352
publisher = "MIT Press" ,
365
353
address = "Cambridge, MA" ,
366
354
venue_ids = [venue ],
367
355
journal_volume = volume ,
368
356
journal_issue = issue ,
369
357
)
370
- # ------
371
358
372
359
# Check if the paper is already present in the volume
373
360
if any (paper .get ("doi" ) == paper_dict ["doi" ] for paper in volume .papers ()):
@@ -377,7 +364,6 @@ def sort_papers_by_page(paper_tuple):
377
364
# TODO: encapsulate
378
365
from acl_anthology .collections import Paper
379
366
from acl_anthology .people import NameSpecification , Name
380
- from acl_anthology .text import MarkupText
381
367
382
368
paper = Paper (
383
369
id = ..., # should be determined automatically
0 commit comments