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

营销型网站公司排名新闻最新头条10条

营销型网站公司排名,新闻最新头条10条,临沂网站建设服务,网站视频做栏目一般一期多钱原始数据和处理结果: https://gitcode.net/as604049322/blog_data/-/tree/master/mdx 下载help.mdx词典后,我们无法直接查看,我们可以使用readmdict库来完成对mdx文件的读取。 安装库: pip install readmdict对于Windows平台还…

原始数据和处理结果:

https://gitcode.net/as604049322/blog_data/-/tree/master/mdx

下载help.mdx词典后,我们无法直接查看,我们可以使用readmdict库来完成对mdx文件的读取。

安装库:

pip install readmdict

对于Windows平台还需要安装python-lzo:

pip install python-lzo

使用Python读取的示例:

from readmdict import MDXmdx_file = "help.mdx"
mdx = MDX(mdx_file, encoding='utf-8')
items = mdx.items()
for key, value in items:word = key.decode().strip()print(word, value.decode())break
a <link type="text/css" rel="stylesheet" href="jsmind.css"><script type="text/javascript" src="jsmind.js"></script><p id="jsmind_describe"></p><p id="jsmind_container"></p><script>jsMind.show({},{"meta":{"name":"etymology","version":"0.1"},"format":"node_array","data":[{"id":"a","isroot":true,"topic":"a","describe":"英[ə; eɪ]美[ə; e]art. 一"}]});document.getElementById('jsmind_container').style.height=document.querySelector('jmnodes').style.height;</script>

可以看到,词典详情数据以JavaScript脚本形式存在,我们可以使用正则+json进行解析:

import rejson.loads(re.findall('"data":(\[.+\])}\);', value.decode())[0])
[{'id': 'a','isroot': True,'topic': 'a','describe': '英[ə; eɪ]美[ə; e]art. 一'}]

当然这只是最简单的一种情况,下面我们看看一个存在树形关系的单词的例子:

from readmdict import MDX
import remdx_file = "help.mdx"
mdx = MDX(mdx_file, encoding='utf-8')
items = mdx.items()
for key, value in items:word = key.decode().strip()topic = json.loads(re.findall('"data":(\[.+\])}\);', value.decode())[0])if word == "abalienate":print(word, topic)break
abalienate [{'id': 'abalienate', 'isroot': True, 'topic': 'abalienate', 'describe': "英[æb'eiljəneit]美[æb'eiljəneit]【法】 让渡, 转移, 让出"}, {'id': 'ab-', 'parentid': 'abalienate', 'direction': 'left', 'topic': 'ab-', 'describe': '表示从,来自(from);从...离开,离开(away from, sway, off);不,非,表否定(not, opposite)。在字母v 前缩略成a-,在字母c, t 前扩展为abs-。来自拉丁介词ab。'}, {'id': 'alienate', 'parentid': 'abalienate', 'direction': 'left', 'topic': 'alienate', 'describe': "英['eɪlɪəneɪt]vt. 使疏远, 离间, 转让\n【第三人称单数:alienates;现在分词:alienating;过去式:alienated】"}, {'id': 'alien', 'parentid': 'alienate', 'direction': 'left', 'topic': 'alien', 'describe': "英['eɪlɪən]美[ˈeliən,ˈeljən]n. 外国人, 外侨\na. 外国的, 相异的\n【复数:aliens;现在分词:aliening;过去分词:aliened】"}, {'id': '-ate', 'parentid': 'alienate', 'direction': 'left', 'topic': '-ate', 'describe': [['表动词,“做,造成”。']]}, {'id': 'ali-', 'parentid': 'alien', 'direction': 'left', 'topic': 'ali-', 'describe': [['= other, to change, 表示“其他的,改变状态”,来源于拉丁语 alius "another, other, different."']]}, {'id': '-en', 'parentid': 'alien', 'direction': 'left', 'topic': '-en', 'describe': [['表名词,“人或物”,有时构成小词或昵称。']]}]

同时我们可以看到有部分词的描述可能会嵌套列表。

下面我们的目标是将每个单词都处理成如下形式:

最终的完整代码为:

from readmdict import MDX
import re
import json
import csvdef get_describe(describe):if isinstance(describe, (list, tuple)):return ';'.join(get_describe(i) for i in describe)else:return describedef deal_node(node, result=[], num=-1):chars = "■□◆▲●◇△○★☆"for k, (d, cs) in node.items():if num >= 0:d = d.replace('\n', '')result.append(f"{'    '*num}{chars[num]} {k}: {d}")if cs:deal_node(cs, result, num+1)def get_row(topic):id2children = {}root = {}for d in topic:node = id2children.get(d.get("parentid"), root)tmp = {}node[d['id']] = (get_describe(d['describe']), tmp)id2children[d['id']] = tmpname, (describe, _) = list(root.items())[0]txts = []deal_node(root, txts)other = "\n".join(txts)return name, describe, othermdx_file = "help.mdx"
mdx = MDX(mdx_file, encoding='utf-8')
items = mdx.items()
data = []
for key, value in items:word = key.decode().strip()topic = json.loads(re.findall('"data":(\[.+\])}\);', value.decode())[0])name, describe, other = get_row(topic)data.append((name, describe, other))with open(mdx_file.replace('.mdx', '-UTF8 .csv'), 'w', newline='', encoding='u8') as f:cw = csv.writer(f, delimiter=',')cw.writerow(["单词", "释义", "扩展"])cw.writerows(data)
http://www.hkea.cn/news/532992/

相关文章:

  • 网站建设的小结可以发外链的论坛有哪些
  • 网站正常打开速度网店营销与推广策划方案
  • 义乌 网站制作进入百度app
  • 做外围网站赌球红树林seo基础入门免费教程
  • 绿色风格网站seo排名赚钱
  • 南宁企业免费建站百度推广营销怎么做
  • 建立个人网站的成本短视频seo营销系统
  • 深圳公司名称大全网站结构优化的内容和方法
  • 安康市代驾公司上海网站关键词排名优化报价
  • 怎么在网站上建设投票统计在线培训系统app
  • 泰州网站建设哪家好网站seo的主要优化内容
  • 洛卡博网站谁做的seo权重查询
  • 东莞网络科技公司有哪些山东网站seo
  • 网站建设需要学什么网站模板购买
  • 用html做的游戏网站关键词推广效果分析
  • 做影视网站引流正规推广平台有哪些
  • 免费下载简历模板北京seo排名厂家
  • 西昌市做网站的百度搜索排名靠前
  • 办公室装修实景拍摄图重庆seo俱乐部联系方式
  • 网站建设阶段推广计划书怎么写
  • 代做毕业设计网站现成注册网站平台
  • 电商网站开发工作计划企业网络营销策划
  • 用wps网站栏目做树形结构图网页设计代码案例
  • 多媒体网站设计开发是指什么每日关键词搜索排行
  • 网站 seo正规网络公司关键词排名优化
  • 建立网站赚多少钱seo收录排名
  • 怎么做app网站seo学习网站
  • 广西建设职业技术学院官网免费的seo优化
  • 凡科网电脑版怎么做网站百度知道官网手机版
  • 贵卅省住房和城乡建设厅网站周口seo推广