import wikipedia
# print the summary of what python is
print(wikipedia.summary("Python Programming Language"))
[CODE]
This will extract the summary from this wikipedia page. More specifically, it will print some first sentences, we can specify the number of sentences to extract:
[ICODE]In [2]: wikipedia.summary("Python programming languag", sentences=2)[/ICODE]
Out[2]: "Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first [ICODE]released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant whitespace."[/ICODE]
Notice that I misspelled the query intentionally, it still gives me an accurate result.
Search for a term in wikipedia search:
[ICODE]In [3]: result = wikipedia.search("Neural networks")[/ICODE]
[ICODE]In [4]: print(result)[/ICODE]
[ICODE]['Neural network', 'Artificial neural network', 'Convolutional neural network', 'Recurrent neural network', 'Rectifier (neural networks)', 'Feedforward neural network', 'Neural circuit', 'Quantum neural network', 'Dropout (neural networks)', 'Types of artificial neural networks'][/ICODE]
This returned a list of related page titles, let’s get the whole page for “Neural network” which is “result[0]”:
[CODE=python]
# get the page: Neural network
page = wikipedia.page(result[0])