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

旅游后台网站app域名在哪里注册

旅游后台网站,app域名在哪里注册,网页制作与网站建设服务器,建设工程自学网站一#xff1a;爬取词库#xff0c;使用jieba分词库#xff0c;自定义dict.txt文件 import jiebafrom urllib.request import urlopen from bs4 import BeautifulSoup# 来源于地图搜索数据#xff0c;按照网民输入习惯精心筛选使用较多的词条。包含城市地名、公交、购物、餐…一爬取词库使用jieba分词库自定义dict.txt文件 import jiebafrom urllib.request import urlopen from bs4 import BeautifulSoup# 来源于地图搜索数据按照网民输入习惯精心筛选使用较多的词条。包含城市地名、公交、购物、餐饮、楼盘等各种信息适合本地区网友使用 url http://search.qinggl.com/dict-3687.html html urlopen(url).read().decode(utf-8) soup BeautifulSoup(html, featureslxml) urls soup.find_all(div, {id: box-new,class:wordbox basic}) print(urls) print(type(urls)) x str(urls) x x.replace(span,) x x.replace(span,) x x.replace(/span,\n) x x.replace(/div,) x x.split(\n) x x[1:] x.pop() print(len(x)) print(x)jieba.load_userdict(./dict.txt) word_list jieba.cut(我今天不处理逾期信用贷款因为成都木材防腐厂根本打不开.我几天想去语过添情网吧开心happy一下。) print(|.join(word_list)) # #D:\anacoda\envs\nlp\Lib\site-packages\jieba 二将搜狗词库.scel文件为.txt文件 # -*- coding: utf-8 -*- import struct import os# 主要两部分 # 1.全局拼音表貌似是所有的拼音组合字典序 # 格式为(index,len,pinyin)的列表 # index: 两个字节的整数 代表这个拼音的索引 # len: 两个字节的整数 拼音的字节长度 # pinyin: 当前的拼音每个字符两个字节总长len # # 2.汉语词组表 # 格式为(same,py_table_len,py_table,{word_len,word,ext_len,ext})的一个列表 # same: 两个字节 整数 同音词数量 # py_table_len: 两个字节 整数 # py_table: 整数列表每个整数两个字节,每个整数代表一个拼音的索引 # # word_len:两个字节 整数 代表中文词组字节数长度 # word: 中文词组,每个中文汉字两个字节总长度word_len # ext_len: 两个字节 整数 代表扩展信息的长度好像都是10 # ext: 扩展信息 前两个字节是一个整数(不知道是不是词频) 后八个字节全是0 # # {word_len,word,ext_len,ext} 一共重复same次 同音词 相同拼音表# 拼音表偏移 startPy 0x1540;# 汉语词组表偏移 startChinese 0x2628;# 全局拼音表 GPy_Table {}# 解析结果 # 元组(词频,拼音,中文词组)的列表# 原始字节码转为字符串 def byte2str(data):pos 0str while pos len(data):c chr(struct.unpack(H, bytes([data[pos], data[pos 1]]))[0])if c ! chr(0):str cpos 2return str# 获取拼音表 def getPyTable(data):data data[4:]pos 0while pos len(data):index struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]pos 2lenPy struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]pos 2py byte2str(data[pos:pos lenPy])GPy_Table[index] pypos lenPy# 获取一个词组的拼音 def getWordPy(data):pos 0ret while pos len(data):index struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]ret GPy_Table[index]pos 2return ret# 读取中文表 def getChinese(data):GTable []pos 0while pos len(data):# 同音词数量same struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]# 拼音索引表长度pos 2py_table_len struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]# 拼音索引表pos 2py getWordPy(data[pos: pos py_table_len])# 中文词组pos py_table_lenfor i in range(same):# 中文词组长度c_len struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]# 中文词组pos 2word byte2str(data[pos: pos c_len])# 扩展数据长度pos c_lenext_len struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]# 词频pos 2count struct.unpack(H, bytes([data[pos], data[pos 1]]))[0]# 保存GTable.append((count, py, word))# 到下个词的偏移位置pos ext_lenreturn GTabledef scel2txt(file_name):print(- * 60)with open(file_name, rb) as f:data f.read()print(词库名, byte2str(data[0x130:0x338])) # .encode(GB18030)print(词库类型, byte2str(data[0x338:0x540]))print(描述信息, byte2str(data[0x540:0xd40]))print(词库示例, byte2str(data[0xd40:startPy]))getPyTable(data[startPy:startChinese])getChinese(data[startChinese:])return getChinese(data[startChinese:])#scel2txt(.ChengDuInformationWord.scel)if __name__ __main__:# scel所在文件夹路径in_path rD:\InternetOffice\code# 输出词典所在文件夹路径out_path rD:\InternetOffice\code#fname ChengDuInformationWord.scelfin [fname for fname in os.listdir(in_path) if fname[-5:] .scel]for f in fin:try:for word in scel2txt(os.path.join(in_path, f)):file_path (os.path.join(out_path, str(f).split(.)[0] .txt))# 保存结果with open(file_path, a, encodingutf-8)as file:file.write(word[2] \n)os.remove(os.path.join(in_path, f))except Exception as e:print(e)pass
http://www.ihoyoo.com/news/110366.html

相关文章:

  • 网站建设与代运营介绍杭州绿城乐居建设管理有限公司网站
  • 做网站asp和asp.net无锡工程建设招标网站
  • 外贸soho自己建站春节网页设计主题
  • 门户网站创新的方式有12306网站的建设历程
  • 青岛开发区做网站设计的四川冠辰网站建设
  • 网站建设培训内容wordpress指定域名
  • 为什么做电影网站没有流量吗七牛云wordpress缓存配置
  • 自己做卖东西网站中山搜索排名提升
  • 品牌网站建设只詢大蝌蚪怎么做网站的主页面
  • 西安网站制作流程建一个网站式系统
  • 地方门户网站如何盈利dede手机网站仿站
  • 网站用ps下拉效果怎么做就业创业网站建设
  • wordpress网站扫描工具义乌门户网站建设
  • 信誉好的营销单页网站化妆品网站建设可行性报告
  • 多媒体资源库网站建设专业做厂房的网站
  • 客户评价 网站如何留住网站用户
  • 自己做的网站怎么上线编程自学
  • 怎么做网站数据库2017年做网站多少钱
  • 网站建设的优点和缺点个人网站 怎么设计
  • 怎么在新建网站上做分享代码做跨境的网站有哪些内容
  • 图片网站优化学生做防溺水题的网站
  • 中国工业设计网站最超值的锦州网站建设
  • 西部数据网站建设中国企业黄页大全
  • 学校校园网站建设实践选题背景做目的旅游网站的
  • 建设项目网站网站建设技术支持祥云平台
  • 营销网站的关键字怎样用jsp做网站登录
  • 摄影网站介绍网站开发推荐一本书
  • 如何做好品牌网站建设策划书广州地产网站设计
  • wp建站做知乎网站要多少钱
  • php做网站导购模板我想要个网站