Skip to content

More informative panic message when you try to train on data that is too short - #566

Open
sandbergja wants to merge 1 commit into
pemistahl:mainfrom
sandbergja:more-informative-message
Open

More informative panic message when you try to train on data that is too short#566
sandbergja wants to merge 1 commit into
pemistahl:mainfrom
sandbergja:more-informative-message

Conversation

@sandbergja

Copy link
Copy Markdown

Thanks so much for this cool project!

While experimenting with it locally, I attempted to create a new language model with create_and_write_language_model_files, and got a panic with the somewhat mysterious message:

attempt to subtract with overflow

It was because my input file had a line with only 4 characters, but the model creation was trying to extract a five-gram.

In case it is useful, here is a PR to provide a (for me, at least) more useful panic message -- please feel free to close this pr if it is not helpful!

input text must be at least 5 chars

…too short

Before this commit, if your data contained a line with, say, only 4 characters,
when you run `create_and_write_language_model_files`, it will fail with a
somewhat mysterious message:

```
attempt to subtract with overflow
```

This is because the trainer is attempting to extract a five-gram, but you can't
make a five-gram with only 4 characters!

This commit provides a somewhat more useful panic message:

```
input text must be at least 5 chars
```
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

Successfully merging this pull request may close these issues.

1 participant