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

Error from ppp_datamodel: AttributeError: ('Sort', 0) #126

Closed yhamoudi closed 9 years ago

yhamoudi commented 9 years ago

Another error that i cannot solve: List the fastest animals in the world (test on demo6.py, branch reverse_predicates):

Traceback (most recent call last):
  File "demo6.py", line 35, in <module>
    print(json.dumps(get_answer().as_dict(), indent=4))
  File "demo6.py", line 31, in get_answer
    t = ppp_questionparsing_grammatical.normalFormProduction(tree,qw)
  File "/home/yassine/ppp/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/normalization.py", line 187, in normalFormProduction
    return questionWordNormalForm(nf,qw)
  File "/home/yassine/ppp/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/questionWordProcessing.py", line 146, in questionWordNormalForm
    return processQuestionInfo(nf,w)
  File "/home/yassine/ppp/PPP-QuestionParsing-Grammatical/ppp_questionparsing_grammatical/questionWordProcessing.py", line 114, in processQuestionInfo
    for u in nf.list:
  File "/home/yassine/.local/lib/python3.4/site-packages/ppp_datamodel-0.6.7-py3.4.egg/ppp_datamodel/nodes/abstractnode.py", line 75, in get
AttributeError: ('Sort', 0)
Ezibenroc commented 9 years ago

There is dead code after the line 119 in processQuestionInfo.

Moreover, you do not use the constructors of the operators correctly in this function (and maybe somewhere else, I did not check).

yhamoudi commented 9 years ago

There is dead code after the line 119 in processQuestionInfo.

I forgot to remove line 119 after I was looking for the bug.

Moreover, you do not use the constructors of the operators correctly in this function (and maybe somewhere else, I did not check).

How do we access to the subtree of a Sort node nf for instance. This is not correct (?):

for u in nf.list:
    ...
Ezibenroc commented 9 years ago

How do we access to the subtree of a Sort node nf for instance.

nf.list is a python list of trees if nf is: Intersection, Union, And, Or, List. In this case, it is ok to iterate on nf.list like you are doing.

nf.list is a tree if nf is: First, Last, Sort. In this case, you cannot iterate on nf.list. If I understood well what you want to do, you can simply call processQuestionInfo(nf.list, w).


This come from the fact that each tree represents a list of entities (for instance, (France, president, ?) represents the list of all the presidents of France). Thus, you give a tree to operators which take as input one list (First, Last, Sort). You give a list of trees to operators which take as input several list (Intersection, Union, Or, And).

I got really confused with this when I coded assertIncluded...

yhamoudi commented 9 years ago

It works! Thanks :)