예제 #1
0
    def update_descriptions(self):
        """
        Set descriptions of the object.

        All the objects have a "type" field.
        Use it in connection with the municipality:
        "skanse i Nyborg Kommune"
        """
        mun_dict = self.data_files["municipalities"]
        monument_type = utils.remove_markup(self.type).lower()
        municipality_da = utils.remove_markup(self.kommune)
        description_da = "{} i {}".format(monument_type, municipality_da)
        self.add_description("da", description_da)

        try:
            location_en = [
                x["en"] for x in mun_dict if x["da"] == municipality_da
            ]
            location_en = location_en[0]
        except IndexError:
            location_en = "Denmark"
        description_en = "ancient monument in {}".format(location_en)

        try:
            location_sv = [
                x["sv"] for x in mun_dict if x["da"] == municipality_da
            ]
            location_sv = location_sv[0]
        except IndexError:
            location_sv = "Danmark"
        description_sv = "fornlämning i {}".format(location_sv)

        self.add_description("en", description_en)
        self.add_description("sv", description_sv)
예제 #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)
예제 #3
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)
예제 #4
0
 def set_address(self):
     if self.has_non_empty_attribute("adres"):
         if utils.contains_digit(self.adres):
             town = utils.remove_markup(self.plaats)
             address = "{}, {}".format(self.adres, town)
             self.add_statement("located_street", address)
         else:
             self.add_to_report("adres", self.adres, "located_street")
예제 #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)
예제 #6
0
    def set_labels(self, language, content):
        """
        Add a label in a specific language using content with markup.

        This will clean up markup, for instance if it's a Wiki-link
        it will extract its title.

        :param language: code of language, e.g. "fi"
        :param text: content of the label
        """
        self.add_label(language, utils.remove_markup(content))
예제 #7
0
파일: PlPl.py 프로젝트: Vesihiisi/COH-tools
 def set_location(self):
     settlements_dict = self.data_files["settlements"]
     if utils.count_wikilinks(self.miejscowosc) == 1:
         location = utils.q_from_first_wikilink("pl", self.miejscowosc)
         self.add_statement("location", location)
     else:
         placename = utils.remove_markup(self.miejscowosc)
         try:
             location = [x["item"] for x in settlements_dict if x[
                 "pl"].strip() == placename][0]
             self.add_statement("location", location)
         except IndexError:
             return
예제 #8
0
def bokref_to_work(bokref):
    try:
        title = str(bokref.get("titel").value)
    except ValueError:
        title = ""
    try:
        author = utils.remove_markup(str(bokref.get("författare").value))
    except ValueError:
        try:
            last = bokref.get("efternamn").value
            first = bokref.get("förnamn").value
            author = " ".join([
                utils.remove_markup(str(first)),
                utils.remove_markup(str(last))
            ])
        except ValueError:
            author = ""

    if len(title) > 0:
        title = utils.remove_markup(title)
        work = "{}\t{}".format(title, author)
        return work
예제 #9
0
파일: PlPl.py 프로젝트: Vesihiisi/COH-tools
    def set_address(self):
        """
        Set the address.

        NOTE
        Sometimes this is broken and only a number is included,
        like "70".
        But then you can't just test for if it's only number
        because sometimes it's like "70 B"
        Check for length? Min 5 characters?
        """
        if self.has_non_empty_attribute("adres") and len(self.adres) > 5:
            street = utils.remove_markup(self.adres)
            self.add_statement("located_street", street)
예제 #10
0
    def clean_type(self):
        """
        Return a cleaned version of self.type.

        Multiple types may exist either separated by "<br />" or ",".
        Types may include NATIONAL_IMPORTANCE_STR which should be used only
        for heritage status.
        """
        raw_type = self.type.replace("<br />", ",")
        raw_type = utils.remove_markup(raw_type)
        types = [typ.strip() for typ in raw_type.split(',')]
        if self.NATIONAL_IMPORTANCE_STR in types:
            types.remove(self.NATIONAL_IMPORTANCE_STR)
        types = list(filter(None, types))  # remove empty entries
        return ', '.join(types)
예제 #11
0
    def update_labels(self):
        """
        Create a label.

        Some of the items have the 'namn' column
        filled out, and others don't.
        If it exists, it looks like:
            [[Grytahögen]]
             Kung Björns Grav
        In which case, use that as a label.
        Otherwise, use the RAÄ number as a label:
            Mellby 84:1
        """
        if len(self.namn) == 0:
            self.add_label("sv", self.raa_nr)
        else:
            self.add_label("sv", utils.remove_markup(self.namn))
예제 #12
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)
예제 #13
0
    def set_address_and_disambig(self):
        street_with_no = utils.remove_markup(self.adres.title()).rstrip(',')

        # strip "0" as the number
        streets = [
            street.partition(' 0')[0] for street in street_with_no.split(', ')
        ]
        street_with_non_zero_no = ', '.join(streets)

        if self.has_non_empty_attribute("plaats"):
            # w/o plaats happen
            whole_address = "{}, {}".format(street_with_non_zero_no,
                                            self.plaats)
        else:
            whole_address = street_with_non_zero_no

        qualifier = {"language of name": "Q7411"}  # in dutch
        self.add_statement("located_street", whole_address, qualifier)

        self.add_disambiguator(street_with_non_zero_no, 'nl')
예제 #14
0
    def set_location(self):
        """
        Set the location.

        Using external file of all populated places in Sweden,
        and the 'ort' column,
        add location statement.
        The file contains all subclasses of settlement,
        such as town, village, etc.

        If raw data cannot be matched, add to problem report.
        """
        settlements_dict = self.data_files["settlements"]
        if self.has_non_empty_attribute("ort"):
            try:
                location = [
                    x["item"] for x in settlements_dict
                    if x["sv"].strip() == utils.remove_markup(self.ort)
                ][0]
                self.add_statement("location", location)
            except IndexError:
                self.add_to_report("ort", self.ort)
예제 #15
0
 def update_labels(self):
     spanish = utils.get_rid_of_brackets(utils.remove_markup(
         self.monumento))
     self.add_label("es", spanish)
예제 #16
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)
예제 #17
0
 def update_labels(self):
     """Set Danish label of the object."""
     self.add_label("da", utils.remove_markup(self.stednavn))
예제 #18
0
 def update_labels(self):
     name = utils.remove_markup(self.description)
     self.add_label("hy", name)
예제 #19
0
 def update_labels(self):
     name = utils.remove_markup(self.name)
     self.add_label("hu", name)
예제 #20
0
 def update_labels(self):
     english = utils.remove_markup(self.name)
     self.add_label("en", english)
     if self.has_non_empty_attribute("alternative_names"):
         for alias in self.alternative_names.split(','):
             self.add_label("en", alias.strip())
예제 #21
0
 def update_labels(self):
     dutch = utils.remove_markup(self.omschrijving)
     self.add_label("nl", dutch)
예제 #22
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"))
예제 #23
0
 def update_labels(self):
     spanish = utils.remove_markup(self.monumento)
     self.add_label("es", spanish)
예제 #24
0
 def update_labels(self):
     english = utils.remove_markup(self.name)
     self.add_label("en", english)
예제 #25
0
 def update_labels(self):
     name = utils.remove_markup(self.monumento)
     self.add_label("es", name)
예제 #26
0
 def update_labels(self):
     french = utils.remove_markup(self.monument)
     self.add_label("fr", french)
예제 #27
0
파일: PtPt.py 프로젝트: Vesihiisi/COH-tools
 def update_descriptions(self):
     if self.has_non_empty_attribute("freguesia"):
         freg = utils.remove_markup(self.freguesia)
         desc_en = "heritage site in " + freg + ", Portugal"
         self.add_description("en", desc_en)
         print(desc_en)
예제 #28
0
 def update_labels(self):
     self.add_label("da", utils.remove_markup(self.sagsnavn))
예제 #29
0
 def update_labels(self):
     romanian = utils.remove_markup(self.denumire)
     self.add_label("ro", romanian)
예제 #30
0
파일: PtPt.py 프로젝트: Vesihiisi/COH-tools
 def update_labels(self):
     name = utils.remove_markup(self.designacoes)
     self.add_label("pt", name)