gabrielaltay commited on
Commit
85638fe
1 Parent(s): c4f6d7e

Upload license.py

Browse files
Files changed (1) hide show
  1. license.py +332 -0
license.py ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ License objects.
5
+ """
6
+
7
+ import importlib.resources as pkg_resources
8
+ import json
9
+ from dataclasses import dataclass
10
+ from types import SimpleNamespace
11
+ from typing import Dict, Optional
12
+
13
+ from bigbio.utils import resources
14
+
15
+
16
+ @dataclass
17
+ class License:
18
+ """
19
+ Base class from which all licenses inherit
20
+
21
+ Args:
22
+ name: License title
23
+ text: Accompanying information of the license
24
+ link: URL to License
25
+ version: Current version of license
26
+ provenance: Organization providing authorization, if possible
27
+ """
28
+
29
+ name: Optional[str] = None
30
+ short_name: Optional[str] = None
31
+ text: Optional[str] = None
32
+ link: Optional[str] = None
33
+ version: Optional[str] = None
34
+ provenance: Optional[str] = None
35
+
36
+ @property
37
+ def is_share_alike(self):
38
+ """
39
+ Is Share-alike?
40
+ """
41
+ # NOTE: leave here has an example of license properties
42
+ raise NotImplementedError()
43
+
44
+
45
+ @dataclass
46
+ class CustomLicense(License):
47
+ """
48
+ This class is for custom licenses.
49
+ It must contain the text of the license.
50
+ Optionally its version and a link to the license webpage.
51
+ """
52
+
53
+ def __post_init__(self):
54
+ if self.name is None:
55
+ self.name = "Custom license"
56
+
57
+ if self.text is None and self.link is None:
58
+ raise ValueError(
59
+ "A `CustomLicense` must provide either (a) the license text or (b) the license link!"
60
+ )
61
+
62
+
63
+ def _get_variable_name(k: str) -> str:
64
+
65
+ return k.replace("-", "_").upper().replace(".", "p").replace("+", "plus")
66
+
67
+
68
+ _GENIA_PROJECT_LICENSE_TEXT = """
69
+ GENIA Project License for Annotated Corpora
70
+
71
+ 1. Copyright of abstracts
72
+
73
+ Any abstracts contained in this corpus are from PubMed(R), a database
74
+ of the U.S. National Library of Medicine (NLM).
75
+
76
+ NLM data are produced by a U.S. Government agency and include works of
77
+ the United States Government that are not protected by U.S. copyright
78
+ law but may be protected by non-US copyright law, as well as abstracts
79
+ originating from publications that may be protected by U.S. copyright
80
+ law.
81
+
82
+ NLM assumes no responsibility or liability associated with use of
83
+ copyrighted material, including transmitting, reproducing,
84
+ redistributing, or making commercial use of the data. NLM does not
85
+ provide legal advice regarding copyright, fair use, or other aspects
86
+ of intellectual property rights. Persons contemplating any type of
87
+ transmission or reproduction of copyrighted material such as abstracts
88
+ are advised to consult legal counsel.
89
+
90
+ 2. Copyright of full texts
91
+
92
+ Any full texts contained in this corpus are from the PMC Open Access
93
+ Subset of PubMed Central (PMC), the U.S. National Institutes of Health
94
+ (NIH) free digital archive of biomedical and life sciences journal
95
+ literature.
96
+
97
+ Articles in the PMC Open Access Subset are protected by copyright, but
98
+ are made available under a Creative Commons or similar license that
99
+ generally allows more liberal redistribution and reuse than a
100
+ traditional copyrighted work. Please refer to the license of each
101
+ article for specific license terms.
102
+
103
+ 3. Copyright of annotations
104
+
105
+ The copyrights of annotations created in the GENIA Project of Tsujii
106
+ Laboratory, University of Tokyo, belong in their entirety to the GENIA
107
+ Project.
108
+
109
+ 4. Licence terms
110
+
111
+ Use and distribution of abstracts drawn from PubMed is subject to the
112
+ PubMed(R) license terms as stated in Clause 1.
113
+
114
+ Use and distribution of full texts is subject to the license terms
115
+ applying to each publication.
116
+
117
+ Annotations created by the GENIA Project are licensed under the
118
+ Creative Commons Attribution 3.0 Unported License. To view a copy of
119
+ this license, visit http://creativecommons.org/licenses/by/3.0/ or
120
+ send a letter to Creative Commons, 444 Castro Street, Suite 900,
121
+ Mountain View, California, 94041, USA.
122
+
123
+ Annotations created by the GENIA Project must be attributed as
124
+ detailed in Clause 5.
125
+
126
+ 5. Attribution
127
+
128
+ The GENIA Project was founded and led by prof. Jun'ichi Tsujii and
129
+ the project and its annotation efforts have been coordinated in part
130
+ by Nigel Collier, Yuka Tateisi, Sang-Zoo Lee, Tomoko Ohta, Jin-Dong
131
+ Kim, and Sampo Pyysalo.
132
+
133
+ For a complete list of the GENIA Project members and contributors,
134
+ please refer to http://www.geniaproject.org.
135
+
136
+ The GENIA Project has been supported by Grant-in-Aid for Scientific
137
+ Research on Priority Area "Genome Information Science" (MEXT, Japan),
138
+ Grant-in-Aid for Scientific Research on Priority Area "Systems
139
+ Genomics" (MEXT, Japan), Core Research for Evolutional Science &
140
+ Technology (CREST) "Information Mobility Project" (JST, Japan),
141
+ Solution Oriented Research for Science and Technology (SORST) (JST,
142
+ Japan), Genome Network Project (MEXT, Japan) and Grant-in-Aid for
143
+ Specially Promoted Research (MEXT, Japan).
144
+
145
+ Annotations covered by this license must be attributed as follows:
146
+
147
+ Corpus annotations (c) GENIA Project
148
+
149
+ Distributions including annotations covered by this licence must
150
+ include this license text and Attribution section.
151
+
152
+ 6. References
153
+
154
+ - GENIA Project : http://www.geniaproject.org
155
+ - PubMed : http://www.pubmed.gov/
156
+ - NLM (United States National Library of Medicine) : http://www.nlm.nih.gov/
157
+ - MEXT (Ministry of Education, Culture, Sports, Science and Technology) : http://www.mext.go.jp/
158
+ - JST (Japan Science and Technology Agency) : http://www.jst.go.jp
159
+ """
160
+
161
+ GeniaProjectLicense = CustomLicense(
162
+ name="GENIA Project License for Annotated Corpora",
163
+ # NOTE: just in case the link will break
164
+ text=_GENIA_PROJECT_LICENSE_TEXT,
165
+ link="http://www.nactem.ac.uk/meta-knowledge/GENIA_license.txt",
166
+ )
167
+
168
+
169
+ _NLM_LICENSE_TEXT = """
170
+ National Library of Medicine Terms and Conditions
171
+
172
+ INTRODUCTION
173
+
174
+ Downloading data from the National Library of Medicine FTP servers indicates your acceptance of the following Terms and Conditions: No charges, usage fees or royalties are paid to NLM for this data.
175
+
176
+ GENERAL TERMS AND CONDITIONS
177
+
178
+ Users of the data agree to:
179
+ acknowledge NLM as the source of the data by including the phrase "Courtesy of the U.S. National Library of Medicine" in a clear and conspicuous manner,
180
+ properly use registration and/or trademark symbols when referring to NLM products, and
181
+ not indicate or imply that NLM has endorsed its products/services/applications.
182
+
183
+ Users who republish or redistribute the data (services, products or raw data) agree to:
184
+ maintain the most current version of all distributed data, or
185
+ make known in a clear and conspicuous manner that the products/services/applications do not reflect the most current/accurate data available from NLM.
186
+
187
+ These data are produced with a reasonable standard of care, but NLM makes no warranties express or implied, including no warranty of merchantability or fitness for particular purpose, regarding the accuracy or completeness of the data. Users agree to hold NLM and the U.S. Government harmless from any liability resulting from errors in the data. NLM disclaims any liability for any consequences due to use, misuse, or interpretation of information contained or not contained in the data.
188
+
189
+ NLM does not provide legal advice regarding copyright, fair use, or other aspects of intellectual property rights. See the NLM Copyright page.
190
+
191
+ NLM reserves the right to change the type and format of its machine-readable data. NLM will take reasonable steps to inform users of any changes to the format of the data before the data are distributed via the announcement section or subscription to email and RSS updates.
192
+
193
+ """
194
+ NLMLicense = CustomLicense(
195
+ name="National Library of Medicine Terms and Conditions",
196
+ # NOTE: just in case the link will break
197
+ text=_NLM_LICENSE_TEXT,
198
+ link="https://www.nlm.nih.gov/databases/download/terms_and_conditions.html",
199
+ )
200
+
201
+
202
+ _PHYSIONET_LICENSE_1p5_TEXT = """
203
+ The PhysioNet Credentialed Health Data License
204
+ Version 1.5.0
205
+
206
+ Copyright (c) 2022 MIT Laboratory for Computational Physiology
207
+
208
+ The MIT Laboratory for Computational Physiology (MIT-LCP) wishes to make data available for research and educational purposes to qualified requestors, but only if the data are used and protected in accordance with the terms and conditions stated in this License.
209
+
210
+ It is hereby agreed between the data requestor, hereinafter referred to as the "LICENSEE", and MIT-LCP, that:
211
+
212
+ The LICENSEE will not attempt to identify any individual or institution referenced in PhysioNet restricted data.
213
+ The LICENSEE will exercise all reasonable and prudent care to avoid disclosure of the identity of any individual or institution referenced in PhysioNet restricted data in any publication or other communication.
214
+ The LICENSEE will not share access to PhysioNet restricted data with anyone else.
215
+ The LICENSEE will exercise all reasonable and prudent care to maintain the physical and electronic security of PhysioNet restricted data.
216
+ If the LICENSEE finds information within PhysioNet restricted data that he or she believes might permit identification of any individual or institution, the LICENSEE will report the location of this information promptly by email to PHI-report@physionet.org, citing the location of the specific information in question.
217
+ The LICENSEE will use the data for the sole purpose of lawful use in scientific research and no other.
218
+ The LICENSEE will be responsible for ensuring that he or she maintains up to date certification in human research subject protection and HIPAA regulations.
219
+ The LICENSEE agrees to contribute code associated with publications arising from this data to a repository that is open to the research community.
220
+ This agreement may be terminated by either party at any time, but the LICENSEE's obligations with respect to PhysioNet data shall continue after termination.
221
+
222
+ THE DATA ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE USE OR OTHER DEALINGS IN THE DATA.
223
+ """
224
+ PhysioNetLicense1p5 = CustomLicense(
225
+ name="PhysioNet Credentialed Health Data License",
226
+ version="1.5",
227
+ link="https://physionet.org/content/mimiciv/view-license/0.4/",
228
+ # NOTE: just in case the link will break
229
+ text=_PHYSIONET_LICENSE_1p5_TEXT,
230
+ )
231
+
232
+
233
+ UMLSLicense = CustomLicense(
234
+ name="UMLS - Metathesaurus License Agreement",
235
+ link="https://www.nlm.nih.gov/research/umls/knowledge_sources/metathesaurus/release/license_agreement.html",
236
+ )
237
+
238
+ _NCBI_LICENSE_TEXT = """
239
+ ===========================================================================
240
+ *
241
+ * PUBLIC DOMAIN NOTICE
242
+ * National Center for Biotechnology Information
243
+ *
244
+ * This software/database is a "United States Government Work" under the
245
+ * terms of the United States Copyright Act. It was written as part of
246
+ * the author's official duties as a United States Government employee and
247
+ * thus cannot be copyrighted. This software/database is freely available
248
+ * to the public for use. The National Library of Medicine and the U.S.
249
+ * Government have not placed any restriction on its use or reproduction.
250
+ *
251
+ * Although all reasonable efforts have been taken to ensure the accuracy
252
+ * and reliability of the software and data, the NLM and the U.S.
253
+ * Government do not and cannot warrant the performance or results that
254
+ * may be obtained by using this software or data. The NLM and the U.S.
255
+ * Government disclaim all warranties, express or implied, including
256
+ * warranties of performance, merchantability or fitness for any particular
257
+ * purpose.
258
+ *
259
+ * Please cite the author in any work or product based on this material.
260
+ *
261
+ *
262
+ ===========================================================================
263
+ """
264
+ NCBILicense = CustomLicense(
265
+ name="National Center fr Biotechnology Information PUBLIC DOMAIN NOTICE",
266
+ link="https://github.com/openbiocorpora/genetag/blob/master/LICENSE",
267
+ # NOTE: just in case link will break
268
+ text=_NCBI_LICENSE_TEXT,
269
+ )
270
+
271
+ PublicDomainMark_1p0 = CustomLicense(
272
+ name="Public Domain Mark 1.0",
273
+ text="""This work has been identified as being free of known restrictions under copyright law,
274
+ including all related and neighboring rights.
275
+ """,
276
+ link="https://creativecommons.org/publicdomain/mark/1.0/",
277
+ )
278
+
279
+
280
+ def load_json_licenses() -> Dict[str, str]:
281
+ """
282
+ Load all licenses from JSON file.
283
+ Amend names to be valid variable names
284
+ """
285
+
286
+ # shamelessly compied from:
287
+ # https://github.com/huggingface/datasets/blob/master/src/datasets/utils/metadata.py
288
+ licenses = {
289
+ _get_variable_name(k): v
290
+ for k, v in json.loads(
291
+ pkg_resources.read_text(resources, "licenses.json")
292
+ ).items()
293
+ }
294
+
295
+ licenses["ZERO_BSD"] = licenses.pop("0BSD")
296
+
297
+ return licenses
298
+
299
+
300
+ def load_licenses() -> Dict[str, License]:
301
+ """
302
+ Load `_LICENSES` dict:
303
+ - key (str) : license name
304
+ - value (License) : instance of license class
305
+ """
306
+
307
+ json_licenses = load_json_licenses()
308
+
309
+ json_licenses.update({"DUA": "Data User Agreement"})
310
+
311
+ licenses_kwargs = {k: {"name": v} for k, v in json_licenses.items()}
312
+
313
+ licenses = {k: License(**kwargs) for k, kwargs in licenses_kwargs.items()}
314
+
315
+ custom_licenses = {
316
+ "PUBLIC_DOMAIN_MARK_1p0": PublicDomainMark_1p0,
317
+ "GENIA_PROJECT_LICENSE": GeniaProjectLicense,
318
+ "NLM_LICENSE": NLMLicense,
319
+ "NCBI_LICENSE": NCBILicense,
320
+ "UMLS_LICENSE": UMLSLicense,
321
+ "PHYSIONET_LICENSE_1p5": PhysioNetLicense1p5,
322
+ }
323
+
324
+ licenses.update(custom_licenses)
325
+ for k, v in licenses.items():
326
+ v.short_name = k
327
+
328
+ return licenses
329
+
330
+
331
+ _LICENSES = load_licenses()
332
+ Licenses = SimpleNamespace(**_LICENSES)