當前位置: 首頁>>代碼示例>>Golang>>正文


Golang pipeline.StandardModule類代碼示例

本文整理匯總了Golang中github.com/opinionated/pipeline.StandardModule的典型用法代碼示例。如果您正苦於以下問題:Golang StandardModule類的具體用法?Golang StandardModule怎麽用?Golang StandardModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了StandardModule類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getConceptModule

func getConceptModule() (pipeline.Module, error) {
	weight := 1.0
	scoreFunc := getCountSqLambdaWithWeight(weight)
	neoFunc := pipeline.NeoAnalyzer{MetadataType: "Concept",
		ScoreFunc: scoreFunc}

	module := new(pipeline.StandardModule)
	module.SetFuncs(&neoFunc)

	return module, nil
}
開發者ID:opinionated,項目名稱:pipeline,代碼行數:11,代碼來源:main.go

示例2: getTaxonomyModule

func getTaxonomyModule() (pipeline.Module, error) {
	weight := 1.0
	scoreFunc := getCountSqLambdaWithWeight(weight)
	taxFunc := pipeline.NeoAnalyzer{MetadataType: "Taxonomy",
		ScoreFunc: scoreFunc}

	taxModule := new(pipeline.StandardModule)
	taxModule.SetFuncs(&taxFunc) // is safe to ref local value

	return taxModule, nil
}
開發者ID:opinionated,項目名稱:pipeline,代碼行數:11,代碼來源:main.go

示例3: TestError

func TestError(t *testing.T) {

	errFunc := errorAnalyzer{when: 2}
	funcModule := pipeline.StandardModule{}
	funcModule.SetFuncs(&errFunc)

	pipe := pipeline.NewPipeline()
	pipe.AddStage(&funcModule)

	story := storyFromSet(simpleSet)
	data, err := storyDriver(pipe, story)

	assert.NotNil(t, err)
	assert.EqualError(t, err, "Error(s) closing pipeline:\n\tok bump!")
	assert.Len(t, data, 0)
}
開發者ID:opinionated,項目名稱:pipeline,代碼行數:16,代碼來源:standardModule_test.go

示例4: TestBump

func TestBump(t *testing.T) {

	add := addAnalyzer{howmuch: 1}
	addModule := pipeline.StandardModule{}
	addModule.SetFuncs(add)

	bump := bumpAnalyzer{when: 1, count: 0}
	bumpModule := pipeline.StandardModule{}
	bumpModule.SetFuncs(&bump)

	pipe := pipeline.NewPipeline()
	pipe.AddStage(&addModule)
	pipe.AddStage(&bumpModule)

	story := storyFromSet(simpleSet)
	data, err := storyDriver(pipe, story)

	assert.Nil(t, err)
	assert.Len(t, data, 2)

	for i := range data {
		scorei, err := data[i].GetScore("add")
		assert.Nil(t, err)
		score := scorei.(TestStandardScore)

		assert.EqualValues(t, 1.0, score.score)
	}
}
開發者ID:opinionated,項目名稱:pipeline,代碼行數:28,代碼來源:standardModule_test.go

示例5: TestStandardAdd

func TestStandardAdd(t *testing.T) {

	add := addAnalyzer{howmuch: 1}
	funcModule := pipeline.StandardModule{}
	funcModule.SetFuncs(add)

	pipe := pipeline.NewPipeline()
	pipe.AddStage(&funcModule)

	story := storyFromSet(simpleSet)
	data, err := storyDriver(pipe, story)

	assert.Nil(t, err)
	assert.Len(t, data, 3)

	for i := range data {
		scorei, err := data[i].GetScore("add")
		assert.Nil(t, err)
		score := scorei.(TestStandardScore)

		assert.EqualValues(t, 1.0, score.score)
	}
}
開發者ID:opinionated,項目名稱:pipeline,代碼行數:23,代碼來源:standardModule_test.go

示例6: TestFull

func TestFull(t *testing.T) {

	taxFunc := pipeline.NeoAnalyzer{MetadataType: "Taxonomy"}
	taxModule := pipeline.StandardModule{}
	taxModule.SetFuncs(taxFunc)

	conceptsFunc := pipeline.NeoAnalyzer{MetadataType: "Concept"}
	conceptsModule := pipeline.StandardModule{}
	conceptsModule.SetFuncs(conceptsFunc)

	keyFunc := pipeline.NeoAnalyzer{MetadataType: "Keyword"}
	keyModule := pipeline.StandardModule{}
	keyModule.SetFuncs(&keyFunc)

	entityFunc := pipeline.NeoAnalyzer{MetadataType: "Entity"}
	entityModule := pipeline.StandardModule{}
	entityModule.SetFuncs(&entityFunc)

	// idf funcs
	keyIDFFunc := pipeline.IDFAnalyzer{MetadataType: "Keyword"}
	keyIDFModule := pipeline.StandardModule{}
	keyIDFModule.SetFuncs(&keyIDFFunc)

	entityIDFFunc := pipeline.IDFAnalyzer{MetadataType: "Entity"}
	entityIDFModule := pipeline.StandardModule{}
	entityIDFModule.SetFuncs(&entityIDFFunc)

	conceptIDFFunc := pipeline.IDFAnalyzer{MetadataType: "Concept"}
	conceptIDFModule := pipeline.StandardModule{}
	conceptIDFModule.SetFuncs(&conceptIDFFunc)

	// word2vec
	entityWVFunc := pipeline.WordVecAnalyzer{MetadataType: "Entity"}
	entityWVModule := pipeline.StandardModule{}
	entityWVModule.SetFuncs(&entityWVFunc)

	conceptWVFunc := pipeline.WordVecAnalyzer{MetadataType: "Concept"}
	conceptWVModule := pipeline.StandardModule{}
	conceptWVModule.SetFuncs(&conceptWVFunc)

	keyWVFunc := pipeline.WordVecAnalyzer{MetadataType: "Keyword"}
	keyWVModule := pipeline.StandardModule{}
	keyWVModule.SetFuncs(&keyWVFunc)

	scoreFuncs := make(map[string]func(pipeline.Score) float32)
	scoreFuncs["neo_Taxonomy"] = SquareCount //SquareFlow
	scoreFuncs["neo_Concept"] = SquareCount
	scoreFuncs["neo_Keyword"] = ScoreAverage
	scoreFuncs["neo_Entity"] = ScoreAverage
	scoreFuncs["idf_Keyword"] = IDFAverage
	scoreFuncs["idf_Entity"] = IDFAverage
	scoreFuncs["idf_Concept"] = IDFAverage
	scoreFuncs["wordvec_Concept"] = SquareFlow
	scoreFuncs["wordvec_Keyword"] = SquareFlow
	scoreFuncs["wordvec_Entity"] = SquareFlow

	weightMap := make(map[string]float32)
	weightMap["neo_Taxonomy"] = 3.0
	weightMap["neo_Concept"] = 3.0
	weightMap["neo_Keyword"] = 3.0
	weightMap["neo_Entity"] = 3.0
	weightMap["idf_Keyword"] = 10.0
	weightMap["idf_Entity"] = 10.0
	weightMap["idf_Concept"] = 10.0
	weightMap["wordvec_Taxonomy"] = 10.0
	weightMap["wordvec_Concept"] = 15.0
	weightMap["wordvec_Keyword"] = 10.0
	weightMap["wordvec_Entity"] = 10.0

	threshFunc := threshAnalyzer{0.0, scoreFuncs, weightMap}
	threshModule := pipeline.StandardModule{}
	threshModule.SetFuncs(threshFunc)

	lastThreshFunc := threshAnalyzer{0.0, scoreFuncs, weightMap}
	lastThreshModule := pipeline.StandardModule{}
	lastThreshModule.SetFuncs(lastThreshFunc)

	// build the pipe
	pipe := pipeline.NewPipeline()

	// 1.1 seems to do it for words

	// do coarse methods
	//	pipe.AddStage(&taxModule)
	//pipe.AddStage(&conceptsModule)
	//pipe.AddStage(&keyIDFModule)
	//pipe.AddStage(&entityIDFModule)
	//pipe.AddStage(&conceptIDFModule)
	//pipe.AddStage(&threshModule)
	pipe.AddStage(&entityWVModule)
	pipe.AddStage(&conceptWVModule)
	//pipe.AddStage(&lastThreshModule)
	pipe.AddStage(&keyWVModule)

	// thresh then do finer methods
	//pipe.AddStage(&keyModule)
	//pipe.AddStage(&entityModule)

	// build the story
	assert.Nil(t, relationDB.Open("http://localhost:7474"))
//.........這裏部分代碼省略.........
開發者ID:opinionated,項目名稱:pipeline,代碼行數:101,代碼來源:module_test.go


注:本文中的github.com/opinionated/pipeline.StandardModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。