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

关键词能报价的网站北京网站备案的地址

关键词能报价的网站,北京网站备案的地址,wordpress文章后添加除非,中国电子商务公司排名一、任务目标 python代码写将 HarryPorter 电子书作为语料库#xff0c;分别使用词袋模型#xff0c;TF-IDF模型和Word2Vec模型进行文本向量化。 1. 首先将数据预处理#xff0c;Word2Vec 训练时要求考虑每个单词前后的五个词汇#xff0c;地址为 作为其上下文 #xf…一、任务目标 python代码写将 HarryPorter 电子书作为语料库分别使用词袋模型TF-IDF模型和Word2Vec模型进行文本向量化。 1. 首先将数据预处理Word2Vec 训练时要求考虑每个单词前后的五个词汇地址为 作为其上下文 生成的向量维度为50维 2.分别搜索 courtroom 和 wizard 这两个词语义最近的5个单词 3.对wizard 和witch 这两个单词在二维平面上进行可视化 二、代码部分 nltk.download(punkt) nltk.download(stopwords) from nltk.corpus import stopwords from nltk.tokenize import word_tokenize from gensim.models import Word2Vec from gensim.models import TfidfModel from gensim.corpora import Dictionary import matplotlib.pyplot as plt# 导入停用词 stop_words set(stopwords.words(english))# 加载数据 corpus_file /Users/zhengyawen/Downloads/HarryPorter.txt with open(corpus_file, r, encodingutf-8) as file:data file.read()# 预处理数据 sentences [word_tokenize(sentence.lower()) for sentence in data.split(.)] preprocessed_sentences [] for sentence in sentences:valid_words []for word in sentence:if word.isalpha() and word not in stop_words:valid_words.append(word)preprocessed_sentences.append(valid_words)# 构建Word2Vec模型 w2v_model Word2Vec(sentencespreprocessed_sentences, vector_size50, window5, min_count1, sg0)# 获取单词向量 vector_courtroom w2v_model.wv[courtroom] vector_wizard w2v_model.wv[wizard]# 搜索与“courtroom”和“wizard”最相似的5个单词 similar_words_courtroom w2v_model.wv.most_similar(courtroom, topn5) similar_words_wizard w2v_model.wv.most_similar(wizard, topn5)print(Word2Vec模型:) print(单词 courtroom 的向量:, vector_courtroom) print(单词 wizard 的向量:, vector_wizard) print(语义最近的5个单词 (courtroom):) for word, similarity in similar_words_courtroom:print(f{word}: {similarity})print(\n语义最近的5个单词 (wizard):) for word, similarity in similar_words_wizard:print(f{word}: {similarity})# 构建词袋模型 dictionary Dictionary(preprocessed_sentences) corpus [dictionary.doc2bow(sentence) for sentence in preprocessed_sentences] tfidf_model TfidfModel(corpus) corpus_tfidf tfidf_model[corpus]# 可视化Word2Vec模型中wizard和witch的向量 words_to_plot [wizard, witch] word_vectors [w2v_model.wv[word] for word in words_to_plot]# 可视化 plt.figure(figsize(10, 6)) for i, word in enumerate(words_to_plot):plt.scatter(word_vectors[i][0], word_vectors[i][1], labelword)plt.xlabel(Dimension 1) plt.ylabel(Dimension 2) plt.title(Visualization of Word Vectors) plt.legend() plt.show()三、代码运行结果
http://www.pierceye.com/news/632231/

相关文章:

  • 福田我要做网站优化比较好wordpress美图模板
  • wordpress 分享可见湖南优化电商服务有限公司
  • 高培淇自己做的网站网站页面可以用什么框架做
  • 在线推广企业网站的方法有哪些门户网站例子
  • 网站集约化建设 技术优质网站建设是哪家
  • 网站技术制作广州番禺建设银行网站登录
  • 女同性怎么做的视频网站wordpress 文章 定时
  • 域名备案时网站名字wordpress mip主题
  • 旅行社服务网点能否做网站wordpress4.9.8 php版本
  • 网站名称 如何注册wordpress用户名的要求
  • 玉树州wap网站建设公司常州市工程建设招标网
  • 自助网站建设技术支持如何做网站代码
  • 企业数据查询网站word 没有安装wordpress
  • 注册一个设计公司需要多少钱重庆网站建设及优化
  • 青岛企业建设网站公司如何传图片做网站
  • 手机网站源码教程个人博客系统的设计与实现
  • 高端网站改版南京网站如何制作
  • 个人网站建设课程专业彩票网站开发 APP开发
  • 学网站开发首先学哪些基础兰州网站设计哪个平台好
  • 网站后台看不到部分内容桐庐建设局网站
  • 宁夏网站建设费用地址wordpress建站好用吗
  • 微信网站制作哪个好吕梁网站制作
  • 手机怎么制作自己的网站线上运营推广方案
  • 泉州企业制作网站wordpress上传顶部图像
  • php建立网站广州创意设计公司
  • 东营专业网站建设济南天桥区网站建设公司
  • 鹤壁做网站多少钱网站开发 简单留言板
  • 网站建设 阿里东莞seo建站优化公司
  • logo设计竞标网站wordpress攻击跳转
  • 专门做瑜伽的网站wordpress docker镜像