Example #1
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)
Example #2
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)
Example #3
0
def create_seasons():
    PATH = str(Path(__file__).parent)
    seasons = Knead(PATH + "/data/zomergasten/zomergasten.json").data()

    # Sort seasons by season_nr
    seasons.sort(key=lambda i: i["season_nr"])

    for season in seasons:
        season_nr = season["season_nr"]
        print("----" * 20)
        print()
        print(f"Handling season #{season_nr}")

        year = season["year"]
        presenter_name = season["presenter"]["title"]
        presenter_qid = season["presenter"]["qid"]
        episodes_count = len(season["guests"])

        if season_nr < 4:
            print("Existing season, skipping")
            continue

        desc = {
            "label_en":
            f"Zomergasten season {season_nr} ({year})",
            "label_nl":
            f"Zomergasten seizoen {season_nr} ({year})",
            "description_en":
            f"Season {season_nr} of the Dutch talk show 'Zomergasten', as broadcasted by VPRO in {year}",
            "description_nl":
            f"Seizoen {season_nr} van het VPRO-televisieprogramma 'Zomergasten', uitgezonden in {year}",
            "aliases_en":
            [f"Zomergasten {year}", f"Zomergasten season {season_nr}"],
            "aliases_nl":
            [f"Zomergasten {year}", f"Zomergasten seizoen {season_nr}"]
        }

        item = WikidataItem(
            summary=f"Creating new item for the Zomergasten season {season_nr}",
            labels={
                "en": desc["label_en"],
                "nl": desc["label_nl"]
            },
            descriptions={
                "en": desc["description_en"],
                "nl": desc["description_nl"]
            },
            aliases={
                "en": desc["aliases_en"],
                "nl": desc["aliases_nl"]
            })

        item.add_item_claim(Props.INSTANCE_OF, Items.TV_SERIES_SEASON)
        item.add_item_claim(Props.PART_OF_SERIES,
                            Items.ZOMERGASTEN,
                            qualifiers=[
                                item.get_string_claim(Props.SERIES_ORDINAL,
                                                      str(season_nr))
                            ])
        item.add_item_claim(Props.PRESENTER,
                            presenter_qid,
                            references=get_ref(item))
        item.add_time_claim(Props.PUB_DATE,
                            pywikibot.WbTime(year=year),
                            references=get_ref(item))
        item.add_item_claim(Props.GENRE, Items.TALK_SHOW)
        item.add_item_claim(Props.ORIGINAL_BROADCASTER, Items.VPRO)
        item.add_item_claim(Props.COUNTRY_OF_ORIGIN, Items.NETHERLANDS)
        item.add_item_claim(Props.LANGUAGE_SHOW, Items.DUTCH)
        item.add_item_claim(Props.DISTRIBUTED_BY, Items.NPO)
        item.add_quantity_claim(Props.NR_OF_EPISODES,
                                episodes_count,
                                references=get_ref(item))