ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
tools_filterword.h File Reference

敏感词过滤和文本验证工具 More...

#include "utf8cpp/utf8/cpp11.h"
#include "utf8cpp/utf8.h"
#include "tools/tools.h"
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <locale>
#include <queue>

Classes

struct  ngl::tools::nacnode
 Aho-Corasick自动机Trie节点 More...
class  ngl::tools::filterword
 敏感词过滤器 More...

Namespaces

namespace  ngl::tools
 工具函数命名空间。

Functions

void ngl::tools::test_filterword ()
 敏感词过滤功能测试函数

Detailed Description

敏感词过滤和文本验证工具

基于 Aho-Corasick 自动机实现的高效敏感词检测和过滤系统。 支持 UTF-8 文本处理、emoji 特殊字符检测、名称验证等功能。 用于聊天内容过滤、玩家名称验证等场景。

Note
所有类和函数均位于 ngl::tools 命名空间下。
// 敏感词过滤示例
ngl::tools::filterword::init(); // 初始化过滤器
ngl::tools::filterword::build(); // 构建自动机
std::string filtered = ngl::tools::filterword::filter("包含敏感词的文本");
// filtered: "包含***的文本"
// 名称验证示例
auto result = ngl::tools::filterword::check_name("玩家名称", 2, 12);
// 名称有效
}