Skip to content

Adding Wikidata Tags

Snowysauce edited this page Sep 26, 2024 · 6 revisions

Warning

April 2022 Update

The use of *:wikipedia tag has been discontinued (issue #6481)

Contributing the *:wikidata tag is a very useful task that anybody can help with. It involves a little bit of Internet research.

Entities need a *:wikidata tag to be properly integrated into the Name Suggestion Index. This tag would be brand:wikidata for brands, flag:wikidata for flags, operator:wikidata for operators, and network:wikidata for transit networks. In all cases, the tag is a reference to the entity's page on Wikidata.org, a free and open knowledge base operated by the Wikimedia Foundation. (For more information about Wikidata, see Editing Wikidata.)

You can use the online file editor on GitHub to edit the category files under /data/*, add *:wikidata tags, and send a pull request with your changes.

Adding tags to existing entities

Note: the examples listed here are written from the perspective of a speaker of the English language. If you are proficient in another language, you can substitute all mentions of "English" for your language of choice - the steps to take will remain the same.

Example #1 - Worldwide / English entities

  1. Find an entry in a file that is missing the *:wikidata tag.

    We'll use a simplified version of the entry for the American fast food chain Chipotle from data/brands/amenity/fast_food.json to illustrate the process of finding and adding *:wikidata tags. Let's assume that the entry for Chipotle in data/brands/amenity/fast_food.json looks like this:

    {
      "displayName": "Chipotle",
      "id": "chipotle-658eea",
      "locationSet": { "include": ["us"] }
      "matchNames": ["chipotle mexican grill"],
      "tags": {
        "amenity": "fast_food",
        "brand": "Chipotle",
        "cuisine": "mexican",
        "name": "Chipotle"
      }
    },

    The brand:wikidata tag is missing and needs to be added. Let's try to find the info we need to properly add the tag.

     

  2. Google for that entity - if you are lucky, you might find a Wikipedia page right away.

    Google for Chipotle

     

  3. On the entity's Wikipedia page, you can also find its "Wikidata item" link. This appears under the "tools" menu in the sidebar.


    👉 Tip: @maxerickson has created a user script to make copying these values even easier - see #1881

    Chipotle Wikipedia

     

  4. On the entity's Wikidata page, you can identify the *:wikidata value. It is a code with several numbers prefixed by the letter 'Q'.

    Chipotle Wikidata

     

  5. Update the file where the entity is located.

    Continuing with our example, in this case the relevant file for Chipotle is data/brands/amenity/fast_food.json. Now that we know the Wikidata code for Chipotle, we can add the "brand:wikidata" tag and the corresponding value.

    {
      "displayName": "Chipotle",
      "id": "chipotle-658eea",
      "locationSet": { "include": ["us"] }
      "matchNames": ["chipotle mexican grill"],
      "tags": {
        "amenity": "fast_food",
        "brand": "Chipotle",
        "brand:wikidata": "Q465751",                            // added
        "cuisine": "mexican",
        "name": "Chipotle"
      }
    },

    (comments added for clarity)

     

  6. Submit a pull request for the updated file.

    If you have a local copy of the project for development, you can rebuild the index before submitting a pull request. This step is completely optional, however.

    • Run npm run build
    • If it does not fail with an error, you can submit a pull request with your changes (warnings are OK).

    If you don't have a local copy of the project for development, just send the pull request anyway. GitHub will test your changes, and a maintainer will run npm run build later.

 

Example #2 - Regional / non-English entities

  1. Find an entry in a file that is missing the *:wikidata tag.

    In this example, we'll use a brand named "かっぱ寿司". Since this brand is in a language other than English, the process of finding and adding *:wikidata tags will likely require some additional research for anyone who is not multilingual. If we search the data files of the NSI, though, we will find a brand matching this text in data/brands/amenity/fast_food.json. Let's assume that the entry for かっぱ寿司 in data/brands/amenity/fast_food.json looks like this:

    {
      "displayName": "かっぱ寿司",
      "id": "e7198e-3e7699",
      "locationSet": {"include": ["jp"]},
      "tags": {
        "amenity": "fast_food",
        "brand": "かっぱ寿司",
        "name": "かっぱ寿司"
      }
    },

    The brand:wikidata tag is missing and needs to be added. Let's try to find the info we need to properly add the tag.

     

  2. Google for that entity - if you are lucky, you might find the Wikipedia page right away.


    👉 Tip: If you recognize the language that the entity is in, you might want to narrow your search by Googling with a site: filter: "かっぱ寿司 site:ja.wikipedia.org"

    From these results, we can discover that the brand is "Kappa Sushi", owned by a Japanese company called "Kappa Create". We can also find the Wikipedia page.

    Google for かっぱ寿司

     

  3. On the entity's Wikipedia page, you can also find its "Wikidata item" link.

    As with English brands, you can identify an entity's Wikipedia article title from the URL. Because our example uses a Japanese brand, we will link to its page on the Japanese Wikipedia.

    Even if we cannot read Japanese, we can identify the "Wikidata item" link because it always appears in the sidebar on all Wikipedias and a mouseover will show "wikidata.org" and the Wikidata 'Q' code in the URL.

    Kappa Sushi Wikipedia

     

  4. On the entity's Wikidata page, you can identify the *:wikidata value. It is a code with several numbers prefixed by the letter 'Q'.

    Note: in this case, the Wikidata page looks a bit sparse - you can edit this too if you want to help!

    Kappa Sushi Wikidata

     

  5. Update the file where the entity is located.

    Continuing with our example, in this case the relevant file for Kappa Sushi is data/brands/amenity/fast_food.json. Now that we know the Wikidata code and a bit more info for Kappa Sushi, we can add:

    • "brand:en" and "name:en" tags to contain the English name "Kappa Sushi"
    • "name:ja" and "brand:ja" tags to contain the local name "かっぱ寿司"
    • "brand:wikidata" tag and the corresponding value
    • "cuisine": "sushi" OpenStreetMap tag

    Also check the "locationSet" property to make sure it is accurate.

    It may seem redundant to add both "name": "かっぱ寿司" and also "name:ja": "かっぱ寿司" tags. We follow this convention because some validator software will complain if there is a name tag and no matching language tag, such as name:ja. See also issue #2245


    👉 Important: When an item has any name:xx language tags, make sure there exists a name:xx tag that matches the name tag. See https://wiki.openstreetmap.org/wiki/Multilingual_names#Repeating_name_with_language_specific_tag

    {
      "displayName": "かっぱ寿司",
      "id": "kappasushi-3e7699",
      "locationSet": {"include": ["jp"]},
      "tags": {
        "amenity": "fast_food",
        "brand": "かっぱ寿司",
        "brand:en": "Kappa Sushi",             // added
        "brand:ja": "かっぱ寿司",               // added
        "brand:wikidata": "Q11263916",        // added
        "cuisine": "sushi",                   // added
        "name": "かっぱ寿司",
        "name:en": "Kappa Sushi",             // added
        "name:ja": "かっぱ寿司"                 // added
      }
    },

    (comments added for clarity)

     

  6. Submit a pull request for the updated file.

    If you have a local copy of the project for development, you can rebuild the index before submitting a pull request. This step is completely optional, however.

    • Run npm run build
    • If it does not fail with an error, you can submit a pull request with your changes (warnings are OK).

    If you don't have a local copy of the project for development, just send the pull request anyway. GitHub will test your changes, and a maintainer will run npm run build later.

 

Adding missing entities

Some entities haven't been mapped enough on OpenStreetMap (generally 50+ times) to be automatically added to the index. If a notable entity is missing from the NSI, you can add it manually to establish a preferred tagging.

  1. Before adding a new entity, the minimum information you should know is the correct tagging required for instances of the entity:

    • brands: name and brand
    • flags: flag:name and subject
    • operators: operator
    • transit networks: network

    You should also know which OSM category it falls into (e.g. amenity=fast_food). Ideally, you would also have a *:wikidata tag and any other appropriate tags - e.g. cuisine.

  2. Add your new entry anywhere into the appropriate file in the data folder. The entries in the files are automatically sorted alphabetically whenever the index build script is run, so it does not matter where you place your new entry. Remember to use the "tags" key and add all appropriate OSM tags for the entity. Refer to Category Files if you're not familiar with the syntax or how the data folder is organized.

  3. If the entity only exists in a known set of countries, add the countries to the "locationSet" property. This (at minimum) takes an array of ISO 3166-1 alpha-2 country codes in lowercase (e.g. ["de", "at", "nl"]). Some countries have files in the NSI called "features" that allow for more precise location narrowing, and there are additional ways to identify locations other than ISO 3166-1 codes; see Item Property Reference for more details.

  4. If instances of this entity are commonly mistagged with less preferred names, add the "matchNames": [] key to list these. Again, refer to Category Files for syntax.

  5. Submit a pull request for the updated file.

    If you have a local copy of the project for development, you can rebuild the index before submitting a pull request. This step is completely optional, however.

    • Run npm run build
    • If it does not fail with an error, you can submit a pull request with your changes (warnings are OK).

    If you don't have a local copy of the project for development, just send the pull request anyway. GitHub will test your changes, and a maintainer will run npm run build later.

Home

For Contributors

Contributing to the index

Advanced Topics

For Developers

Information for developers using the name-suggestion-index in another project.

For Maintainers

Information for maintainers, including how to clone and build the project.

 

Clone this wiki locally