大吉SEO:自动提取文章关键词和高频词

seo问答评论32阅读模式
摘要

我们做文章相关推荐的时候,需要根据关键词来调用相关文章,从而提高页面的相关性。那我们需要实现这个效果的话,下一步就是提取文章关键词了。

  2 通过程序提取文章的关键词。

  如果文章的量比较多。用程序的方法是比较便捷的,python中一个nltk模块,里面有相应的方法来提取页面的核心词。

  上代码:

  import nltk

  from nltk.probability import FreqDist

  binfo = '''

  shibang Mibile Crusher offers optimum set-up flexibility, from coarse to fine bashing, and is cost efficient. The application improves working safety, reduces the need for quarry highway maintenance, and gives coal minng significantly better access to material information. A further benefit is this : waste material can be separated on-site. shibang Mibile Crusher can be arranged to provide a two-stage crushing and evaluating system, as a three-stage abrasive, secondary and tertiary mashing and screening method, or as three independent units. Getting crushing and evaluating process on small wheels really boosts approach efficiency. shibang Mibile Crusher can be used for all mobile mashing applications, opening up clients opportunities. shibang Collection Cell Crusher is wholly adaptable to all cellular crushing needs.The item sets up a new variety of business opprtunities for trades-people,quarry operators, recycling along with mining applications.

  '''

  textinfo = nltk.word_tokenize(binfo)##分词

  tagged = nltk.pos_tag(textinfo)##词性

  fdist1 = FreqDist(textinfo)

  minfo = dict(fdist1)

  info = list(set([k.lower() for k,v in tagged if v == 'NN']))##所有名词

  kinfo = [(k,minfo.get(k)) for k in info]

  kinfo.sort(key=lambda k:k[1],reverse=True)

  print ",".join([m[0] for m in kinfo[:5]])

  输出的结果就是:shibang,crushing,material,mashing,process

  这是出现频率最高的5个名词。

方法SEO:网站组织系统和网站架构

精确的体系,会将信息分别定义明确的区域,规律是可循的。比如电话本的字母顺序就是一个经典的例子,B就是在A前面。

蒲公英博客
  • 本文由 发表于 2023年3月21日 11:55:33
  • 转载请务必保留本文链接:https://www.yjro.com/457572.html

发表评论