{"id":13481742,"url":"https://github.com/huichen/sego","last_synced_at":"2025-05-15T02:09:45.664Z","repository":{"id":9613727,"uuid":"11538858","full_name":"huichen/sego","owner":"huichen","description":"Go中文分词","archived":false,"fork":false,"pushed_at":"2022-11-16T02:13:58.000Z","size":3675,"stargazers_count":1818,"open_issues_count":31,"forks_count":356,"subscribers_count":109,"default_branch":"master","last_synced_at":"2025-04-14T00:58:31.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huichen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-19T23:02:06.000Z","updated_at":"2025-04-08T14:21:08.000Z","dependencies_parsed_at":"2023-01-13T15:30:19.638Z","dependency_job_id":null,"html_url":"https://github.com/huichen/sego","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fsego","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fsego/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fsego/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fsego/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huichen","download_url":"https://codeload.github.com/huichen/sego/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259384,"owners_count":22040820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:55.042Z","updated_at":"2025-05-15T02:09:45.636Z","avatar_url":"https://github.com/huichen.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Open source library"],"sub_categories":["搜索推荐","Search Recommendations"],"readme":"sego\n====\n\nGo中文分词\n\n\u003ca href=\"https://github.com/huichen/sego/blob/master/dictionary.go\"\u003e词典\u003c/a\u003e用双数组trie（Double-Array Trie）实现，\n\u003ca href=\"https://github.com/huichen/sego/blob/master/segmenter.go\"\u003e分词器\u003c/a\u003e算法为基于词频的最短路径加动态规划。\n\n支持普通和搜索引擎两种分词模式，支持用户词典、词性标注，可运行\u003ca href=\"https://github.com/huichen/sego/blob/master/server/server.go\"\u003eJSON RPC服务\u003c/a\u003e。\n\n分词速度\u003ca href=\"https://github.com/huichen/sego/blob/master/tools/benchmark.go\"\u003e单线程\u003c/a\u003e9MB/s，\u003ca href=\"https://github.com/huichen/sego/blob/master/tools/goroutines.go\"\u003egoroutines并发\u003c/a\u003e42MB/s（8核Macbook Pro）。\n\n# 安装/更新\n\n```\ngo get -u github.com/huichen/sego\n```\n\n# 使用\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/huichen/sego\"\n)\n\nfunc main() {\n\t// 载入词典\n\tvar segmenter sego.Segmenter\n\tsegmenter.LoadDictionary(\"github.com/huichen/sego/data/dictionary.txt\")\n\n\t// 分词\n\ttext := []byte(\"中华人民共和国中央人民政府\")\n\tsegments := segmenter.Segment(text)\n  \n\t// 处理分词结果\n\t// 支持普通模式和搜索模式两种分词，见代码中SegmentsToString函数的注释。\n\tfmt.Println(sego.SegmentsToString(segments, false)) \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuichen%2Fsego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuichen%2Fsego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuichen%2Fsego/lists"}