QT Programming QT-based Dictionary development series < two >--local dictionary design

Source: Internet
Author: User


the dictionary I designed not only allows you to look up words online, but also has a great feature of a rich local dictionary library : I've added eight types of dictionaries by default, as shown here:
because I am a communications professional, so joined the Communications Dictionary, Electronic Engineering dictionary, and because I love programming, but also added the C language basic function dictionary. Here's how to design a local dictionary:
selection of dictionary typesOf Course the TXT format is the best, because we can use the program to read directly. But online dictionaries are generally used in MDX format, LD2 format, I can not use QT to read directly. Finally, after continuous groping, online search, found that we can convert the MDX format dictionary through the software into TXT format!

download of the MDX dictionaryHow do I get the MDX-formatted dictionary? Direct Baidu MDX Dictionary can find the following search results:

choose to download the dictionary you want, here I use the first MDX dictionary in Http://bbs.meizu.cn/thread-3299845-1-1.html, "three-in-one Chinese dictionary" as an example.
view of the MDX dictionarybecause it is in MDX format, you can open it with Notepad and it will show garbled characters. So how do you check the contents of your downloaded dictionary? We can then open the MDX dictionary using a software mdict (click Download) that resolves the MDX format.
To illustrate:Suppose I download a "three-in-one Chinese dictionary. MDX", we first open the Mdict software to view the contents of the dictionary. First select "Thesaurus"-"Thesaurus Management"-"Add a dictionary" to join our downloaded dictionary file, then click on the "Thesaurus", from the drop-down list we just joined the "three-in-one Chinese dictionary." Then click on the left column to display the corresponding content in the right column. The detailed operation diagram is as follows:

Conversion of MDX dictionariesconverting an MDX-formatted dictionary to a TXT format requires the use of the Tools MDX Dictionary conversion tool (click Download), just to convert to a TXT file:

Open the TXT file with Notepad and we can find a similar language format:


We take the second act example, aadb for the word we want to check (note: Our dictionary here is the idiom dictionary, that is, to find aadb four pinyin first letter of the idiom), and the back <font </font><br> Is that we want to find the idiom, learn the web design people should know <font color= "#0000FF" ><br> starving </font><br> meaning, this is actually HTML language, will " Starving "into a blue font, as we saw in mdict. And just QT can recognize the HTML language, so even people like me who have not learned the HTML language need not bother to understand.
the processing of the TXT dictionaryWe basically finished the dictionary production, but for the sake of brevity, I kept the words and contents in the dictionary separate. For example, I renamed the TXT file above to Chinese.txt (for ease of programming), splitting it into the following file named Chinesea and Chineseb:

The advantage of this is that whenever I enter the content I want to query in the Search window (for example, input aadb), I just need to open the Chinesea file and find out if there is a word in it, instead of opening the entire dictionary (word + content) so that the lookup will be faster, Because it is obvious that the size of the Chinesea file is significantly smaller than the size of the Chinese file, there is a bit of benefit that will be mentioned in a later series of articles . As shown below:

about how to split the above file into two files, I think it should be very simple, I do not write a concrete implementation of this process, just say: first read the entire file, each read a row, in each row, When the first space is encountered, it is extracted into ChineseA.txt, and the remainder of the line is put into ChineseB.txt. It is worth noting that in two sub-files, the corresponding content should be in the same line!
Well, maybe that's so much, you too too complicated, too lazy to operate, think my local dictionary is enough, well, you can download the TXT format I have processed the dictionary file. Link to:http://download.csdn.net/detail/tengweitw/8588209
QT-based dictionary development series
    1. Dictionary frame design and finished product display
    2. Design of local dictionaries
works: http://download.csdn.net/detail/tengweitw/8548767

Original: http://blog.csdn.net/tengweitw/article/details/45014771

Nineheadedbird






QT Programming QT-based Dictionary development series < two >--local dictionary design


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.