func getCharFilters(charFilterNames []string, cache *registry.Cache) ([]analysis.CharFilter, error) { charFilters := make([]analysis.CharFilter, len(charFilterNames)) for i, charFilterName := range charFilterNames { charFilter, err := cache.CharFilterNamed(charFilterName) if err != nil { return nil, err } charFilters[i] = charFilter } return charFilters, nil }
func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) { zFilter, err := cache.CharFilterNamed(zero_width_non_joiner.Name) if err != nil { return nil, err } unicodeTokenizer, err := cache.TokenizerNamed(unicode.Name) if err != nil { return nil, err } normArFilter, err := cache.TokenFilterNamed(ar.NormalizeName) if err != nil { return nil, err } normFaFilter, err := cache.TokenFilterNamed(NormalizeName) if err != nil { return nil, err } toLowerFilter, err := cache.TokenFilterNamed(lower_case_filter.Name) if err != nil { return nil, err } stopFaFilter, err := cache.TokenFilterNamed(StopName) if err != nil { return nil, err } rv := analysis.Analyzer{ CharFilters: []analysis.CharFilter{ zFilter, }, Tokenizer: unicodeTokenizer, TokenFilters: []analysis.TokenFilter{ toLowerFilter, normArFilter, normFaFilter, stopFaFilter, }, } return &rv, nil }