1 ## Add Wikipedia and Wikidata to Nominatim
3 OSM contributors frequently tag items with links to Wikipedia and Wikidata. Nominatim can use the page ranking of Wikipedia pages to help indicate the relative importance of osm features. This is done by calculating an importance score between 0 and 1 based on the number of inlinks to an article for a location. If two places have the same name and one is more important than the other, the wikipedia score often points to the correct place.
5 These scripts extract and prepare both Wikipedia page rank and Wikidata links for use in Nominatim.
7 #### Create a new postgres DB for Processing
9 Due to the size of initial and intermediate tables, processing can be done in an external database:
11 CREATE DATABASE wikiprocessingdb;
17 Processing these data requires a large amount of disk space (~1TB) and considerable time (>24 hours).
19 #### Import & Process Wikipedia tables
21 This step downloads and converts [Wikipedia](https://dumps.wikimedia.org/) page data SQL dumps to postgreSQL files which can be imported and processed with pagelink information from Wikipedia language sites to calculate importance scores.
23 - The script will processes data from whatever set of Wikipedia languages are specified in the initial languages array
25 - Note that processing the top 40 Wikipedia languages can take over a day, and will add nearly 1TB to the processing database. The final output tables will be approximately 11GB and 2GB in size
27 To download, convert, and import the data, then process summary statistics and compute importance scores, run:
35 This script downloads and processes Wikidata to enrich the previously created Wikipedia tables for use in Nominatim.
37 #### Import & Process Wikidata
39 This step downloads and converts [Wikidata](https://dumps.wikimedia.org/wikidatawiki/) page data SQL dumps to postgreSQL files which can be processed and imported into Nominatim database. Also utilizes Wikidata Query Service API to discover and include place types.
41 - Script presumes that the user has already processed Wikipedia tables as specified above
43 - Script requires wikidata_place_types.txt and wikidata_place_type_levles.csv
45 - script requires the [jq json parser](https://stedolan.github.io/jq/)
47 - Script processes data from whatever set of Wikipedia languages are specified in the initial languages array
49 - Script queries Wikidata Query Service API and imports all instances of place types listed in wikidata_place_types.txt
51 - Script updates wikipedia_articles table with extracted wikidata
53 By including Wikidata in the wikipedia_articles table, new connections can be made on the fly from the Nominatim placex table to wikipedia_article importance scores.
55 To download, convert, and import the data, then process required items, run: