Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions detectlang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## detect_lang token filter

A bleve token filter which passes the text of each token and passes it to the cld2 library. The library determines what it thinks the language most likely is. The ISO-639 language code replaces the token term.
A bleve token filter which passes the text of each token and passes it to the [whatlanggo](https://github.com/abadojack/whatlanggo) library. The library determines what it thinks the language most likely is. The ISO-639 language code replaces the token term.

## detect_lang analyzer

Expand All @@ -12,4 +12,4 @@ When you configure a field to use this analyzer, the effect will be to index a s

### Dependency

This language uses a [Go wrapper](https://github.com/blevesearch/cld2) around [CLD2](https://github.com/CLD2Owners/cld2). The wrapper includes the C++ source directly so previous complications around static vs dynamic linking have gone away.
This language uses a [whatlanggo](https://github.com/abadojack/whatlanggo).
4 changes: 2 additions & 2 deletions detectlang/detect_lang_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/blevesearch/bleve/analysis"
"github.com/blevesearch/bleve/registry"

"github.com/blevesearch/cld2"
"github.com/abadojack/whatlanggo"
)

const FilterName = "detect_lang"
Expand All @@ -30,7 +30,7 @@ func (f *DetectLangFilter) Filter(input analysis.TokenStream) analysis.TokenStre

offset := 0
for _, token := range input {
token.Term = []byte(cld2.Detect(string(token.Term)))
token.Term = []byte(whatlanggo.Detect(string(token.Term)).Lang.Iso6391())
token.Start = offset
token.End = token.Start + len(token.Term)
token.Type = analysis.AlphaNumeric
Expand Down