google / sling

SLING - A natural language frame semantics parser
Apache License 2.0
1.93k stars 268 forks source link

What does "mapping.sling" do? #441

Closed jiangjiechen closed 4 years ago

jiangjiechen commented 4 years ago

I understand that e/wiki/en/mapping.sling is created by wikipedia-mapping task, but how can I access the mapping between the article ids (PAGEIDs) of Wikipedia and entity ids (QIDs) of Wikidata using this "mapping.sling" or something else? Is there an api to convert article ids to entity ids and vice versa? Thank you in advance.

ringgaard commented 4 years ago

You can load the mapping.sling file into memory as a SLING store, e.g.:

import sling
mapping = sling.Store()
mapping.load("mapping.sling")

You can use the API in sling/nlp/wiki/wikipedia-map.h to convert from Wikipedia article names to Wikidata QIDs. This uses mapping.sling together with redirects.sling. The formats are described in the wiki workflow file.

jiangjiechen commented 4 years ago

Thanks!

I now understand how to get QIDs with Wikipedia article NAMEs with mapping.sling, though it still troubles me to get QIDs with Wikipedia PAGEIDs (i.e. WIDs). I know that the WID can be acquired when queried with the corresponding QID in documents@10.rec, but can it be done reversely, and more elegantly/efficiently?

i.e. 1) is there a way to get QIDs with WIDs in sling with Python? or 2) is there a way to get article NAMEs with WIDs in sling with Python?

ringgaard commented 4 years ago

The Wikipedia page ids are not recorded in Wikidata, so we do the mapping through Wikipedia article names instead. We keep the Wikipedia page ids in documents@10.rec so you can make your own mapping.

jiangjiechen commented 4 years ago

OK, thanks a lot.