client9 / misspell

Correct commonly misspelled English words in source files
MIT License
1.35k stars 114 forks source link

Please document basic usage #156

Open GaussianZero opened 5 years ago

GaussianZero commented 5 years ago

I can't get the basic hello world example to work, maybe I'm just being dense? Can you please document how to use this library for the simple use case of correcting a word that is misspelled?


import (
  "fmt"
  "github.com/client9/misspell"
)

func main() {
  fmt.Println("hello")

  r := misspell.New()

  result, diffs := r.Replace("whlie")
  fmt.Println(result)
  fmt.Println(diffs)
  for _, d := range diffs {
    fmt.Println(d)
  }
}

Results:

hello
whlie
[]
GaussianZero commented 5 years ago

I would expect this to correct "whlie" -> "while"

GaussianZero commented 5 years ago

Just realized that the rule of "whlie" -> "while" is not in this library, so perhaps this is "working as intended"? The above code works with "langauge" -> "language"

This seems like a bit of a miss from this library (i.e. shouldn't mispellings one or two edit distance away be picked up as misspellings?) I can do this on my own of course, but I'd prefer this library do it for me...