{"id":18034826,"url":"https://github.com/importcjj/sensitive","last_synced_at":"2025-05-16T04:05:13.330Z","repository":{"id":19371983,"uuid":"86890819","full_name":"importcjj/sensitive","owner":"importcjj","description":"敏感词查找,验证,过滤和替换 🤓 FindAll, Validate, Filter and Replace words.","archived":false,"fork":false,"pushed_at":"2022-07-01T02:56:44.000Z","size":142,"stargazers_count":661,"open_issues_count":8,"forks_count":155,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-08T14:09:17.548Z","etag":null,"topics":["dirtywords","filter","go","golang","keyword","sensitive","text","trie","trie-tree","word"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/importcjj.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":"2017-04-01T06:44:03.000Z","updated_at":"2025-03-18T02:32:33.000Z","dependencies_parsed_at":"2022-07-12T15:15:00.303Z","dependency_job_id":null,"html_url":"https://github.com/importcjj/sensitive","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/importcjj%2Fsensitive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/importcjj%2Fsensitive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/importcjj%2Fsensitive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/importcjj%2Fsensitive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/importcjj","download_url":"https://codeload.github.com/importcjj/sensitive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464895,"owners_count":22075570,"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":["dirtywords","filter","go","golang","keyword","sensitive","text","trie","trie-tree","word"],"created_at":"2024-10-30T11:14:08.171Z","updated_at":"2025-05-16T04:05:08.320Z","avatar_url":"https://github.com/importcjj.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Sensitive\n\n敏感词查找,验证,过滤和替换\n\nFindAll, Validate, Filter and Replace words. \n\n[![Build Status](https://travis-ci.org/importcjj/sensitive.svg?branch=master)](https://travis-ci.org/importcjj/sensitive) [![GoDoc](https://godoc.org/github.com/importcjj/sensitive?status.svg)](https://godoc.org/github.com/importcjj/sensitive)\n\n\n新增分支[Aho-Corasick](https://github.com/importcjj/sensitive/tree/Aho-Corasick)以支持AC自动机\n\n#### 用法\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/importcjj/sensitive\"\n)\n\nfunc main() {\n\tfilter := sensitive.New()\n\tfilter.LoadWordDict(\"path/to/dict\")\n\t// Do something\n}\n```\n\n#### AddWord\n\n添加敏感词\n\n```go\nfilter.AddWord(\"垃圾\")\n```\n\n#### Replace\n\n把词语中的字符替换成指定的字符，这里的字符指的是rune字符，比如`*`就是`'*'`。\n\n```go\nfilter.Replace(\"这篇文章真的好垃圾\", '*')\n// output =\u003e 这篇文章真的好**\n```\n\n#### Filter\n\n直接移除词语\n\n```go\nfilter.Filter(\"这篇文章真的好垃圾啊\")\n// output =\u003e 这篇文章真的好啊\n```\n\n#### FindIn\n\n查找并返回第一个敏感词，如果没有则返回`false`\n\n```go\nfilter.FindIn(\"这篇文章真的好垃圾\")\n// output =\u003e true, 垃圾\n```\n\n#### Validate\n\n验证内容是否ok，如果含有敏感词，则返回`false`和第一个敏感词。\n\n```go\nfilter.Validate(\"这篇文章真的好垃圾\")\n// output =\u003e false, 垃圾\n```\n\n#### FindAll\n\n查找内容中的全部敏感词，以数组返回。\n\n```go\nfilter.FindAll(\"这篇文章真的好垃圾\")\n// output =\u003e [垃圾]\n```\n\n#### LoadNetWordDict\n\n加载网络词库。\n\n```go\nfilter.LoadNetWordDict(\"https://raw.githubusercontent.com/importcjj/sensitive/master/dict/dict.txt\")\n```\n\n#### UpdateNoisePattern\n\n设置噪音模式，排除噪音字符。\n\n```go\n// failed\nfilter.FindIn(\"这篇文章真的好垃x圾\")      // false\nfilter.UpdateNoisePattern(`x`)\n// success\nfilter.FindIn(\"这篇文章真的好垃x圾\")      // true, 垃圾\nfilter.Validate(\"这篇文章真的好垃x圾\")    // False, 垃圾\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimportcjj%2Fsensitive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimportcjj%2Fsensitive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimportcjj%2Fsensitive/lists"}