WikiDataFetcher

javadoc

 

[ service actualy in debug state for some fixes ( quantities ) ]

Mostly copy/paste from Beetlejuice blog post : http://myrobotlab.org/content/wikidatafetcher

This service grab data from wikis website ( for now wikidata )

wikidata store data by entities with an ID , by exemple, Adam Sandler have the ID Q132952 .

each entity contain several elements :

To use wikiDataFetcher , you will need an ID for the properties , but not for the label . the better thing is to show you a demo file ! see at the bottom of this post !

Here you can use french or english ID database for MAP

https://github.com/MyRobotLab/inmoov/blob/develop/InMoov/system/bdd/WIKI...

https://github.com/MyRobotLab/inmoov/blob/develop/InMoov/system/bdd/WIKI...

There is a lot of possibily with this service ; It's possible to use it with AIML so when the bot don't know the answer, it can have a look on the web to find it , wikidata is multilingual so the description can be returned in english, but also in french, italian, spanish ...

Examples:


#file : service/WikiDataFetcher.py edit raw
#########################################
# WikiDataFetcher.py
# description: used as a general template
# more info @: http://myrobotlab.org/service/WikiDataFetcher
#########################################
# start the service
wikidatafetcher = Runtime.start("wikidatafetcher","WikiDataFetcher")

# english crawl

query = "eiffel tower"
wikidatafetcher.setWebSite("enwiki") 
print "Url : " + wikidatafetcher.getData(query,"P856")
# Display a property ( high of the eiffel tower )
# print "high : " + wikidatafetcher.getData(query,"P2048")
# this is actually broken

# Display a monolingual value
print "Birthname of Adam Sandler : " + wikidatafetcher.getData("Adam Sandler","P1477")

# Display Date or time  (day, month, year, hour, minute, second, after, before
query = "adam sandler"
ID = "P569"
print "BirthDate : " + wikidatafetcher.getTime(query,ID,"day") +"/" + wikidatafetcher.getTime(query,ID,"month") + "/" + wikidatafetcher.getTime(query,ID,"year")

# Display Date by default
query = "statue of liberty"
ID = "P571"
print "Label : " + wikidatafetcher.getLabel(query)
print "Built in : " + wikidatafetcher.getData(query,ID)
# Display Date (year)
print "Built in : " + wikidatafetcher.getTime(query,ID,"year")
print "Coordinates : " + wikidatafetcher.getData(query,"P625")

# french crawl

wikidatafetcher.setWebSite("frwiki")
wikidatafetcher.setLanguage("fr") 
print u"c est quoi un éléphant  : " + wikidatafetcher.getDescription(u"éléphant")