Wikia / ask-fandom

Your semantic data-based assistant from Wikia
MIT License
7 stars 1 forks source link
alexa fandom natural-language-processing semantic-data voice-assistant

ask-fandom

Build Status

Your semantic data-based assistant aka Tell me FANDOM, ...

Supported questions

Examples for https://tardis.fandom.com/wiki/Doctor_Who_Wiki

Examples for https://wowwiki.fandom.com

Supported "commands"

>>> rrp.simple_parse("Was Jake Simmonds in the Doctor Who cast?")
'(S1 (SQ (VBD Was) (NP (NP (NNP Jake) (NNPS Simmonds)) (PP (IN in) (NP (DT the) (NN Doctor)))) (NP (WP Who) (NN cast)) (. ?)))'
>>> rrp.simple_parse("Tell me something about foo")
'(S1 (S (VP (VB Tell) (NP (PRP me)) (NP (NP (NN something)) (PP (IN about) (NP (NN foo)))))))'

Command-line tool

$ python ask.py  "Who played Lionel Carson?"
Model directory: /home/macbre/.local/share/bllipparser/WSJ-PTB3
Model directory already exists, not reinstalling
INFO:get_oracle:Parsing question: Who played Lionel Carson?
INFO:get_oracle:Parsed question: [('WP', 'Who'), ('VBD', 'played'), ('NP', 'Lionel Carson')]
INFO:PersonFactOracle:You've asked: 'Who played Lionel Carson?' ({'name': 'Lionel Carson', 'property': 'played'})
INFO:PersonFactOracle:Asking SMW for 'Lionel Carson' page Actor property
INFO:PersonFactOracle:Got the value for Actor: ['Peter Bowles']
---
Who played Lionel Carson?
Lionel Carson is played by Peter Bowles.

Web interface / HTTP API

Run make server to start it. Flask server will listen on 0.0.0.0:5050.

/ask

$ curl -s 'http://127.0.0.1:5050/ask?q=Who%20directed%20The%20Big%20Bang%20episode?' | jq
{
  "_intent": "EpisodeFactIntent",
  "_meta": {
    "answer": "Toby Haynes",
    "name": "The Big Bang episode",
    "property": "directed"
  },
  "_reference": null,
  "_words": {
    "NN": "episode",
    "NP": "The Big Bang episode",
    "VBD": "directed",
    "WP": "Who"
  },
  "answer": "\"The Big Bang episode\" episode has been directed by Toby Haynes."
}

/examples

$ curl -s 'http://127.0.0.1:5050/examples' | jq
{
  "questions": [
    "Where does Lionel Messi play?",
    "Which club Cristiano Ronaldo plays for?",
    "Which faction does the Alterac belong to?",
    "Who directed The Big Bang episode?",
    "Who played Jake Simmonds?"
  ]
}

Data sources

SemanticMediaWiki API

Tools

Questions parsing libraries

Inspirations

Whitepapers

See https://groups.csail.mit.edu/infolab/publications.html

Install

virtualenv env -ppython3
. env/bin/activate
pip install -r requirements.txt
make server