facebookresearch / DrQA

Reading Wikipedia to Answer Open-Domain Questions
Other
4.48k stars 898 forks source link

How to get DrQA answers in JSON format...?? #43

Closed Deepakchawla closed 7 years ago

Deepakchawla commented 7 years ago

Currently, I am getting answers with use python scripts/pipeline/interactive.py and format is something like that

>>> process('What is question answering?')

Top Predictions:
+------+----------------------------------------------------------------------------------------------------------+--------------------+--------------+-----------+
| Rank |                                                  Answer                                                  |        Doc         | Answer Score | Doc Score |
+------+----------------------------------------------------------------------------------------------------------+--------------------+--------------+-----------+
|  1   | a computer science discipline within the fields of information retrieval and natural language processing | Question answering |    1917.8    |   327.89  |
+------+----------------------------------------------------------------------------------------------------------+--------------------+--------------+-----------+

Contexts:
[ Doc = Question answering ]
Question Answering (QA) is a computer science discipline within the fields of
information retrieval and natural language processing (NLP), which is
concerned with building systems that automatically answer questions posed by
humans in a natural language.

But it is not much use for my project. So can anyone tell how to get the answers in JSON format or in one line which I can....

ajfisch commented 7 years ago

Look at the code for interactive.py to see how it uses the drqa.pipeline.DrQA API. The return of process() is a dict.

So if you want to use DrQA in a project, it's probably better to import it yourself and use the functions directly (rather than parse the output of the scripts). The scripts are just to serve as an example.

Deepakchawla commented 7 years ago

Thanks Again @ajfisch for helping me and you really help me a lot in my project... Once I will accomplish my project I will show its demo