Connecting to Wikidata

NLUlite can be used as a natural language interface to Wikidata. This option requires an internet connection to work, since the Wikidata information is not stored locally.

Starting the server

First of all, you must tell the server you need to access Wikidata before starting it: Access the NLUlite/ folder:

$ cd ~/NLUlite/

and then type:

$ ./NLUlite-server --wikidata

This last option loads some of the Wikidata items and rules for converting a natural language query into a Wikidata query. With this option the server will take about 2GB of RAM.

Querying Wikidata

After starting the server with the –wikidata option you can use the class Wikidata to get your answers from the client side:

from NLUlite import ServerProxy, Wisdom, Wikidata

server = ServerProxy()
wikidata = Wikidata(server)

answers = wikidata.ask('when was gandhi born')

print answers.comment()
for item in answer.elements():
    print item.comment()

with result:

A gandhi is born on 2 november 1869.

when: 2 november 1869
From Wikidata

If your script does not need to access Wikidata the –wikidata option will change nothing except the amount of RAM taken by the server.