linux英英词典项目,[开发手记] 一款基于命令行的英英词典 (A CLI-Based EE Dictionary)...

A CLI-Based EE Dictionary Supported by API of "Merriam-Webster‘s Collegiate® Dictionary with Audio"

(一款基于命令行的英英词典, 由API提供支持)

如果有疑问及建议请在该repository页面的issues中提出!

准备工作:

了解Java对XML文件的解析

了解Java对文件的读写(用于存储Cache文件)

程序流程:

COND1: 传入单词或词组 -> 本地是否已有缓存文件? -> 否 -> 拼接请求URL -> 提交 -> 取得返回XML -> 保存在本地 -> 开始解析XML文件

-> 是否为有效查询? -> 是 -> 打印结果

-> 否 -> 是否有建议单词或词组? -> 是 -> 提示查无此词并打印建议 -> 删除本地缓存文件

-> 否 -> 提示查无此词 -> 删除本地缓存文件

COND2: 传入单词或词组 -> 本地是否已有缓存文件? -> 是 -> 开始解析XML文件 -> 打印结果

可以看出将查询有效的结果缓存在本地可以极大程度的简化重复查询的流程, 以提高效率.

难点:

返回的XML层次极为复杂, 需要逐级拆解以提取有效信息

不同层次信息的组织与显示

注意事项:

1 File file = new File(CACHE_PATH, string + ".tmp");2 DocumentBuilderFactory documentBuilderFactory =DocumentBuilderFactory.newInstance();3 DocumentBuilder documentBuilder =documentBuilderFactory.newDocumentBuilder();4 Document document =documentBuilder.parse(file);5 Element rootElement =document.getDocumentElement();6 NodeList content = rootElement.getChildNodes();

首先读出请求之后缓存在本地的结果文件, 将其解析为Document类, 再使用DOM方法去解析XML中的节点信息

逐层解析后, 将收集到的信息根据XML中的结点层次有序的反馈在CLI中

(具体实现请见见项目地址中的源码, 注释会陆续补充)

截图:

帮助信息(正在完善中)

20180110204001821838.png

有效查询结果

20180110204001829650.png

无效查询结果并提供拼写建议

20180110204001843323.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux 大全; 按照A~Z区分; A a−Linux a−Linux is an x86 floppy−based mini−distribution, where assembly code meets Linux kernel. It contains only programs written in assembly language. It is extemely small, yet functional, and provides HTTP and FTP services out−of−the−box. Initial version 0.17 was released August 17, 2002. A floppy−based distribution. From LWN Distribution List http://www.tldp.org/LDP/LinuxDictionary/html/index.html a2p Awk to Perl translator From whatis http://www.tldp.org/LDP/LinuxDictionary/html/index.html a2ps GNU a2ps 'Anything to PostScript' converter and pretty−printer a2ps converts files into PostScript for printing or viewing. It uses a nice default format, usually two pages on each physical page, borders surrounding pages, headers with useful information (page number, printing date, file name or supplied header), line numbering, symbol substitution as well as pretty printing for a wide range of programming languages. Historically, a2ps started as a text to PostScript converter, but thanks to powerful delegations it is able to let you use it for any kind of files, ie it can also digest manual pages, dvi files, texinfo, .... Among the other most noticeable features of a2ps are: − various encodings (all the Latins and others), − various fonts (automatic font down loading), − various medias, − various printer interfaces, − various output styles, − various programming languages, − various helping applications, − and various spoken languages. From Debian 3.0r0 APT http://www.tldp.org/LDP/LinuxDictionary/html/index.html a2ps The a2ps filter converts text and other types of files to PostScript format. A2ps has pretty−printing capabilities and includes support for a wide number of programming languages, encodings (ISO Latins, Cyrillic, etc.), and media. From Redhat 8.0 RPM http://www.tldp.org/LDP/LinuxDictionary/html/index.html a52dec Utilities to extract and decode ATCS A/52 streams Utilities to extract and decode ATCS A/52 streams. The A/52 standard is used in a variety of applications, including digital television and DVD. It is also known as AC−3. From Debian 3.0r0 APT http://www.tldp.org/LDP/LinuxDictionary/html/index.html AA Auto Answer (MODEM) From VERA http://www.tldp.org/LDP/LinuxDictionary/html/index.html aa3d An ASCII art stereogram generator This program generates the well known and popular random dot stereograms in ASCII art. From Debian 3.0r0 APT http://www.tldp.org/LDP/LinuxDictionary/html/index.html AAA Authentication, Authorization and Accounting From VERA http://www.tldp.org/LDP/LinuxDictionary/html/index.html AAC Advanced Audio Coding (IIS, MPEG) From VERA http://www.tldp.org/LDP/LinuxDictionary/html/index.html AAC Authorization and Access Control (IETF) From VERA http://www.tldp.org/LDP/LinuxDictionary/html/index.html AAD Authorized AutoCAD Dealer (AutoCAD, CAD) From VERA http://www.tldp.org/LDP/LinuxDictionary/html/index.html A
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值