From b3ea94ba47a94ba1df4345598d90c5c27870d1f3 Mon Sep 17 00:00:00 2001 From: Wang Bin Date: Wed, 6 May 2015 16:11:11 +0800 Subject: [PATCH] tweak docs --- analyse/example_test.go | 22 ++++++++++++++++++++++ dictionary/dictionary.go | 4 +++- finalseg/finalseg.go | 1 + util/util.go | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/analyse/example_test.go b/analyse/example_test.go index 3c804e2..b527d0c 100644 --- a/analyse/example_test.go +++ b/analyse/example_test.go @@ -20,3 +20,25 @@ func ExampleExtractTags() { // Output: // Top 5 tags: Python / C++ / 伸手不见五指 / 孙悟空 / 黑夜 / } + +func ExampleTextRank() { + var t analyse.TextRanker + t.LoadDictionary("../dict.txt") + sentence := "此外,公司拟对全资子公司吉林欧亚置业有限公司增资4.3亿元,增资后,吉林欧亚置业注册资本由7000万元增加到5亿元。吉林欧亚置业主要经营范围为房地产开发及百货零售等业务。目前在建吉林欧亚城市商业综合体项目。2013年,实现营业收入0万元,实现净利润-139.13万元。" + + result := t.TextRank(sentence, 10) + for _, segment := range result { + fmt.Printf("%s %f\n", segment.Text(), segment.Weight()) + } + // Output: + // 吉林 1.000000 + // 欧亚 0.878078 + // 置业 0.562048 + // 实现 0.520906 + // 收入 0.384284 + // 增资 0.360591 + // 子公司 0.353132 + // 城市 0.307509 + // 全资 0.306324 + // 商业 0.306138 +} diff --git a/dictionary/dictionary.go b/dictionary/dictionary.go index c62e2d3..d216415 100644 --- a/dictionary/dictionary.go +++ b/dictionary/dictionary.go @@ -1,3 +1,5 @@ +// Package dictionary contains a interface and wraps all io related work. +// It is used by jiebago module to read/write files. package dictionary import ( @@ -8,7 +10,7 @@ import ( "strings" ) -// DictLoader represents a interface that could add one token or load bunch of +// DictLoader is the interface that could add one token or load // tokens from channel. type DictLoader interface { Load(<-chan Token) diff --git a/finalseg/finalseg.go b/finalseg/finalseg.go index aace620..d09a139 100644 --- a/finalseg/finalseg.go +++ b/finalseg/finalseg.go @@ -1,3 +1,4 @@ +// Package finalseg is the Golang implementation of Jieba's finalseg module. package finalseg import ( diff --git a/util/util.go b/util/util.go index ae4f0ba..e2fc8bf 100644 --- a/util/util.go +++ b/util/util.go @@ -1,3 +1,4 @@ +// Package util contains some util functions used by jiebago. package util import "regexp"