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

Nonetype object Not Iterable on using thesaurus #56

Open
Pushkalb opened this issue Feb 26, 2019 · 9 comments
Open

Nonetype object Not Iterable on using thesaurus #56

Pushkalb opened this issue Feb 26, 2019 · 9 comments

Comments

@Pushkalb
Copy link

Hi, I tried to use thesaurus, but I'm getting an issue saying "argument of type 'NoneType' is not iterable".
Could anyone help on this?
Thanks!

@sakuranew
Copy link

some word‘s equivalences is none but original code have code like “sth in equivalences“,
so you just need to add a condition to ensure this part code doesnt execute when equivalence is none

@vlevieux
Copy link

I had this problem it seems that self.database_object.get_table_by_name(table_name).equivalences in parser.py:711&806 can be NoneType.

You can avoid the bugs by adding these two lines above:

if self.database_object.get_table_by_name(table_name).equivalences is None:
    continue

Why is this variable sometimes NoneType?

  • I have no idea.

@Heernandez
Copy link

Heernandez commented May 22, 2019 via email

@vlevieux
Copy link

It seems to be a problem by reading the thesaurus dictionary. In the paper, they indicated:

Ainsi si la table regroupant les informations des étudiants a par exemple pour nom ETUD_UNIV_01, et qu'aucun synonyme n'a donc été automatiquement ajouté à ce nom de table, l'utilisateur pourra rentrer manuellement le mot étudiant comme synonyme [...].

Thus, if the table containing the students' information has, for example, the name ETUD_UNIV_01, and no synonyms have been automatically added to this table name, the user can manually enter the word student as a synonym [...].

Then I tried to get the table chambre when I ask with azertyuiop (random word) to try this feature.

Then I added these lines in the thesaurus dictionary:

chambre|1
(noun)|azertyuiop|randomword

I ran the following command:

python -m ln2sql.main -d database_store/hotel.sql -l lang_store/english.csv -t thesaurus_store\th_english.dat -j output.json -i "What are the azertyuiop with nbLit greater than 3?"

The result is: (it's correct)

SELECT *
FROM chambre
WHERE chambre.nbLit > '3';

I noticed with the following lines in the thesaurus dictionary doesn't work. You need to add another value as above.

chambre|1
(noun)|azertyuiop

I need to figure out the way they retrieve values. Why does it return NoneType? Why doesn't single synonym work?

@sakuranew
Copy link

just let the equivalences =[] rather than Nonetype when initialize the database object

@bdonepudi97
Copy link

I had this problem it seems that self.database_object.get_table_by_name(table_name).equivalences in parser.py:711&806 can be NoneType.

You can avoid the bugs by adding these two lines above:

if self.database_object.get_table_by_name(table_name).equivalences is None:
    continue

Why is this variable sometimes NoneType?

  • I have no idea.

After which line of code(please put the statement) should we place the if condition?

@rakesh160
Copy link

rakesh160 commented Apr 9, 2020

I had this problem it seems that self.database_object.get_table_by_name(table_name).equivalences in parser.py:711&806 can be NoneType.
You can avoid the bugs by adding these two lines above:

if self.database_object.get_table_by_name(table_name).equivalences is None:
    continue

Why is this variable sometimes NoneType?

  • I have no idea.

After which line of code(please put the statement) should we place the if condition?

i tried adding after 709 and 805. However the output seems to be different before and after. Please refer to below screenshot

image

So, Instead of continuing when the self.database_object.get_table_by_name(table_name).equivalences is None, i have tried setting it to empty List.

if self.database_object.get_table_by_name(table_name).equivalences is None:
      self.database_object.get_table_by_name(table_name).equivalences = []

Here is the expected output:
image

@rakesh160
Copy link

It seems to be a problem by reading the thesaurus dictionary. In the paper, they indicated:

Ainsi si la table regroupant les informations des étudiants a par exemple pour nom ETUD_UNIV_01, et qu'aucun synonyme n'a donc été automatiquement ajouté à ce nom de table, l'utilisateur pourra rentrer manuellement le mot étudiant comme synonyme [...].

Thus, if the table containing the students' information has, for example, the name ETUD_UNIV_01, and no synonyms have been automatically added to this table name, the user can manually enter the word student as a synonym [...].

Then I tried to get the table chambre when I ask with azertyuiop (random word) to try this feature.

Then I added these lines in the thesaurus dictionary:

chambre|1
(noun)|azertyuiop|randomword

I ran the following command:

python -m ln2sql.main -d database_store/hotel.sql -l lang_store/english.csv -t thesaurus_store\th_english.dat -j output.json -i "What are the azertyuiop with nbLit greater than 3?"

The result is: (it's correct)

SELECT *
FROM chambre
WHERE chambre.nbLit > '3';

I noticed with the following lines in the thesaurus dictionary doesn't work. You need to add another value as above.

chambre|1
(noun)|azertyuiop

I need to figure out the way they retrieve values. Why does it return NoneType? Why doesn't single synonym work?

Seems like even the single word works but we have to end it with a pipe as below

chambre|1
(noun)|azertyuiop|

instead of

chambre|1
(noun)|azertyuiop

@rakesh160
Copy link

rakesh160 commented Apr 9, 2020

It seems to be a problem by reading the thesaurus dictionary. In the paper, they indicated:

Ainsi si la table regroupant les informations des étudiants a par exemple pour nom ETUD_UNIV_01, et qu'aucun synonyme n'a donc été automatiquement ajouté à ce nom de table, l'utilisateur pourra rentrer manuellement le mot étudiant comme synonyme [...].

Thus, if the table containing the students' information has, for example, the name ETUD_UNIV_01, and no synonyms have been automatically added to this table name, the user can manually enter the word student as a synonym [...].

Then I tried to get the table chambre when I ask with azertyuiop (random word) to try this feature.

Then I added these lines in the thesaurus dictionary:

chambre|1
(noun)|azertyuiop|randomword

I ran the following command:

python -m ln2sql.main -d database_store/hotel.sql -l lang_store/english.csv -t thesaurus_store\th_english.dat -j output.json -i "What are the azertyuiop with nbLit greater than 3?"

The result is: (it's correct)

SELECT *
FROM chambre
WHERE chambre.nbLit > '3';

I noticed with the following lines in the thesaurus dictionary doesn't work. You need to add another value as above.

chambre|1
(noun)|azertyuiop

I need to figure out the way they retrieve values. Why does it return NoneType? Why doesn't single synonym work?

Change the first few lines in load method in thesaurus.py file to below:

    def load(self, path):
        with open(self._generate_path(path)) as f:
            # content = f.readlines()
            content = f.read().splitlines()

Now its working even id we dont add an extra pipe at the end
ref: https://stackoverflow.com/questions/12330522/how-to-read-a-file-without-newlines

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

6 participants