-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbibliographic.py
447 lines (359 loc) · 26.5 KB
/
bibliographic.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
from __future__ import annotations
from datetime import (
datetime,
date
)
from decimal import Decimal
from enum import Enum
import re
import sys
from typing import (
Any,
List,
Literal,
Dict,
Optional,
Union
)
from pydantic.version import VERSION as PYDANTIC_VERSION
if int(PYDANTIC_VERSION[0])>=2:
from pydantic import (
BaseModel,
ConfigDict,
Field,
field_validator
)
else:
from pydantic import (
BaseModel,
Field,
validator
)
metamodel_version = "None"
version = "None"
class WeakRefShimBaseModel(BaseModel):
__slots__ = '__weakref__'
class ConfiguredBaseModel(WeakRefShimBaseModel,
validate_assignment = True,
validate_all = True,
underscore_attrs_are_private = True,
extra = "forbid",
arbitrary_types_allowed = True,
use_enum_values = True):
pass
class RelativeTimeEnum(str, Enum):
BEFORE = "BEFORE"
AFTER = "AFTER"
AT_SAME_TIME_AS = "AT_SAME_TIME_AS"
class HumanLanguageCodeEnum(str):
"""
An enumeration of languages
"""
pass
class PersonStatus(str, Enum):
# the person is living
ALIVE = "ALIVE"
# the person is deceased
DEAD = "DEAD"
# the vital status is not known
UNKNOWN = "UNKNOWN"
class Identified(ConfiguredBaseModel):
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
class Typed(ConfiguredBaseModel):
type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Entity(Typed):
"""
A physical, digital, conceptual, or other kind of thing with some common characteristics
"""
type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Intangible(Entity):
"""
An entity that is not a physical object, process, or information
"""
type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class PhysicalEntity(Entity, Identified):
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["PhysicalEntity"] = Field("PhysicalEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Concept(Intangible, Identified):
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class InformationEntity(Intangible, Identified):
"""
An entity that describes some information
"""
describes: Optional[Any] = Field(None, description="""The thing that is being described""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class PhysicalDevice(PhysicalEntity):
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class StructuredValue(Intangible):
"""
A value that is a structured collection of other values
"""
type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Role(Intangible):
type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Relationship(Intangible):
type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Location(StructuredValue):
type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class PointLocation(Location):
type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Specification(InformationEntity):
"""
A specification of a thing
"""
describes: Optional[Any] = Field(None, description="""The thing that is being described""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Procedure(Specification):
"""
A canonical series of actions conducted in a certain order or manner
"""
describes: Optional[Any] = Field(None, description="""The thing that is being described""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class EntitySet(Intangible):
"""
A group of things. The collection may be heterogeneous or homogeneous.
"""
members: Optional[List[Union[Entity,Intangible,PhysicalEntity,Event,LifeEvent,PhysicalDevice,Agent,CreativeWork,Person,Organization,AutomatedAgent,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,TimePointOrTemporalInterval,Quantity,QuantityRange,Service,Duration,SimpleQuantity,Ratio,TemporalInterval,TimePoint,TemporalRelationship,Location,PointLocation,Specification,Publication,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""")
type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Event(Entity, Identified):
"""
A thing that happens
"""
starts_at: Optional[TimePoint] = Field(None)
ends_at: Optional[TimePoint] = Field(None)
happens_at: Optional[TimePoint] = Field(None)
has_interval: Optional[TemporalInterval] = Field(None)
has_duration: Optional[Duration] = Field(None)
is_ongoing_as_of: Optional[TimePoint] = Field(None)
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class TimePointOrTemporalInterval(Intangible):
starts_at: Optional[TimePoint] = Field(None)
ends_at: Optional[TimePoint] = Field(None)
type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class TemporalInterval(TimePointOrTemporalInterval):
"""
A period of time
"""
starts_at: Optional[TimePoint] = Field(None)
ends_at: Optional[TimePoint] = Field(None)
type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class TimePoint(TimePointOrTemporalInterval):
"""
A point in time. Can be fully specified, or specified in relative terms.
"""
year_value: Optional[int] = Field(None)
date_value: Optional[date] = Field(None)
time_value: Optional[str] = Field(None)
datetime_value: Optional[datetime ] = Field(None)
marker_event: Optional[str] = Field(None)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
starts_at: Optional[TimePoint] = Field(None)
ends_at: Optional[TimePoint] = Field(None)
type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class TemporalRelationship(Relationship):
"""
A relationship to another time point
"""
predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""")
relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None)
type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class QuantityKind(Concept):
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Quantity(Intangible):
has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""")
type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Duration(Quantity):
"""
A length of time
"""
has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""")
type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class SimpleQuantity(Quantity):
"""
A quantity is a property that can be measured or counted
"""
value: Optional[float] = Field(None, description="""The value of the quantity""")
unit: Optional[str] = Field(None)
has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""")
type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Ratio(Quantity):
"""
A tuple of two quantities
"""
numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""")
denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""")
has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""")
type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class QuantityRange(Intangible):
"""
A quantity range is a property that can be measured or counted
"""
lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""")
upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""")
type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class UnitConcept(Concept):
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Agent(PhysicalEntity):
"""
Represents an Agent
"""
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Person(Agent):
"""
Represents a Person
"""
primary_email: Optional[str] = Field(None, description="""The main email address of a person""")
birth_date: Optional[date] = Field(None, description="""Date on which a person is born""")
age_in_years: Optional[int] = Field(None, description="""Number of years since birth""")
vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""")
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
@validator('primary_email', allow_reuse=True)
def pattern_primary_email(cls, v):
pattern=re.compile(r"^\S+@[\S+\.]+\S+")
if isinstance(v,list):
for element in v:
if not pattern.match(element):
raise ValueError(f"Invalid primary_email format: {element}")
elif isinstance(v,str):
if not pattern.match(v):
raise ValueError(f"Invalid primary_email format: {v}")
return v
class Organization(Agent):
"""
Represents an Organization
"""
provides_services: Optional[List[Service]] = Field(default_factory=list)
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class AutomatedAgent(Agent):
"""
Represents an Automated Agent
"""
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class LifeEvent(Event):
starts_at: Optional[TimePoint] = Field(None)
ends_at: Optional[TimePoint] = Field(None)
happens_at: Optional[TimePoint] = Field(None)
has_interval: Optional[TemporalInterval] = Field(None)
has_duration: Optional[Duration] = Field(None)
is_ongoing_as_of: Optional[TimePoint] = Field(None)
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class CreationMetadata(ConfiguredBaseModel):
title: Optional[str] = Field(None, description="""The title of the item""")
abstract: Optional[str] = Field(None, description="""A summary of the item""")
rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""")
creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""")
contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""")
contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""")
keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""")
class CreativeWork(CreationMetadata, PhysicalEntity):
"""
The most generic kind of creative work, including books, movies, photographs, software programs, etc.
"""
title: Optional[str] = Field(None, description="""The title of the item""")
abstract: Optional[str] = Field(None, description="""A summary of the item""")
rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""")
creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""")
contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""")
contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""")
keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""")
classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""")
ontology_types: Optional[List[str]] = Field(default_factory=list)
description: Optional[str] = Field(None, description="""A human-readable description for a thing""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Service(Intangible):
"""
A service provided by an organization
"""
type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
class Publication(InformationEntity):
describes: Optional[Any] = Field(None, description="""The thing that is being described""")
id: str = Field(..., description="""A unique identifier for a thing""")
name: Optional[str] = Field(None, description="""A human-readable name for a thing""")
type: Literal["Publication"] = Field("Publication", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""")
# Update forward refs
# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/
Identified.update_forward_refs()
Typed.update_forward_refs()
Entity.update_forward_refs()
Intangible.update_forward_refs()
PhysicalEntity.update_forward_refs()
Concept.update_forward_refs()
InformationEntity.update_forward_refs()
PhysicalDevice.update_forward_refs()
StructuredValue.update_forward_refs()
Role.update_forward_refs()
Relationship.update_forward_refs()
Location.update_forward_refs()
PointLocation.update_forward_refs()
Specification.update_forward_refs()
Procedure.update_forward_refs()
EntitySet.update_forward_refs()
Event.update_forward_refs()
TimePointOrTemporalInterval.update_forward_refs()
TemporalInterval.update_forward_refs()
TimePoint.update_forward_refs()
TemporalRelationship.update_forward_refs()
QuantityKind.update_forward_refs()
Quantity.update_forward_refs()
Duration.update_forward_refs()
SimpleQuantity.update_forward_refs()
Ratio.update_forward_refs()
QuantityRange.update_forward_refs()
UnitConcept.update_forward_refs()
Agent.update_forward_refs()
Person.update_forward_refs()
Organization.update_forward_refs()
AutomatedAgent.update_forward_refs()
LifeEvent.update_forward_refs()
CreationMetadata.update_forward_refs()
CreativeWork.update_forward_refs()
Service.update_forward_refs()
Publication.update_forward_refs()