bendichter / tenseflow

Change the tense of any text
MIT License
41 stars 12 forks source link

"RuntimeError: generator raised StopIteration" from module pattern/text #11

Open snej opened 3 years ago

snej commented 3 years ago

I got past the previous error by giving in and installing MySQL (via homebrew.) Then I installed the SpaCy English model as directed. But basic CLI usage as in your example fails:

$  python3
Python 3.9.1 (default, Dec 17 2020, 03:56:09) 
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tenseflow import change_tense
>>> change_tense('I will go to the store.', 'past')
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pattern/text/__init__.py", line 609, in _read
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/snej/Code/tenseflow/tenseflow/change_tense.py", line 116, in change_tense
    out.append(conjugate(words[-1].text, tense=this_tense, person=person, number=number))
  File "/usr/local/lib/python3.9/site-packages/pattern/text/__init__.py", line 2208, in conjugate
    b = self.lemma(verb, parse=kwargs.get("parse", True))
  File "/usr/local/lib/python3.9/site-packages/pattern/text/__init__.py", line 2172, in lemma
    self.load()
  File "/usr/local/lib/python3.9/site-packages/pattern/text/__init__.py", line 2127, in load
    for v in _read(self._path):
RuntimeError: generator raised StopIteration
>>> 
hablema commented 2 years ago

Same issue. Did you resolve it? @snej , @bendichter

mepiyush2000 commented 1 year ago

git clone https://github.com/bendichter/tenseflow.git

I was getting the same issue, but cloning the repository first helped

bendichter commented 1 year ago

There are still people using this? chatGPT would probably be easier and better

snej commented 1 year ago

Huh? That’s like using a sledgehammer to crack open an walnut. (A sledgehammer you can’t even use yourself, you have to send the walnut to the cloud.)

Besides, there’s no assurance that if you tell ChatGPT “change the following text from third to first person…” that it won’t start confabulating and making its own random changes to the text. Especially if the text is long enough to exceed its token window.

bendichter commented 1 year ago

That's all technically true, but I'd recommend at least trying it for your application. There are many nuances of this that my solution handles poorly.

snej commented 1 year ago

I was able, with some hacking, to get it to a state where it converted large swathes of a novel-in-progress from 1st to 3rd person or vice versa. I had to proofread and fix some mistakes, but it was a big help.

bendichter commented 1 year ago

That's great to hear!