Ejemplo n.º 1
0
    def set_heritage_bbr(self):
        """
        Set the specific type of heritage status.

        In Sweden there are three different types of legal protection
        for different types of cultural heritage,
        so we created three new items:

        governmental listed building complex (Q24284071)
        for buildings owned by the state,

        individual listed building complex (Q24284072)
        for privately owned buildings,

        ecclesiastical listed building complex (Q24284073)
        for older buildings owned by the Church of Sweden.
        """
        type_q = None
        protection_date = False
        if self.online_data is None:
            self.add_to_report("invalid_bbr_url", self.bbr_link)
            return
        for element in self.online_data["@graph"]:
            if "ns5:spec" in element:
                bbr_type = element["ns5:spec"]
                if bbr_type.startswith("Kyrkligt kulturminne"):
                    # Kyrkligt kulturminne. 4 kap. KML -- these don't seem to
                    # have dates
                    type_q = "Q24284073"
                elif bbr_type.startswith("Byggnadsminne"):
                    # Byggnadsminne (BM) 3 kap. KML (1977-02-25)
                    type_q = "Q24284072"
                    protection_date = bbr_type.split("(")[-1][:-1]
                elif bbr_type.startswith("Statligt byggnadsminne"):
                    # Statligt byggnadsminne (SBM). Förordning (2013:558)
                    # (1935-01-25)
                    type_q = "Q24284071"
                    protection_date = bbr_type.split("(")[-1][:-1]
        # The original set_heritage() added an empty claim
        # because there's no heritage status specified in mapping file,
        # so we start by removing that empty claim.
        self.remove_statement("heritage_status")
        qualifier = None
        if protection_date:
            # 1969-01-31
            try:
                date_dict = utils.date_to_dict(protection_date, "%Y-%m-%d")
                qualifier = {"start_time": utils.package_time(date_dict)}
            except ValueError:
                self.add_to_report("protection_type", bbr_type)
        url = "http://kulturarvsdata.se/{}".format(self.kulturarv_id)
        kulturarv_source = self.create_kulturarv_source(url)
        if type_q:
            self.add_statement("heritage_status",
                               type_q,
                               qualifier,
                               refs=[kulturarv_source])
        else:
            self.add_to_report("heritage_status", self.kulturarv_id,
                               "heritage_status")
Ejemplo n.º 2
0
    def set_heritage(self):
        """
        Set heritage status with optional qualifiers.

        The heritage type is set by 'tipo'
        Use 'decreto' as 'legal_citation'.
        Extract date from 'fecha' as 'start time'.
        """
        quals = {}

        heritage_default = self.mapping["heritage"]["item"]
        heritages = {"MH": "Q35863415", "SN": "Q35863088", "ZT": "Q6171610"}
        heritage_item = heritages.get(self.tipo) or heritage_default

        if self.has_non_empty_attribute("decreto"):
            quals["legal_citation"] = self.decreto

        if self.has_non_empty_attribute("fecha"):
            es_date = dateparser.parse(self.fecha, languages=['es'])
            if es_date:
                date_dict = utils.datetime_object_to_dict(es_date)
                quals["start_time"] = utils.package_time(date_dict)
            else:
                self.add_to_report("fecha", self.fecha, "start_time")

        self.add_statement("heritage_status", heritage_item, quals)
Ejemplo n.º 3
0
 def set_building_year(self):
     if self.has_non_empty_attribute("bouwjaar"):
         if utils.legit_year(self.bouwjaar):
             self.add_statement("inception",
                                utils.package_time({"year": self.bouwjaar}))
         else:
             self.add_to_report("bouwjaar", self.bouwjaar, "inception")
Ejemplo n.º 4
0
 def set_inception(self):
     if self.has_non_empty_attribute("date"):
         if utils.legit_year(self.date):
             inc_year = utils.package_time({"year": self.date})
             self.add_statement("inception", inc_year)
         else:
             self.add_to_report("date", self.date, "inception")
Ejemplo n.º 5
0
    def set_inception(self):
        """Set building year if parseable."""
        if self.has_non_empty_attribute("construido"):
            date_dict = None
            if utils.legit_year(self.construido):
                # plain years cannot be sent to dateparser
                date_dict = {"year": self.construido}
            else:
                date_p = dateparser.parse(self.construido)
                if date_p:
                    date_dict = utils.datetime_object_to_dict(date_p)

            if date_dict:
                self.add_statement("inception", utils.package_time(date_dict))
            else:
                self.add_to_report("construido", self.construido, "inception")
Ejemplo n.º 6
0
    def set_inception(self):
        """
        Set the building year.

        The 'byggar' column can have many forms,
        but here we only process the obvious cases:
            1865
            [[1865]]
        It can also look like:
            1100- eller 1200-talet
        and many other variants, which are ignored.
        """
        if self.has_non_empty_attribute("byggar"):
            year_parsed = utils.parse_year(self.byggar)
            if isinstance(year_parsed, int):
                date_dict = {"year": year_parsed}
                self.add_statement("inception", utils.package_time(date_dict))
Ejemplo n.º 7
0
    def set_manufacture_year(self):
        """
        Set the manufacture year.

        If the column 'byggar' has a parsable value,
        use it as year of manufacture.
        Use WLM database as a source.
        """
        if self.has_non_empty_attribute("byggar"):
            byggar = utils.parse_year(
                utils.remove_characters(self.byggar, ".,"))
            if isinstance(byggar, int):
                ref = self.wlm_source
                self.add_statement(
                    "inception", utils.package_time({"year": byggar}),
                    refs=[ref])
            else:
                self.add_to_report("byggår", self.byggar)
Ejemplo n.º 8
0
    def set_heritage(self):
        """Set the heritage status, using mapping file."""
        if self.has_non_empty_attribute("registration_date"):
            try:
                iso_date = JalaliCalendar(self.registration_date).get_date()
            except TypeError:
                print("dateparser.JalaliCalendar could not handle: {}".format(
                    self.registration_date))
                iso_date = None

            if iso_date:
                date_dict = utils.datetime_to_dict(iso_date.get('date_obj'),
                                                   "%Y%m%d")
                qualifier = {"start_time": utils.package_time(date_dict)}
                heritage = self.mapping["heritage"]["item"]
                self.add_statement("heritage_status", heritage, qualifier)
            else:
                self.add_to_report("registration_date", self.registration_date,
                                   "start_time")
        else:
            super().set_heritage()
Ejemplo n.º 9
0
    def set_heritage(self):
        """
        Set heritage.

        National Monument of Bosnia and Herzegovina (Q12637954)
        with facultative start date and
        'described at url'.
        """
        heritage = self.mapping["heritage"]["item"]
        url = self.clean_url()
        date_parsed = dateparser.parse(self.designated)
        quals = {}
        if date_parsed:
            date_dict = utils.datetime_object_to_dict(date_parsed)
            quals["start_time"] = utils.package_time(date_dict)
        if url:
            quals["described_at_url"] = url

        self.add_statement("heritage_status",
                           heritage,
                           quals=quals,
                           refs=self.source)
Ejemplo n.º 10
0
    def set_heritage(self):
        """
        Set heritage status with or without start date.

        If possible to parse the date of when
        the heritage status was assigned, add it
        as qualifier to the heritage status property.
        Otherwise, add default heritage status
        without start date.
        """
        if self.has_non_empty_attribute("beschermd"):
            prot_date = self.beschermd
            try:
                date_dict = utils.date_to_dict(prot_date, "%d/%m/%Y")
                qualifier = {"start_time": utils.package_time(date_dict)}
                heritage = self.mapping["heritage"]["item"]
                self.add_statement("heritage_status", heritage, qualifier)
            except ValueError:
                self.add_to_report("beschermd", self.beschermd,
                                   "heritage_status")
                return super().set_heritage()
        else:
            return super().set_heritage()
Ejemplo n.º 11
0
 def set_inception(self):
     if self.has_non_empty_attribute("opforelsesar"):
         inception = utils.parse_year(self.opforelsesar)
         if isinstance(inception, int):
             self.add_statement("inception",
                                utils.package_time({"year": inception}))