Text loading method

Through tagged cache and dynamic cache adjustment strategies, combined with deep learning technology and distributed network, the problems of low efficiency of rich text parsing and waste of resources in iOS system are solved, and efficient rich text loading and cache management are realized, ensuring the stability of the system effective utilization of sex and resources.

CN119294354APending Publication Date: 2025-01-10SHANGHAI EHI CAR RENTAL CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411241254.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-05
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

In iOS system, the rich text parsing process is inefficient and resource waste is severe, especially when switching between front and backend, it is easy to trigger crashes, especially high-frequency list label parsing, resulting in duplicate parsing, wasting system resources.

Method used

Adopt a tag-based cache strategy, split and cache rich text data according to labels, analyze pictures and text separately, introduce dynamic cache adjustment mechanism, and adopt memory and disk double cache or short-term cache strategies according to the tag access frequency and update frequency, and use depth Learning technology builds an analytical model, and uses distributed networks to caching and load balancing.

Benefits of technology

It significantly improves the efficiency of rich text loading, reduces resource waste, ensures the effectiveness and timeliness of cache, avoids repeated parsing operations, and improves the stability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119294354A_ABST
    Figure CN119294354A_ABST
Patent Text Reader

Abstract

The invention discloses a text loading method which comprises the following steps: S1, loading rich text data to be processed and sending the rich text data to a label analyzer, and splitting a label of the rich text data to be processed into a plurality of label blocks by the label analyzer according to a preset label rule; s2, sequentially checking whether each tag block exists in a tag buffer or not, if so, directly loading the content of the corresponding tag block in the tag buffer without analyzing, and if not, executing the next step for analyzing; s3, the label parser parses the label blocks formed by splitting in the step S1 according to two categories of pictures and texts, and caches the parsed content according to the label blocks and labels; the method comprises the following steps of: splitting contents according to tags by adopting a tagging cache strategy, and creating an independent cache item for each tag; when the label content changes, only the corresponding cache needs to be updated, the whole rich text does not need to be reloaded, and the loading efficiency is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of text processing, and in particular to a text loading method for optimizing a label processing process of an iOS system. Background Art

[0002] During the development of the project, it is often necessary to process images, texts and html (Hypertext Markup Language) tag texts, and they need to be parsed into NSMutableAttributedString texts that can be recognized by the iOS system. This process is very time-consuming, especially for html tag texts, which can easily trigger crashes when switching between the foreground and background.

[0003] At present, in order to deal with the above-mentioned rich text parsing performance issues, a common method is to open up multi-threaded parsing, which can speed up the parsing speed without blocking the main thread and affecting user page interaction. However, when encountering high-frequency list tags, this method will result in a large number of repeated parsing, wasting system resources.

[0004] The statements herein merely provide background art related to the present invention and do not necessarily constitute prior art. Summary of the invention

[0005] The purpose of the present invention is to solve the current problems of low efficiency and waste of resources when performing rich text parsing.

[0006] To achieve the above object, the present invention discloses a text loading method, comprising the following steps:

[0007] S1, loading the rich text data to be processed and sending it to a tag parser, wherein the tag parser splits the tags of the rich text data to be processed into multiple tag blocks according to a preset tag rule;

[0008] S2, check in turn whether each tag block exists in the tag buffer, if so, directly load the content of the corresponding tag block in the tag buffer without performing a parsing operation, if not, execute the next step for parsing;

[0009] S3, the tag parser parses the tag blocks split in S1 according to two categories: pictures and texts, and caches the parsed content according to the tag blocks and tags.

[0010] Preferably, after step S3, it also includes: each of the tags can be split into one or more tag blocks, and after the content of each tag block is parsed or loaded from the tag buffer, the content of the tag block is spliced ​​into the original tag for caching, and sent to the interactive end for display.

[0011] Preferably, before step S2, the method further includes: the tag parser divides the rich text data to be processed into multiple tags to be parsed, and compares the tags to be parsed with the cache tags in the tag cache; if there is a cache tag in the tag cache that is the same as the tag to be parsed, the corresponding cache tag is directly loaded; if the cache tag in the tag cache is not exactly the same as the tag to be parsed, the tag to be parsed is split into at least one tag block, and steps S2-S3 are executed for parsing.

[0012] Preferably, when the rich text data to be processed is first received and processed, all parsing results are completely cached, and the parsing results include image parsing results and text parsing results; when the rich text data to be processed is subsequently loaded, it is first checked whether the rich text data to be processed is the same as the complete cached content. If they are the same, the complete cached content is directly loaded. If they are not the same, steps S1-S3 are executed for parsing.

[0013] Preferably, step S1 is specifically as follows: the user inputs a request at the interactive end, the interactive end obtains the rich text data to be processed according to the request, and sends the rich text data to be processed to the tag parser, requesting the tag parser to parse it; the tag parser splits the multiple tags of the rich text data to be processed into multiple tag blocks according to preset tag rules.

[0014] Preferably, in step S3, for the label block of picture type, it is sent to the image parsing module for processing, the image parsing module loads and parses the content of the label block of picture type, and converts it into a format recognizable by the iOS system; for the label block of text type, it is sent to the text parsing module for processing, the text parsing module parses the content of the label block of text type, the label block of text type includes HTML label text and ordinary text, and the text parsing module converts the content of the label block of text type into NSMutableAttributedString format for subsequent display and processing in the iOS system.

[0015] Preferably, the tags are divided into high-frequency tags and low-frequency tags and cached separately according to the access frequency and content update frequency of the tags;

[0016] For high-frequency tags, the tag cache caches them in memory and disk. When a high-frequency tag is accessed or updated, the cache content is first loaded from the memory; if there is no cache in the memory or the cache is invalid, it is loaded from the disk and the cache is updated in the memory synchronously;

[0017] For low-frequency tags, the tag cache adopts a short-term cache or real-time loading strategy. When a low-frequency tag is accessed or updated, it chooses to load from the cache or load from the network in real time according to the actual situation.

[0018] Preferably, cache limits are set in the tag cache, including cache expiration time and capacity limit. When the cache reaches the capacity limit or exceeds the set expiration time, cache tags with earlier times are automatically cleared to release system resources.

[0019] Preferably, in the tag parser, deep learning technology is used to build a parsing model, and a large amount of data is used to train the model. The model is used to predict and identify key content and structure in rich text data, so that it can quickly identify and parse pictures, text and HTML tags in rich text data.

[0020] Preferably, in the label cache, a distributed network is used to cache labels, and multiple nodes of the distributed network are used to cache rich text data; when a node fails or has an excessive load, other nodes take over its work.

[0021] Compared with the prior art, the technical solution of the present invention has at least the following advantages and beneficial effects:

[0022] The text loading method of the present invention adopts a tag-based cache strategy, splits the content by tag, and creates an independent cache item for each tag; when the tag content changes, only the corresponding cache needs to be updated without reloading the entire rich text, which significantly improves the loading efficiency;

[0023] The tags are divided into two categories: images and texts for separate analysis, and sent to the image analysis module and text analysis module respectively, to achieve parallel processing without interfering with each other, thus improving the analysis efficiency;

[0024] This solution also introduces a dynamic cache adjustment mechanism to dynamically adjust the cache strategy based on factors such as the number of tag accesses and content update frequency. High-frequency stable tags use a dual cache mechanism of memory and disk, while low-frequency tags use short-term cache or real-time loading to ensure the effectiveness and timeliness of the cache. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 The figure is a flow chart of a text loading method of the present invention. DETAILED DESCRIPTION

[0026] The technical solutions, structural features, achieved objectives and effects of the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0027] It should be noted that the drawings are in a very simplified form and use non-precise proportions. They are only used to conveniently and clearly assist in explaining the embodiments of the present invention, and are not used to limit the conditions for the implementation of the present invention. Therefore, they have no substantive technical significance. Any structural modification, change in proportional relationship or adjustment of size, without affecting the effects and purposes that can be achieved by the present invention, should still fall within the scope of the technical content disclosed by the present invention.

[0028] It should be noted that, in the present invention, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only the elements explicitly listed, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0029] The embodiment of the present invention discloses a text loading method, which adopts the strategy of labeling parsing cache and dynamic cache adjustment, and can quickly parse rich text data into NSMutableAttributedString text that can be recognized by the iOS system, thereby reducing resource waste. The content of the present invention will be described in detail below.

[0030] like Figure 1 As shown, a text loading method of this embodiment includes the following steps:

[0031] S1, loading the rich text data to be processed and sending it to a tag parser, wherein the tag parser splits the tags of the rich text data to be processed into multiple tag blocks according to a preset tag rule;

[0032] S2, check in turn whether each tag block exists in the tag buffer, if so, directly load the content of the corresponding tag block in the tag buffer without performing a parsing operation, if not, execute the next step for parsing;

[0033] S3, the tag parser parses the tag blocks split in S1 according to two categories: pictures and texts, and caches the parsed content in the tag cache according to the tag blocks and tags.

[0034] In this embodiment, the tag block and the tag cached in the tag cache are respectively referred to as a cache tag block and a cache tag.

[0035] The rich text data to be processed includes at least one tag; each tag can be split into one or more tag blocks. After the content of each tag block is parsed or loaded from the tag buffer, its content is spliced ​​into the original tag for caching, and sent to the interactive end for display for user viewing.

[0036] Before step S2, the method further includes: the tag parser divides the new rich text data to be processed into multiple tags to be parsed, and compares the tags to be parsed with the cache tags in the tag cache. If there is a cache tag in the tag cache that is the same as the tag to be parsed, the corresponding cache tag is directly loaded. If the cache tag in the tag cache is not completely the same as the tag to be parsed, that is, the comparison finds that the two have different contents, the tag to be parsed is split into tag blocks, and steps S2-S3 are executed to parse the tag blocks. This processing method does not need to re-parse the entire rich text data, thereby reducing unnecessary parsing operations and improving loading efficiency.

[0037] It should be noted that when caching labels and label blocks, the label buffer will cache both the data before and after parsing. Therefore, by comparing the data before parsing, it can be determined whether the cached label in the label buffer is the same as the label content to be parsed.

[0038] Furthermore, when the rich text data to be processed is first received and processed, all parsing results are completely cached to make them independent cache items, and the parsing results include image parsing results and text parsing results. When the rich text data to be processed is subsequently loaded, first check whether the rich text data to be processed is the same as the complete cache content. If the same, the complete cache content is directly loaded without the need to split the tag blocks and parse and splice the content again, thereby improving the loading efficiency; if not, execute the above steps S1-S3 for parsing.

[0039] In other embodiments, step S1 is specifically as follows: the user inputs a request at the interactive end, the interactive end obtains the rich text data to be processed according to the request, and sends the rich text data to be processed to the tag parser, requesting the tag parser to parse it; the tag parser splits the multiple tags of the rich text data to be processed into multiple tag blocks according to the preset tag rules. The preset tag rules can be manually set as needed.

[0040] In step S3, for the label block of picture type, it is sent to the picture parsing module for processing; the picture parsing module loads and parses the label content of the picture type, converts it into a format recognizable by the iOS system (such as UIImage), and then caches it under the corresponding label block for subsequent use. For the text type label, it is sent to the text parsing module for processing; the text parsing module parses the text type label content, and the text type label includes HTML tag text and ordinary text. The text parsing module converts the text type label content into NSMutableAttributedString format for subsequent display and processing in the iOS system. By separating the analysis of pictures and texts, processing them in parallel, and not interfering with each other, the parsing efficiency is improved.

[0041] In step S3, the parsed label blocks are cached, and the parsed label blocks are spliced ​​and cached according to the original labels, so that each label and each label block are independent cache items.

[0042] In other embodiments, tags are divided into high-frequency tags and low-frequency tags and cached separately according to the access frequency and content update frequency of the tags. Tags with high access frequency or update frequency are listed as high-frequency tags, and tags with low access frequency or update frequency are listed as low-frequency tags, where the number of times is determined according to actual conditions.

[0043] For high-frequency tags, the tag cache caches them in memory and disk. When a high-frequency tag is accessed or updated, the cache content is first loaded from the memory; if there is no cache in the memory or the cache is invalid, it is loaded from the disk and the cache is updated in the memory synchronously.

[0044] For low-frequency tags, the tag cache adopts a short-term cache or real-time loading strategy. When a low-frequency tag is accessed or updated, it chooses to load from the cache or load from the network in real time according to the actual situation.

[0045] The division of high-frequency tags and low-frequency tags is dynamic. When the access frequency or update frequency does not meet its standards, the cache strategy is updated. By dynamically adjusting the cache mechanism, the effectiveness and timeliness of the cache are ensured.

[0046] Furthermore, cache limits are set in the tag cache, including cache expiration time and capacity limit. When the cache reaches the capacity limit or exceeds the set expiration time, the cache tags with earlier time are automatically cleared to release system resources.

[0047] In other embodiments, tags may be classified and cached according to other rules as needed.

[0048] In other embodiments, for the tag parser, a deep learning technology can also be used to build a parsing model, and a large amount of data can be used to train the model. The model is used to predict and identify key content and structure in rich text data, so that it can quickly identify and parse pictures, texts and HTML tags in rich text data. This solution can reduce the traditional parsing time and is suitable for processing rich text data with complex structures and changing formats.

[0049] In other embodiments, a distributed network can also be used as a label cache, and multiple nodes of the distributed network are used to cache labels, label blocks, and parsed labels and label blocks. Through load balancing and cache synchronization mechanisms, a load balancer is created to evenly distribute parsing requirements to multiple parsers, and after the parsers are parsed, they are transferred to the label cache for caching, and the parsing work is completed efficiently, thereby ensuring data consistency and availability between multiple nodes. When a node fails or is overloaded, other nodes can take over its work to ensure the stability and reliability of the system. This solution is suitable for processing large-scale, high-concurrency rich text data.

[0050] For the above-mentioned tag buffer solutions, in practical applications, comprehensive consideration and selection can be made based on the specific needs of the project, technology stack, performance requirements, etc. At the same time, these solutions can also be used in combination with the main solution of the present invention to achieve better results.

[0051] Although the content of the present invention has been described in detail through the above preferred embodiments, it should be appreciated that the above description should not be considered as a limitation of the present invention. After reading the above content, it will be apparent to those skilled in the art that various modifications and substitutions of the present invention will occur. Therefore, the protection scope of the present invention should be limited by the appended claims.

Claims

1. A text loading method, characterized in that: The following steps are involved: S1, loading the rich text data to be processed and sending it to a tag parser, wherein the tag parser splits the tags of the rich text data to be processed into multiple tag blocks according to a preset tag rule; S2, check in turn whether each tag block exists in the tag buffer, if so, directly load the content of the corresponding tag block in the tag buffer without performing a parsing operation, if not, execute the next step for parsing; S3, the tag parser parses the tag blocks split in S1 according to two categories: pictures and texts, and caches the parsed content according to the tag blocks and tags.

2. A text loading method as claimed in claim 1, characterized in that: After step S3, it also includes: each of the tags can be split into one or more tag blocks, and after the content of each tag block is parsed or loaded from the tag buffer, the content of the tag block is spliced ​​into the original tag for caching, and sent to the interactive end for display.

3. A text loading method as claimed in claim 1, characterized in that: Before step S2, the method further includes: the tag parser divides the rich text data to be processed into multiple tags to be parsed, and compares the tags to be parsed with the cache tags in the tag cache; if there is a cache tag in the tag cache that is the same as the tag to be parsed, the corresponding cache tag is directly loaded; if the cache tag in the tag cache is not exactly the same as the tag to be parsed, the tag to be parsed is split into at least one tag block, and steps S2-S3 are executed for parsing.

4. A text loading method as claimed in claim 1, characterized in that: When the rich text data to be processed is received and processed for the first time, all parsing results are completely cached, including image parsing results and text parsing results; when the rich text data to be processed is subsequently loaded, first check whether the rich text data to be processed is the same as the complete cached content. If they are the same, directly load the complete cached content. If they are not the same, execute steps S1-S3 for parsing.

5. A text loading method as claimed in claim 1, characterized in that: Step S1 is specifically as follows: the user inputs a request at the interactive end, the interactive end obtains the rich text data to be processed according to the request, and sends the rich text data to be processed to the tag parser, requesting the tag parser to parse it; the tag parser splits the multiple tags of the rich text data to be processed into multiple tag blocks according to preset tag rules.

6. A text loading method as claimed in claim 1, characterized in that: In step S3, for the label block of picture type, it is sent to the picture parsing module for processing, and the picture parsing module loads and parses the content of the label block of picture type and converts it into a format recognizable by the iOS system; for the label block of text type, it is sent to the text parsing module for processing, and the text parsing module parses the content of the label block of text type, and the label block of text type includes HTML label text and ordinary text. The text parsing module converts the content of the label block of text type into NSMutableAttributedString format for subsequent display and processing in the iOS system.

7. A text loading method as claimed in claim 1, characterized in that: According to the access frequency and content update frequency of tags, tags are divided into high-frequency tags and low-frequency tags and cached separately; For high-frequency tags, the tag cache caches them in memory and disk. When a high-frequency tag is accessed or updated, the cache content is first loaded from the memory; If there is no cache in the memory or the cache is invalid, it is loaded from the disk and the cache is updated in the memory synchronously; For low-frequency tags, the tag cache adopts a short-term cache or real-time loading strategy. When a low-frequency tag is accessed or updated, it chooses to load from the cache or load from the network in real time according to the actual situation.

8. A text loading method as claimed in claim 1, characterized in that: The tag cache is provided with cache limits, including cache expiration time and capacity limit. When the cache reaches the capacity limit or exceeds the set expiration time, the cache tags with earlier time are automatically cleared to release system resources.

9. A text loading method as claimed in claim 1, characterized in that: In the tag parser, deep learning technology is used to build a parsing model, and a large amount of data is used to train the model. The model is used to predict and identify key content and structure in rich text data, so that it can quickly identify and parse pictures, text and HTML tags in rich text data.

10. A text loading method as claimed in claim 1, characterized in that: In the label cache, a distributed network is used to cache labels, and multiple nodes of the distributed network are used to cache rich text data; When a node fails or becomes overloaded, other nodes take over its work.