Example #1
0
def main():
    items = Knead(PATH + "/data/uds/monuments-with-qids.csv").data()
    skiplist = Skiplist("projects/skiplists/uds.txt")

    for index, item in enumerate(items):
        print(item)
        qid = item["qid"]
        bag = item["bag_ok"]
        url = item["url"]
        print()
        print(f"#{index} / #{len(items)}")
        print(f"Handling {qid} / {bag} / {url}")

        if skiplist.has(qid):
            print(f"{qid} in skiplist, skipping")
            continue

        wd_item = WikidataItem(qid)
        claims = wd_item.get_claims()

        if Props.BAG_BUILDING in claims:
            print("This item already has a BAG building ID, skipping")
            continue

        wd_item.add_string_claim(
            Props.BAG_BUILDING,
            bag,
            references=[
                wd_item.get_item_claim(Props.STATED_IN, Items.UDS_DOC),
                wd_item.get_url_claim(Props.REF_URL, url),
                wd_item.get_item_claim(Props.LANGUAGE_WORK, Items.DUTCH)
            ])

        skiplist.add(qid)
Example #2
0
def add_inventory(item):
    qid = item["item"]
    url = item["url"]

    if "https://www.nijmegen.nl/kos/kunstwerk" not in url:
        return

    kid = url.replace("https://www.nijmegen.nl/kos/kunstwerk.aspx?id=", "")

    item = WikidataItem(qid)

    if Props.INVENTORY_NR in item.get_claims():
        print("has inventory!")
        return

    item.add_string_claim(
        Props.INVENTORY_NR, kid,
        qualifiers = [
            item.get_item_claim(Props.COLLECTION, Items.PUBLIC_ART_IN_NIJMEGEN)
        ],
        references = get_refs(item, url)
    )
Example #3
0
def create_new():
    items = Knead(PATH + "/data/reliwiki/new-churches.csv",
                  has_header=True).data()
    CITY = "Amsterdam"

    for church in items:
        print()
        print(f"Creating new church", church)
        pageid = church["pageid"]

        # Last, final check if this church doesn't exist
        if claim_exists(Props.RELIWIKI, f'"{pageid}"'):
            print(f"This Reliwiki ID exists, skipping")
            continue

        name = church["name"]

        item = WikidataItem(
            summary=f"Creating new item for Dutch church with name {name}",
            labels={
                "en": name,
                "nl": name
            },
            descriptions={
                "de": f"Kirche in {CITY} (Niederlande)",
                "en": f"church in {CITY}, the Netherlands",
                "es": f"iglesia en {CITY} (Holanda)",
                "fr": f"Église d'{CITY} (Pays-Bas)",
                "nl": f"kerk in {CITY}"
            })

        item.add_item_claim(Props.INSTANCE_OF, Items.CHURCH_BUILDING)
        item.add_string_claim(Props.RELIWIKI, pageid)
        item.add_item_claim(Props.COUNTRY, Items.NETHERLANDS)
        item.add_item_claim(Props.LOCATED_IN, church["admin_qid"])

        if church["sonneveld"] != "":
            item.add_string_claim(Props.SONNEVELD,
                                  church["sonneveld"],
                                  references=get_refs(item, pageid))

        if church["coordinates"] != "":
            coord = church["coordinates"].split(",")
            item.add_coordinate(Props.COORDINATES,
                                coord,
                                references=get_refs(item, pageid))

        if church["zipcode"] != "":
            item.add_string_claim(Props.ZIP,
                                  church["zipcode"],
                                  references=get_refs(item, pageid))

        if church["address"] != "":
            item.add_monoling_claim(Props.STREET_ADDRESS,
                                    church["address"],
                                    "nl",
                                    references=get_refs(item, pageid))

        if church["denomination_qid"] != "":
            item.add_item_claim(Props.RELIGION,
                                church["denomination_qid"],
                                references=get_refs(item, pageid))

        if church["year_use"] != "":
            if "s" in church["year_use"]:
                decade = int(church["year_use"].replace("s", ""))
                time = WbTime(year=decade, precision="decade")
            else:
                time = WbTime(year=int(church["year_use"]))

            item.add_time_claim(Props.INCEPTION,
                                time,
                                references=get_refs(item, pageid))

        print()

        break
Example #4
0
def add_item(data):
    print("----" * 20)
    print()
    print(data)

    title = data["title"]
    url = data["url"]
    kid = data["id"]

    # if kid != "50":
    #     return

    print(f"Handling {title}")

    if skiplist.has(kid):
        print(f"In skiplist, skipping")
        return

    creator = data["creator"]

    if creator == "":
        desc_nl = "kunstwerk in de openbare ruimte te Nijmegen"
        desc_en = "public artwork in Nijmegen, the Netherlands"
    elif creator == "Onbekend":
        desc_nl = "kunstwerk in de openbare ruimte van een onbekende maker te Nijmegen"
        desc_en = "public artwork by an unknown artist in Nijmegen, the Netherlands"
    else:
        desc_nl = f"kunstwerk van {creator} in de openbare ruimte te Nijmegen"
        desc_en = f"public artwork by {creator} in Nijmegen, the Netherlands"

    item = WikidataItem(
        summary = f"public artwork '{title}' in Nijmegen, the Netherlands",
        labels = {
            "nl" : title
        }
    )

    item.edit_descriptions({
            "de" : f"Kunst im öffentlichen Raum in Nijmegen (Niederlande)",
            "en" : desc_en,
            "es" : f"arte público en Nijmegen (Holanda)",
            "fr" : f"art public à Nimègue (Pays-Bas)",
            "nl" : desc_nl
    })

    item.edit_aliases({
        "en" : title
    })

    # Basics
    item.add_item_claim(Props.INSTANCE_OF, Items.SCULPTURE)
    item.add_item_claim(Props.COUNTRY, Items.NETHERLANDS)
    item.add_item_claim(Props.LOCATED_IN_ADMIN, Items.NIJMEGEN_MUNIP)
    item.add_item_claim(Props.GENRE, Items.PUBLIC_ART)


    # Actual data
    coord = [data["lat"], data["lon"]]
    item.add_coordinate(
        Props.COORDINATES, coord, references = get_refs(item, url)
    )

    item.add_string_claim(
        Props.INVENTORY_NR, kid,
        qualifiers = [
            item.get_item_claim(Props.COLLECTION, Items.PUBLIC_ART_IN_NIJMEGEN)
        ],
        references = get_refs(item, url)
    )

    item.add_string_claim(
        Props.DESCRIBED_AT_URL,
        url,
        qualifiers = [
            item.get_item_claim(Props.LANGUAGE_WORK, Items.DUTCH)
        ]
    )

    if data["year"] != "":
        year = int(data["year"])
        item.add_time_claim(
            Props.INCEPTION, WbTime(year = year), references = get_refs(item, url)
        )

    if data["creator_qid"] != "":
        item.add_item_claim(
            Props.CREATOR, data["creator_qid"], references = get_refs(item, url)
        )
    elif data["creator"] == "Onbekend":
        item.add_item_claim(
            Props.CREATOR, "somevalue", references = get_refs(item, url)
        )

    if data["owner"] == "gemeente":
        item.add_item_claim(
            Props.COLLECTION, Items.NIJMEGEN_MUNIP, references = get_refs(item, url)
        )
    elif data["owner"] == "particulier":
        item.add_item_claim(
            Props.COLLECTION, Items.PRIVATE_COLLECTION, references = get_refs(item, url)
        )

    if data["location_clean"] != "":
        item.add_monoling_claim(
            Props.STREET_ADDRESS, data["location_clean"], "nl", references = get_refs(item, url)
        )

    skiplist.add(kid)