当前位置: 首页 > news >正文

网站用户推广网络游戏陪玩

网站用户推广,网络游戏陪玩,网络网站建设10大指标,卖房子最快的平台一、文本的基本单位 1、Token 定义#xff1a;文本的最小单位#xff0c;例如单词、标点符号。 示例#xff1a; 原句#xff1a; I love NLP. 分词结果#xff1a; [I, love, NLP, .] 2、语法与语义 语法#xff1a;词的结构和句子的组合规则。 语义文本的最小单位例如单词、标点符号。 示例 原句 I love NLP. 分词结果 [I, love, NLP, .] 2、语法与语义 语法词的结构和句子的组合规则。 语义词的含义和上下文理解。 示例 句子 Time flies like an arrow. 有多重解释 时间像箭一样飞逝。 像箭一样的飞虫在时间中飞翔。 二、基本的文本预处理 1、分词Tokenization 英文分词基于空格或标点分隔。中文分词基于统计和规则的方法如 Jieba。 2、去停用词 停用词意义较小或频率过高的词例如 the, is, and。 3、词干化 将词语削减为根形式例如 running → run。 4、词形还原 考虑语法规则还原为词的基本形式例如 mice → mouse。 三、用nltk库做文本预处理 NLTKNatural Language Toolkit 是一个功能强大、 灵活性高的开源 Python 库 专为自然 语言处理NLP 领域的研究和开发而设计。 NLTK 提供了一套丰富的工具和资源 适合处 理、分析和理解人类语言文本。 1、文本预处理包 分词 nltk.tokenize.word_tokenize停用词库 nltk.corpus.stopwords词干化 nltk.stem.PorterStemmer词形还原 nltk.stem.WordNetLemmatizer 2、案例 使用 Python 对自己的文本数据进行分词、去停用词操作并计算剩余单词的数量 文本如下 Dr. Smiths favorite movie in 2024 is Inception; he rates it 9/10 stars! Isnt that amazing? Lets analyze this #text with NLP techniques: homework1.py, line 42. 代码如下 from nltk import pos_tag from nltk.tokenize import word_tokenize from nltk.corpus import stopwords from nltk.stem import PorterStemmer,WordNetLemmatizerfrom src.common import utildef text_prepare(text):#分词print(f原始文本{text})tokens word_tokenize(text)print(f分词后{tokens})#去除停用词en_stopwords stopwords.words(english) #获取英文停用词表print(f去除停用词前文本长度{len(tokens)})filter_stop_words []for token in tokens:token token.lower()if token not in en_stopwords:filter_stop_words.append(token)print(f去除停用词后文本{filter_stop_words})print(f去除停用词后文本长度{len(filter_stop_words)})#词干化prepare_stem []porter_stemmer PorterStemmer()for token in filter_stop_words:token porter_stemmer.stem(token)prepare_stem.append(token)print(f词干化后{prepare_stem})#词性标注tagged_pos pos_tag(filter_stop_words)print(f词性标注后{tagged_pos})#词形还原prepare_lemma []wordnetLemma WordNetLemmatizer()for word, pos in tagged_pos:prepare_lemma.append(wordnetLemma.lemmatize(word,util.get_wordnet_pos(pos)))print(f词形还原后{prepare_lemma})def main():file_path examplewith(open(file_path, r, encodingutf-8)) as file:text file.read()text_prepare(text)if __name__ __main__:main() 运行结果 原始文本Dr. Smiths favorite movie in 2024 is Inception; he rates it 9/10 stars! Isnt that amazing? Lets analyze this #text with NLP techniques: homework1.py, line 42.分词后[, Dr., Smith, s, favorite, movie, in, 2024, is, Inception, , ;, he, rates, it, 9/10, stars, !, Is, nt, that, amazing, ?, Let, s, analyze, this, #, text, with, NLP, techniques, :, , homework1.py, ,, line, 42, ., ]去除停用词前文本长度40去除停用词后文本[, dr., smith, s, favorite, movie, 2024, inception, , ;, rates, 9/10, stars, !, nt, amazing, ?, let, s, analyze, #, text, nlp, techniques, :, , homework1.py, ,, line, 42, ., ] 去除停用词后文本长度32词干化后[, dr., smith, s, favorit, movi, 2024, incept, , ;, rate, 9/10, star, !, nt, amaz, ?, let, s, analyz, #, text, nlp, techniqu, :, , homework1.pi, ,, line, 42, ., ]词性标注后[(, ), (dr., NN), (smith, NN), (s, POS), (favorite, JJ), (movie, NN), (2024, CD), (inception, NN), (, ), (;, :), (rates, NNS), (9/10, CD), (stars, NNS), (!, .), (nt, RB), (amazing, VBG), (?, .), (let, NN), (s, POS), (analyze, JJ), (#, #), (text, JJ), (nlp, NN), (techniques, NNS), (:, :), (, NN), (homework1.py, NN), (,, ,), (line, NN), (42, CD), (., .), (, )]词形还原后[, dr., smith, s, favorite, movie, 2024, inception, , ;, rate, 9/10, star, !, nt, amaze, ?, let, s, analyze, #, text, nlp, technique, :, , homework1.py, ,, line, 42, ., ]
http://www.dnsts.com.cn/news/272718.html

相关文章:

  • 惠州网站建设服务商网站建设属于无形资产吗
  • 网站收录登录入口上海注册公司注册地址
  • 国内视频培训网站建设企业网站标题优化
  • wordpress做网站教程wordpress页面错乱
  • 网站开发后需要交接哪些材料asp网站怎么打开
  • 徐州专业做网站较好的公司wordpress dedecms哪个好
  • 创新的常州网站建设苏州做网站价格
  • 阿里云网站建设视频wordpress多用户多模板
  • 河北建设厅网站登陆怎么找附件中国建筑工程个人信息网
  • 网站开发软件h开头的wordpress系列文章实现
  • 哪些网站可以医生做兼职ui设计公司官网
  • 北京建外贸网站公司怀化市建设局网站
  • 做的好的有哪些网站wordpress分类信息导航
  • 用dw做网站的菜单栏网页站点的用途
  • 比较大网站建设公司炫酷的企业网站模板
  • 济南做外贸的网站公司重庆建站培训
  • discuz 企业网站广告制作单位
  • 网站不接入备案如何看免费的片
  • 公司网站可以用个人备案吗网站建设在国外
  • 网站网页优化技巧怎么看网站开发的发展
  • 上传网站根目录百度竞价一个月5000够吗
  • 免费注册网站有哪些运动 网站专题怎么做
  • 苏州网站优化推广做网站有什么
  • 网站建设简运维 简历wordpress 下拉框图标
  • 在线课堂网站开发怎么弄视频
  • 深圳做网站推荐哪家公司品牌创建策划方案
  • 品牌网站建设方案ppt建设网站简单的需要多少天
  • 58里面的网站怎么建设用jquery做网站好吗
  • 域名是什么有什么用淘宝关键词排名优化技巧
  • 企业门户网站建设方案怎么写网站规范建设