]> git.openstreetmap.org Git - nominatim.git/blob - data-sources/wikipedia-wikidata/README.md
Gsoc2019 contributions for adding Wikidata to Nominatim (#1475)
[nominatim.git] / data-sources / wikipedia-wikidata / README.md
1 ## Add Wikipedia and Wikidata to Nominatim
2
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. 
4
5 These scripts extract and prepare both Wikipedia page rank and Wikidata links for use in Nominatim.  
6
7 #### Create a new postgres DB for Processing
8
9 Due to the size of initial and intermediate tables, processing can be done in an external database:
10 ```
11 CREATE DATABASE wikiprocessingdb;
12 ```
13 ---
14 Wikipedia
15 ---  
16
17 Processing these data requires a large amount of disk space (~1TB) and considerable time (>24 hours).
18
19 #### Import & Process Wikipedia tables
20
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.
22
23 - The script will processes data from whatever set of Wikipedia languages are specified in the initial languages array
24
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
26
27 To download, convert, and import the data, then process summary statistics and compute importance scores, run:
28 ```
29 ./wikipedia_import.sh
30 ```
31 ---
32 Wikidata
33 ---
34
35 This script downloads and processes Wikidata to enrich the previously created Wekipedia tables for use in Nominatim.
36
37 #### Import & Process Wikidata
38
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.
40
41 - Script presumes that the user has already processed Wikipedia tables as specified above
42
43 - Script requires wikidata_place_types.txt and wikidata_place_type_levles.csv
44
45 - script requires the [jq json parser](https://stedolan.github.io/jq/)
46
47 - Script processes data from whatever set of Wikipedia languages are specified in the initial languages array
48
49 - Script queries Wikidata Query Service API and imports all instances of place types listed in wikidata_place_types.txt
50
51 - Script updates wikipedia_articles table with extracted wikidata 
52
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. 
54
55 To download, convert, and import the data, then process required items, run:
56 ``` 
57 ./wikidata_import.sh
58 ```