Exemplo n.º 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)
Exemplo n.º 2
0
def add_sites():
    PATH = str(Path(__file__).parent)
    sites = Knead(PATH + "/data/zomergasten/guest-sites.csv").data()

    for site in sites:
        qid = site["qid"]
        url = site["url"]
        name = site["guest"]

        print()
        print(f"Now handling {qid} / {name}")

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

        if Props.OFFICIAL_WEBSITE in claims:
            print("Already got a site, skip")
            continue

        item.add_url_claim(
            Props.OFFICIAL_WEBSITE,
            url,
            qualifiers=[item.get_item_claim(Props.LANGUAGE_WORK, Items.DUTCH)],
            references=[
                item.get_claim(Props.RETRIEVED, wbtime_now()),
                item.get_url_claim(
                    Props.REF_URL,
                    "https://www.vpro.nl/programmas/zomergasten/a-z.html"),
                item.get_item_claim(Props.LANGUAGE_WORK, Items.DUTCH)
            ])
Exemplo n.º 3
0
def add_image_alias(item):
    qid = item["item"]
    img = item["Afbeelding"]
    alias = item["alias"]

    item = WikidataItem(qid)
    claims = item.get_claims()
    aliases = item.get_aliases("nl")

    if img != "" and Props.IMAGE not in claims:
        item.add_commonsmedia(
            Props.IMAGE, img,
            references = [
                item.get_item_claim(Props.IMPORTED_FROM, Items.WIKIPEDIA_NL),
                item.get_url_claim(Props.WM_IMPORT_URL, WP_PERMALINK)
            ]
        )
    else:
        print("has an image already")

    if (alias != "") and (not aliases):
        print(f"Setting alias: {alias}")
        item.edit_aliases({
            "nl" : [ alias ]
        })
    else:
        print("Already has aliases")
Exemplo n.º 4
0
def add_party_data(row):
    print("----" * 20)
    print()
    print(row)

    title = row["title"]
    qid = row["qid"]

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

    item = WikidataItem(qid)

    if Props.NR_OF_SEATS in item.get_claims():
        print("Got seats already, skipping party")
        return

    for key, val in row.items():
        if not key.isdigit():
            continue

        year = int(key)

        if val == "":
            continue

        seats = int(val)

        print(f"{title} ({qid}) had {seats} seats in {year}")

        item.add_quantity_claim(
            Props.NR_OF_SEATS,
            seats,
            qualifiers=[
                item.get_item_claim(Props.LEGISLATIVE_BODY,
                                    Items.NL_LOWER_HOUSE),
                item.get_claim(Props.START_TIME, WbTime(year=year))
            ],
            references=[
                item.get_item_claim(Props.IMPORTED_FROM, Items.WIKIPEDIA_NL),
                item.get_url_claim(Props.WM_IMPORT_URL, WP_PERMALINK)
            ])

    skiplist.add(qid)
Exemplo n.º 5
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)
    )
Exemplo n.º 6
0
def main():
    items = Knead("projects/data/churchseats/seats-qids.csv").data()
    skiplist = Skiplist("projects/skiplists/churchseats.txt")
    permalink = "https://nl.wikipedia.org/w/index.php?title=Lijst_van_grootste_Nederlandse_kerkgebouwen_naar_zitplaatsen&oldid=56777124"

    for index, item in enumerate(items):
        qid = item["qid"]
        title = item["name"]
        seats = item["seats"]
        print()
        print(f"#{index} / #{len(items)}")
        print(f"Handling {qid} / {title} / {seats} seats")

        print(item)

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

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

        if Props.CAPACITY in claims:
            print("This item already has capacity, skipping")
            continue

        wd_item.add_quantity_claim(
            Props.CAPACITY,
            seats,
            references=[
                wd_item.get_item_claim(Props.IMPORTED_FROM,
                                       Items.WIKIPEDIA_NL),
                wd_item.get_url_claim(Props.WM_IMPORT_URL, permalink)
            ])

        skiplist.add(qid)
Exemplo n.º 7
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)