Wikimedia Developer Support

Extract referring sentence using "what links here"

Hi,
I recently started working on a wikipedia nlp project, and I am very new to mediawiki, I hope that the question is not too dumb…

I am now trying to extract sentences from other wikipedia pages that refer to a specific wikipedia entity. I know that the"what links here" tool can give me the names of those backlinks. Is there any way I can make “what links here” return the exact sentence that is referring to the entity?

For example, the entity that is referred to is Alien%20%28film%29.

The following call to API
https://en.wikipedia.org/w/api.php?action=query&list=backlinks&bltitle=Alien%20%28film%29&bllimit=500
gives me a list of wikipedia page names.

Now, I want to go to several of those pages and fetch the referring sentences.
e.g. Extract “It featured a fierce, carnivorous alien, the coeurl, stalking the crew of an exploration spaceship, and served as the inspiration for multiple science fiction movies, including Alien (1979).” from https://en.wikipedia.org/wiki/A._E._van_Vogt.
Extract “That date was chosen by producer Alan Ladd Jr. because his previous highest-grossing films Star Wars and Alien had a similar opening date (May 25) in 1977 and 1979, making the 25th of the month his “lucky day”.” from https://en.wikipedia.org/wiki/Blade_Runner.

Is this possible?

Thanks a lot!

No, that kind of information is not stored anywhere. You’d have to do some kind of lightweight wikitext or HTML parsing yourself.

1 Like