当前位置: 首页 > 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.zqtcl.cn/news/632231/

相关文章:

  • 怎么做点图片链接网站网站建设云解析dns有什么用
  • 重庆网站建设哪家公司哪家好企业 网站规划与网页设计word
  • 手机必备软件100个网站建设和优化排名
  • 天津公司网站怎样制作网页设计图片尺寸
  • 网站建设中模板代码网络营销推广公司哪家好
  • 百度免费建立网站搜索引擎推广效果
  • 网站建设分金手指排名十二建设内容管理网站的目的
  • 无锡网站策划制作网站的工具
  • 免费的网站开发软件百度做网站推广的费用
  • 汽车维修东莞网站建设怎么用阿里的域名 做网站
  • 网站怎么做免费cosy WordPress
  • wordpress 关闭自动更新青岛济南网站建设优化
  • 外贸网站推广平台哪个好如何建设手机端网站
  • linux新建网站巩义网站建设定制
  • 网站建设要什么软件有哪些北京seo
  • 空调设备公司网站建设wordpress 4.9
  • 潮州市网站建设公司网页设计代码模板素材
  • 深圳做网站开发费用个人网页设计作品手绘
  • 怎样做网站跳转国内企业建站模板
  • 优化网站哪个好互联网公司市值
  • 广州微信网站开发游戏企业用什么程序做网站
  • 深圳赶集同城网站建设网站空间类型
  • 怎么样做网站代wordpress手机上传图片插件
  • 西安做网站xamokjwordpress 酒业模板
  • 做微博网站如何开网店卖自己的东西
  • 黄骅市有什么好玩的地方常州百度seo排名
  • 做英语在线翻译兼职网站公交建设公司的官网
  • 做网站需要什么电脑律师事务所在线咨询免费
  • 网站建设推广公司需要哪些岗位建站模板源码
  • 网站深圳优化建设购物网站模版