ProjetPP / PPP-QuestionParsing-Grammatical

Question Parsing module for the PPP using a grammatical approch
GNU Affero General Public License v3.0
33 stars 11 forks source link

failed to run demos : 'indexeddependencies' #155

Closed kaushal2161 closed 8 years ago

kaushal2161 commented 8 years ago

I'm interested to make one module which gives mathematical formula for a given question so, i wanted to use question parser module but having trouble. It works till demo2.py but for tree it gives following error:

Traceback (most recent call last):
  File "demo4.py", line 35, in <module>
    print(get_tree())
  File "demo4.py", line 28, in get_tree
    tree = ppp_questionparsing_grammatical.computeTree(result)
  File "/home/kaushal/workspace1/askplatyp_formula_retrieval/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/dependencyTree.py", line 336, in computeTree
    tree = generator.computeTree()
  File "/home/kaushal/workspace1/askplatyp_formula_retrieval/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/dependencyTree.py", line 249, in computeTree
    self._computeEdges()
  File "/home/kaushal/workspace1/askplatyp_formula_retrieval/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/dependencyTree.py", line 189, in _computeEdges
    for edge in self.stanfordResult['basic-dependencies']: # use 'collapsed-dependencies' ?
KeyError: 'basic-dependencies'

Any ideas how to solve this error?

Ezibenroc commented 8 years ago

Which sentence did you use? Which version of Stanford CoreNLP do you have?

kaushal2161 commented 8 years ago

i have solved the issue. I have to change File "/home/kaushal/workspace1/askplatyp_formula_retrieval/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/dependencyTree.py", line 189, in _computeEdges for edge in self.stanfordResult['basic-dependencies']: to for edge in self.stanfordResult['basicDependencies']:

One more thing i wanted to ask for another type of question: what is relation between energy and mass? for this question i didn't get D graph but got warning which is as follows:

digraph relations { "7"[label="ROOT", shape=box]; "7" -> "6"[label="ROOT"]; "6"[label="is", shape=box]; "6" -> "0"[label="nsubj"]; "6" -> "5"[label="xcomp"]; "0"[label="what", shape=box]; "5"[label="realtion", shape=box]; "5" -> "4"[label="nmod"]; "4"[label="energy", shape=box]; "4" -> "1"[label="case"]; "4" -> "2"[label="cc"]; "4" -> "3"[label="conj"]; "1"[label="between", shape=box]; "2"[label="and", shape=box]; "3"[label="mass", shape=box]; labelloc="t" label=""; } WARNING:root:'between' digraph G {

}

Any suggestion how to get triple like (energy,relation,?)∩(mass,relation,?) for this type of questions? In online platypus i got this triple.

Ezibenroc commented 8 years ago

i have solved the issue. I have to change File "/home/kaushal/workspace1/askplatyp_formula_retrieval/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/dependencyTree.py", line 189, in _computeEdges for edge in self.stanfordResult['basic-dependencies']: to for edge in self.stanfordResult['basicDependencies']:

Thank you for noticing this bug and solving it. It seems that there has been an API change in CoreNLP. This commit fixes the bug: https://github.com/ProjetPP/PPP-QuestionParsing-Grammatical/commit/bdfd16c8c5653b64bd287c0a7cd481f889afd5ff

Any suggestion how to get triple like (energy,relation,?)∩(mass,relation,?) for this type of questions? In online platypus i got this triple.

The online platypus uses an old version of the module QuestionParsing-Grammatical. We updated the module in https://github.com/ProjetPP/PPP-QuestionParsing-Grammatical/pull/149 to use a more recent version of CoreNLP which has a built-in http server. The downside is that there has been some regressions, as the one you noticed. We could try to fix them, but I cannot say when. We are not even sure to keep using CoreNLP.

If you want to use the old version of the module, you can checkout commit https://github.com/ProjetPP/PPP-QuestionParsing-Grammatical/commit/32c44816a66a2caea39f03a13b3989064efbde0b and https://github.com/ProjetPP/Scripts/commit/e8483fda10a493514c82700e2b419e1f2f1b2031

kaushal2161 commented 8 years ago

Thank you for quick answer. one more thing to ask. i am getting triple node for question - what is volume of sphere? {'type': 'triple', 'subject': {'type': 'triple', 'predicate': {'type': 'resource', 'value': 'volume'}, 'object': {'type': 'missing'}, 'subject': {'type': 'resource', 'value': 'sphere'}}}

But i need (sphere,volume,?) this format so that i can get predicate value and subject value for formula. Any suggestions?

In addition to that, i wanted to develop question parsing module which takes question in "hindi" language. So, to make it possible i have to develop same module as PPP-QuestionParsing-PLYFrench or something else i have to change in QuestionParsing-Grammatical module. Small guidance would be grateful to start.

Ezibenroc commented 8 years ago

one more thing to ask. i am getting triple node for question - what is volume of sphere? {'type': 'triple', 'subject': {'type': 'triple', 'predicate': {'type': 'resource', 'value': 'volume'}, 'object': {'type': 'missing'}, 'subject': {'type': 'resource', 'value': 'sphere'}}}

But i need (sphere,volume,?) this format so that i can get predicate value and subject value for formula. Any suggestions?

I get (sphere, volume, ?) both with the current version and the online platypus. Moreover, what you get is not formed correctly: the outer dict has triple for type, but has no objecŧ nor predicate. This would be a very strange bug. Can you check that you copied correctly the output?

In addition to that, i wanted to develop question parsing module which takes question in "hindi" language. So, to make it possible i have to develop same module as PPP-QuestionParsing-PLYFrench or something else i have to change in QuestionParsing-Grammatical module. Small guidance would be grateful to start.

I do not think there is a straightforward way to translate the QuestionParsing-Grammatical module, especially for a language like Hindi which has no common root with English. I have not any knowledge of this language, but I guess that its grammatical structure may be very different. Moreover, CoreNLP has no model for Hindi, according to their website. So you would have to either develop yourself a model for Hindi, find another library, or develop everything from scratch by yourself.

kaushal2161 commented 8 years ago

i have checked its correctly copied. query = Triple(q.answer()) print(query.as_dict()) for this i am getting following: digraph relations { "6"[label="ROOT", shape=box]; "6" -> "5"[label="ROOT"]; "5"[label="is", shape=box]; "5" -> "0"[label="dobj"]; "5" -> "3"[label="nsubj"]; "5" -> "4"[label="punct"]; "0"[label="what", shape=box]; "3"[label="volume", shape=box]; "3" -> "2"[label="nmod"]; "2"[label="sphere", shape=box]; "2" -> "1"[label="case"]; "1"[label="of", shape=box]; "4"[label="?", shape=box]; labelloc="t" label=""; } {'type': 'triple', 'subject': {'type': 'triple', 'subject': {'type': 'resource', 'value': 'sphere'}, 'predicate': {'type': 'resource', 'value': 'volume'}, 'object': {'type': 'missing'}}}

Ezibenroc commented 8 years ago

I do not know what is q, but I guess you should do this:

 query = q.answer()
kaushal2161 commented 8 years ago

thanks now it shows correct. {'subject': {'value': 'sphere', 'type': 'resource'}, 'object': {'type': 'missing'}, 'type': 'triple', 'predicate': {'value': 'volume', 'type': 'resource'}}