This project is a pattern matching question answering script demo, which is simple enough to consider as a baseline approach or a tutorial.
- Take the sentence from command line
- Every word in the sentence will be scanned by a list of EntityKeywordDictionaries and RelationshipKeywordDictionaries, which then triggers the classification strategy to transform it into labels
- For example, sentence like "What is Amantadine used to treat?" would trigger the Cure keyword (as Relationship) and Drug keyword (as Entity)
- According to the classification strategy, this sentence will be transformed into a
drug_disease
relationship label andAmantadine
entity label
- Since the entity and relationship have been determined, the query will be constructed and send to a database or even a file to get the answer
- Prompt the answer back to the command line
sequenceDiagram
Actor User
User->>+Chatbot: raw sentence
Chatbot->>+Classifier: raw sentence
Classifier->>+RelationshipPicker: raw sentence
RelationshipPicker-->>-Classifier: relationships
Classifier->>+EntityPicker: raw sentence
EntityPicker-->>-Classifier: entities
Classifier-->>Chatbot: question type (inferred from relationships)
Classifier-->>-Chatbot: entity dict (entities)
Chatbot->>+SQLParser: question type and entity dict
SQLParser-->>-Chatbot: parsed SQL command
Chatbot->>-User: parsed SQL command
Run python3 .\Chatbot.py
in command line only to start the integration test. To start a conversation, you have to add a while loop into the main function of Chatbot.py
There is no configuration file, any adaption must be done by modifying the Parser.py
Add keyword dictionaries manually, then change the process in Classifier.py