Esempio n. 1
0
    def set_function(self):
        """
        Set the use (P366) property.

        Extract the functions from the 'funktion' field,
        whose contents look like 'Kyrka med kyrkotomt,Skola (1 byggnad)'.
        Use the mapping table:
        https://www.wikidata.org/wiki/Wikidata:WikiProject_WLM/Mapping_tables/se-bbr_(sv)/functions
        """
        functions_map = self.data_files["functions"]["mappings"]
        if self.has_non_empty_attribute("funktion"):
            functions_string = utils.get_rid_of_brackets(self.funktion)
            functions = functions_string.lower().split(",")
            for item in functions:
                function = item.strip()
                try:
                    function_item = [
                        functions_map[x]["items"] for x in functions_map
                        if x.lower() == function
                    ]
                    function_item_clean = function_item[0][0]
                    self.add_statement("use", function_item_clean)
                except IndexError:
                    data_string = "{} ({})".format(function, self.funktion)
                    # report both this particular function and the whole
                    # string containing it
                    self.add_to_report("funktion", data_string, "use")
Esempio n. 2
0
    def set_street_address(self):
        """
        Set the street address.

        These all have nice looking street addresses, which, however,
        do not include the municipality name.
        So add it to the address after stripping potential
        bracketed part.
        """
        if utils.contains_digit(self.adresse):
            city_clean = utils.get_rid_of_brackets(self.gemeinde)
            address = "{}, {}".format(self.adresse, city_clean)
            self.add_statement("located_street", address)
Esempio n. 3
0
    def set_address(self):
        """
        Set address / directions.

        Address, with attached city, if there's digits in it.
        Otherwise directions.
        """
        if self.has_non_empty_attribute("address"):
            if utils.contains_digit(self.address):
                if self.has_non_empty_attribute("city"):
                    city_no_brackets = utils.get_rid_of_brackets(self.city)
                    address = "{}, {}".format(self.address, city_no_brackets)
                else:
                    address = self.address
                self.add_statement("located_street", address)
            else:
                dirs = utils.package_monolingual("sr", self.address)
                self.add_statement("directions", dirs)
Esempio n. 4
0
    def update_labels(self):
        """
        Set the label in Swedish.

        Original labels look like this:
            Wickmanska gården (Paradis 35)
        We don't need the latter part (fastighetsbeteckning) in the label.

        If there's an error in parsing the brackets,
        use the raw version.
        """
        clean_name = utils.remove_markup(self.namn)
        try:
            label = utils.get_rid_of_brackets(clean_name)
        except ValueError:
            label = clean_name
            self.add_to_report("malformed_label", self.namn)
        self.add_label("sv", label)
Esempio n. 5
0
    def update_descriptions(self):
        """
        Set the descriptions in en and mt.

        Try to add the place name. Since the municipality
        names are titles of articles, sometimes they
        have the form of "$municipality (Malta)", in which
        case remove the bracketed part.
        """
        patterns = {
            "en": "cultural property in {}",
            "mt": "propjeta' kulturali ġewwa {}"
        }

        placename = "Malta"
        if self.has_non_empty_attribute("gemeinde"):
                municip_base = utils.get_rid_of_brackets(self.gemeinde)
                placename = "{}, {}".format(municip_base, "Malta")

        for lg, descr in patterns.items():
                self.add_description(lg, descr.format(placename))
Esempio n. 6
0
 def update_labels(self):
     spanish = utils.get_rid_of_brackets(utils.remove_markup(
         self.monumento))
     self.add_label("es", spanish)