Skip to content

Commit

Permalink
limit generated text
Browse files Browse the repository at this point in the history
sometimes, there's no sentence terminator generated and we'd run forever/
  • Loading branch information
breznak committed Nov 16, 2013
1 parent ea93deb commit cdc547d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/linguist.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,17 @@ def tellStory(model, startSent, lenght):

numSent = 0
c = s
sentence_len = 0
while numSent <= lenght:
print(c),
modelInput = {'letter': c}
result = model.run(modelInput)
c=result.inferences['prediction'][0]

sentence_len += 1
if(sentence_len > 30): #limit, sometimes there's no sentence terminator generated and we'd run forever
numSent += 1
sentence_len = 0

if c in TERMINATORS:
numSent += 1
Expand Down

0 comments on commit cdc547d

Please sign in to comment.