Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuestionTranslater gets stuck #35

Closed
edeutsch opened this issue Mar 26, 2018 · 12 comments
Closed

QuestionTranslater gets stuck #35

edeutsch opened this issue Mar 26, 2018 · 12 comments

Comments

@edeutsch
Copy link
Collaborator

The new QuestionTranslator gets wedged on this question:

What is the clinical outcome pathway of dicumarol for treatment of coagulation?

@dkoslicki
Copy link
Member

Doesn't appear to get stuck in the actual translation of the question:

txltr = QuestionTranslator.QuestionTranslator()
txltr.find_question_parameters("What is the clinical outcome pathway of dicumarol for treatment of coagulation")
Out[591]: 
{'corpus_index': 2,
 'error_code': 'missing_term',
 'error_message': 'Sorry, I was unable to find the appropriate terms to answer your question. Missing term(s):\nA disease (eg. diphtheritic cystitis, pancreatic endocrine carcinoma, malaria, clear cell sarcoma, etc.)',
 'input_text': 'What is the clinical outcome pathway of dicumarol for treatment of coagulation',
 'terms': {'disease_name': None, 'drug_name': 'dicumarol'}}

It's just that coagulation isn't a disease, and COP's need a drug and a disease

@dkoslicki
Copy link
Member

@edeutsch Any updates for this issue?

@edeutsch
Copy link
Collaborator Author

you're right, this is definitely a response parsing issue, not a stuck issue. I haven't tried to work on the solution yet. been working on the response API. But I will try to fix it tonight.

@edeutsch
Copy link
Collaborator Author

@dkoslicki , so while trying to sleuth this out, I just tried this: in the file QuestionTranslator.py, in main():
When I run:
$ python3 QuestionTranslator.py
with:
question = {"language": "English", "text": "What is the clinical outcome pathway of physostigmine for treatment of glaucoma"}
I get:
[{'terms': ['DOID:1686', 'physostigmine'], 'originalQuestion': 'What is the clinical outcome pathway of physostigmine for treatment of glaucoma', 'restatedQuestion': 'What is the clinical outcome pathway of CHEMBL94 for the treatment of glaucoma', 'knownQueryTypeId': 'Q2'}]

but when I run with:
question = {"language": "English", "text": "What is the clinical outcome pathway of dicumarol for treatment of coagulation"}
I get:
Traceback (most recent call last):
File "QuestionTranslator.py", line 722, in
main()
File "QuestionTranslator.py", line 716, in main
res = txltr.translate(question)
File "QuestionTranslator.py", line 581, in translate
return self.format_answer(results_dict, logging=logging)
File "QuestionTranslator.py", line 201, in format_answer
"restatedQuestion": "%s" % self.restate_question(corpus_index, terms), "originalQuestion": input_text}]
File "QuestionTranslator.py", line 139, in restate_question
restated = "What is the clinical outcome pathway of %s for the treatment of %s" % (names2descrip[terms["drug_name"]], names2descrip[terms["disease_name"]])
KeyError: None

I am uncertain if this is the problem, but it seems like a problem?
Or am I barking up the wrong tree?

dkoslicki added a commit that referenced this issue Mar 29, 2018
@dkoslicki
Copy link
Member

@edeutsch Yeah, I was incorrectly assuming a drug and a disease were given. Fix pushed to NewStdAPI branch.

@edeutsch
Copy link
Collaborator Author

This is still causing problems. So now the result is:
[{'originalQuestion': 'What is the clinical outcome pathway of dicumarol for treatment of coagulation', 'knownQueryTypeId': 'Q2', 'message': 'Sorry, I was unable to find the appropriate terms to answer your question. Missing term(s):\nA disease (eg. diphtheritic cystitis, pancreatic endocrine carcinoma, malaria, clear cell sarcoma, etc.)', 'restatedQuestion': 'What is the clinical outcome pathway of CHEMBL1466 for the treatment of ?'}]

The way my code currently works is: if there is a specified knownQueryTypeId, then the result get forwarded to than query type handler. So I suggest that if the QuestionTranslator doesn't feel that there is enough information to forward to a QX handler, then knownQueryTypeId should be None/null.

Does that seem like a good rule? Or what should be the signal that the translated question should be forwarded to a QX handler?

Maybe we need to come up with a flow diagram for the QuestionTranslator

@dkoslicki
Copy link
Member

Yeah, a flow diagram would be helpful. Maybe as a condition to be passed to QX handler would be:

  1. known query type ID
  2. all terms not None
    It would seem odd to set the query type ID to None when it's actually known (but that could be a workaround for the time being).

@edeutsch
Copy link
Collaborator Author

okay, i suppose it makes sense to me to set the query type ID to None if there isn't enough information to send it to the reasoner, and only an error message should be displayed. But it's not black and white.

I wonder if there will ever be a case where a query type is ready to be sent to a reasoner with one of the terms set to None. Maybe some queries will have optional terms? I don't know, but seems possible maybe?

What is the clinical outcome pathway of physostigmine for treatment of glaucoma, excluding fructose metabolism?

@dkoslicki
Copy link
Member

Hmmm... good point! Maybe we just add a new key to the dict called something like OkToSend? Ugly, but at least obvious what it does.

@edeutsch
Copy link
Collaborator Author

while compiling the spreadsheet I did notice that if there is a message, then it is not ready to send. So I could change the logic to say: if there is a message, then halt and print the message rather than proceed. Does that seem like a good rule for now?

@dkoslicki
Copy link
Member

@edeutsch Yeah, that seems like a good way to go!

@dkoslicki
Copy link
Member

@edeutsch Closing this issue in favor of #52

saramsey added a commit that referenced this issue May 4, 2018
saramsey added a commit that referenced this issue May 4, 2018
saramsey added a commit that referenced this issue May 4, 2018
saramsey added a commit that referenced this issue May 4, 2018
saramsey added a commit that referenced this issue May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants