-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
update code to support TA - Tamil language #33
base: main
Are you sure you want to change the base?
Conversation
arcturusannamalai
commented
Dec 19, 2023
- update code to support TA - Tamil language
- add README to show how to add new language
- add option to download wordlist from different repository
- add assertions for incorrectly downloaded files etc.
c9ff125
to
549d6a0
Compare
Hi there @arcturusannamalai! First off, I'd like to say I sincerely appreciate you putting in the work to add a language and making
Regarding the code changes, I'll take a look once you push the changes that I've requested so far because that will make it much easier to review. Just to recap that is:
|
- add README to show how to add new language - add option to download wordlist from different repository - add assertions for incorrectly downloaded files etc. - run rustfmt and update README.md
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.55 to 0.10.60. - [Release notes](https://github.com/sfackler/rust-openssl/releases) - [Commits](sfackler/rust-openssl@openssl-v0.10.55...openssl-v0.10.60) --- updated-dependencies: - dependency-name: openssl dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
a38118e
to
13a86b5
Compare
@hisbaan - thanks for feedback; I updated. Can you take a look ? |
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.
Sorry for taking so long to get back to you, had a busy busy few weeks
=================== | ||
Update the language code in the list at | ||
|
||
|
||
Update the language wordlist | ||
============================ | ||
``` | ||
$ cargo run -- --lang ta --update-langs --wordlist-url https://raw.githubusercontent.com/arcturusannamalai/wordlists/main/ | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.17s | ||
Running `target/debug/dym --lang ta --update-langs --wordlist-url 'https://raw.githubusercontent.com/arcturusannamalai/wordlists/main/'` | ||
Downloading English word list... | ||
Accessing URL: https://raw.githubusercontent.com/arcturusannamalai/wordlists/main//en | ||
[00:00:00] [############################################################################################################################] 4.12MiB/4.12MiB (0s) | ||
Downloading Tamil word list... | ||
Accessing URL: https://raw.githubusercontent.com/arcturusannamalai/wordlists/main//ta | ||
[00:00:00] [############################################################################################################################] 1.73MiB/1.73MiB (0s) | ||
``` | ||
|
||
Run did you mean: | ||
================ | ||
e.g. | ||
``` | ||
cargo run -- --lang ta கலஅ | ||
Compiling didyoumean v1.1.4 (/Users/user/devel/rust-in-action/didyoumean) | ||
Finished dev [unoptimized + debuginfo] target(s) in 1.18s | ||
Running `target/debug/dym --lang ta 'கலஅ'` | ||
Did you mean? | ||
1. கலி | ||
2. கலை | ||
3. கல் | ||
4. அ | ||
5. அகல் | ||
|
||
``` | ||
|
||
|
||
For more info see the help text and options, | ||
``` | ||
$ cargo run -- --help | ||
|
||
didyoumean user$ cargo run -- --help | ||
Compiling didyoumean v1.1.4 (/Users/user/devel/rust-in-action/didyoumean) | ||
Finished dev [unoptimized + debuginfo] target(s) in 2.24s | ||
Running `target/debug/dym --help` | ||
didyoumean 1.1.4 | ||
Hisbaan Noorani | ||
Did You Mean: A cli spelling corrector | ||
|
||
USAGE: | ||
dym [OPTIONS] [SEARCH_TERM] | ||
|
||
ARGS: | ||
<SEARCH_TERM> | ||
|
||
|
||
OPTIONS: | ||
-c, --clean-output | ||
Print a clean version of the output without the title, numbers or colour. | ||
|
||
-h, --help | ||
Print help information | ||
|
||
-l, --lang <LANG> | ||
Select the desired language using its locale code. For example, English would have the | ||
locale code en and French would have the locale code fr. See --print-langs for a list of | ||
locale codes and the corresponding languages. | ||
|
||
[default: en] | ||
|
||
-n, --number <NUMBER> | ||
Change the number of words the program will print. The default value is five. | ||
|
||
[default: 5] | ||
|
||
--print-langs | ||
Display a list of supported languages and their respective locale codes. | ||
|
||
--update-langs | ||
Update all language files from the repository specified by CLI @wordlist-url@. | ||
|
||
-v, --verbose | ||
Print verbose output including the edit distance of the found word to the queried word. | ||
|
||
-V, --version | ||
Print version information | ||
|
||
-w, --wordlist-url <WORDLIST_URL> | ||
Wordlist repository URL. The default value is | ||
'https://raw.githubusercontent.com/hisbaan/wordlists/main' | ||
|
||
[default: https://raw.githubusercontent.com/hisbaan/wordlists/main] | ||
|
||
-y, --yank | ||
Yank (copy) the selected word to the system clipboard. If no word is selected, the | ||
clipboard will not be altered. | ||
|
||
``` | ||
|
||
|
||
|
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.
Please remove these changes to the README.
- The information is not needed in the README. Anyone can access it via the help command or the man page where it is better formatted and more general.
- This information is not well formatted. You use specific to Tamil commands to showcase functionality, these (if it was to be included) should be general commands with placeholders for specific values. Also, when showing these off they should generally be using the binary to run these commands and
short = 'w', | ||
long = "wordlist-url", | ||
help = "Wordlist repository URL", | ||
long_help = "Wordlist repository URL. The default value is 'https://raw.githubusercontent.com/hisbaan/wordlists/main'", |
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.
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.
Rust has a sensible affordance here for CLI help to also print the default; this is not the case in C++, Python @ argparse etc. nice to know!
// Get word list. The program will only get here if/when this is a valid word list. | ||
let word_list = read_to_string(dirs::data_dir().unwrap().join("didyoumean").join(args.lang)) | ||
.expect("Error reading file"); | ||
|
||
// Get dictionary of words from words.txt. | ||
let dictionary = word_list.split('\n'); | ||
|
||
//assert!(dictionary.clone().count()>20,"Size of wordlist > 20 words"); |
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.
I think this was used in debugging? Please remove this
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.
still new to Rust as you can see from the clone-ing. Sorry.
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.
No worries! I really appreciate the effort and desire to make software better :)
@@ -17,6 +17,7 @@ pub fn yank(string: &str) { | |||
"freebsd", | |||
"netbsd", | |||
"dragonfly", | |||
"mac osx", |
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.
The reason "mac osx" was not on this list before is that (as far as I know) it handles clipboard functionality just fine without this hack. This is not a "supported operating systems" list but instead a list of operating systems for which a certain workaround is required. Please remove it from this list.
assert!( | ||
!args.wordlist_url.ends_with("/"), | ||
"URL should end with branch name in github without trailing /" | ||
); |
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.
This is fine, but please use the proper error handling instead of just asserting. You can see an example a little below in the code or right here:
let error = cmd.error(
clap::ErrorKind::MissingRequiredArgument,
format!(
"The {} argument was not provided.\n\n\tEither provide it as an argument or pass it in from standard input.",
"<SEARCH_TERM>".green()
)
);
clap::Error::exit(&error);
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.
I should also note that the repository doesn't necessarily have to be on GitHub so the error message should be something like
The provided wordlist URL must not end with a trailing '/'
@@ -224,7 +227,7 @@ fn run_app() -> std::result::Result<(), Error> { | |||
/// | |||
/// * `lang` - A locale code string to define the word list file to fetch. |
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.
Please update the comment string here with the new parameter.
); | ||
|
||
let url = format!("{}/{}", wordlist_url, &lang); | ||
println!("Accessing URL: {}", url); |
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.
This extra print is not required as it adds extra clutter and doesn't give any new information to the user since they know the URL they added.