Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorelosorio/spellingcorrector
Spelling corrector for Spanish language
https://github.com/jorelosorio/spellingcorrector
containers docker go http spelling-correction
Last synced: 14 days ago
JSON representation
Spelling corrector for Spanish language
- Host: GitHub
- URL: https://github.com/jorelosorio/spellingcorrector
- Owner: jorelosorio
- License: gpl-3.0
- Created: 2022-03-14T16:38:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-23T10:33:20.000Z (over 2 years ago)
- Last Synced: 2024-07-31T20:52:33.618Z (3 months ago)
- Topics: containers, docker, go, http, spelling-correction
- Language: Go
- Homepage:
- Size: 389 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - spelling-corrector - A spelling corrector for the Spanish language or create your own. (Natural Language Processing / Morphological Analyzers)
- zero-alloc-awesome-go - spelling-corrector - A spelling corrector for the Spanish language or create your own. (Natural Language Processing / Morphological Analyzers)
- awesome-go-extra - spellingcorrector - 03-14T16:38:32Z|2022-03-23T10:33:20Z| (Bot Building / Morphological Analyzers)
README
# Spelling Corrector
[![Tests](https://github.com/jorelosorio/spellingcorrector/actions/workflows/tests.yml/badge.svg)](https://github.com/jorelosorio/spellingcorrector/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/jorelosorio/spellingcorrector/badge.svg?branch=main)](https://coveralls.io/github/jorelosorio/spellingcorrector?branch=main)
[![Go Reference](https://pkg.go.dev/badge/github.com/jorelosorio/spellingcorrector.svg)](https://pkg.go.dev/github.com/jorelosorio/spellingcorrector)
[![Go Report Card](https://goreportcard.com/badge/github.com/jorelosorio/spellingcorrector)](https://goreportcard.com/report/github.com/jorelosorio/spellingcorrector)A spelling corrector for the Spanish language or create your own.
The solution for this project was based on the proposal made on the following website: http://norvig.com/spell-correct.html and some ideas from https://cxwangyi.wordpress.com/2012/02/15/peter-norvigs-spelling-corrector-in-go/ as well.
> The built-in data was trained using the `Spanish` language.
## Try it
Use it now with a Docker instance. It will open the `8080` port to access the service.
docker pull jorelosorio/spellingcorrector:latest
docker run --name spellingcorrector -d -p 8080:80 -t jorelosorio/spellingcorrector:latest
Try it using the following example:
http://localhost:8080/spelling?word=espanol
## Tools
- GoLang `1.17.x`
- Docker
- Visual Studio Code `Optional!`
> It requires a `Remote - Containers` extension. for more information please refers to: https://code.visualstudio.com/docs/remote/containers#_getting-started## Development
This project contains a `Dockerfile` file with all required dependencies to run it using `Visual Studio Code` + `Remote - Containers` extension.
However, if you want to make it run locally in your development machine, please follow the instructions below.### Install Go
Install it from https://go.dev/dl/
### Build the `Example/Service`
> Make sure the port `80` is currently free. **Optionally could be changed in the code!**
go build -o ./bin/ ./examples/service.go
Then run the service
./bin/service ./dictionaries/es.dic
### Example of correction
Simple usage example of the `Corrector` function.
```go
package mainimport (
"fmt"sc "github.com/jorelosorio/spellingcorrector"
)func main() {
spelling, _ := sc.NewSpelling("{YOUR_PATH_TO_DICTIONARY}")
correctedWord := spelling.Correction("espanol")
fmt.Println(correctedWord)
}
```> `NewSpelling` functions returns (`Spelling`, `error`), make sure to handle errors when creating a new object.
### Training
Most of the training was made using free versions of books in `Spanish`. However, if you like to train for a new language you can use the following functions
```go
package mainimport (
sc "github.com/jorelosorio/spellingcorrector"
)func main() {
dic, _ := sc.NewDictionary("{YOUR_PATH_TO_DICTIONARY}", sc.ESAlphabet) // Or ENAlphabet
dic.TrainFromTextFile("{YOUR_INPUT_TEXT}")
}
```> Call `TrainFromTextFile` function as many times you wish with different inputs.
> `NewDictionary` functions returns (`Dictionary`, `error`), make sure to handle errors when creating a new dictionary.
### Build Docker
To build the docker image use `.dockers/Dockerfile.deploy` and the command
docker build -f Dockerfile.deploy -t jorelosorio/spellingcorrector:latest .
To run the docker image
docker run --name spellingcorrector -d -p 8080:80 -t jorelosorio/spellingcorrector:latest
Test the `spelling corrector` from the docker image
http://localhost:8080/spelling?word=espanol