clipperhouse/uax29
소개
A tokenizer based on Unicode text segmentation (UAX #29), for Go. Split graphemes, words, sentences.
AI 및 머신러닝측정된 스타 증가
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +3
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalThis package tokenizes (splits) words, sentences and graphemes, based on Unicode text segmentation (UAX #29), for Unicode 17. Details and usage are in the respective packages:
Why tokenize?
Any time our code operates on individual words, we are tokenizing. Often, we do it ad hoc, such as splitting on spaces, which gives inconsistent results. The Unicode standard is better: it is multi-lingual, and handles punctuation, special characters, etc.
Uses
The uax29 module has 4 tokenizers. In decreasing granularity: sentences → phrases → words → graphemes. Words and graphemes are the most common uses.
You might use words for inverted indexes, full-text search, TF-IDF, BM25, embeddings, etc.
If you're doing embeddings, the definition of “meaningful unit” will depend on your application. You might choose sentences, phrases, words, or a combination.
Conformance
We use the official Unicode test suites. Status:
Quick start
go get "github.com/clipperhouse/uax29/v2/words"
import "github.com/clipperhouse/uax29/v2/words"
text := "Hello, 世界. Nice dog! 👍🐶"
tokens := words.FromString(text)
for tokens.Next() { // Next() returns true until end of data
fmt.Println(tokens.Value()) // Do something with the current token
}
See also
jargon, a text pipelines package for CLI and Go, which consumes this package.
Prior art
Other language implementations
C# (also by me)
관련 프로젝트 살펴보기
불러오는 중…