示例#1
0
文件: main.go 项目: yukihir0/hbn
func main() {
	client := hbn.NewClient()
	client.SetTotalPages(2)
	client.SetMaxParallelRequest(10)

	user := "******"
	bookmarks := client.RequestBookmarks(user)
	//bookmarks := client.RequestFavoriteBookmarks(user)
	//bookmarks := client.RequestHotEntryBookmarks()
	//bookmarks := client.RequestSearchBookmarks("golang")
	//bookmarks := client.RequestRelatedBookmarks(user)

	neighbors := client.SearchNeighbors(bookmarks)
	excluded := neighbors.Exclude([]string{
		user,
	})
	top := excluded.Top(20)

	for _, neighbor := range top {
		fmt.Printf(
			"[%s] : %.1f%% (%d/%d)\n",
			neighbor.User,
			neighbor.Similarity*100,
			len(neighbor.CommonBookmarks),
			len(bookmarks),
		)

		for _, bookmark := range neighbor.CommonBookmarks {
			fmt.Printf(" - %s\n", bookmark.Title)
		}
		fmt.Println()
	}
}
示例#2
0
文件: main.go 项目: yukihir0/hbcf
func ImportUserItemsNetwork(user string) []hbcf.UserItem {
	client := hbn.NewClient()
	client.SetTotalPages(2)
	client.SetMaxParallelRequest(10)

	bookmarks := client.RequestBookmarks(user)
	//bookmarks := client.RequestRelatedBookmarks(user)
	//bookmarks := client.RequestFavoriteBookmarks(user)
	//bookmarks := client.RequestHotEntryBookmarks()
	//bookmarks := client.RequestSearchBookmarks("golang")

	neighbors := client.SearchNeighbors(bookmarks)
	//sort.Sort(sort.Reverse(neighbors))
	excluded := neighbors.Exclude([]string{user})
	users := hbcf.NewUsers(excluded.Top(20))

	c := hbcf.NewClient()
	c.SetTotalPages(2)
	c.SetMaxParallelRequest(10)
	userItems := c.RequestUserItems(users)

	return userItems
}