A CLI spelling corrector for when you're unsure

Overview

DidYouMean

DidYouMean (or dym) is a command-line spelling corrector written in rust utilizing a simplified version of Damerau-Levenshtein distance. DidYouMean is for those moments when you know what a word sounds like, but you're not quite sure how it's spelled.

Installation

Arch Linux (and derivatives)

DidYouMean is available on the AUR as three different packages:

  • didyoumean: Last stable release, built from source (Thank you orhun!).
  • didyoumean-git: Last git commit, built from source. This is the most up to date, but the least stable.
  • didyoumean-bin: Last stable release, distributed as a binary. This is only available for x86_64 at the moment.

You can install it using any AUR helper. Using paru, the command would be as follows:

paru -S <package choice from above>

Homebrew (macOS)

Homebrew is a package manager for macOS. Currently, I have only packaged an x86_64 binary. The command to install it is as follows:

brew tap hisbaan/tap
brew install didyoumean

NixOS

evanjs very kindly packaged didyoumean for NixOS. The command to install is as follows:

nix-env install -iA nixpkgs.didyoumean

Cargo

Run the following command to build dym from source and install it in your home directory. Ensure that you have $CARGO_HOME/bin/ in your path.

cargo install didyoumean

Developer Installation

The build dependencies for this project are git, rust, rustc, and cargo. First, clone this repository, then run

cargo run -- <args>

where <args> are the command-line arguments you would pass the DidYouMean binary. Note that this is an unoptimized build contianing debug information so it runs much, much slower.

Comments
  • Word Fail

    Word Fail

    So I saw this, fought with my package manager (cue Karen joke fighting with the manager) to get it installed, first test fails.

    So if it's not obvious I'm 12 (at hart <-- see what I did there?) I tested the with the word "fert." The expectation was the top match should be fart but fart is no where to be seen...or smelt...(again see what I did there? I've got a million of them I tellz ya!) Swing and a miss. Then I tried "hart", again expecting heart, swing and a miss. If it wasn't obvious "smelt" also failed to suggest smelled.

    Is there a way to improve matching? So far it's failed every test word but one.

    opened by nPHYN1T3 3
  • It would be nice if I could copy the correct word into my clipboard after selecting the number of that word

    It would be nice if I could copy the correct word into my clipboard after selecting the number of that word

    for example:

    ❯ dym tomrrow
    Did you mean?
    1. tomorrow
    2. borrow
    3. morrow
    4. orrow
    5. sorrow
    

    I want it to be like

    ❯ dym tomrrow -y
    Did you mean?
    1. tomorrow
    2. borrow
    3. morrow
    4. orrow
    5. sorrow
    
    Which word should be copied: 1
    "tomorrow" has been copied to your clipboard.
    

    -y flag stands for yanking the text to clipboard

    enhancement 
    opened by throwaway69420-69420 3
  • refactor: remove unnecessary library declaration

    refactor: remove unnecessary library declaration

    This PR fixes the following warning which is shown during cargo build:

    warning: found module declaration for lib.rs
     --> src/main.rs:3:1
      |
    3 | pub mod lib;
      | ^^^^^^^^^^^^
      |
      = note: lib.rs is the root of this crate's library target
      = help: to refer to it from other targets, use the library's name as the path
      = note: `#[warn(special_module_name)]` on by default
    
    warning: `didyoumean` (bin "dym") generated 1 warning
    
    opened by orhun 1
  • Consider a different exit code and message when the input is spelled correctly

    Consider a different exit code and message when the input is spelled correctly

    I would really appreciate a different exit code when my input word is spelled correctly vs when it is not.

    Additionally, I would like to see a different message noting that my input was spelled correctly. Sometimes (when I forget to specify -v), I have to take a moment to double check if the first result is different from my input word.

    $ dym supercalifragilisticexpialidocious # correct spelling
    supercalifragilisticexpialidocious is spelled correctly
    $ echo $?
    0
    
    $ dym supercalifragilisticexpialidociouX # last char typo
    Did you mean?
    1. supercalifragilisticexpialidocious
    2. supercalifragilistic
    3. superphlogistication
    4. superartificiality
    5. supercapabilities
    $ echo $?
    1
    

    Regardless, thanks for your work on dym. It is very helpful as is!

    enhancement good first issue 
    opened by adam-gaia 1
  • Incorrect encoding on some language files

    Incorrect encoding on some language files

    Some language files have encoding problems. I'm aware of the problem affecting Russian, Bosnian and possibly Estonian.

    I can probably have a closer look at some others in the coming week.

    opened by omarandlorraine 1
  • Insert words/distances in-place

    Insert words/distances in-place

    Improves performance

    Example

    Before:

    time ./target/release/dym phoanix -n 10000 > test
    
    real    0m1.459s
    user    0m1.432s
    sys     0m0.020s
    

    After:

    time ./target/release/dym phoanix -n 10000 > test
    
    real    0m0.498s
    user    0m0.485s
    sys     0m0.010s
    
    optimization 
    opened by cojuer 1
  • Fix Powershell colorization

    Fix Powershell colorization

    On Windows, Powershell handles ANSI escape codes incorrectly, but colored lets you fix that behavior. See https://github.com/mackwic/colored/issues/59

    Before:

    image

    After:

    image

    bug 
    opened by zohnannor 1
  • Add man page and shell completion generation

    Add man page and shell completion generation

    Add man pages and shell completions via a build.rs build script. This PR also refactors the clap Cli struct into its own file to improve modularity.

    closes #8 closes #9

    documentation 
    opened by hisbaan 0
  • External word lists

    External word lists

    Use wordlists external to the binary to provide support for the following languages:

    • Afrikaans
    • Arabic
    • Azerbaijani
    • Belarusian
    • Bulgarian
    • Breton
    • Bosnian
    • Catalan
    • Czech
    • Welsh
    • Danish
    • German
    • Greek
    • English
    • Spanish
    • Estonian
    • Basque
    • Faeroese
    • French
    • Frisian
    • Galician
    • Hungarian
    • Indonesian
    • Icelandic
    • Italian
    • Kazach
    • Korean
    • Latin
    • Luxembourgish
    • Lithuanian
    • Latvian
    • Malaysian
    • Norwegian
    • Dutch
    • Norwegian
    • Occitan
    • Polish
    • Romanian
    • Russian
    • Slovak
    • Slovenian
    • Albanian
    • Serbian
    • Sesotho
    • Swedish
    • Swahili
    • Tajik
    • Turkmen
    • Tagalog
    • Tswana
    • Turkish
    • Tsonga
    • Tatar
    • Ukranian
    • Venda
    • Vietnamese
    • Xhosa
    • Yiddish
    • Zulu

    A list of supported languages can be obtained using the --print-langs flag, and the language files can be updated by using the --update-langs flag. You can select the desired language by passing the -l or --lang flag followed by the two letter language code (also provided in --print-langs)

    enhancement 
    opened by hisbaan 0
  • Standard input support

    Standard input support

    Add the ability to read the search_term argument from standard input if no argument is provided. Standard input will be ignored if there is a search_term argument provided. An error message will be printed if neither standard input or a search_term argument are provided.

    enhancement 
    opened by hisbaan 0
  • Add support for copying to clipboard

    Add support for copying to clipboard

    Add support for copying to the system clipboard. This was harder than expected as you need a workaround for X11/Wayland. X11 and Wayland clear the clipboard when the process that sets it exits, so dym will now fork and keep a process around to maintain the clipboard until the value stored in the clipboard changes, at which point the child process will exit.

    resolves #1

    enhancement 
    opened by hisbaan 0
  • Hilight differences between the searched word and the resulting words (diff style)

    Hilight differences between the searched word and the resulting words (diff style)

    As the title says (with an optional flag), show the differences between the queried and resulting words. Showing removals is not recommended as that would require some sort of thinner character which I don't think would look very nice. Showing additions and substitutions should be easy enough. Showing transpositions as two insertions may be simpler? I'm not quite sure how that would work, but it should be doable.

    enhancement 
    opened by hisbaan 0
  • Child process created for clipboard terminates immediately (Hyprland)

    Child process created for clipboard terminates immediately (Hyprland)

    As the title describes, the child process created to keep the clipboard from being cleared on X11/Wayland does not terminate when the clipboard changes on sway. On Hyprland (still in early development), it terminates right away. Not that sway is using wlroots and Hyprland is using wlroots-git. This is likely an issue with the clipboard being read and thus is likely not within the scope of this project, but instead in the cli-clipboard dependency.

    bug 
    opened by hisbaan 1
Releases(v1.1.4)
Owner
Hisbaan Noorani
I’m a computer science student at the University of Toronto who is passionate about Linux and open source development
Hisbaan Noorani
Quickly build cool CLI apps in Rust.

QuiCLI Quickly build cool CLI apps in Rust. Getting started Read the Getting Started guide! Thanks This is only possible because of all the awesome li

Pascal Hertleif 538 Dec 5, 2022
A minimal CLI framework written in Rust

seahorse A minimal CLI framework written in Rust Features Easy to use No dependencies Typed flags(Bool, String, Int, Float) Documentation Here Usage T

Keisuke Toyota 223 Dec 30, 2022
CLI calculator app and library

calc Yet another CLI calculator. Inspired by the excellent https://github.com/alfredxing/calc. Installation With a Rust toolchain in place: cargo inst

Peter Goodspeed-Niklaus 34 Nov 13, 2022
Turn static CLI commands into TUIs with ease

lazycli Turn static CLI commands into TUIs with ease Demo: Usage Pick a command that spits out either a list or table of content, like ls, docker ps,

Jesse Duffield 255 Dec 20, 2022
CLI Tool for tagging and organizing files by tags.

wutag ?? ??️ CLI tool for tagging and organizing files by tags. Install If you use arch Linux and have AUR repositories set up you can use your favour

Wojciech Kępka 32 Dec 6, 2022
📜🔁🎶 A CLI which converts morse code into sound

morse2sound ?? A CLI which converts morse code to sound Big shoutout to Br1ght0ne for guiding me how to use Rust on stream

Ilya Revenko 15 Dec 4, 2022
A CLI utility to secretly copy secrets to your clipboard. 🦀

seclip ?? ?? A CLI utility to secretly copy secrets to your clipboard. ?? Table of Contents Features Installation Usage Build From Source Contribution

Mufeed VH 34 Dec 27, 2022
Punic is a remote caching CLI built for Apple's .xcframework

Punic is a remote caching CLI built for Carthage that exclusively supports Apple's .xcframeworks.

Shred Labs 26 Nov 22, 2022
CLI tool to bake your fresh and hot MD files

At least once in your Rust dev lifetime you wanted to make sure all code examples in your markdown files are up-to-date, correct and code is formated, but you couldn't make that done with already existing tools - fear not!

Patryk Budzyński 39 May 8, 2021
A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies

cargo-temp A CLI tool that allow you to create a new rust project in a temporary directory with already installed dependencies. Install Requires Rust

Yohan Boogaert 61 Oct 31, 2022
qsv - Performant CLI tool to query CSVs through SQL

qsv Performant CLI tool to query CSVs through SQL Installation After cloning the repository, you can install a binary locally using cargo install --pa

Dermot Haughey 3 Oct 28, 2021
CLI search and replace | Space Age seD

SAD! Space Age seD What does it do? Basically sad is a Batch File Edit tool. It will show you a really nice diff of proposed changes before you commit

i love my dog 986 Dec 29, 2022
Intuitive find & replace CLI (sed alternative)

sd - s[earch] & d[isplace] sd is an intuitive find & replace CLI. The Pitch Why use it over any existing tools? Painless regular expressions sd uses r

Gregory 4k Jan 4, 2023
CLI Web client for moedict.tw

meowdict CLI Web client for moedict.tw Usage Console Mode

Mag Mell 18 May 12, 2022
😎 A CLI tool for fetching data and displaying it nicely

?? A CLI tool for fetching data and displaying it nicely. (The neofetch for remote data fetching)

Milo 6 Aug 24, 2022
kwctl is the go-to CLI tool for Kubewarden users.

kwctl kwctl is the go-to CLI tool for Kubewarden users. Think of it as the docker CLI tool if you were working with containers. How does kwctl help me

Kubewarden 45 Dec 21, 2022
⚗️ Superfast CLI interface for the conventional commits commit format

resin ⚗️ Superfast CLI interface for the conventional commits commit format ❓ What is resin? resin is a CLI (command-line interface) tool that makes i

Matt Gleich 23 Oct 12, 2022
A CLI utility installed as "ansi" to quickly get ANSI escape sequences. Supports the most basic ones, like colors and styles as bold or italic.

'ansi' - a CLI utility to quickly get ANSI escape codes This Rust project called ansi-escape-sequences-cli provides an executable called ansi which ca

Philipp Schuster 5 Jul 28, 2022
A simple CLI pomodoro timer written in Rust.

Pomodoro A simple CLI pomodoro timer written in Rust. Based on the Pomodoro Technique. Works on any platform that supports desktop notifications. Exam

null 6 Nov 26, 2021