Documentation ¶
Index ¶
- type NGram
- func (gram *NGram) AddText(value string) error
- func (gram *NGram) ListGrams() (grams []string)
- func (gram *NGram) ListTexts() (texts []string)
- func (gram *NGram) ListWords() (words []string)
- func (gram *NGram) Search(value string) string
- func (gram *NGram) SearchLimit(value string, limit float32) (result []NGramSearchResult)
- func (gram *NGram) SearchLimitSQL(tableNameTexts string, pkColumnNameTexts string, tableNameWords string, ...) string
- type NGramSearchResult
- type Text
- type Word
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NGram ¶
type NGram struct { Texts []*Text // Тексты // contains filtered or unexported fields }
Индексатор
func (*NGram) SearchLimit ¶
func (gram *NGram) SearchLimit(value string, limit float32) (result []NGramSearchResult)
Поиск с установленным порогом совпадения
func (*NGram) SearchLimitSQL ¶
func (gram *NGram) SearchLimitSQL( tableNameTexts string, pkColumnNameTexts string, tableNameWords string, pkColumnNameWords string, tableNameTextsAndWords string, fkColumnNameWordsForTableWords string, fkColumnNameTextsForTableTexts string, tableNameNGrams string, pkColumnNameNGrams string, tableNameWordsAndNGrams string, columnNameNGram string, fkColumnNameWords2ForTableWords string, fkColumnNameNGramsForTableNGrams string, ) string
Генерирование SQL-запроса для выполнения в БД Для выполнения данного запроса потребуется примерно следующая структура таблиц:
CREATE TABLE texts (id BIGINT PRIMARY KEY, txt TEXT); CREATE TABLE words (id BIGINT PRIMARY KEY, word VARCHAR (150)); CREATE TABLE ngram (id BIGINT PRIMARY KEY, ngram VARCHAR (20)); CREATE TABLE word_and_text (id_text BIGINT REFERENCES texts (id), id_word BIGINT REFERENCES words (id)); CREATE TABLE ngram_and_word (id_word BIGINT REFERENCES words (id), id_ngram BIGINT REFERENCES ngram (id));
Соответственно таблицы и поля могут быть переименованы и дополнены в соответствии с нужными требованиями
type NGramSearchResult ¶
type NGramSearchResult struct { Value string // Результирующая строка Coeff float32 // Коэффициент соответствия }
Результат поиска
type Text ¶
type Text struct { Value string // Текст (значение) Words []*Word // Слова Size int // Размерность n-грамм }
Обработка текста
Click to show internal directories.
Click to hide internal directories.