forked from acl-org/acl-anthology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
91 lines (75 loc) · 3.01 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- coding: utf-8 -*-
#
# Copyright 2019 Marcel Bollmann <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
# This file contains all constants and functions that have hardcoded data (such
# as URLs or journal titles) which does not come from the XML. This is to
# provide a single file where such hardcoded data can be looked up and/or
# changed.
################################################################################
import os
# this is the canonical URL. In contrast to all other
# URL templates, it always links to the official anthology.
CANONICAL_URL_TEMPLATE = "https://aclanthology.org/{}"
# the prefix is used in different programs and we need to set it everywhere
# We use a environment variable to set this and not have to forward the value
# through all the programs. If this does not look like the best idea, keep in mind
# that the structure is historically grown -- from 2019 to 2020 :-)
try:
ANTHOLOGY_PREFIX = os.environ["ANTHOLOGY_PREFIX"]
except KeyError:
ANTHOLOGY_PREFIX = "https://aclanthology.org"
ATTACHMENT_PREFIX = ANTHOLOGY_PREFIX + "/attachments"
ATTACHMENT_TEMPLATE = ATTACHMENT_PREFIX + "/{}"
PDF_LOCATION_TEMPLATE = ANTHOLOGY_PREFIX + "/{}.pdf"
PDF_THUMBNAIL_LOCATION_TEMPLATE = ANTHOLOGY_PREFIX + "/thumb/{}.jpg"
# URL template for videos
VIDEO_LOCATION_TEMPLATE = ANTHOLOGY_PREFIX + "/{}"
# URL template for handbooks Where files related to events can be found, e.g., /{2022.acl.handbook.pdf}
EVENT_LOCATION_TEMPLATE = ANTHOLOGY_PREFIX + "/{}"
# Regular expression matching full Anthology IDs
ANTHOLOGY_ID_REGEX = r"[A-Z]\d{2}-\d{4}"
# Anthology file location on server
# Defaults to ~/anthology-files
ANTHOLOGY_FILE_DIR = os.environ.get(
"ANTHOLOGY_FILES", os.path.join(os.environ["HOME"], "anthology-files")
)
# Names of XML elements that may appear multiple times, and should be accumulated as a list
LIST_ELEMENTS = (
"attachment",
"author",
"editor",
"video",
"revision",
"erratum",
"award",
"pwcdataset",
"video",
"venue",
)
# Names of XML elements that should not be parsed, so that they can be interpreted later in
# a context-specific way
DONT_PARSE_ELEMENTS = (
"abstract",
"title",
"booktitle",
)
# Constants associated with DOI assignation
DOI_URL_PREFIX = "https://dx.doi.org/"
DOI_PREFIX = "10.18653/v1/"
# Default ingestion date (= unknown)
UNKNOWN_INGEST_DATE = "1900-01-01"
# The venue format must match this pattern
VENUE_FORMAT = r"^[a-z\d]+$"