11# Suggest
22
3- Library for Top-k Approximate String Matching.
3+ Library for Top-k Approximate String Matching, autocomplete and spell checking .
44
5+ [ ![ Build Status] ( https://travis-ci.com/alldroll/suggest.svg?branch=master )] ( https://travis-ci.com/alldroll/suggest )
56[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/alldroll/suggest )] ( https://goreportcard.com/report/github.com/alldroll/suggest )
67[ ![ GoDoc] ( https://godoc.org/github.com/alldroll/suggest?status.svg )] ( https://godoc.org/github.com/alldroll/suggest )
78
@@ -15,16 +16,17 @@ The library was mostly inspired by
1516
1617## Purpose
1718
18- Let's imagine you have a website, for instance a pharmacy website.
19+ Let's imagine you have a website, for instance, a pharmacy website.
1920There could be a lot of dictionaries, such as a list of medical drugs,
2021a list of cities (countries), where you can deliver your goods and so on.
21- Some of these dictionaries could be a pretty large, and it might be a
22+ Some of these dictionaries could be pretty large, and it might be a
2223tedious for a customer to choose the correct option from the dictionary.
2324Having the possibility of ` Top-k approximate string search ` in a dictionary
24- is a significant in these cases.
25+ is significant in these cases.
2526
26- This library provides API and the simple ` http service ` for such purposes .
27+ Also, the library provides spell checking functionality, that allows you to predict the next word .
2728
29+ The library provides API and the simple ` HTTP service ` for such purposes.
2830
2931## Demo
3032
@@ -55,8 +57,9 @@ of choosing a similarity, type of metric and topK.
5557## Usage
5658
5759``` go
58- // The dictionary, on which we expect fuzzy search
59- dictionary := dictionary.NewInMemoryDictionary ([]string {
60+ // we create InMemoryDictionary. Here we can use anything we want,
61+ // for example SqlDictionary, CDBDictionary and so on
62+ dict := dictionary.NewInMemoryDictionary ([]string {
6063 " Nissan March" ,
6164 " Nissan Juke" ,
6265 " Nissan Maxima" ,
@@ -67,10 +70,7 @@ dictionary := dictionary.NewInMemoryDictionary([]string{
6770 " Toyota Corona" ,
6871})
6972
70- // create suggest service
71- service := suggest.NewService ()
72-
73- // here we describe our index configuration
73+ // describe index configuration
7474indexDescription := suggest.IndexDescription {
7575 Name : " cars" , // name of the dictionary
7676 NGramSize : 3 , // size of the nGram
@@ -79,15 +79,17 @@ indexDescription := suggest.IndexDescription{
7979 Alphabet : []string {" english" , " $" }, // alphabet of allowed chars (other chars will be replaced with pad symbol)
8080}
8181
82- // create runtime search index builder (because we don't have indexed data)
83- builder , err := suggest.NewRAMBuilder (dictionary , indexDescription)
82+ // create runtime search index builder
83+ builder , err := suggest.NewRAMBuilder (dict , indexDescription)
8484
8585if err != nil {
8686 log.Fatalf (" Unexpected error: %v " , err)
8787}
8888
89- // asking our service for adding a new search index with the given configuration
90- if err := service.AddIndex (indexDescription.Name , dictionary, builder); err != nil {
89+ service := suggest.NewService ()
90+
91+ // add a new search index with the given configuration
92+ if err := service.AddIndex (indexDescription.Name , dict, builder); err != nil {
9193 log.Fatalf (" Unexpected error: %v " , err)
9294}
9395
@@ -116,16 +118,32 @@ fmt.Println(values)
116118
117119## Suggest eval
118120
119- Eval command is a command line tool for approximate string search.
121+ Eval command is a command- line tool for approximate string search.
120122
121123## Suggest indexer
122124
123125Indexer command builds a search index with the given [ configuration] ( ##index-description-format ) .
124- Generated data is required by ` DISC ` implementation of a index driver.
126+ Generated data is required by ` DISC ` implementation of an index driver.
125127
126128## Suggest service-run
127129
128- Runs a http web server with suggest methods.
130+ Runs HTTP webserver with suggest methods.
131+
132+ ## Language model ngram-count
133+
134+ Creates Google n-grams format
135+
136+ ## Language model build-lm
137+
138+ Builds a binary representation of a stupid-backoff language model and writes it to disk
139+
140+ ## Language model eval
141+
142+ Eval command is a cli for lm scoring
143+
144+ ## Spellchecker
145+
146+ Cli for spell checking
129147
130148### REST API
131149
@@ -221,9 +239,3 @@ Returns a list of managed dictionaries
221239
222240 * **Code:** 500 SERVER ERROR <br />
223241 **Content:** `description`
224-
225- ## TODO
226-
227- * Autocomplete (to improve initial prototype)
228- * NGram language model
229- * Spellchecker
0 commit comments