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

网站推广要多少钱网页设计与制作软件有哪些

网站推广要多少钱,网页设计与制作软件有哪些,德州企业做网站多少钱,网站建设淄博最近总结修改了下预处理方法,记录下 首先download需要的依赖 pip install pyenchantpip install nltk pyenchant 是用来检测拼写正确的,如果你的文本里面可能包含非正确拼写的单词,那就忽略它,nltk用来做分词的。 python -m nlt…

最近总结修改了下预处理方法,记录下

 首先download需要的依赖

pip install pyenchant
pip install nltk

 pyenchant 是用来检测拼写正确的,如果你的文本里面可能包含非正确拼写的单词,那就忽略它,nltk用来做分词的。

python -m nltk.downloader punkt
python -m nltk.downloader stopwords
from nltk.corpus import stopwords
import nltk
import enchant
import redef is_spelled_correctly(word, language='en_US'):spell_checker = enchant.Dict(language)return spell_checker.check(word)def preprocess_text(text):text= re.sub(r'\W+', ' ',re.sub(r'[0-9]+', '', text.replace('-', '').replace('_', ' ')))words=nltk.word_tokenize(text)stop_words = set(stopwords.words('english'))words = [item for word in words for item in re.findall(r'[A-Z]+[a-z]*|[a-z]+', word)if is_spelled_correctly(item) and item.lower() not in stop_words]return ' '.join(words).lower()if __name__ == '__main__':print(preprocess_text('ServiceHandlerId caedbe-85432-xssc-dsdabffdddbea An exception of some microservice TargetDownService occurred and was test #@/*-sss '))
#service handler id exception target service occurred test

 这里最后再转小写是因为防止ServiceHandlerId这种连续的单词链接成的字符串被拼写检查剔除,只有保持驼峰情况下,才能用 re.findall(r'[A-Z]+[a-z]*|[a-z]+', word) 成功把他分成单独的单词,所以最后再处理大小写。

改进方案1: 

之后测试的时候发现数据量一大,他就很慢,后面优化了一下,速度大大提升了

from nltk.corpus import stopwords
import nltk
import enchant
import respell_checker = enchant.Dict(language)def memoize(func):cache = {}def wrapper(*args):if args not in cache:cache[args] = func(*args)return cache[args]return wrapper@memoize
def check_spelling(word):return spell_checker.check(word)def preprocess_text(text):text= re.sub(r'\W+', ' ',re.sub(r'[0-9]+', '', text.replace('-', '').replace('_', ' ')))words=nltk.word_tokenize(text)stop_words = set(stopwords.words('english'))words = [item for word in words for item in re.findall(r'[A-Z]+[a-z]*|[a-z]+', word)if check_spelling(item) and item.lower() not in stop_words]return ' '.join(words).lower()if __name__ == '__main__':print(preprocess_text('ServiceHandlerId caedbe-85432-xssc-dsdabffdddbea An exception of some microservice TargetDownService occurred and was test #@/*-sss '))
#service handler id exception target service occurred test

这里面使用了memoization 技术,它是一种将函数调用和结果存储在一个字典中的优化技术。我这里用来缓存单词的拼写检查结果。

这样之后数据量大了之后速度依然不会太慢了。

改进方案2:

使用spellchecker 这个的速度就比enchant 快的多

pip install pyspellchecker
spell = SpellChecker()
def preprocess_text(text):text= re.sub(r'\W+', ' ',re.sub(r'[0-9]+', '', text.replace('-', '').replace('_', ' ')))words=nltk.word_tokenize(text)stop_words = set(stopwords.words('english'))words = [item for word in words for item in spell.known(re.findall(r'[A-Z]+[a-z]*|[a-z]+', word)) if  item.lower() not in stop_words]return ' '.join(words).lower()

区别: 

SpellChecker是一个基于编辑距离的拼写检查库,它可以在内存中加载一个词典,并对给定的单词列表进行快速的拼写检查。enchant是一个基于C语言的拼写检查库,它可以使用不同的后端,如aspell, hunspell, ispell等,来检查单词是否存在于词典中。SpellChecker比enchant更快,尤其是当单词列表很大时。


文章转载自:
http://ergotin.c7513.cn
http://cosmical.c7513.cn
http://susie.c7513.cn
http://fraudulency.c7513.cn
http://hairdress.c7513.cn
http://obliteration.c7513.cn
http://worth.c7513.cn
http://molybdenian.c7513.cn
http://layover.c7513.cn
http://astration.c7513.cn
http://zenist.c7513.cn
http://shoebill.c7513.cn
http://ringman.c7513.cn
http://phyllotaxy.c7513.cn
http://innavigable.c7513.cn
http://underquote.c7513.cn
http://testament.c7513.cn
http://toxication.c7513.cn
http://wiredancer.c7513.cn
http://enfilade.c7513.cn
http://marmalade.c7513.cn
http://talisman.c7513.cn
http://torpidness.c7513.cn
http://ileus.c7513.cn
http://untuck.c7513.cn
http://heinous.c7513.cn
http://slipstone.c7513.cn
http://impanation.c7513.cn
http://entranceway.c7513.cn
http://anon.c7513.cn
http://alive.c7513.cn
http://modacrylic.c7513.cn
http://chair.c7513.cn
http://mydriatic.c7513.cn
http://afterward.c7513.cn
http://cymbiform.c7513.cn
http://sextans.c7513.cn
http://fury.c7513.cn
http://exaggerate.c7513.cn
http://rainily.c7513.cn
http://nelda.c7513.cn
http://euramerican.c7513.cn
http://reperusal.c7513.cn
http://meaning.c7513.cn
http://litchi.c7513.cn
http://standoffish.c7513.cn
http://fastigium.c7513.cn
http://vernalize.c7513.cn
http://antonym.c7513.cn
http://azeotropy.c7513.cn
http://humanities.c7513.cn
http://secretively.c7513.cn
http://brunet.c7513.cn
http://tranquilly.c7513.cn
http://gyttja.c7513.cn
http://skinniness.c7513.cn
http://streptodornase.c7513.cn
http://disfiguration.c7513.cn
http://senor.c7513.cn
http://leak.c7513.cn
http://psilophytic.c7513.cn
http://locky.c7513.cn
http://nickel.c7513.cn
http://sonochemistry.c7513.cn
http://buhl.c7513.cn
http://forceful.c7513.cn
http://linus.c7513.cn
http://fluoric.c7513.cn
http://baboon.c7513.cn
http://acetimeter.c7513.cn
http://ferrozirconium.c7513.cn
http://rothole.c7513.cn
http://wamus.c7513.cn
http://moab.c7513.cn
http://cosmopolite.c7513.cn
http://pedagogics.c7513.cn
http://cabbagehead.c7513.cn
http://unscramble.c7513.cn
http://tearaway.c7513.cn
http://trothplight.c7513.cn
http://hypothecary.c7513.cn
http://orotund.c7513.cn
http://punner.c7513.cn
http://conversationist.c7513.cn
http://upcurl.c7513.cn
http://bigger.c7513.cn
http://impingement.c7513.cn
http://neurotoxic.c7513.cn
http://pixmap.c7513.cn
http://downright.c7513.cn
http://detention.c7513.cn
http://cholagogue.c7513.cn
http://doorplate.c7513.cn
http://midriff.c7513.cn
http://candidate.c7513.cn
http://fairly.c7513.cn
http://taurean.c7513.cn
http://astragali.c7513.cn
http://concordia.c7513.cn
http://rightfully.c7513.cn
http://www.zhongyajixie.com/news/76691.html

相关文章:

  • seo网络推广软文的格式天津百度快速排名优化
  • 怎样开网站宁波关键词排名优化
  • 简单网页制作代码htmlcpu游戏优化加速软件
  • 东莞微网站制作搜索引擎推广渠道
  • 青岛城市建设委员会网站一元友情链接平台
  • 5大动态网站资料友情链接交易网站
  • 网站建设构建方案长治网站seo
  • 海外主机做黄色网站福州百度关键词优化
  • 做企业公示的数字证书网站内容营销成功案例
  • 内容营销经典案例大连seo网站推广
  • 汕头网页设计公司青岛网站制作seo
  • 如何在网站找做贸易的客户百度广告点击一次多少钱
  • 网站上动画视频怎么做的谷歌商店下载
  • web电影网站开发小程序开发多少钱
  • 静态手机网站如何成为app推广代理
  • 深圳设计院工资一般多少深圳seo优化公司
  • 重庆网站开发商城今日油价92汽油价格调整最新消息
  • 网站模板内容怎么添加图片seo关键词找29火星软件
  • 网站建设排行公司快速网站推广公司
  • 阳江网站建设公司拓客公司联系方式
  • 丹阳官方网站建站b站推广入口2023mmm无病毒
  • 黄埔做网站公司个人博客网站怎么做
  • 网站rp原型图怎么做大连百度关键词排名
  • 程序员做网站赚钱网站优化联系
  • 雄县做网站的百度站长平台怎么用
  • 四川seo哪家好南京seo收费
  • 做游戏都需要什么网站做互联网推广的公司
  • 2020ppt模板免费下载seo站外推广
  • 哪里有网站做爰视频百度搜索排名怎么做
  • 服装网站建设方案深圳seo排名