A comprehensive text correction package for Go that combines spell checking with punctuation and grammar correction.
- Spell Checking: Uses fuzzy matching to suggest corrections for misspelled words
- Punctuation Correction: Fixes spacing around punctuation marks
- Capitalization: Properly capitalizes sentences and after periods
- Article Correction: Fixes "a" vs "an" usage
- Sentence Structure: Improves overall text flow and readability
go get github.com/sajari/fuzzypackage main
import (
"fmt"
"your-module/typograph"
)
func main() {
// Create a new typograph instance
tg := typograph.New()
// Add words to the dictionary
words := []string{"hello", "world", "example", "text"}
tg.AddWords(words)
// Correct text
text := "hello world this is an test"
corrected := tg.CorrectText(text)
fmt.Println(corrected) // "Hello world this is a test."
}// Check if a word is correct
isCorrect := tg.IsCorrect("helo") // false
// Get suggestions for a word
suggestions := tg.GetSuggestions("helo", 3) // ["hello"]
// Correct comprehensive text
text := "i hope this email reaches you in good health, after careful consideration,i have decided to take the difficult decision of resigning from my post.to be honest this was not an easy decision."
corrected := tg.CorrectText(text)
// Result: "I hope this email reaches you in good health, after careful consideration have decided to take the difficult decision of resigning from my post. To be honest this was not an easy decision."Creates a new Typograph instance with default settings.
Adds words to the spellchecker dictionary.
Performs comprehensive text correction including spelling, punctuation, and grammar.
Checks if a word is spelled correctly.
Returns spelling suggestions for a word.
- github.com/sajari/fuzzy - For spell checking functionality
MIT