GNU Aspell spell checking library bindings for Go (golang)

Overview

Aspell library bindings for Go

GNU Aspell is a spell checking tool written in C/C++. This package provides simplified Aspell bindings for Go. It uses UTF-8 by default and encapsulates some Aspell internals.

Getting started

First make sure aspell library and headers are installed on your system. On Debian/Ubuntu you could install it this way:

sudo apt-get install aspell libaspell-dev

It you need some more dictionaries you can install them like this:

sudo apt-get install aspell-ua aspell-se

Then you can install the package using the Go tool:

go get github.com/trustmaster/go-aspell

Usage

Here is a simple spell checker program using the aspell package:

package main

import (
	"github.com/trustmaster/go-aspell"
	"fmt"
	"os"
	"strings"
)

func main() {
	// Get a word from cmd line arguments
	if len(os.Args) != 2 {
		fmt.Print("Usage: aspell_example word\n")
		return
	}
	word := os.Args[1]

	// Initialize the speller
	speller, err := aspell.NewSpeller(map[string]string{
		"lang": "en_US",
	})
	if err != nil {
		fmt.Errorf("Error: %s", err.Error())
		return
	}
	defer speller.Delete()

	// Check and suggest
	if speller.Check(word) {
		fmt.Print("OK\n")
	} else {
		fmt.Printf("Incorrect word, suggestions: %s\n", strings.Join(speller.Suggest(word), ", "))
	}
}

For more information see aspell_test.go file and use the godoc tool:

godoc github.com/trustmaster/go-aspell

License

Copyright (c) 2012, Vladimir Sibirov All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Issues
  • use a for..break because we can't depend on count

    use a for..break because we can't depend on count

    As commented in http://aspell.net/sf-issue-files/11b76e92/632d/test.c aspell_dict_info_list_size(dlist) will allways return 0 for some reason. Execute aspell_dict_info_enumeration_next(dels) until it returns nil.

    This will resolve #2.

    opened by subutux 1
  • Dicts() doesn't seem to work

    Dicts() doesn't seem to work

    Hi,

    bit of a long shot given that this hasn't been updated for ages...the Dicts() call does not seem to return any data. I know it is configured correctly (i.e. I can check spellings) but I'd like to check if a dictionary is installed. I figured I would be able to get a list of Dictionaries and then check if my desired dictionary is in the list.

    Furthermore, as there are no exported functions on the Dict data structure it's not very useful.

    I see that this area is commented out in the tests - is this because it doesn't work? Any idea how to fix?

    Thanks Alan

    opened by gawth 1
  • crash of go program with no dictionary installed

    crash of go program with no dictionary installed

    was getting a crash as listed below trying to use this and i traced it down to fact there was no dictionary installed the code around where it crashed should be speller, err = aspell.NewSpeller(map[string]string{ "lang": "en_US", }) if err != nil { fmt.Errorf("Error: %s", err.Error()) *fakeWords = false } defer speller.Delete()

    so even with the error check its doing the below

    *** Error in `./markov': double free or corruption (fasttop): 0x0000000002a74720 *** ======= Backtrace: ========= /usr/lib/libc.so.6(+0x71bad)[0x7ff68aa0abad] /usr/lib/libc.so.6(+0x770fe)[0x7ff68aa100fe] /usr/lib/libc.so.6(+0x778db)[0x7ff68aa108db] /usr/lib/libaspell.so.15(_ZN7acommon12CanHaveErrorD1Ev+0x20)[0x7ff68afa5a20] /usr/lib/libaspell.so.15(_ZN7acommon12CanHaveErrorD0Ev+0x9)[0x7ff68afa5a49] ./markov[0x441465] ======= Memory map: ======== 00400000-00846000 r-xp 00000000 00:30 293 /home/bret/testweb/cur/markov/markov 00a46000-00a64000 rw-p 00446000 00:30 293 /home/bret/testweb/cur/markov/markov 00a64000-00a80000 rw-p 00000000 00:00 0 02a62000-02a94000 rw-p 00000000 00:00 0 [heap] c000000000-c0000c2000 rw-p 00000000 00:00 0 c204f98000-c238680000 rw-p 00000000 00:00 0 7ff688cc1000-7ff688ef7000 rw-p 00000000 00:00 0 7ff688ef7000-7ff688ef8000 ---p 00000000 00:00 0 7ff688ef8000-7ff6896f8000 rw-p 00000000 00:00 0 [stack:16709] 7ff6896f8000-7ff6896f9000 ---p 00000000 00:00 0 7ff6896f9000-7ff689ef9000 rw-p 00000000 00:00 0 [stack:16708] 7ff689ef9000-7ff689f0f000 r-xp 00000000 00:11 242431 /usr/lib/libgcc_s.so.1 7ff689f0f000-7ff68a10e000 ---p 00016000 00:11 242431 /usr/lib/libgcc_s.so.1 7ff68a10e000-7ff68a10f000 rw-p 00015000 00:11 242431 /usr/lib/libgcc_s.so.1 7ff68a10f000-7ff68a212000 r-xp 00000000 00:11 241783 /usr/lib/libm-2.21.so 7ff68a212000-7ff68a411000 ---p 00103000 00:11 241783 /usr/lib/libm-2.21.so 7ff68a411000-7ff68a412000 r--p 00102000 00:11 241783 /usr/lib/libm-2.21.so 7ff68a412000-7ff68a413000 rw-p 00103000 00:11 241783 /usr/lib/libm-2.21.so 7ff68a413000-7ff68a585000 r-xp 00000000 00:11 242438 /usr/lib/libstdc++.so.6.0.21 7ff68a585000-7ff68a785000 ---p 00172000 00:11 242438 /usr/lib/libstdc++.so.6.0.21 7ff68a785000-7ff68a78f000 r--p 00172000 00:11 242438 /usr/lib/libstdc++.so.6.0.21 7ff68a78f000-7ff68a791000 rw-p 0017c000 00:11 242438 /usr/lib/libstdc++.so.6.0.21 7ff68a791000-7ff68a795000 rw-p 00000000 00:00 0 7ff68a795000-7ff68a798000 r-xp 00000000 00:11 241766 /usr/lib/libdl-2.21.so 7ff68a798000-7ff68a997000 ---p 00003000 00:11 241766 /usr/lib/libdl-2.21.so 7ff68a997000-7ff68a998000 r--p 00002000 00:11 241766 /usr/lib/libdl-2.21.so 7ff68a998000-7ff68a999000 rw-p 00003000 00:11 241766 /usr/lib/libdl-2.21.so 7ff68a999000-7ff68ab32000 r-xp 00000000 00:11 241737 /usr/lib/libc-2.21.so 7ff68ab32000-7ff68ad31000 ---p 00199000 00:11 241737 /usr/lib/libc-2.21.so 7ff68ad31000-7ff68ad35000 r--p 00198000 00:11 241737 /usr/lib/libc-2.21.so 7ff68ad35000-7ff68ad37000 rw-p 0019c000 00:11 241737 /usr/lib/libc-2.21.so 7ff68ad37000-7ff68ad3b000 rw-p 00000000 00:00 0 7ff68ad3b000-7ff68ad53000 r-xp 00000000 00:11 241757 /usr/lib/libpthread-2.21.so 7ff68ad53000-7ff68af52000 ---p 00018000 00:11 241757 /usr/lib/libpthread-2.21.so 7ff68af52000-7ff68af53000 r--p 00017000 00:11 241757 /usr/lib/libpthread-2.21.so 7ff68af53000-7ff68af54000 rw-p 00018000 00:11 241757 /usr/lib/libpthread-2.21.so 7ff68af54000-7ff68af58000 rw-p 00000000 00:00 0 7ff68af58000-7ff68b011000 r-xp 00000000 00:11 71956 /usr/lib/libaspell.so.15.1.5 7ff68b011000-7ff68b211000 ---p 000b9000 00:11 71956 /usr/lib/libaspell.so.15.1.5 7ff68b211000-7ff68b217000 r--p 000b9000 00:11 71956 /usr/lib/libaspell.so.15.1.5 7ff68b217000-7ff68b219000 rw-p 000bf000 00:11 71956 /usr/lib/libaspell.so.15.1.5 7ff68b219000-7ff68b220000 rw-p 00000000 00:00 0 7ff68b220000-7ff68b242000 r-xp 00000000 00:11 241779 /usr/lib/ld-2.21.so 7ff68b24c000-7ff68b417000 rw-p 00000000 00:00 0 7ff68b43e000-7ff68b441000 rw-p 00000000 00:00 0 7ff68b441000-7ff68b442000 r--p 00021000 00:11 241779 /usr/lib/ld-2.21.so 7ff68b442000-7ff68b443000 rw-p 00022000 00:11 241779 /usr/lib/ld-2.21.so 7ff68b443000-7ff68b444000 rw-p 00000000 00:00 0 7ffe579f2000-7ffe57a13000 rw-p 00000000 00:00 0 [stack] 7ffe57afc000-7ffe57afe000 r--p 00000000 00:00 0 [vvar] 7ffe57afe000-7ffe57b00000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] SIGABRT: abort PC=0x7ff68a9cc528 signal arrived during cgo execution

    goroutine 1 [syscall, locked to thread]: runtime.cgocall_errno(0x4022b0, 0xc20807fbe8, 0xc200000000) /usr/lib/go/src/runtime/cgocall.go:130 +0xf5 fp=0xc20807fbc8 sp=0xc20807fba0 github.com/trustmaster/go-aspell._Cfunc_delete_aspell_can_have_error(0x2a745e0) /home/bret/golang/gopath/src/github.com/trustmaster/go-aspell/:130 +0x45 fp=0xc20807fbe8 sp=0xc20807fbc8 github.com/trustmaster/go-aspell.NewSpeller(0xc238078900, 0x0, 0x0, 0x0, 0x0) /home/bret/golang/gopath/src/github.com/trustmaster/go-aspell/aspell.go:77 +0x572 fp=0xc20807fd78 sp=0xc20807fbe8 main.main() /home/bret/testweb/cur/markov/markov.go:218 +0x882 fp=0xc20807ff98 sp=0xc20807fd78 runtime.main() /usr/lib/go/src/runtime/proc.go:63 +0xf3 fp=0xc20807ffe0 sp=0xc20807ff98 runtime.goexit() /usr/lib/go/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc20807ffe8 sp=0xc20807ffe0

    goroutine 17 [syscall, locked to thread]: runtime.goexit() /usr/lib/go/src/runtime/asm_amd64.s:2232 +0x1

    rax 0x0 rbx 0x55 rcx 0x7ff68a9cc528 rdx 0x6 rdi 0x4143 rsi 0x4143 rbp 0x7ffe57a108f0 rsp 0x7ffe57a10558 r8 0x7ff68aaf6140 r9 0x0 r10 0x8 r11 0x202 r12 0x55 r13 0x7ffe57a10708 r14 0x7ffe57a10708 r15 0x2 rip 0x7ff68a9cc528 rflags 0x202 cs 0x33 fs 0x0 gs 0x0

    opened by brettowe 1
Owner
Vladimir Sibirov
Tech lead, teamwork amplifier, flow-based programming ambassador. Pushing open source code since 2002.
Vladimir Sibirov
Selected Machine Learning algorithms for natural language processing and semantic analysis in Golang

Natural Language Processing Implementations of selected machine learning algorithms for natural language processing in golang. The primary focus for t

James Bowman 366 Jun 15, 2022
GNU Aspell spell checking library bindings for Go (golang)

Aspell library bindings for Go GNU Aspell is a spell checking tool written in C/C++. This package provides simplified Aspell bindings for Go. It uses

Vladimir Sibirov 44 Nov 29, 2021
Golang (Go) bindings for GNU's gettext (http://www.gnu.org/software/gettext/)

gosexy/gettext Go bindings for GNU gettext, an internationalization and localization library for writing multilingual systems. Requeriments GNU gettex

Go toolbelt 61 Jun 6, 2022
Readline is a pure go(golang) implementation for GNU-Readline kind library

A powerful readline library in Linux macOS Windows Solaris Guide Demo Shortcut Repos using readline Feedback If you have any questions, please submit

chzyer 1.8k Jun 17, 2022
Go file operations library chasing GNU APIs.

flop flop aims to make copying files easier in Go, and is modeled after GNU cp. Most administrators and engineers interact with GNU utilities every da

The Home Depot 31 Feb 10, 2022
GNU GSL Statistics library (v1.15, GPLv3) implemented in Go

Statistics Pure Go implementation of the GSL Statistics library. For the API overview see Godoc. Why create this repository when there is also "github

grd 77 Nov 23, 2021
manage your mocks / run mockgen more quickly / mocks up-to-date checking

gomockhandler If you find any bugs or have feature requests, please feel free to create an issue. gomockhandler is handler of golang/mock, as the name

Kensei Nakada 66 Jun 14, 2022
Generate QR-Codes for checking into events using the official Corona Warn App.

Corona Warn App QR-Code Generator Generate QR-Codes for checking into events using the official Corona Warn App. Table of Contents Introduction Instal

Lukas Malkmus 7 Nov 6, 2021
Simple JSON type checking.

go-map-schema Table of Contents Overview Use Case Do I Really Need This? Examples Usage Full Code Output Universal Type Names Overview go-map-schema i

Jessie 86 Dec 15, 2021
Key-Checker - Go scripts for checking API key / access token validity

Key-Checker Go scripts for checking API key / access token validity Update V1.0.0 ?? Added 37 checkers! Screenshoot ?? How to Install go get github.co

Muhammad Daffa 188 Jun 24, 2022
A Go package for checking conditions for slices and maps.

check Go package The check package of Go helps one to check various conditions for slices: []int []float64 []string []bool maps: map[string]int map[st

null 4 Feb 3, 2022
A tool for checking the accessibility of your data by IPFS peers

ipfs-check Check if you can find your content on IPFS A tool for checking the accessibility of your data by IPFS peers Documentation Build go build wi

Adin Schmahmann 16 Jun 22, 2022
gostatement is an analyzer checking for occurrence of `go` statements

gostatement gostatement is an analyzer checking for occurrence of go statements. You may want to use a custom func wrapping the statement utilizing re

Felix 0 Nov 4, 2021
Checking if some websites of interest are online

Web site status checker Checking if some websites of interest are online. A little weekend project. Technologies used Go Gin Current sites supported G

null 0 Nov 28, 2021
PinGo is a standalone and feature-rich tool for common IP-based reachability checking tasks. Ping or Trace and Observe in real-time the statistics.

pingo As a network champion from designing and implementing to troubleshooting large scale networks - I know that is usually not easy for administrato

Jerome Amon 2 May 21, 2022
A tool for checking log4shell vulnerability mitigations

log4shell-ldap A tool for checking log4shell vulnerability mitigations. Usage: Build a container image: docker build . -t log4shell Run it: docker run

Jaromir Hamala 26 Jan 25, 2022
Go implementation of a vanity attempt to generate Bitcoin private keys and subsequently checking whether the corresponding Bitcoin address has a non-zero balance.

vanity-BTC-miner Go implementation of a vanity attempt to generate Bitcoin private keys and subsequently checking whether the corresponding Bitcoin ad

Lih Ingabo 1 Jun 3, 2022
Simple IPO Checking Utility.

Simple IPO Checking Utility Usage: share-check [--version] [--help] <command> [<args>] Available commands are: check Check multiple share by p

Mahesh C. Regmi 2 Feb 14, 2022
A tool for capturing newly issued x.509 from Certificate Transparency logs & performing periodic revocation checking.

ct-logster This repository contains the tools for collecting newly issued x509 certificates from Certificate Transparency logs, as well as performing

Adam Halim 4 May 4, 2022
A simple, standalone, and lightWeight tool that can do health/status checking, written in Go.

EaseProbe EaseProbe is a simple, standalone, and lightWeight tool that can do health/status checking, written in Go. Table of Contents EaseProbe 1. Ov

MegaEase 782 Jun 24, 2022
Go (Golang) GNU gettext utilities package

Gotext GNU gettext utilities for Go. Features Implements GNU gettext support in native Go. Complete support for PO files including: Support for multil

Leonel Quinteros 342 Jun 29, 2022
Concurrent task runner, developer's routine tasks automation toolkit. Simple modern alternative to GNU Make 🧰

taskctl - concurrent task runner, developer's routine tasks automation toolkit Simple modern alternative to GNU Make. taskctl is concurrent task runne

null 192 Jun 18, 2022
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.

Description pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to

Steve Francia 1.8k Jun 29, 2022
Dependency-free replacement for GNU parallel, perfect fit for usage in an initramfs.

coshell v0.2.5 A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage. Licensed under GNU/GPL v2. How it works An sh -c

gdm85 41 May 11, 2022
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.

Description pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to

Alex Ogier 516 Jun 24, 2022
:ab: GNU gettext for Go (Imported By Kubernetes)

Go语言QQ群: 102319854, 1055927514 凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa gettext-go: GNU gettext for Go (Imported By Ku

chai2010 77 May 6, 2022
A GNU/Linux monitoring and profiling tool focused on single processes.

Uroboros is a GNU/Linux monitoring tool focused on single processes. While utilities like top, ps and htop provide great overall details, they often l

Simone Margaritelli 648 Jun 13, 2022
Interactive package manager and resource monitor designed for the GNU/Linux.

pkgtop is an interactive package manager & resource monitor tool designed for the GNU/Linux. Package management (install/upgrade/remove etc.) can be a

Orhun Parmaksız 242 Jun 15, 2022
GNU coreutils remade in Go for RosetteOS

Rosebush GNU and POSIX coreutils remade in Go for RosetteOS Build To compile the Rosebush, simply make -B This will compile all the utils one by one.

RosetteOS Linux 5 Oct 4, 2021