Skip to content

Commit

Permalink
wikidata in entities (#17)
Browse files Browse the repository at this point in the history
* wikidata in entities

* updated url
  • Loading branch information
theorm authored Nov 20, 2024
1 parent 8bc0af2 commit 7a006a6
Show file tree
Hide file tree
Showing 17 changed files with 965 additions and 30 deletions.
287 changes: 283 additions & 4 deletions examples/notebooks/entities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -109,10 +109,10 @@
"</div>"
],
"text/plain": [
"<impresso.resources.entities.FindEntitiesContainer at 0x1147b1fd0>"
"<impresso.resources.entities.FindEntitiesContainer at 0x1049b1010>"
]
},
"execution_count": 3,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -597,6 +597,285 @@
"from impresso import AND\n",
"impresso.entities.find(wikidata_id=AND(\"Q2\", \"Q4\", \"Q42\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get wikidata details"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"display: grid; \">\n",
"<div>\n",
"<h2>FindEntities result</h2>\n",
"<div>Contains <b>3</b> items of <b>3</b> total items.</div>\n",
"<br/>\n",
"See this result in the <a href=\"https://impresso-project.ch/app/entities?q=Douglas Adams\">Impresso App</a>.\n",
"</div>\n",
"</div>\n",
"<h3>Data preview:</h3>\n",
"<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>label</th>\n",
" <th>type</th>\n",
" <th>wikidataId</th>\n",
" <th>totalMentions</th>\n",
" <th>totalContentItems</th>\n",
" <th>wikidataDetails.id</th>\n",
" <th>wikidataDetails.type</th>\n",
" <th>wikidataDetails.descriptions.en</th>\n",
" <th>wikidataDetails.descriptions.fr</th>\n",
" <th>wikidataDetails.descriptions.it</th>\n",
" <th>wikidataDetails.descriptions.de</th>\n",
" <th>wikidataDetails.birthDate</th>\n",
" <th>wikidataDetails.deathDate</th>\n",
" <th>wikidataDetails.birthPlace.id</th>\n",
" <th>wikidataDetails.birthPlace.type</th>\n",
" <th>wikidataDetails.birthPlace.labels.en</th>\n",
" <th>wikidataDetails.birthPlace.labels.fr</th>\n",
" <th>wikidataDetails.birthPlace.labels.it</th>\n",
" <th>wikidataDetails.birthPlace.labels.de</th>\n",
" <th>wikidataDetails.birthPlace.descriptions.en</th>\n",
" <th>wikidataDetails.birthPlace.descriptions.fr</th>\n",
" <th>wikidataDetails.birthPlace.descriptions.it</th>\n",
" <th>wikidataDetails.birthPlace.descriptions.de</th>\n",
" <th>wikidataDetails.birthPlace.coordinates.latitude</th>\n",
" <th>wikidataDetails.birthPlace.coordinates.longitude</th>\n",
" <th>wikidataDetails.deathPlace.id</th>\n",
" <th>wikidataDetails.deathPlace.type</th>\n",
" <th>wikidataDetails.deathPlace.labels.fr</th>\n",
" <th>wikidataDetails.deathPlace.labels.it</th>\n",
" <th>wikidataDetails.deathPlace.labels.de</th>\n",
" <th>wikidataDetails.deathPlace.labels.en</th>\n",
" <th>wikidataDetails.deathPlace.descriptions.de</th>\n",
" <th>wikidataDetails.deathPlace.descriptions.en</th>\n",
" <th>wikidataDetails.deathPlace.descriptions.fr</th>\n",
" <th>wikidataDetails.deathPlace.descriptions.it</th>\n",
" <th>wikidataDetails.deathPlace.coordinates.latitude</th>\n",
" <th>wikidataDetails.deathPlace.coordinates.longitude</th>\n",
" <th>wikidataDetails.labels.de</th>\n",
" <th>wikidataDetails.labels.en</th>\n",
" <th>wikidataDetails.labels.it</th>\n",
" <th>wikidataDetails.labels.fr</th>\n",
" </tr>\n",
" <tr>\n",
" <th>uid</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>aida-0001-50-Douglas_Adams</th>\n",
" <td>Douglas Adams</td>\n",
" <td>person</td>\n",
" <td>Q42</td>\n",
" <td>94</td>\n",
" <td>94</td>\n",
" <td>Q42</td>\n",
" <td>human</td>\n",
" <td>English science fiction writer and humorist (1...</td>\n",
" <td>écrivain et humoriste anglais (1952–2001)</td>\n",
" <td>scrittore e umorista britannico (1952–2001)</td>\n",
" <td>britischer Science-Fiction-Autor und Humorist</td>\n",
" <td>1952-03-11T00:00:00+00:00</td>\n",
" <td>2001-05-11T00:00:00+00:00</td>\n",
" <td>Q350</td>\n",
" <td>location</td>\n",
" <td>Cambridge</td>\n",
" <td>Cambridge</td>\n",
" <td>Cambridge</td>\n",
" <td>Cambridge</td>\n",
" <td>city in Cambridgeshire, England</td>\n",
" <td>ville britannique</td>\n",
" <td>città della Gran Bretagna</td>\n",
" <td>englische Universitätsstadt, Hauptort von Camb...</td>\n",
" <td>52.208056</td>\n",
" <td>0.1225</td>\n",
" <td>Q159288</td>\n",
" <td>location</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Stadt in Kalifornien, Vereinigte Staaten</td>\n",
" <td>city in and county seat of Santa Barbara Count...</td>\n",
" <td>municipalité de Californie</td>\n",
" <td>città della California</td>\n",
" <td>34.425833</td>\n",
" <td>-119.714167</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>aida-0001-50-Douglas_Q._Adams</th>\n",
" <td>Douglas Q. Adams</td>\n",
" <td>person</td>\n",
" <td>Q932869</td>\n",
" <td>30</td>\n",
" <td>30</td>\n",
" <td>Q932869</td>\n",
" <td>human</td>\n",
" <td>American professor of English</td>\n",
" <td>NaN</td>\n",
" <td>linguista statunitense</td>\n",
" <td>US-amerikanischer Sprachwissenschaftler</td>\n",
" <td>2000-01-01T00:00:00+00:00</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Douglas Quentin Adams</td>\n",
" <td>Douglas Q. Adams</td>\n",
" <td>Douglas Q. Adams</td>\n",
" <td>Douglas Q. Adams</td>\n",
" </tr>\n",
" <tr>\n",
" <th>aida-0001-54-Douglas_Adams</th>\n",
" <td>Douglas Adams</td>\n",
" <td>location</td>\n",
" <td>Q42</td>\n",
" <td>24</td>\n",
" <td>24</td>\n",
" <td>Q42</td>\n",
" <td>human</td>\n",
" <td>English science fiction writer and humorist (1...</td>\n",
" <td>écrivain et humoriste anglais (1952–2001)</td>\n",
" <td>scrittore e umorista britannico (1952–2001)</td>\n",
" <td>britischer Science-Fiction-Autor und Humorist</td>\n",
" <td>1952-03-11T00:00:00+00:00</td>\n",
" <td>2001-05-11T00:00:00+00:00</td>\n",
" <td>Q350</td>\n",
" <td>location</td>\n",
" <td>Cambridge</td>\n",
" <td>Cambridge</td>\n",
" <td>Cambridge</td>\n",
" <td>Cambridge</td>\n",
" <td>city in Cambridgeshire, England</td>\n",
" <td>ville britannique</td>\n",
" <td>città della Gran Bretagna</td>\n",
" <td>englische Universitätsstadt, Hauptort von Camb...</td>\n",
" <td>52.208056</td>\n",
" <td>0.1225</td>\n",
" <td>Q159288</td>\n",
" <td>location</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Santa Barbara</td>\n",
" <td>Stadt in Kalifornien, Vereinigte Staaten</td>\n",
" <td>city in and county seat of Santa Barbara Count...</td>\n",
" <td>municipalité de Californie</td>\n",
" <td>città della California</td>\n",
" <td>34.425833</td>\n",
" <td>-119.714167</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"<impresso.resources.entities.FindEntitiesContainer at 0x10ff8f250>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"impresso.entities.find(term=\"Douglas Adams\", resolve=True)"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 7a006a6

Please sign in to comment.