blob: d541bb4f91473f2931169828d1114cc1371f21f6 (
plain)
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
|
from entities.basic_entity import BasicEntity
class Person(BasicEntity):
def __init__(self, name, date_of_birth, name_in_langs, bio_data):
"""
:param name:
:param date_of_birth:
:param name_in_langs: Mapping of the persons's name in various languages, as a dictionary. For example:
{
"latin": "George"
"heb": "[george in hebrew]"
}
"""
self.name = name
years_parts = date_of_birth.split('-')
if (len(years_parts) == 2):
self.birth_year = years_parts[0]
self.death_year = years_parts[1]
else:
self.birth_year = date_of_birth.strip()
self.death_year = ''
self.name_in_langs = name_in_langs
place_of_birth = list()
place_of_death = list()
profession = list()
for comment in bio_data:
encoded_comment = ''.join(comment).strip()
if encoded_comment.startswith(u"מקום לידה: "):
place_of_birth.append(encoded_comment.partition(u"מקום לידה: ")[2])
if encoded_comment.startswith(u"מקום פטירה: "):
place_of_death.append(encoded_comment.partition(u"מקום פטירה: ")[2])
if encoded_comment.startswith(u"מקצוע: "):
profession.append(encoded_comment.partition(u"מקום פטירה: ")[2])
self.place_of_birth = place_of_birth
self.place_of_death = place_of_death
self.profession = profession
def print_entity(self):
print("Name = " + self.name)
print("Birth year = " + self.birth_year)
print("Death year = " + self.death_year)
print("Names in langs" + str(self.name_in_langs))
print("Places of birth = " + str(self.place_of_birth))
print("Places of death = " + str(self.place_of_death))
print("profession = " + str(self.profession))
|