summaryrefslogtreecommitdiff
path: root/factories/INL_factory.py
blob: 6607368562de48fdf1cc516ef6a3b4b6021eab86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import entities
from factories import BasicFactory

TAG_TO_ENTITY_MAPPING = {
    '100': entities.Person,
    '110': entities.Institution,
    '151': entities.Location
}


class INLFactory(BasicFactory):
    def __init__(self, tag_to_entity_mapping=None):
        self.mapping = tag_to_entity_mapping or TAG_TO_ENTITY_MAPPING

    def get_entity(self, entity_key, raw_object):
        if entity_key == '100':
            return entities.Person('', '', '')
        elif entity_key == '110':
            return entities.Institution()
        elif entity_key == '151':
            return entities.Location('', '', '')
        else:
            raise KeyError('Key {} was not recognized for factory {}'.format(entity_key, type(self)))