Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Jerry to list the idioms used in Jin Yong's novels

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Jerry to list the idioms used in Jin Yong's novels". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Jerry to list the idioms used in Jin Yong's novels.

Jerry briefly talks about the principle of implementation. There is a text file in the Web app that maintains all Chinese idioms separated by semicolons.

At run time, this content is loaded into memory and built into a tree, as shown in the following figure:

The leaf node is distinguished by the attribute end as true.

The core logic of idiom retrieval lies in the search function. Let's use a loud slogan in "The Smiling、Proud Wanderer" to debug and understand its realization logic step by step.

Enter the outer while loop on line 165and then enter the inner for loop on line 173to see if there is an idiom that begins with the first character "day" of the test string. Because the idiom is made up of four characters, you need to use the inner for loop to explore one by one. If you encounter an element whose tblCur.end is true, you have found an idiom in the test string.

The following figure shows the tblCur content after the inner for loop is executed for the first time:

The inner loop executes a second time, when tblCur points to a tree made up of all the idioms that begin with "sun and moon":

Perform the third iteration of the inner loop, because there is no "god" node under the "sun-moon" branch of the tree, so end the current inner loop, return to the outer while loop through break, and do a new round of trials to enter the second character "month" of the string, and so on.

Finally, starting from the character "thousand", passing through the path "Qiu-Wan" along the tree in memory, and finally coming to the leaf node "load" whose end attribute is true, write down the offset of "thousand" in the input string and save it in an array arrMatch.

After all the input strings are tested, the corresponding strings are highlighted according to the offset stored in arrMatch, and the retrieval is completed.

Tree as a data structure has a perfect performance in the implementation of this requirement.

At this point, I believe you have a deeper understanding of "how to use Jerry to list the idioms used in Jin Yong's novels". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report