-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat: add just sample
to list all forms of random dictionary words
#646
base: master
Are you sure you want to change the base?
feat: add just sample
to list all forms of random dictionary words
#646
Conversation
Modified `harper-cli forms` to accept a space-separated list of annotated words to support this. `just sample` accepts a numeric argument for how many words to choose from the curated dictionary. I've already fixed some mistakes with wrong affix annotations in the curated dictionary. This provides a way to check randomly to see if anything looks wrong. It may actually be more useful for the user dictionary. Let me know if I should add that and suggest names for switches. Another possibility as to also have an option that samples from the combined curated+user dictionaries. The implementation uses the *nix `jot` command which is included with macOS which does not have `shuf`. Let me know if this solution is broken for Linux etc.
@@ -259,6 +259,21 @@ getmetadata word: | |||
# Get all the forms of a word using the affixes. | |||
getforms word: | |||
cargo run --bin harper-cli -- forms {{word}} | |||
# Get a random sample of words from Harper's dictionary and list all forms of each. | |||
sampleforms count: | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding set -eo pipefail
?
Right now, if jot
is not available on the machine (like mine), it silently errors. I'm fine with adding it as a dependency, but I'd like it to error out when it's missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding
set -eo pipefail
?
Is that as a separate *nix command? I'm a CLI guy but no *nix or shell wizard.
Right now, if
jot
is not available on the machine (like mine), it silently errors. I'm fine with adding it as a dependency, but I'd like it to error out when it's missing.
Ah I was worried about that. The other solution is to use shuf
on machines that have it and jot
otherwise, but I'm not sure how to handle that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elijah-potter I just made an alternate PR that should work with either jot
or shuf
but I'm unable to test. Please give it a try and let me know: #653
Modified
harper-cli forms
to accept a space-separated list of annotated words to support this.just sample
accepts a numeric argument for how many words to choose from the curated dictionary.I've already fixed some mistakes with wrong affix annotations in the curated dictionary. This provides a way to check randomly to see if anything looks wrong.
It may actually be more useful for the user dictionary. Let me know if I should add that and suggest names for switches. Another possibility as to also have an option that samples from the combined curated+user dictionaries.
The implementation uses the *nix
jot
command which is included with macOS which does not haveshuf
. Let me know if this solution is broken for Linux etc.Example:
(sett is a word, but not that common, so might not be a mistake)