-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathobjects.py
379 lines (337 loc) · 9.38 KB
/
objects.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
from typing import Union, List
import dataclasses
from dataclasses import dataclass, fields, field
@dataclass
class thing:
name: str = ""
alternateName: List[str] = field(default_factory=list)
description: str = ""
url: str = ""
image: str = "" #url of the image
identifier: str = "" #doi or pid will be stored as identifier
additionalType: str = ""
originalSource: str = ""
source: list() = field(default_factory=list) # this list will have "thing" objects
rankScore: float = 0 #bm25 ranking score for sorting the search results
partiallyLoaded: bool = False
# @classmethod
def __str__(self):
strValue = ""
for field in fields(self):
# print(field.type)
# concatenate all the property values
strValue += f"{getattr(self, field.name)}###"
return strValue
@dataclass
class Organization(thing):
address: str = ""
email: str = ""
legalName: str = ""
location: str = ""
logo: str = "" # url
numberOfEmployees: str = ""
telephone: str = ""
foundingDate: str = ""
keywords: List[str] = field(default_factory=list)
@dataclass
class Person(thing):
additionalName: str = ""
address: str = "" #this should be a list
affiliation: List[Organization] = field(default_factory=list) #this should be a list
alumniOf: List[Organization] = field(default_factory=list) #this should be a list
birthDate: str = ""
birthPlace: str = ""
deathDate: str = ""
deathPlace: str = ""
email: str = "" #this should be a list
familyName: str = ""
gender: str = ""
givenName: str = "" # usually the first name
homeLocation: str = "" #this should be a list
honorificPrefix: str = "" #An honorific prefix preceding a Person's name such as Dr/Mrs/Mr. #this should be a list
honorificSuffix: str = "" #An honorific suffix following a Person's name such as M.D./PhD/MSCSW. #this should be a list
jobTitle: str = "" #this should be a list
nationality: str = "" # we can later link it to country #this should be a list
workLocation: str = "" #this should be a list
worksFor: Organization = None #this should be a list
Organization.founder = List[Person]
# Organization.funder = Union[Organization(), Person()]
Organization.parentOrganization = Organization()
@dataclass
class CreativeWork(thing):
abstract: str = ""
alternativeHeadline: str = ""
author: List[Union[Organization, Person]] = field(default_factory=list)
citation: list() = field(default_factory=list) # this list will have "CreativeWork" objects
countryOfOrigin: str = ""
creativeWorkStatus: str = ""
dateCreated: str = ""
dateModified: str = ""
datePublished: str = ""
encoding_contentUrl: str = ""
encodingFormat: str = ""
funder: Union[Organization, Person] = None # Organization | Person # we can use pipe operator for Union in Python >= 3.10
funding: str = "" # we can change this to Grant
genre: str = ""
headline: str = ""
inLanguage: List[str] = field(default_factory=list)
keywords: List[str] = field(default_factory=list)
license: str = "" # url or license type
publication: str = "" #publication event
publisher: Union[Organization, Person] = None
sourceOrganization: Organization = None
sponsor: Union[Organization, Person] = None
text: str = ""
thumbnail: str = "" #ImageObject
thumbnailUrl: str = "" #url
version: str = ""
@dataclass
class Article(CreativeWork):
articleBody: str = ""
pageEnd: str = ""
pageStart: str = ""
pagination: str = ""
wordCount: str = ""
referenceCount: str = ""
citationCount: str = ""
reference: list() = field(default_factory=list) # this list will have "CreativeWork" or "Article" objects
@dataclass
class Dataset(CreativeWork):
distribution: str = ""
issn: str = ""
@dataclass
class Author(Person):
works_count: str = ""
about: str = ""
banner: str = ""
cited_by_count: str = ""
researchAreas: List[str] = field(default_factory=list)
works: List[Union[Article, Dataset]] = field(default_factory=list)
#The 'Project' is a new addition to schema.org, and as of now, there are no defined properties for it
@dataclass
class Project(CreativeWork):
dateStart: str = ""
dateEnd: str = ""
duration: str = ""
status: str = ""
currency: str = ""
totalCost: str = ""
fundedAmount: str = ""
eu_contribution: str = ""
@dataclass
class SoftwareApplication(CreativeWork):
distribution: str = ""
issn: str = ""
@dataclass
class LearningResource(CreativeWork):
assesses: str = "" #The item being described is intended to assess the competency or learning outcome defined by the referenced term.
competencyRequired: str = ""
educationalAlignment:str = ""
educationalLevel:str = ""
educationalUse:str = ""
learningResourceType:str = ""
teaches:str = "" #The item being described is intended to help a person learn the competency or learning outcome defined by the referenced term.
@dataclass
class MediaObject(CreativeWork):
associatedArticle: str = ""
bitrate: str = ""
contentSize: str = ""
contentUrl: str = ""
duration: str = ""
embedUrl: str = ""
encodesCreativeWork: str = ""
encodingFormat: str = ""
endTime: str = ""
height: str = ""
ineligibleRegion: str = ""
playerType: str = ""
productionCompany: str = ""
regionsAllowed: str = ""
requiresSubscription: str = ""
sha256: str = ""
startTime: str = ""
uploadDate: str = ""
width: str = ""
@dataclass
class VideoObject(MediaObject):
actor: str = ""
caption: str = ""
director: str = ""
embeddedTextCaption: str = ""
musicBy: str = ""
transcript: str = ""
videoFrameSize: str = ""
videoQuality: str = ""
@dataclass
class ImageObject(MediaObject):
caption: str = ""
embeddedTextCaption: str = ""
exifData: str = "" #exif data for this object
representativeOfPage: str = "" #Indicates whether this image is representative of the content of the page
@dataclass
class Place(thing):
additionalProperty: str = ""
address: str = ""
addressType: str = ""
aggregateRating: str = ""
amenityFeature: str = ""
branchCode: str = ""
containedInPlace: str = ""
containsPlace : str = ""
event: str = ""
faxNumber: str = ""
geo: str = ""
geoContains: str = ""
geoCoveredBy: str = ""
geoCovers: str = ""
geoCrosses: str = ""
geoDisjoint: str = ""
geoEquals: str = ""
geoIntersects: str = ""
geoOverlaps: str = ""
geoTouches: str = ""
geoWithin: str = ""
globalLocationNumber: str = ""
hasDriveThroughService: str = ""
hasMap: str = ""
isAccessibleForFree: str = ""
isicV4: str = ""
keywords: str = ""
latitude: str = ""
licence: str = ""
logo: str = ""
longitude: str = ""
maximumAttendeeCapacity: str = ""
openingHoursSpecification: str = ""
photo: str = ""
placType: str = ""
publicAccess: str = ""
review: str = ""
slogan: str = ""
smokingAllowed: str = ""
specialOpeningHoursSpecification: str = ""
telephone: str = ""
tourBookingPage: str = ""
#################################################################################
# classes defined below should not be used, as they are not mapped to schema.org
# ###############################################################################
@dataclass
class Zenodo:
resource_type: str
url: str
date: str # e.g. '2022-07-06'
title: str
description: str
author: str
# @dataclass
# class Zenodo:
# resource_type: str
# url: str
# date: str # e.g. '2022-07-06'
# title: str
# description: str
# author: str
@dataclass
class Institute:
name: str
id: str
country: str
institute_type: str
acronyms_name: str
homepage_url: str
description: str
@dataclass
class Presentation:
title: str
url: str
authors: str
description: str
date: str
@dataclass
class Poster:
title: str
url: str
authors: str
description: str
date: str
# @dataclass
# class Dataset:
# title: str
# url: str
# authors: str
# description: str
# date: str
'''
@dataclass
class Software:
title: str
url: str
date: str
authors: str
description: str
version: str
'''
@dataclass
class Image:
title: str
authors: str
url: str
date: str
@dataclass
class Video:
title: str
url: str
authors: str
date: str
@dataclass
class Lesson:
title: str
url: str
authors: str
description: str
date: str
@dataclass
class Publisher:
id: str
name: str
homepage_url: str
country_codes: str
works_count: str
h_index: str
description: str
@dataclass
class Funder:
name: str
id: str
description: str
country_code: str
grants_count: str
homepage_url: str
works_count: str
@dataclass
class Gesis:
resource_type: str
url: str
date: str
title: str
description: str
authors: str
@dataclass
class Cordis:
id: str
url: str
date: str
title: str
description: str
@dataclass
class Orcid:
id: str
url: str
name: str
@dataclass
class Gepris:
url: str
title: str
description: str
date: str
applicant_or_leader:str