当前位置: 首页>>代码示例>>Golang>>正文


Golang registry.Cache类代码示例

本文整理汇总了Golang中github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/blevesearch/bleve/registry.Cache的典型用法代码示例。如果您正苦于以下问题:Golang Cache类的具体用法?Golang Cache怎么用?Golang Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExceptionsTokenizerConstructor

func ExceptionsTokenizerConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.Tokenizer, error) {
	exceptions := []string{}
	iexceptions, ok := config["exceptions"].([]interface{})
	if ok {
		for _, exception := range iexceptions {
			exception, ok := exception.(string)
			if ok {
				exceptions = append(exceptions, exception)
			}
		}
	}
	aexceptions, ok := config["exceptions"].([]string)
	if ok {
		exceptions = append(exceptions, aexceptions...)
	}
	exceptionPattern := strings.Join(exceptions, "|")
	r, err := regexp.Compile(exceptionPattern)
	if err != nil {
		return nil, fmt.Errorf("unable to build regexp tokenizer: %v", err)
	}

	remainingName, ok := config["tokenizer"].(string)
	if !ok {
		return nil, fmt.Errorf("must specify tokenizer for remaining input")
	}
	remaining, err := cache.TokenizerNamed(remainingName)
	if err != nil {
		return nil, err
	}
	return NewExceptionsTokenizer(r, remaining), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:31,代码来源:exception.go

示例2: ElisionFilterConstructor

func ElisionFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {
	articlesTokenMap, err := cache.TokenMapNamed(ArticlesName)
	if err != nil {
		return nil, fmt.Errorf("error building elision filter: %v", err)
	}
	return elision_filter.NewElisionFilter(articlesTokenMap), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:7,代码来源:elision_it.go

示例3: AnalyzerConstructor

func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
	icuTokenizer, err := cache.TokenizerNamed(icu.Name)
	if err != nil {
		return nil, err
	}
	normCkbFilter, err := cache.TokenFilterNamed(NormalizeName)
	if err != nil {
		return nil, err
	}
	toLowerFilter, err := cache.TokenFilterNamed(lower_case_filter.Name)
	if err != nil {
		return nil, err
	}
	stopCkbFilter, err := cache.TokenFilterNamed(StopName)
	if err != nil {
		return nil, err
	}
	stemmerCkbFilter, err := cache.TokenFilterNamed(StemmerName)
	if err != nil {
		return nil, err
	}
	rv := analysis.Analyzer{
		Tokenizer: icuTokenizer,
		TokenFilters: []analysis.TokenFilter{
			normCkbFilter,
			toLowerFilter,
			stopCkbFilter,
			stemmerCkbFilter,
		},
	}
	return &rv, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:32,代码来源:analyzer_ckb.go

示例4: AnalyzerConstructor

func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
	tokenizer, err := cache.TokenizerNamed(unicode.Name)
	if err != nil {
		return nil, err
	}
	elisionFilter, err := cache.TokenFilterNamed(ElisionName)
	if err != nil {
		return nil, err
	}
	toLowerFilter, err := cache.TokenFilterNamed(lower_case_filter.Name)
	if err != nil {
		return nil, err
	}
	stopFrFilter, err := cache.TokenFilterNamed(StopName)
	if err != nil {
		return nil, err
	}
	stemmerFrFilter, err := cache.TokenFilterNamed(LightStemmerName)
	if err != nil {
		return nil, err
	}
	rv := analysis.Analyzer{
		Tokenizer: tokenizer,
		TokenFilters: []analysis.TokenFilter{
			elisionFilter,
			toLowerFilter,
			stopFrFilter,
			stemmerFrFilter,
		},
	}
	return &rv, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:32,代码来源:analyzer_fr.go

示例5: DictionaryCompoundFilterConstructor

func DictionaryCompoundFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {

	minWordSize := defaultMinWordSize
	minSubWordSize := defaultMinSubWordSize
	maxSubWordSize := defaultMaxSubWordSize
	onlyLongestMatch := defaultOnlyLongestMatch

	minVal, ok := config["min_word_size"].(float64)
	if ok {
		minWordSize = int(minVal)
	}
	minSubVal, ok := config["min_subword_size"].(float64)
	if ok {
		minSubWordSize = int(minSubVal)
	}
	maxSubVal, ok := config["max_subword_size"].(float64)
	if ok {
		maxSubWordSize = int(maxSubVal)
	}
	onlyVal, ok := config["only_longest_match"].(bool)
	if ok {
		onlyLongestMatch = onlyVal
	}

	dictTokenMapName, ok := config["dict_token_map"].(string)
	if !ok {
		return nil, fmt.Errorf("must specify dict_token_map")
	}
	dictTokenMap, err := cache.TokenMapNamed(dictTokenMapName)
	if err != nil {
		return nil, fmt.Errorf("error building dict compound words filter: %v", err)
	}
	return NewDictionaryCompoundFilter(dictTokenMap, minWordSize, minSubWordSize, maxSubWordSize, onlyLongestMatch), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:34,代码来源:dict.go

示例6: StopTokenFilterConstructor

func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {
	tokenMap, err := cache.TokenMapNamed(StopName)
	if err != nil {
		return nil, err
	}
	return stop_tokens_filter.NewStopTokensFilter(tokenMap), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:7,代码来源:stop_filter_hi.go

示例7: AnalyzerConstructor

func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
	tokenizer, err := cache.TokenizerNamed(unicode.Name)
	if err != nil {
		return nil, err
	}
	toLowerFilter, err := cache.TokenFilterNamed(lower_case_filter.Name)
	if err != nil {
		return nil, err
	}
	normalizeFilter := unicode_normalize.MustNewUnicodeNormalizeFilter(unicode_normalize.NFKC)
	stopArFilter, err := cache.TokenFilterNamed(StopName)
	if err != nil {
		return nil, err
	}
	normalizeArFilter, err := cache.TokenFilterNamed(NormalizeName)
	if err != nil {
		return nil, err
	}
	stemmerArFilter, err := cache.TokenFilterNamed(StemmerName)
	if err != nil {
		return nil, err
	}
	rv := analysis.Analyzer{
		Tokenizer: tokenizer,
		TokenFilters: []analysis.TokenFilter{
			toLowerFilter,
			normalizeFilter,
			stopArFilter,
			normalizeArFilter,
			stemmerArFilter,
		},
	}
	return &rv, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:34,代码来源:analyzer_ar.go

示例8: AnalyzerConstructor

func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
	tokenizer, err := cache.TokenizerNamed(unicode.Name)
	if err != nil {
		return nil, err
	}
	possEnFilter, err := cache.TokenFilterNamed(PossessiveName)
	if err != nil {
		return nil, err
	}
	toLowerFilter, err := cache.TokenFilterNamed(lower_case_filter.Name)
	if err != nil {
		return nil, err
	}
	stopEnFilter, err := cache.TokenFilterNamed(StopName)
	if err != nil {
		return nil, err
	}
	stemmerEnFilter, err := cache.TokenFilterNamed(porter.Name)
	if err != nil {
		return nil, err
	}
	rv := analysis.Analyzer{
		Tokenizer: tokenizer,
		TokenFilters: []analysis.TokenFilter{
			possEnFilter,
			toLowerFilter,
			stopEnFilter,
			stemmerEnFilter,
		},
	}
	return &rv, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:32,代码来源:analyzer_en.go

示例9: AnalyzerConstructor

func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
	keywordTokenizer, err := cache.TokenizerNamed(single_token.Name)
	if err != nil {
		return nil, err
	}
	rv := analysis.Analyzer{
		Tokenizer: keywordTokenizer,
	}
	return &rv, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:10,代码来源:keyword_analyzer.go

示例10: KeyWordMarkerFilterConstructor

func KeyWordMarkerFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {
	keywordsTokenMapName, ok := config["keywords_token_map"].(string)
	if !ok {
		return nil, fmt.Errorf("must specify keywords_token_map")
	}
	keywordsTokenMap, err := cache.TokenMapNamed(keywordsTokenMapName)
	if err != nil {
		return nil, fmt.Errorf("error building keyword marker filter: %v", err)
	}
	return NewKeyWordMarkerFilter(keywordsTokenMap), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:11,代码来源:keyword_marker_filter.go

示例11: StopTokensFilterConstructor

func StopTokensFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {
	stopTokenMapName, ok := config["stop_token_map"].(string)
	if !ok {
		return nil, fmt.Errorf("must specify stop_token_map")
	}
	stopTokenMap, err := cache.TokenMapNamed(stopTokenMapName)
	if err != nil {
		return nil, fmt.Errorf("error building stop words filter: %v", err)
	}
	return NewStopTokensFilter(stopTokenMap), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:11,代码来源:stop_tokens_filter.go

示例12: ElisionFilterConstructor

func ElisionFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {
	articlesTokenMapName, ok := config["articles_token_map"].(string)
	if !ok {
		return nil, fmt.Errorf("must specify articles_token_map")
	}
	articlesTokenMap, err := cache.TokenMapNamed(articlesTokenMapName)
	if err != nil {
		return nil, fmt.Errorf("error building elision filter: %v", err)
	}
	return NewElisionFilter(articlesTokenMap), nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:11,代码来源:elision_filter.go

示例13: getCharFilters

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
}
开发者ID:postfix,项目名称:name_pending,代码行数:12,代码来源:custom_analyzer.go

示例14: getTokenFilters

func getTokenFilters(tokenFilterNames []string, cache *registry.Cache) ([]analysis.TokenFilter, error) {
	tokenFilters := make([]analysis.TokenFilter, len(tokenFilterNames))
	for i, tokenFilterName := range tokenFilterNames {
		tokenFilter, err := cache.TokenFilterNamed(tokenFilterName)
		if err != nil {
			return nil, err
		}
		tokenFilters[i] = tokenFilter
	}

	return tokenFilters, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:12,代码来源:custom_analyzer.go

示例15: AnalyzerConstructor

func AnalyzerConstructor(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error) {
	kagomeTokenizer, err := cache.TokenizerNamed(TokenizerName)
	if err != nil {
		return nil, err
	}
	normalizeFilter := unicode_normalize.MustNewUnicodeNormalizeFilter(unicode_normalize.NFKD)
	rv := analysis.Analyzer{
		Tokenizer: kagomeTokenizer,
		TokenFilters: []analysis.TokenFilter{
			normalizeFilter,
		},
	}
	return &rv, nil
}
开发者ID:postfix,项目名称:name_pending,代码行数:14,代码来源:analyzer_ja.go


注:本文中的github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/blevesearch/bleve/registry.Cache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。