Skip to content

Instantly share code, notes, and snippets.

@kozo2
Last active March 23, 2016 21:04
Show Gist options
  • Select an option

  • Save kozo2/eba07be8b6fe23bb38a3 to your computer and use it in GitHub Desktop.

Select an option

Save kozo2/eba07be8b6fe23bb38a3 to your computer and use it in GitHub Desktop.
wikidata notes for compound

bh1515


PREFIX wdt: <http://www.wikidata.org/prop/direct/>

SELECT DISTINCT ?compound ?label ?napid ?keggid ?casid
WHERE {
  ?compound wdt:P31 wd:Q11173 ;
    rdfs:label ?label
  FILTER ( lang(?label) = "en" )
  OPTIONAL {?compound wdt:P2064 ?napid .}
  OPTIONAL {?compound wdt:P665 ?keggid . }
  OPTIONAL {?compound wdt:P231 ?casid . }
}

knapsack

PREFIX wdt: <http://www.wikidata.org/prop/direct/>

SELECT DISTINCT ?compound ?label ?knapsackid ?keggid ?casid
WHERE { ?compound wdt:P2064 ?id ;
                  rdfs:label ?label
                  FILTER ( lang(?label) = "en" )
  OPTIONAL {?compound wdt:P2064 ?knapsackid .}
  OPTIONAL {?compound wdt:P665 ?keggid . }
  OPTIONAL {?compound wdt:P231 ?casid . }
}

egonw

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?compound ?id WHERE {
  ?compound wdt:P2064 ?id .
}

import pywikibot
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
item = pywikibot.ItemPage(repo, u"Q415011")
print item.contributors()

stringclaim = pywikibot.Claim(repo, u'P2064')
stringclaim.setTarget(u"C00000674")
item.addClaim(stringclaim)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment