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

text_model.make_sentence() always outputs none, even with a script running it for an infinite number of tries. #96

Closed
Id405 opened this issue Mar 21, 2018 · 2 comments

Comments

@Id405
Copy link

Id405 commented Mar 21, 2018

import markovify

with open("data", encoding="utf-8") as f:
    text = f.read()
text_model = markovify.Text(text, state_size=7)

txt = []
while len(txt) in range(0,5):
        txt.append(text_model.make_sentence(tries=100))
        txt = [x for x in txt if x is not None]

print(txt)

This script just hangs on my screen. Reinstalling the library did nothing for me, trying different corpus did not work either.

@theIsaacLim
Copy link

you need to specify the length of the statement
ie. text_model.make_sentence(140, tries=100)

@jsvine
Copy link
Owner

jsvine commented Apr 29, 2018

@8o7wer's code above seems to work fine on large corpora. E.g., the sherlock.txt test text. The hitch seems to be the specification of state_size = 7. That's a fairly large state size, and will only be able to generate new sentences with fairly large corpora. (I.e., those which contain many examples of the same seven-word sequences.)

If you reduce the state_size to a smaller number — e.g., 2 or 3 — it should work fine on most corpora.

@jsvine jsvine closed this as completed Apr 29, 2018
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

3 participants