企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
从一个句子中提取的*N*个(或更少)连续单词的集合。这一概念中的“单词”也可以替换为“字符” > “The cat sat on the mat.”(“猫坐在垫子上”) > **二元语法(2-grams):** ~~~ {"The", "The cat", "cat", "cat sat", "sat", "sat on", "on", "on the", "the", "the mat", "mat"} ~~~ **三元语法(3-grams):** ~~~ {"The", "The cat", "cat", "cat sat", "The cat sat", "sat", "sat on", "on", "cat sat on", "on the", "the", "sat on the", "the mat", "mat", "on the mat"} ~~~ * 这样的集合分别叫作**二元语法袋**(bag-of-2-grams)及**三元语法袋**(bag-of-3-grams) * **袋**(bag)这一术语指的是,我们处理的是标记组成的集合,而不是一个列表或序列,即标记**没有特定的顺序** * 词袋是一种**不保存顺序**的分词方法(生成的标记组成一个集合,而不是一个序列,舍弃了句子的总体结构) ***** * 使用**轻量级**的浅层文本处理模型时(比如 logistic 回归和随机森林),n-gram 是一种功能强大、不可或缺的特征工程工具