Wikidata:WikiProject Chronic Pain/How to massively add main topics to scholarly articles using keywords in the label

This guide explain how to add massively main topics on the scholarly articles.

Find all articles with a keyword in the label edit

The following code has been contributed in the request for Query: Wikidata:Request_a_query#List_all_items_that_have_a_specific_keyword_in_the_title

SELECT DISTINCT ?item ?itemLabel 
WHERE {
  hint:Query hint:optimizer "None".
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Search";
                    wikibase:endpoint "www.wikidata.org";
                    mwapi:srsearch "keyword haswbstatement:P31=Q13442814".
    ?title wikibase:apiOutput mwapi:title.
  }
  BIND(IRI(CONCAT(STR(wd:), ?title)) AS ?item)
  FILTER NOT EXISTS { ?item wdt:P921 wd:Q202864. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
}
Try it!

Details :

mwapi:srsearch "keyword haswbstatement:P31=Q13442814".

"Keyword" is to be replaced with searched names. Please notice that, if you search for 2 words, it will find out any label having the 2 words independantly of them place in the label.

instance of (P31) has to be settled to scholarly article (Q13442814) because we are only working on scholarly articles here. All articles massively imported from PubMed or them DOI have this settled.

The API documentation is on mw:API:Search and m:Help:Searching gives the details on how a request works.

FILTER NOT EXISTS { ?item wdt:P921 wd:Q202864. }

Ensure that main subject (P921) is not already settled to the targeted item.

A similar request for bots in under work : Wikidata:WikiProject Chronic Pain/fibromyalgia/In the title

Create the QuickStatements request edit

  1. Export the request result to .CSV format
  2. Open it with Google Speadsheets.
  3. Delete evrything but the Qids of the articles. Use search and replace to delet the base URLs.
  4. You should have now a clean spreadsheet with only the Qids of the articles in the first column
  5. In the second column write P921 in front of each article Qid. It stands for main subject (P921).
  6. In the third column enter the Qid of the item you want to settle as a main topic.
  7. Select the 3 columns and hit Ctrl+C for copy.
  8. Open and log in QuickStatements.
  9. Hit Ctrl+V to past the columns. These should be now separated by tabs in a text aera.
  10. Clic on the first "Import V1 commands" box
  11. Check your request
  12. Run in background