diff --git a/biographic-timelines/jls-editorial-board.rmd b/biographic-timelines/jls-editorial-board.rmd index c295290f212a96139e51eb006acf5b7070a2002d..2987dece1371145ff2a2510845489f96618a39fc 100644 --- a/biographic-timelines/jls-editorial-board.rmd +++ b/biographic-timelines/jls-editorial-board.rmd @@ -13,7 +13,7 @@ library(htmlwidgets) vertical_stripes = "background: repeating-linear-gradient(to right, transparent, transparent 2px, lightgray 2px, lightgray 4px);" diagonal_stripes = "background: repeating-linear-gradient(135deg, transparent, transparent 2px, lightgray 2px, lightgray 4px);" -editors <- read_excel("data/jls-editors.xlsx") %>% +editors <- read_excel("data/jls-editors.xlsx") |> mutate( content = name, title = name, @@ -30,6 +30,6 @@ hw <- timevis(editors, width = "1500px", options = list(start="1974-01-01", end = "2025-12-31", selectable=FALSE, showCurrentTime = FALSE)) -saveWidget(hw, "docs/jls-editors.html") -unlink("docs/jls-editors_files", recursive = TRUE) +saveWidget(hw, "jls-editors.html") +unlink("jls-editors_files", recursive = TRUE) ``` \ No newline at end of file diff --git a/wikidata/.gitignore b/wikidata/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..eab782912afeca927c87be0bcb6a4fa49fc01f40 --- /dev/null +++ b/wikidata/.gitignore @@ -0,0 +1 @@ +timeline_data.xlsx \ No newline at end of file diff --git a/wikidata/query-wikidata.ipynb b/wikidata/query-wikidata.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..62233c8afd2b9036f271260ff293860e7c1e39bd --- /dev/null +++ b/wikidata/query-wikidata.ipynb @@ -0,0 +1,265 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 45, + "id": "initial_id", + "metadata": { + "collapsed": true, + "ExecuteTime": { + "end_time": "2024-03-06T15:11:09.869085700Z", + "start_time": "2024-03-06T15:11:09.839951600Z" + } + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd\n", + "\n", + "def generate_sparql_query(fullName, property_labels_to_ids, language='en'):\n", + " \"\"\"\n", + " Query WikiData for the properties of the given person listed in the given property map.\n", + " All properties that are simple values without a label must have an \"_id\" suffix, all date\n", + " properties must begin with \"date\"\n", + " :param fullName: \n", + " :param property_labels_to_ids: \n", + " :param language: \n", + " :return: \n", + " \"\"\"\n", + " propSelection = \"\"\n", + " for label, pid in property_labels_to_ids.items():\n", + " if label.endswith(\"_id\") or label.startswith(\"image\"):\n", + " propSelection += f\"OPTIONAL {{ ?item wdt:{pid} ?{label}. }}\"\n", + " elif label.startswith(\"date\"): \n", + " # Dates, fetched directly but need special handling for formatting if desired\n", + " propSelection += f\"OPTIONAL {{ ?item wdt:{pid} ?{label}. }}\" \n", + " else:\n", + " propSelection += f\"\"\"OPTIONAL {{ ?item wdt:{pid} ?{label}Id .\n", + " ?{label}Id rdfs:label ?{label} FILTER(LANG(?{label}) = \"{language}\") .\n", + " SERVICE wikibase:label {{ bd:serviceParam wikibase:language \"{language}\". }} }}\"\"\"\n", + "\n", + " # Include English and German Wikipedia URLs\n", + " wikipediaURLs = \"\"\"\n", + " OPTIONAL { ?article schema:about ?item; schema:inLanguage \"en\"; schema:isPartOf <https://en.wikipedia.org/>. BIND(CONCAT(STR(?article)) AS ?englishWikipedia) }\n", + " OPTIONAL { ?article schema:about ?item; schema:inLanguage \"de\"; schema:isPartOf <https://de.wikipedia.org/>. BIND(CONCAT(STR(?article)) AS ?germanWikipedia) }\n", + " \"\"\"\n", + "\n", + " query = f\"\"\"\n", + " SELECT DISTINCT ?itemLabel {\"\".join([f\"(SAMPLE(?{label}) AS ?{label})\" for label in property_labels_to_ids])} ?englishWikipedia ?germanWikipedia WHERE {{\n", + " ?item wdt:P31 wd:Q5; rdfs:label \"{fullName}\"@{language}.\n", + " {propSelection}\n", + " {wikipediaURLs}\n", + " }}\n", + " GROUP BY ?itemLabel ?englishWikipedia ?germanWikipedia\n", + " \"\"\"\n", + " return query\n", + "\n", + "def construct_image_url(filename):\n", + " return f\"https://commons.wikimedia.org/wiki/Special:FilePath/{requests.utils.quote(filename)}\"\n", + "\n", + "\n", + "def query_wikidata(fullName, property_labels_to_ids, language='en'):\n", + " SPARQL_ENDPOINT = \"https://query.wikidata.org/sparql\"\n", + " query = generate_sparql_query(fullName, property_labels_to_ids, language)\n", + " headers = {'User-Agent': 'Mozilla/5.0', 'Accept': 'application/json'}\n", + " response = requests.get(SPARQL_ENDPOINT, headers=headers, params={'query': query, 'format': 'json'})\n", + "\n", + " if response.status_code == 200:\n", + " results = response.json()['results']['bindings']\n", + " data = {'fullName': fullName} # Initialize with fullName to ensure it appears first\n", + " if results:\n", + " for label in property_labels_to_ids:\n", + " if f\"{label}\" in results[0]:\n", + " value = results[0][f\"{label}\"]['value']\n", + " #if label.startswith(\"image\"):\n", + " # value = construct_image_url(value)\n", + " data[label] = value\n", + " else:\n", + " data[label] = None\n", + " return data\n", + " return None\n", + "\n", + "def properties_to_dataframe(names, property_labels_to_ids, language='en'):\n", + " all_data = []\n", + " for fullName in names:\n", + " data = query_wikidata(fullName, property_labels_to_ids, language)\n", + " if data:\n", + " all_data.append(data)\n", + " if all_data:\n", + " # Ensure fullName appears first by reordering columns based on property_labels_to_ids keys\n", + " columns_order = ['fullName'] + list(property_labels_to_ids.keys())\n", + " df = pd.DataFrame(all_data, columns=columns_order)\n", + " else:\n", + " df = pd.DataFrame(columns=['fullName'] + list(property_labels_to_ids.keys()))\n", + " return df\n", + "\n", + "\n", + "\n", + "# Now calling the updated function with the 'language' parameter\n", + "property_labels_to_ids = {\n", + " 'sexOrGender': 'P21',\n", + " 'image': 'P18',\n", + " 'countryOfCitizenship': 'P27',\n", + " 'givenName': 'P735',\n", + " 'familyName': 'P734',\n", + " 'dateOfBirth': 'P569',\n", + " 'dateOfDeath': 'P570',\n", + " 'occupation': 'P106',\n", + " 'fieldOfWork': 'P101',\n", + " 'employer': 'P108',\n", + " 'viaf_id': 'P214',\n", + " 'isni_id': 'P213',\n", + " 'gnd_id': 'P227'\n", + "}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "outputs": [ + { + "data": { + "text/plain": " fullName sexOrGender \\\n0 Hans Kelsen male \n1 Hugo Sinzheimer male \n2 Karl Renner male \n3 Ernst Fraenkel male \n4 Franz Leopold Neumann male \n5 Otto Kahn-Freund male \n6 Otto Kirchheimer male \n7 Ludwig Bendix male \n8 Arthur Nussbaum male \n9 Theodor Geiger male \n10 Erhard Blankenburg male \n11 Wolfgang Kaupen male \n12 Rüdiger Lautmann male \n13 Thilo Ramm male \n14 Rudolf Wiethölter male \n15 Niklas Luhmann male \n16 Gunther Teubner male \n\n image \\\n0 http://commons.wikimedia.org/wiki/Special:File... \n1 http://commons.wikimedia.org/wiki/Special:File... \n2 http://commons.wikimedia.org/wiki/Special:File... \n3 None \n4 None \n5 http://commons.wikimedia.org/wiki/Special:File... \n6 None \n7 None \n8 http://commons.wikimedia.org/wiki/Special:File... \n9 None \n10 http://commons.wikimedia.org/wiki/Special:File... \n11 None \n12 http://commons.wikimedia.org/wiki/Special:File... \n13 None \n14 None \n15 http://commons.wikimedia.org/wiki/Special:File... \n16 http://commons.wikimedia.org/wiki/Special:File... \n\n countryOfCitizenship givenName familyName dateOfBirth \\\n0 Czechoslovakia Hans Kelsen 1881-10-11T00:00:00Z \n1 Germany Hugo Sinzheimer 1875-04-12T00:00:00Z \n2 First Republic of Austria Karl Renner 1870-12-14T00:00:00Z \n3 Germany Ernst Fraenkel 1891-04-05T00:00:00Z \n4 None Leopold Neumann None \n5 Germany Otto None 1900-11-17T00:00:00Z \n6 Germany Otto Kirchheimer 1905-11-11T00:00:00Z \n7 Germany Ludwig Bendix 1877-06-28T00:00:00Z \n8 Germany Arthur Nussbaum 1877-01-31T00:00:00Z \n9 Germany Theodor Geiger 1891-11-09T00:00:00Z \n10 Germany Erhard Blankenburg 1938-10-30T00:00:00Z \n11 None Wolfgang None 1936-01-01T00:00:00Z \n12 Germany Rüdiger None 1935-12-22T00:00:00Z \n13 Germany Thilo Ramm 1925-04-04T00:00:00Z \n14 Germany Rudolf None 1929-07-17T00:00:00Z \n15 Germany Niklas Luhmann 1927-12-08T00:00:00Z \n16 Germany Gunther Teubner 1944-04-30T00:00:00Z \n\n dateOfDeath occupation fieldOfWork \\\n0 1973-04-19T00:00:00Z lawyer law \n1 1945-09-16T00:00:00Z lawyer None \n2 1950-12-31T00:00:00Z lawyer politics \n3 1971-08-18T00:00:00Z university teacher None \n4 None printer publishing \n5 1979-08-16T00:00:00Z judge None \n6 1965-11-22T00:00:00Z jurist None \n7 1954-01-03T00:00:00Z lawyer None \n8 1964-11-22T00:00:00Z lawyer international law \n9 1952-06-16T00:00:00Z sociologist None \n10 2018-03-28T00:00:00Z sociology of law sociology of law \n11 1981-01-01T00:00:00Z sociologist sociology of law \n12 None author sociology of law \n13 2018-06-17T00:00:00Z writer None \n14 None jurist None \n15 1998-11-06T00:00:00Z lawyer sociology of law \n16 None jurist None \n\n employer viaf_id \\\n0 Charles University 31998356 \n1 University of Amsterdam 27864307 \n2 Austrian Federal Government 61669459 \n3 Goethe University Frankfurt 50078162 \n4 None 637163874508945722514 \n5 University of Oxford 76317591 \n6 Office of Strategic Services 32042801 \n7 None 74647579 \n8 Frederick William University Berlin 5180962 \n9 Technical University of Braunschweig 56667946 \n10 Free University of Amsterdam 64109592 \n11 None 32919813 \n12 University of Bremen 24732961 \n13 University of Freiburg 9924244 \n14 Goethe University Frankfurt 106974404 \n15 Bielefeld University 29546145 \n16 Goethe University Frankfurt 108364502 \n\n isni_id gnd_id \n0 0000000121266076 118561219 \n1 0000000109619641 118614711 \n2 0000000121358165 118599739 \n3 None 121259854 \n4 None None \n5 0000000109168959 118559362 \n6 0000000081110244 118562371 \n7 0000000081553379 118702033 \n8 0000000120988288 117071676 \n9 0000000109038951 118538187 \n10 0000000110676109 115459235 \n11 0000000035495614 124045405 \n12 000000011469331X 120502208 \n13 0000000108689541 116327391 \n14 0000000116961365 1034437860 \n15 0000000122778532 118575147 \n16 0000000109312017 119443562 ", + "text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>fullName</th>\n <th>sexOrGender</th>\n <th>image</th>\n <th>countryOfCitizenship</th>\n <th>givenName</th>\n <th>familyName</th>\n <th>dateOfBirth</th>\n <th>dateOfDeath</th>\n <th>occupation</th>\n <th>fieldOfWork</th>\n <th>employer</th>\n <th>viaf_id</th>\n <th>isni_id</th>\n <th>gnd_id</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>Hans Kelsen</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Czechoslovakia</td>\n <td>Hans</td>\n <td>Kelsen</td>\n <td>1881-10-11T00:00:00Z</td>\n <td>1973-04-19T00:00:00Z</td>\n <td>lawyer</td>\n <td>law</td>\n <td>Charles University</td>\n <td>31998356</td>\n <td>0000000121266076</td>\n <td>118561219</td>\n </tr>\n <tr>\n <th>1</th>\n <td>Hugo Sinzheimer</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Hugo</td>\n <td>Sinzheimer</td>\n <td>1875-04-12T00:00:00Z</td>\n <td>1945-09-16T00:00:00Z</td>\n <td>lawyer</td>\n <td>None</td>\n <td>University of Amsterdam</td>\n <td>27864307</td>\n <td>0000000109619641</td>\n <td>118614711</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Karl Renner</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>First Republic of Austria</td>\n <td>Karl</td>\n <td>Renner</td>\n <td>1870-12-14T00:00:00Z</td>\n <td>1950-12-31T00:00:00Z</td>\n <td>lawyer</td>\n <td>politics</td>\n <td>Austrian Federal Government</td>\n <td>61669459</td>\n <td>0000000121358165</td>\n <td>118599739</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Ernst Fraenkel</td>\n <td>male</td>\n <td>None</td>\n <td>Germany</td>\n <td>Ernst</td>\n <td>Fraenkel</td>\n <td>1891-04-05T00:00:00Z</td>\n <td>1971-08-18T00:00:00Z</td>\n <td>university teacher</td>\n <td>None</td>\n <td>Goethe University Frankfurt</td>\n <td>50078162</td>\n <td>None</td>\n <td>121259854</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Franz Leopold Neumann</td>\n <td>male</td>\n <td>None</td>\n <td>None</td>\n <td>Leopold</td>\n <td>Neumann</td>\n <td>None</td>\n <td>None</td>\n <td>printer</td>\n <td>publishing</td>\n <td>None</td>\n <td>637163874508945722514</td>\n <td>None</td>\n <td>None</td>\n </tr>\n <tr>\n <th>5</th>\n <td>Otto Kahn-Freund</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Otto</td>\n <td>None</td>\n <td>1900-11-17T00:00:00Z</td>\n <td>1979-08-16T00:00:00Z</td>\n <td>judge</td>\n <td>None</td>\n <td>University of Oxford</td>\n <td>76317591</td>\n <td>0000000109168959</td>\n <td>118559362</td>\n </tr>\n <tr>\n <th>6</th>\n <td>Otto Kirchheimer</td>\n <td>male</td>\n <td>None</td>\n <td>Germany</td>\n <td>Otto</td>\n <td>Kirchheimer</td>\n <td>1905-11-11T00:00:00Z</td>\n <td>1965-11-22T00:00:00Z</td>\n <td>jurist</td>\n <td>None</td>\n <td>Office of Strategic Services</td>\n <td>32042801</td>\n <td>0000000081110244</td>\n <td>118562371</td>\n </tr>\n <tr>\n <th>7</th>\n <td>Ludwig Bendix</td>\n <td>male</td>\n <td>None</td>\n <td>Germany</td>\n <td>Ludwig</td>\n <td>Bendix</td>\n <td>1877-06-28T00:00:00Z</td>\n <td>1954-01-03T00:00:00Z</td>\n <td>lawyer</td>\n <td>None</td>\n <td>None</td>\n <td>74647579</td>\n <td>0000000081553379</td>\n <td>118702033</td>\n </tr>\n <tr>\n <th>8</th>\n <td>Arthur Nussbaum</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Arthur</td>\n <td>Nussbaum</td>\n <td>1877-01-31T00:00:00Z</td>\n <td>1964-11-22T00:00:00Z</td>\n <td>lawyer</td>\n <td>international law</td>\n <td>Frederick William University Berlin</td>\n <td>5180962</td>\n <td>0000000120988288</td>\n <td>117071676</td>\n </tr>\n <tr>\n <th>9</th>\n <td>Theodor Geiger</td>\n <td>male</td>\n <td>None</td>\n <td>Germany</td>\n <td>Theodor</td>\n <td>Geiger</td>\n <td>1891-11-09T00:00:00Z</td>\n <td>1952-06-16T00:00:00Z</td>\n <td>sociologist</td>\n <td>None</td>\n <td>Technical University of Braunschweig</td>\n <td>56667946</td>\n <td>0000000109038951</td>\n <td>118538187</td>\n </tr>\n <tr>\n <th>10</th>\n <td>Erhard Blankenburg</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Erhard</td>\n <td>Blankenburg</td>\n <td>1938-10-30T00:00:00Z</td>\n <td>2018-03-28T00:00:00Z</td>\n <td>sociology of law</td>\n <td>sociology of law</td>\n <td>Free University of Amsterdam</td>\n <td>64109592</td>\n <td>0000000110676109</td>\n <td>115459235</td>\n </tr>\n <tr>\n <th>11</th>\n <td>Wolfgang Kaupen</td>\n <td>male</td>\n <td>None</td>\n <td>None</td>\n <td>Wolfgang</td>\n <td>None</td>\n <td>1936-01-01T00:00:00Z</td>\n <td>1981-01-01T00:00:00Z</td>\n <td>sociologist</td>\n <td>sociology of law</td>\n <td>None</td>\n <td>32919813</td>\n <td>0000000035495614</td>\n <td>124045405</td>\n </tr>\n <tr>\n <th>12</th>\n <td>Rüdiger Lautmann</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Rüdiger</td>\n <td>None</td>\n <td>1935-12-22T00:00:00Z</td>\n <td>None</td>\n <td>author</td>\n <td>sociology of law</td>\n <td>University of Bremen</td>\n <td>24732961</td>\n <td>000000011469331X</td>\n <td>120502208</td>\n </tr>\n <tr>\n <th>13</th>\n <td>Thilo Ramm</td>\n <td>male</td>\n <td>None</td>\n <td>Germany</td>\n <td>Thilo</td>\n <td>Ramm</td>\n <td>1925-04-04T00:00:00Z</td>\n <td>2018-06-17T00:00:00Z</td>\n <td>writer</td>\n <td>None</td>\n <td>University of Freiburg</td>\n <td>9924244</td>\n <td>0000000108689541</td>\n <td>116327391</td>\n </tr>\n <tr>\n <th>14</th>\n <td>Rudolf Wiethölter</td>\n <td>male</td>\n <td>None</td>\n <td>Germany</td>\n <td>Rudolf</td>\n <td>None</td>\n <td>1929-07-17T00:00:00Z</td>\n <td>None</td>\n <td>jurist</td>\n <td>None</td>\n <td>Goethe University Frankfurt</td>\n <td>106974404</td>\n <td>0000000116961365</td>\n <td>1034437860</td>\n </tr>\n <tr>\n <th>15</th>\n <td>Niklas Luhmann</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Niklas</td>\n <td>Luhmann</td>\n <td>1927-12-08T00:00:00Z</td>\n <td>1998-11-06T00:00:00Z</td>\n <td>lawyer</td>\n <td>sociology of law</td>\n <td>Bielefeld University</td>\n <td>29546145</td>\n <td>0000000122778532</td>\n <td>118575147</td>\n </tr>\n <tr>\n <th>16</th>\n <td>Gunther Teubner</td>\n <td>male</td>\n <td>http://commons.wikimedia.org/wiki/Special:File...</td>\n <td>Germany</td>\n <td>Gunther</td>\n <td>Teubner</td>\n <td>1944-04-30T00:00:00Z</td>\n <td>None</td>\n <td>jurist</td>\n <td>None</td>\n <td>Goethe University Frankfurt</td>\n <td>108364502</td>\n <td>0000000109312017</td>\n <td>119443562</td>\n </tr>\n </tbody>\n</table>\n</div>" + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "scholars = [\n", + " \"Hans Kelsen\",\n", + " \"Hugo Sinzheimer\",\n", + " \"Karl Renner\",\n", + " \"Ernst Fraenkel\",\n", + " \"Franz Leopold Neumann\",\n", + " \"Otto Kahn-Freund\",\n", + " \"Otto Kirchheimer\",\n", + " \"Herrmann Kantorowicz\",\n", + " \"Ludwig Bendix\",\n", + " \"Arthur Nussbaum\",\n", + " \"Theodor Geiger\",\n", + " \"Erhard Blankenburg\",\n", + " \"Wolfgang Kaupen\",\n", + " \"Rüdiger Lautmann\",\n", + " \"Thilo Ramm\",\n", + " \"Rudolf Wiethölter\",\n", + " \"Niklas Luhmann\",\n", + " \"Gunther Teubner\"\n", + "]\n", + "df = properties_to_dataframe(scholars, property_labels_to_ids)\n", + "df" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-06T15:12:10.067883900Z", + "start_time": "2024-03-06T15:11:19.392537400Z" + } + }, + "id": "19ddabbda261cc90" + }, + { + "cell_type": "code", + "execution_count": 22, + "outputs": [], + "source": [ + "df.to_csv(\"scholars.csv\", index=False)" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-06T14:15:14.273567900Z", + "start_time": "2024-03-06T14:15:14.251976300Z" + } + }, + "id": "c6c0cc347c8788d0" + }, + { + "cell_type": "code", + "execution_count": 44, + "outputs": [], + "source": [ + "import pandas as pd\n", + "from datetime import datetime\n", + "\n", + "# Assuming df is your existing DataFrame\n", + "\n", + "# Convert dateOfBirth and dateOfDeath to just the year, handle NaT/NaN appropriately\n", + "df['Year'] = pd.to_datetime(df['dateOfBirth'], errors='coerce').dt.year.astype('Int64')\n", + "df['End Year'] = pd.to_datetime(df['dateOfDeath'], errors='coerce').dt.year.astype('Int64')\n", + "\n", + "# Create 'Display Date' as \"dateOfBirth - dateOfDeath\"\n", + "df['Display Date'] = df['Year'].astype(str).replace('<NA>','') + ' - ' + df['End Year'].astype(str).replace('<NA>','')\n", + "\n", + "# Create 'Headline' as \"fullName (dateOfBirth - dateOfDeath)\"\n", + "df['Headline'] = df['fullName'] + ' (' + df['Display Date'] + ')'\n", + "\n", + "# Create 'Text' column by combining occupation, fieldOfWork, employer\n", + "df['Text'] = df[['occupation', 'fieldOfWork']].apply(lambda x: '<br>'.join(x.dropna()), axis=1)\n", + "\n", + "# Use the image directly; assuming the URLs are already correctly formed in the 'image' column\n", + "df['Media'] = df['image']\n", + "\n", + "# Add a \"Group\" column with the value \"actors\" for all rows\n", + "df['Group'] = 'actors'\n", + "\n", + "# fix date columns\n", + "df['Display Date'] = df['Display Date'].fillna('') # Ensure no NaNs in Display Date\n", + "df['Headline'] = df['Headline'].fillna('') # Ensure no NaNs in Headline\n", + "df['Text'] = df['Text'].fillna('') # Ensure no NaNs in Text\n", + "df['Media'] = df['Media'].fillna('') # Ensure no NaNs in Media\n", + "\n", + "# Now select and order the DataFrame according to the TimelineJS template requirements\n", + "columns = \"Year\tMonth\tDay\tTime\tEnd Year\tEnd Month\tEnd Day\tEnd Time\tDisplay Date\tHeadline\tText\tMedia\tMedia Credit\tMedia Caption\tMedia Thumbnail\tType\tGroup\tBackground\tLink\".split(\"\\t\")\n", + "for col in columns:\n", + " if col not in df:\n", + " df[col] = ''\n", + "timeline_df = df[columns]\n", + "\n", + "timeline_df.to_excel(\"timeline_data.xlsx\", index=False)\n" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-06T15:08:24.294712700Z", + "start_time": "2024-03-06T15:08:24.250520100Z" + } + }, + "id": "b8058de7fa9212b" + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [], + "metadata": { + "collapsed": false + }, + "id": "f4b14ea7d4941e57" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/wikidata/readme.md b/wikidata/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..1c6c0535e4dd3a3b1897b9d561c998fd5bf3f168 --- /dev/null +++ b/wikidata/readme.md @@ -0,0 +1,3 @@ +# WikiData data retrieval + +`pip install openpyxl` \ No newline at end of file diff --git a/wikidata/scholars.csv b/wikidata/scholars.csv new file mode 100644 index 0000000000000000000000000000000000000000..2e733beeb360e5fc487b0df800be49f0f692c688 --- /dev/null +++ b/wikidata/scholars.csv @@ -0,0 +1,18 @@ +fullName,sexOrGender,image,countryOfCitizenship,givenName,familyName,dateOfBirth,dateOfDeath,occupation,fieldOfWork,employer,viaf_id,isni_id,gnd_id +Hans Kelsen,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Hans%2520Kelsen%2520%25281881%25E2%2580%25931973%2529%2520~1930%2520%25C2%25A9%2520Georg%2520Fayer%2520%25281892%25E2%2580%25931950%2529%2520OeNB%25208026867.jpg,Cisleithania,Hans,Kelsen,1881-10-11T00:00:00Z,1973-04-19T00:00:00Z,judge,international law,Charles University,31998356,0000000121266076,118561219 +Hugo Sinzheimer,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Hugo%2520Sinzheimer.jpg,Germany,Hugo,Sinzheimer,1875-04-12T00:00:00Z,1945-09-16T00:00:00Z,lawyer,,University of Amsterdam,27864307,0000000109619641,118614711 +Karl Renner,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Karl-renner-hn.jpg,Germany,Karl,Renner,1833-05-13T00:00:00Z,1913-09-22T00:00:00Z,merchant,politics,Austrian Federal Government,171170593,0000000054940875,1012296458 +Ernst Fraenkel,male,,Germany,Ernst,Fraenkel,1891-04-05T00:00:00Z,1971-08-18T00:00:00Z,economic historian,Baltic,Goethe University Frankfurt,50078162,0000000081027854,121259854 +Franz Leopold Neumann,male,,German Empire,Leopold,Neumann,1900-05-23T00:00:00Z,1954-09-02T00:00:00Z,lawyer,publishing,Office of Strategic Services,15561879,0000000109564943,118587293 +Otto Kahn-Freund,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Sir%2520Otto%2520Kahn-Freund%252C%2520c1950.jpg,Germany,Otto,,1900-11-17T00:00:00Z,1979-08-16T00:00:00Z,judge,,University of Oxford,76317591,0000000109168959,118559362 +Otto Kirchheimer,male,,United States of America,Otto,Kirchheimer,1905-11-11T00:00:00Z,1965-11-22T00:00:00Z,jurist,,Office of Strategic Services,32042801,0000000081110244,118562371 +Ludwig Bendix,male,,Germany,Ludwig,Bendix,1877-06-28T00:00:00Z,1954-01-03T00:00:00Z,lawyer,,,74647579,0000000081553379,118702033 +Arthur Nussbaum,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Arthur%2520Nussbaum.jpg,Germany,Arthur,Nussbaum,1877-01-31T00:00:00Z,1964-11-22T00:00:00Z,lawyer,international law,Columbia University,5180962,0000000120988288,117071676 +Theodor Geiger,male,,Denmark,Theodor,Geiger,1891-11-09T00:00:00Z,1952-06-16T00:00:00Z,university teacher,,Technical University of Braunschweig,56667946,0000000109038951,118538187 +Erhard Blankenburg,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Erhard%2520Blankenburg.jpg,Germany,Erhard,Blankenburg,1938-10-30T00:00:00Z,2018-03-28T00:00:00Z,sociology of law,sociology of law,Free University of Amsterdam,64109592,0000000110676109,115459235 +Wolfgang Kaupen,male,,,Wolfgang,,1936-01-01T00:00:00Z,1981-01-01T00:00:00Z,sociologist,sociology of law,,32919813,0000000035495614,124045405 +Rüdiger Lautmann,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Lautmann%25202012.jpg,Germany,Rüdiger,,1935-12-22T00:00:00Z,,sociologist,sociology of law,University of Bremen,24732961,000000011469331X,120502208 +Thilo Ramm,male,,Germany,Thilo,Ramm,1925-04-04T00:00:00Z,2018-06-17T00:00:00Z,writer,,FernUniversität in Hagen,9924244,0000000108689541,116327391 +Rudolf Wiethölter,male,,Germany,Rudolf,,1929-07-17T00:00:00Z,,jurist,,Goethe University Frankfurt,106974404,0000000116961365,1034437860 +Niklas Luhmann,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/HSGH%2520022-000941%2520Niklas%2520Luhmann%2520%2528cropped%2529.png,Germany,Niklas,Luhmann,1927-12-08T00:00:00Z,1998-11-06T00:00:00Z,researcher,sociology of law,TU Wien,29546145,0000000122778532,118575147 +Gunther Teubner,male,https://commons.wikimedia.org/wiki/Special:FilePath/http%3A//commons.wikimedia.org/wiki/Special%3AFilePath/Gunther%2520Teubner%2520%25282017%2529.jpg,Germany,Gunther,Teubner,1944-04-30T00:00:00Z,,sociologist,,Goethe University Frankfurt,108364502,0000000109312017,119443562