{"id":18903806,"url":"https://github.com/bububa/jiagu","last_synced_at":"2025-04-15T03:33:50.466Z","repository":{"id":44447042,"uuid":"388085601","full_name":"bububa/jiagu","owner":"bububa","description":"Jiagu深度学习自然语言处理工具 知识图谱关系抽取 中文分词 词性标注 命名实体识别 情感分析 新词发现 关键词 文本摘要 文本聚类","archived":false,"fork":false,"pushed_at":"2021-07-23T06:14:34.000Z","size":92716,"stargazers_count":18,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-19T06:55:56.705Z","etag":null,"topics":["chinese-nlp","chinese-word-segmentation","classification","clustering","cws","ner","nlp","pos","segmentation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bububa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-21T10:50:37.000Z","updated_at":"2024-06-19T02:51:27.000Z","dependencies_parsed_at":"2022-08-31T09:12:16.049Z","dependency_job_id":null,"html_url":"https://github.com/bububa/jiagu","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fjiagu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fjiagu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fjiagu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fjiagu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bububa","download_url":"https://codeload.github.com/bububa/jiagu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223657830,"owners_count":17181024,"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":["chinese-nlp","chinese-word-segmentation","classification","clustering","cws","ner","nlp","pos","segmentation"],"created_at":"2024-11-08T09:06:32.570Z","updated_at":"2024-11-08T09:06:33.402Z","avatar_url":"https://github.com/bububa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jiagu自然语言处理工具\n[![Go Reference](https://pkg.go.dev/badge/github.com/bububa/jiagu.svg)](https://pkg.go.dev/github.com/bububa/jiagu)\n[![Go](https://github.com/bububa/jiagu/actions/workflows/go.yml/badge.svg)](https://github.com/bububa/jiagu/actions/workflows/go.yml)\n[![goreleaser](https://github.com/bububa/jiagu/actions/workflows/goreleaser.yml/badge.svg)](https://github.com/bububa/jiagu/actions/workflows/goreleaser.yml)\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/bububa/jiagu.svg)](https://github.com/bububa/jiagu)\n[![GoReportCard](https://goreportcard.com/badge/github.com/bububa/jiagu)](https://goreportcard.com/report/github.com/bububa/jiagu)\n[![GitHub license](https://img.shields.io/github/license/bububa/jiagu.svg)](https://github.com/bububa/jiagu/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bububa/jiagu.svg)](https://GitHub.com/bububa/jiagu/releases/)\n\nan NLP toolkit for Chinese.\nThis is a golang port from the [original python3 liberary](https://github.com/ownthink/Jiagu)\n\u003e\u003e\u003e Jiagu使用大规模语料训练而成。将提供中文分词、词性标注、命名实体识别、情感分析、知识图谱关系抽取、关键词抽取、文本摘要、新词发现、情感分析、文本聚类等常用自然语言处理功能。参考了各大工具优缺点制作，将Jiagu回馈给大家。\n\n---\n\n提供的功能有：\n* 中文分词\n* 词性标注\n* 命名实体识别\n* 知识图谱关系抽取\n* 关键词提取\n* 文本摘要\n* 新词发现\n* 情感分析\n* 文本聚类\n* 等等。。。。\n\n---\n\n## 模型转换\n原始模型文件来自[python版本](https://github.com/ownthink/Jiagu), 为pickle或marshal格式，需要先转换json，再转成gob后gzip压缩\n1. pickle/marshal模型转json (sentiment.model 为marshal格式)\n```shell\npython ./cmd/modelconverter/pickle2json.py pickle.model ./data/model/xxx.json\npython ./cmd/modelconverter/marshal2json.py pickle.model ./data/model/xxx.json\n```\n\n2. json模型文件转gob后gzip压缩\n```shell\ngo run ./cmd/modelconverter/main.go -i ./data/model/xxx.json -o ./model/xxx.model\ngo run ./cmd/modelconverter/main.go -i ./data/model/xxx.json -o ./model/xxx.model --sentiment // 仅对sentiment.model使用\n```\n\n## 使用方式\n1. 快速上手：分词、词性标注、命名实体识别\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    // jiagu.Init() // 可手动初始化，也可以动态初始化\n\n    text := \"厦门明天会不会下雨\"\n\n    words := jiagu.Seg(text) // 分词\n\n    pos := jiagu.Pos(words) // 词性标注\n\n    ner := jiagu.Ner(words) // 命名实体识别\n}\n```\n\n2. 中文分词\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    text := \"汉服和服装、维基图谱\"\n\n    words := jiagu.Seg(text)\n    \n\n    // fd, err := os.Open(\"user.dict\")\n    // defer fd.Close()\n    // jiagu.LoadUserDict(fd) # 加载自定义字典，支持字典路径、字典列表形式。\n\n    jiagu.AddVocabs([]string{\"汉服和服装\"})\n\n    words := jiagu.Seg(text) // 自定义分词，字典分词模式有效\n}\n```\n\n3. 知识图谱关系抽取\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    text := '姚明1980年9月12日出生于上海市徐汇区，祖籍江苏省苏州市吴江区震泽镇，前中国职业篮球运动员，司职中锋，现任中职联公司董事长兼总经理。'\n    knowledge := jiagu.Knowledge(text)\n}\n```\n训练数据：https://github.com/ownthink/KnowledgeGraphData\n\n4. 关键词提取\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    text = `\n    该研究主持者之一、波士顿大学地球与环境科学系博士陈池（音）表示，“尽管中国和印度国土面积仅占全球陆地的9%，但两国为这一绿化过程贡献超过三分之一。考虑到人口过多的国家一般存在对土地过度利用的问题，这个发现令人吃惊。”\n    NASA埃姆斯研究中心的科学家拉玛·内曼尼（Rama Nemani）说，“这一长期数据能让我们深入分析地表绿化背后的影响因素。我们一开始以为，植被增加是由于更多二氧化碳排放，导致气候更加温暖、潮湿，适宜生长。”\n    “MODIS的数据让我们能在非常小的尺度上理解这一现象，我们发现人类活动也作出了贡献。”\n    NASA文章介绍，在中国为全球绿化进程做出的贡献中，有42%来源于植树造林工程，对于减少土壤侵蚀、空气污染与气候变化发挥了作用。\n    据观察者网过往报道，2017年我国全国共完成造林736.2万公顷、森林抚育830.2万公顷。其中，天然林资源保护工程完成造林26万公顷，退耕还林工程完成造林91.2万公顷。京津风沙源治理工程完成造林18.5万公顷。三北及长江流域等重点防护林体系工程完成造林99.1万公顷。完成国家储备林建设任务68万公顷。\n    `\n\n    keywords := jiagu.keywords(text, 5) \n}\n```\n\n5. 文本摘要\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    summarize := jiagu.Summarize(text, 3) # 摘要\n}\n```\n\n6. 新词发现\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    fd, err := os.Open(\"input.txt\")\n    defer fd.Close()\n\n    words, err := jiagu.Findword(fd, 0, 0, 0) // 根据文本，利用信息熵做新词发现。\n}\n```\n\n7. 情感分析\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    text := \"很讨厌还是个懒鬼\"\n    words := jiagu.Seg(text)\n    sentiment, probe := jiagu.Sentiment(words)\n}\n```\n\n8. 文本聚类\n```golang\nimport \"github.com/bububa/jiagu\"\n\nfunc main() {\n    docs := []string {\n        \"百度深度学习中文情感分析工具Senta试用及在线测试\",\n        \"情感分析是自然语言处理里面一个热门话题\",\n        \"AI Challenger 2018 文本挖掘类竞赛相关解决方案及代码汇总\",\n        \"深度学习实践：从零开始做电影评论文本情感分析\",\n        \"BERT相关论文、文章和代码资源汇总\",\n        \"将不同长度的句子用BERT预训练模型编码，映射到一个固定长度的向量上\",\n        \"自然语言处理工具包spaCy介绍\",\n        \"现在可以快速测试一下spaCy的相关功能，我们以英文数据为例，spaCy目前主要支持英文和德文\",\n    }\n\ttokenizer := func(txt string) []string {\n\t\treturn jiagu.Seg(txt)\n\t}\n    cluster := jiagu.KmeansCluster(docs, tokenizer, 4)\t\n\n}\nprint(cluster)\n```\n\n\n## 附录\n1. 词性标注说明\n```text\nn　　　普通名词\nnt　 　时间名词\nnd　 　方位名词\nnl　 　处所名词\nnh　 　人名\nnhf　　姓\nnhs　　名\nns　 　地名\nnn 　　族名\nni 　　机构名\nnz 　　其他专名\nv　　 动词\nvd　　趋向动词\nvl　　联系动词\nvu　　能愿动词\na　 　形容词\nf　 　区别词\nm　 　数词　　\nq　 　量词\nd　 　副词\nr　 　代词\np　　 介词\nc　 　连词\nu　　 助词\ne　 　叹词\no　 　拟声词\ni　 　习用语\nj　　 缩略语\nh　　 前接成分\nk　　 后接成分\ng　 　语素字\nx　 　非语素字\nw　 　标点符号\nws　　非汉字字符串\nwu　　其他未知的符号\n```\n\n2. 命名实体说明（采用BIO标记方式）\n```text\nB-PER、I-PER   人名\nB-LOC、I-LOC   地名\nB-ORG、I-ORG   机构名\n```\n\n## Reference：\n- [Jiagu Python version](https://github.com/ownthink/Jiagu)\n- [知识图谱训练数据](https://github.com/ownthink/KnowledgeGraphData)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Fjiagu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbububa%2Fjiagu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Fjiagu/lists"}