question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: 'NoneType' object is not iterable

See original GitHub issue

Hi,

Why do I get the error when running the following code?

`phrases = [“Can you recommend some upscale restaurants in Newyork?”, “What are the famous places we should not miss in Russia?” ]

for phrase in phrases: print(“-”*100) print(“Input_phrase: “, phrase) print(”-”*100) para_phrases = parrot.augment(input_phrase=phrase, use_gpu=False, do_diverse=True, diversity_ranker=“levenshtein”) for para_phrase in para_phrases: print(para_phrase)`

Error:

`TypeError Traceback (most recent call last) /home/user/Code/Parrot/main.ipynb Cell 4 in <cell line: 5>() 8 print(“-”*100) 9 para_phrases = parrot.augment(input_phrase=phrase, use_gpu=False, do_diverse=True, diversity_ranker=“levenshtein”) —> 10 for para_phrase in para_phrases: 11 print(para_phrase)

TypeError: ‘NoneType’ object is not iterable`

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tsikerdekiscommented, Oct 2, 2022

If you look at the code, there are limits that could lead to None if not good candidates are found: https://github.com/PrithivirajDamodaran/Parrot_Paraphraser/blob/2cffbe911341e52dc73b77f9b0154c18d570603f/parrot/parrot.py#L130

You can bypass this by lowering those limits. For example:

para_phrases = None
    fluency_threshold = 0.90
    adequacy_threshold = 0.99
    iter = 0
    while para_phrases == None:
        para_phrases = parrot.augment(input_phrase=paraphrase_sent,
                                diversity_ranker="levenshtein",
                                do_diverse=False,
                                max_return_phrases = 1, 
                                max_length=1000, 
                                adequacy_threshold = adequacy_threshold, 
                                fluency_threshold = fluency_threshold)
        fluency_threshold -= 0.10
        adequacy_threshold -= 0.10
        iter += 1
        print(iter)
    return para_phrases[0][0]
0reactions
MansiSharma98commented, Aug 26, 2022

Same here. This is so frustrating!!

what the parrot paraphraser usually returns: a list of tuples each tuple consists of two things : paraphrased string token_count

if we give max_return_phrases = 3, then it will return a list of 3 such tuples.

but it is randomly returning None for sentences and there is no definite pattern, if I rerun the cell for the same sentence, it then sometimes returns the paraphrases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: 'NoneType' object is not iterable in Python
It means that the data variable is passing None (which is type NoneType), its equivalent for nothing. So ...
Read more >
Python TypeError: 'NoneType' object is not iterable Solution | CK
The TypeError: 'NoneType' object is not iterable error is raised when you try to iterate over an object whose value is equal to...
Read more >
typeerror: 'nonetype' object is not iterable: How to solve this ...
With Python, you can only iterate over an object if that object has a value. This is because iterable objects only have a...
Read more >
Solving python error - 'NoneType' object is not iterable
In the above example, if data is None , we will get the specified error on the second line where we are iterating...
Read more >
Typeerror nonetype object is not iterable : Complete Solution
Typeerror nonetype object is not iterable error occurs when we try to iterate any NoneType object in the place of iterable Python objects....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found