Go-aspell - GNU Aspell spell checking library bindings for golang

Related tags

Network go-aspell
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.

You might also like...
 A Crypto-Secure, Production-Grade Reliable-UDP Library for golang with FEC
A Crypto-Secure, Production-Grade Reliable-UDP Library for golang with FEC

Introduction kcp-go is a Production-Grade Reliable-UDP library for golang. This library intents to provide a smooth, resilient, ordered, error-checked

Simple mDNS client/server library in Golang

mdns Simple mDNS client/server library in Golang. mDNS or Multicast DNS can be used to discover services on the local network without the use of an au

Golang library for Radius

goradius Description goradius package implements basic Radius client capabilities, allowing Go code to authenticate against a Radius server. It is bas

Simple, fast and scalable golang rpc library for high load

gorpc Simple, fast and scalable golang RPC library for high load and microservices. Gorpc provides the following features useful for highly loaded pro

Golang connection multiplexing library

Yamux Yamux (Yet another Multiplexer) is a multiplexing library for Golang. It relies on an underlying connection to provide reliability and ordering,

Go/Golang client library to interact with the Stein API

go-stein This Go / Golang client helps you interact with the Stein API. Stein is a suite of programs to help you turn any Google Sheet to a database.

A golang library about socks5, supports all socks5 commands. That Provides server and client and easy to use. Compatible with socks4 and socks4a.

socks5 This is a Golang implementation of the Socks5 protocol library. To see in this SOCKS Protocol Version 5. This library is also compatible with S

zMemif is a native golang based library for memif to interworking with dpdk.

zMemif zMemif is a native golang based library for memif to interworking with dpdk. it can simply provide 20Mpps recv and 10Mpps xmit capability. The

Ping library for Golang with multi-host support

pingo Fast and lightweight ping library for Golang with multi-host support. Features ICMP sockets: UDP port 0 means "let the kernel pick a free number

Comments
  • 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
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 3 Sep 26, 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 1.4k Dec 24, 2022
A rate limiter for Golang, with ETCD data bindings

Go Rate limiter This package allows us to have a distributed rate limiter, using Redis as a central counter. The limits that are set are only "soft" l

Nadir Hamid 0 Dec 9, 2021
Go bindings for D-Bus

Documentation Look at the API on GoPkgDoc. Installation goinstall github.com/norisatir/go-dbus Usage Methods Methods is obtained with meth, err := co

nori satir 18 Oct 20, 2019
Go bindings for libsndfile

gosndfile is a binding for libsndfile. It is distributed under the same terms (your choice of LGPL 2.1 or 3). If you install libsndfile outside of you

Matt Kane 42 Sep 5, 2022
A library for the MIGP (Might I Get Pwned) protocolA library for the MIGP (Might I Get Pwned) protocol

MIGP library This contains a library for the MIGP (Might I Get Pwned) protocol. MIGP can be used to build privacy-preserving compromised credential ch

Cloudflare 23 Dec 3, 2022
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.1.1 and V5 in golang

中文文档 Gmqtt News: MQTT V5 is now supported. But due to those new features in v5, there area lots of breaking changes. If you have any migration problem

null 817 Jan 5, 2023
An SNMP library written in GoLang.

gosnmp GoSNMP is an SNMP client library fully written in Go. It provides Get, GetNext, GetBulk, Walk, BulkWalk, Set and Traps. It supports IPv4 and IP

Go SNMP 929 Jan 7, 2023