Example #1
0
    def set_title(self):
        """
        Set title of edition.

        Use language code from set_language();
        if it couldn't be extracted there, it will
        default to 'undefined'.
        """
        self.title = None
        raw_title = self.raw_data[1].get("hasTitle")
        if not raw_title:
            return
        if len(raw_title) > 1:
            for title in raw_title:
                if title.get("@type") in ["Title", "CoverTitle"]:
                    self.title = title.get("mainTitle")
        else:
            if raw_title[0].get("@type") == "Title":
                self.title = raw_title[0].get("mainTitle")

        if not self.lang_wikidata:
            language = "und"
        else:
            language = self.lang_wikidata
        if self.title:
            wd_title = utils.package_monolingual(self.title, language)
            self.add_statement("title", wd_title, ref=self.source)
Example #2
0
 def set_address(self):
     street_patterns = ("piața", "str.", "bd.")
     if self.has_non_empty_attribute("adresa"):
         adr_lower = self.adresa.lower()
         adr_nice = utils.remove_markup(self.adresa)
         if any(pattern in adr_lower for pattern in street_patterns):
             if self.has_non_empty_attribute("localitate"):
                 town = utils.remove_markup(self.localitate)
                 adr_nice = "{}, {}".format(adr_nice, town)
             self.add_statement("located_street", adr_nice)
         else:
             directions = utils.package_monolingual(adr_nice, 'ro')
             self.add_statement("directions", directions)
Example #3
0
    def set_directions(self):
        """
        Set directions / address.

        Use street address if 'address' contains digits,
        otherwise add as directions.
        """
        if self.has_non_empty_attribute("address"):
            if utils.contains_digit(self.address):
                self.add_statement("located_street", self.address)
            else:
                monolingual = utils.package_monolingual(self.address, 'hy')
                self.add_statement("directions", monolingual)
Example #4
0
    def set_address(self):
        """
        Set the street address.

        Only if the 'address' field contains a digit.
        Form the address as "$address, $municipality".
        """
        if self.has_non_empty_attribute("address"):
            address = utils.remove_markup(self.address)
            if utils.contains_digit(address):
                placename = utils.remove_markup(self.municipality)
                street_address = "{}, {}".format(address, placename)
                self.add_statement("located_street", street_address)
            else:
                directions = utils.package_monolingual(address, 'ka')
                self.add_statement("directions", directions)
Example #5
0
    def set_street_address(self):
        """
        Set the street address.

        Works if the source data contains a digit.
        Since the place is not included, transpose
        it from the place name.
        """
        if self.has_non_empty_attribute("adresse"):
            addr_raw = utils.remove_markup(self.adresse)
            if utils.contains_digit(addr_raw):
                settlement = utils.remove_markup(self.site)
                address = "{}, {}".format(addr_raw, settlement)
                self.add_statement("located_street", address)
            else:
                monolingual = utils.package_monolingual(addr_raw, 'fr')
                self.add_statement("directions", monolingual)
Example #6
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)
Example #7
0
    def set_subtitle(self):
        """
        Set subtitle.

        Use language code from set_language();
        if it couldn't be extracted there, it will
        default to 'undefined'.
        """
        self.subtitle = None
        raw_subtitle = self.raw_data[1].get("hasTitle")
        if not raw_subtitle:
            return
        if raw_subtitle[0].get("subtitle"):
            subtitle = raw_subtitle[0].get("subtitle")
            self.subtitle = subtitle
            wd_subtitle = utils.package_monolingual(subtitle,
                                                    self.lang_wikidata)
            self.add_statement("subtitle", wd_subtitle, ref=self.source)
Example #8
0
 def set_directions(self):
     if self.has_non_empty_attribute("direccion"):
         monolingual = utils.package_monolingual(
             utils.remove_markup(self.direccion), 'es')
         self.add_statement("directions", monolingual)
Example #9
0
 def set_directions(self):
     if self.has_non_empty_attribute("address"):
         dirs = utils.package_monolingual(self.address, "en")
         self.add_statement("directions", dirs)
Example #10
0
 def set_directions(self):
     if self.has_non_empty_attribute("address"):
         monolingual = utils.package_monolingual(self.address, 'fa')
         self.add_statement("directions", monolingual)
Example #11
0
 def set_directions(self):
     if self.has_non_empty_attribute("direccion"):
         directions = utils.remove_markup(self.direccion)
         self.add_statement("directions",
                            utils.package_monolingual(directions, "es"))