Giter Club home page Giter Club logo

nlquery's Introduction

NLQuery

A natural language query engine on WikiData.

Examples:

Who is Obama? 44th President of the United States
How tall is Yao Ming? 2.286m
Where was Obama born? Kapiolani Medical Center for Women and Children
When was Obama born? August 04, 1961
Who did Obama marry? Michelle Obama
Who is Obama's wife? Michelle Obama
Who is Barack Obama's wife? Michelle Obama
Who was Malcolm Little known as? Malcolm X
What is the birthday of Obama? August 04, 1961
What religion is Obama? Christianity
Who did Obama marry? Michelle Obama

How many countries are there? 196
Which countries have a population over 1000000000? People's Republic of China, India
Which books are written by Douglas Adams? The Hitchhiker's Guide to the Galaxy, ...
Who was POTUS in 1945? Harry S. Truman
Who was Prime Minister of Canada in 1945? William Lyon Mackenzie King
Who was CEO of Apple Inc in 1980? Steve Jobs

Architecture

English query -> Parse Tree -> Matched Context -> Sparql Query -> Answer

Example:
Who did Obama marry?
-> (SBARQ
     (WHNP (WP Who))
     (SQ (VBD did) (NP (NNP Obama)) (VP (VB marry)))
     (. ?))
-> {'subject': 'Obama', 'property': 'marry'}
-> SELECT ?valLabel
        WHERE {
           {
                wd:Q76 p:P26 ?prop .
                ?prop ps:P26 ?val .
            }
            SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
        }
-> Michelle Obama

Install

Download Stanford CoreNLP

Make sure you have Java installed for the Stanford CoreNLP to work.

Download Stanford CoreNLP

Run the Stanford CoreNLP server

Run the following command in the folder where you extracted Stanford CoreNLP

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer

Install nlquery

git clone https://github.com/ayoungprogrammer/nlquery
cd nlquery
pip install -r requirements.txt

Run

Start the command line:

python main.py

To run web app, go to nlquery-app/readme.md

Tests

Run

py.test

nlquery's People

Contributors

ayoungprogrammer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nlquery's Issues

nltk incompatibility?

I just tried to install it myself, and I encountered following issues:

  • it seems nltk is missing in requirements.txt
  • once I pip install nltk then python main.py errors with
Traceback (most recent call last):
  File "main.py", line 17, in <module>
    main(sys.argv[1:])
  File "main.py", line 6, in main
    engine = NLQueryEngine('localhost', 9000)
  File ".../nlquery/nlquery/nlquery.py", line 21, in __init__
    self.parser = StanfordServerParser(host, port, properties)
TypeError: __init__() takes at most 3 arguments (4 given)
% python --version
Python 2.7.12

The CoreNLP server is running at port 9000 (tested via wget).

Getting issue while installing requirements

Collecting lango==0.13.2 (from -r requirements.txt (line 1))
Using cached Lango-0.13.2.tar.gz
Collecting pattern==2.6 (from -r requirements.txt (line 2))
Using cached pattern-2.6.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/7c/8ympcg21083b3pw4pxkyt52c0000gn/T/pip-build-zh8w8w3a/pattern/setup.py", line 40
print n
^
SyntaxError: Missing parentheses in call to 'print'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/7c/8ympcg21083b3pw4pxkyt52c0000gn/T/pip-build-zh8w8w3a/pattern/
--> python --version
Python 2.7.10

Year before 1900

Question: "when was Switzerland founded?"

Answer: "year=1291 is before 1900; the datetime strftime() methods require year >= 1900"

The demo is unavailable

The web says: "The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."

Entity Disambiguation?

I posed the English question: What is China, and it assumes I am interested in a country? That is more likely the case if the English question posed was: Where is China.

Demo site is broken

Hey Michael,

The demo site for this project appears to be non-functional. The answer to all questions entered is:

Cannot connect to CoreNLP server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.