Mail protocol analysis method and device for mixed mode accelerated matching

By combining a lexical analyzer and a single-mode matching algorithm to dynamically select the parsing mode, the problem of insufficient parsing efficiency of email protocols in existing technologies is solved, and an efficient, intelligent, and reliable email processing system is realized.

CN121603580APending Publication Date: 2026-03-03HANGZHOU DPTECH TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610119741.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-28
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing email protocol parsing technologies are inefficient in high-traffic scenarios and cannot meet the requirements for real-time performance and high performance, especially when processing complex email content, where performance drops sharply.

Method used

A hybrid mode matching method is adopted to accelerate matching. It combines a lexical analyzer and a single-pattern matching algorithm. The parsing mode is dynamically selected according to the structure type of the email protocol data. The lexical analyzer is used to parse the email header, and the single-pattern matching algorithm is used to parse the email body, especially the multi-part MIME content.

Benefits of technology

It significantly improves the efficiency and performance of email protocol parsing, reduces parsing time, enhances system response speed, reduces system resource consumption, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121603580A_ABST
    Figure CN121603580A_ABST
Patent Text Reader

Abstract

The invention relates to a mixed mode accelerated matching mail protocol analysis method and device. The method comprises the following steps: receiving mail protocol data to be analyzed; according to a predefined intelligent judgment rule, identifying a data structure type corresponding to a current to-be-analyzed part in the mail protocol data; an analysis mode is determined according to the data structure type, and the analysis mode comprises a lexical analyzer analysis mode and a single-mode matching algorithm analysis mode; and calling an analysis mode matched with the current to-be-analyzed part for analysis so as to generate an analysis result. According to the mail protocol analysis method and device based on mixed mode accelerated matching, the problem that an existing mail protocol analysis technology is insufficient in efficiency in a high-performance requirement scene can be solved, and a core technical scheme is provided for achieving an efficient, intelligent and reliable mail processing system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer information processing, and more specifically, to a method and apparatus for accelerating email protocol parsing using a hybrid mode. Background Technology

[0003] With the development of the internet, email, since its inception in the late 1960s, has become a widely used communication method globally. To ensure accurate transmission of emails across different systems and networks, email protocols have emerged, such as SMTP for sending emails and POP3 and IMAP for receiving them. Email protocol parsing is a technology developed to handle complex email content and address cybersecurity threats. It aims to analyze email headers and bodies to extract information and identify risks. Its applications are wide-ranging, playing a crucial role in email classification and filtering, archiving and retrieval, and marketing. Especially in cybersecurity, for example, in email virus detection, it can identify virus-laden emails through feature recognition and behavioral analysis. In phishing email detection, it can verify sender identity and analyze links and content to prevent phishing attacks.

[0004] In high-traffic scenarios, the volume of emails is enormous and the content is complex and varied. Existing email protocol parsing technologies struggle to complete efficient parsing within a short timeframe, failing to meet real-time and high-performance requirements and making them unsuitable for scenarios with high performance demands. Therefore, a new hybrid mode is needed to accelerate the parsing of email protocols.

[0005] The information disclosed in the background section is only intended to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0007] In view of this, this application provides a hybrid mode accelerated matching email protocol parsing method and apparatus, which can solve the problem of insufficient efficiency of existing email protocol parsing technology in high-performance scenarios, and provides a core technical solution for realizing an efficient, intelligent and reliable email processing system.

[0008] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.

[0009] According to one aspect of this application, a hybrid mode accelerated matching method for email protocol parsing is proposed. The method includes: receiving email protocol data to be parsed; identifying the data structure type corresponding to the current part to be parsed in the email protocol data according to predefined intelligent judgment rules; determining the parsing mode according to the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; and retrieving the parsing mode that matches the current part to be parsed for parsing to generate a parsing result.

[0010] In one exemplary embodiment of this application, the method further includes generating the intelligent judgment rule based on the historical parsing characteristics of each data structure of the email protocol, parsing time statistics, and preset rule templates.

[0011] In one exemplary embodiment of this application, identifying the data structure type corresponding to the currently unparsed portion of the email protocol data according to predefined intelligent judgment rules includes: identifying whether the data structure type of the currently unparsed portion belongs to the email header or the email body according to predefined intelligent judgment rules.

[0012] In one exemplary embodiment of this application, determining the parsing mode based on the data structure type includes: when the current part to be parsed is the email header, determining the parsing mode as the lexical analyzer parsing mode; and when the current part to be parsed is the email body, determining the parsing mode as the single-pattern matching algorithm parsing mode.

[0013] In one exemplary embodiment of this application, when the parsing mode corresponding to the current part to be parsed is the lexical analyzer parsing mode, the parsing mode matching the current part to be parsed is invoked for parsing to generate a parsing result, including: performing lexical analysis on the current part to be parsed based on the lexical analyzer to generate a lexical unit sequence; and completing the parsing of the current part to be parsed based on the lexical unit sequence.

[0014] In one exemplary embodiment of this application, lexical analysis is performed on the current part to be parsed based on a lexical analyzer to generate a sequence of lexical units, including: the lexical analyzer identifies the fields or content contained in the current part to be parsed based on preset lexical rules, thereby dividing it into a sequence of lexical units.

[0015] In one exemplary embodiment of this application, when the parsing mode corresponding to the current part to be parsed is the single-mode matching algorithm parsing mode, the parsing mode that matches the current part to be parsed is retrieved for parsing to generate a parsing result, including: searching for a predefined boundary identifier in the email protocol data; when the boundary identifier is matched, jumping to the position before the boundary identifier, and continuing to parse based on the single-mode matching algorithm.

[0016] In one exemplary embodiment of this application, the method further includes: skipping all content of the current data packet and retaining the incomplete line data at the end when the boundary identifier is not matched.

[0017] In one exemplary embodiment of this application, retrieving a parsing mode that matches the current part to be parsed and performing parsing to generate a parsing result includes: retrieving a parsing mode that matches the current part to be parsed and performing parsing to generate partial parsing data; and generating a final parsing result based on the partial parsing data after all parsing of the email protocol data is completed.

[0018] According to one aspect of this application, a hybrid-mode accelerated matching email protocol parsing device is proposed. The device includes: a data module for receiving email protocol data to be parsed; an identification module for identifying the data structure type corresponding to the currently parsed portion of the email protocol data according to predefined intelligent judgment rules; a mode module for determining a parsing mode based on the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; and a parsing module for retrieving the parsing mode that matches the currently parsed portion for parsing to generate a parsing result.

[0019] According to one aspect of this application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the method as described above.

[0020] According to one aspect of this application, a computer-readable medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described above.

[0021] The hybrid-mode accelerated matching email protocol parsing method and apparatus of this application, by receiving email protocol data to be parsed; identifying the data structure type corresponding to the current part to be parsed in the email protocol data according to predefined intelligent judgment rules; determining the parsing mode according to the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; and retrieving the parsing mode that matches the current part to be parsed for parsing to generate a parsing result, can solve the problem of insufficient efficiency of existing email protocol parsing technology in high-performance scenarios, and provides a core technical solution for realizing an efficient, intelligent and reliable email processing system.

[0022] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description

[0024] The above and other objects, features, and advantages of this application will become more apparent from the detailed description of exemplary embodiments with reference to the accompanying drawings. The drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0025] Figure 1 This is a flowchart illustrating a hybrid mode accelerated matching email protocol parsing method according to an exemplary embodiment.

[0026] Figure 2 This is a flowchart illustrating a hybrid mode accelerated matching email protocol parsing method according to another exemplary embodiment.

[0027] Figure 3 This is a flowchart illustrating a hybrid mode accelerated matching email protocol parsing method according to another exemplary embodiment.

[0028] Figure 4 This is a block diagram illustrating a hybrid mode accelerated matching email protocol parsing apparatus according to an exemplary embodiment.

[0029] Figure 5 This is a block diagram illustrating an electronic device according to an exemplary embodiment.

[0030] Figure 6 This is a block diagram illustrating a computer-readable medium according to an exemplary embodiment. Detailed Implementation

[0032] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.

[0033] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.

[0034] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0035] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0036] It should be understood that although the terms first, second, third, etc., may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another. Therefore, the first component discussed below may be referred to as the second component without departing from the teachings of this application. As used herein, the term "and / or" includes all combinations of any one and more of the associated listed items.

[0037] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of exemplary embodiments, and the modules or processes in the drawings are not necessarily essential for implementing this application, and therefore cannot be used to limit the scope of protection of this application.

[0038] The applicant in this case discovered that existing email protocol parsing technologies mainly include the following: Regular expression matching matches email content based on predefined pattern rules. It can identify text fragments that match specific patterns and is often used to extract email header information and find specific keywords. Finite state automata scan email content character by character by defining states and state transition rules, and change states according to input characters in order to identify various elements in the email protocol. Recursive descent parsing is a top-down parsing method that breaks down the parsing task into multiple subroutines according to grammatical rules, and completes the parsing of the entire email protocol by recursively calling these subroutines. The rule-based parsing method stores the parsing rules in a rule base. The rule engine matches and infers the input email content and processes the email according to the priority and combination of rules.

[0039] Regular expression matching becomes extremely time-consuming and prone to backtracking issues when processing complex email content due to the increased complexity of the pattern, leading to a sharp drop in performance. Finite state automata experience an exponential increase in the number of states for complex protocols, making the construction and maintenance of automata costly, while the overhead of runtime state transitions also affects parsing efficiency. Recursive descent parsing consumes a large amount of system stack space, easily causing stack overflow errors when processing large emails, and also results in slow parsing speed.

[0040] In high-traffic scenarios, the number of emails is enormous and the content is complex and varied. Existing email protocol parsing technologies are unable to complete efficient parsing in a short time, failing to meet real-time and high-performance requirements, and are not suitable for scenarios with high performance requirements.

[0041] To address performance issues in existing technologies, this application proposes a hybrid-pattern accelerated matching method for email protocol parsing. This method combines lexical analysis with a lexical analyzer and utilizes a single-pattern matching algorithm to replace time-consuming rules, comprehensively improving the efficiency and performance of email protocol parsing. Specifically, it significantly reduces parsing time when processing time-consuming rules, improves system response speed, and provides users with a smoother and more efficient email experience.

[0042] The content of this application will be described in detail below with the aid of specific embodiments.

[0043] Figure 1 This is a flowchart illustrating a mixed-pattern accelerated matching email protocol parsing method according to an exemplary embodiment. The mixed-pattern accelerated matching email protocol parsing method 10 includes at least steps S102 to S108.

[0044] like Figure 1 As shown, in S102, the email protocol data to be parsed is received. More specifically, the email protocol data includes, but is not limited to, email streams in SMTP, POP3, or IMAP protocol formats, and its content typically includes a complex structure such as email headers, body, and possible attachments.

[0045] In step S104, the data structure type corresponding to the currently parsed portion of the email protocol data is identified according to predefined intelligent judgment rules. More specifically, the data structure type of the currently parsed portion can be identified as belonging to the email header or email body, based on predefined intelligent judgment rules.

[0046] More specifically, based on predefined intelligent judgment rules, it can identify whether the data structure type of the part to be parsed belongs to the email header or the email body. The email header usually contains key-value pairs such as sender, recipient, and subject, and its structure is relatively fixed; the email body may contain plain text, HTML, or multi-part MIME (Multipurpose Internet Mail Extensions) content, and its structure is complex and varied, especially when it contains attachments or embedded resources, which are separated by specific boundary identifiers.

[0047] In one embodiment, the method further includes generating the intelligent judgment rule based on historical parsing characteristics of various data structures of the email protocol, parsing time statistics, and preset rule templates.

[0048] For example, analysis of historical data reveals that parsing complex multi-part MIME bodies using regular expressions can lead to a sharp performance drop due to backtracking caused by pattern complexity; while parsing simple email headers results in unnecessary stack space overhead from frequent function calls during recursive descent parsing. Based on these characteristics, rules can be generated to categorize email headers into "simple / low-time-consuming" structures suitable for lexical analysis, and email bodies (especially multi-part MIME bodies) into "complex / high-time-consuming" structures suitable for single-pattern matching acceleration.

[0049] In S106, a parsing mode is determined according to the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode.

[0050] In one embodiment, when the current part to be parsed is the email header, the parsing mode can be determined to be the lexical analyzer parsing mode; more specifically, the lexical analyzer identifies the fields or content contained in the current part to be parsed based on preset lexical rules, thereby dividing it into a sequence of lexical units.

[0051] More specifically, when the current part to be parsed is the email header, the parsing mode can be determined to be the lexical analyzer parsing mode. As an efficient tool, the lexical analyzer can convert input text into a series of lexical units with specific meanings according to predefined lexical rules. More specifically, the lexical analyzer identifies the fields or content contained in the current part to be parsed based on preset lexical rules, thereby dividing it into a sequence of lexical units. For example, for "From: user@example.com", the keyword "From", the separator ":", and the identifier "user@example.com" can be identified. These lexical units provide clear and structured basic data for subsequent syntax analysis and semantic understanding, avoiding the inefficiency of character-by-character matching.

[0052] In one embodiment, when the current part to be parsed is the email body, the parsing mode can be determined to be the single-mode matching algorithm parsing mode.

[0053] More specifically, when the current part to be parsed is the email body, the parsing mode can be determined to be a single-pattern matching algorithm. This is an optimization for high-traffic scenarios where traditional methods struggle to quickly process complex email bodies. Single-pattern matching algorithms, such as KMP, BM, or Sunday algorithms, are essentially about efficiently finding a pattern string in the text.

[0054] In step S108, a parsing pattern matching the currently parsed portion is retrieved and parsed to generate a parsing result. For example, a parsing pattern matching the currently parsed portion is retrieved and parsed to generate partial parsed data; after all the email protocol data has been parsed, a final parsing result is generated based on the partial parsed data.

[0055] In one embodiment, when the parsing mode corresponding to the current part to be parsed is the lexical analyzer parsing mode, the parsing mode matching the current part to be parsed is invoked for parsing to generate a parsing result. This includes: performing lexical analysis on the current part to be parsed based on the lexical analyzer to generate a lexical unit sequence; and completing the parsing of the current part to be parsed based on the lexical unit sequence. For example, the email header can be scanned line by line, and fields such as sender, recipient, and date can be quickly extracted according to rules to complete the structuring of the header information.

[0056] A lexical analyzer is a commonly used tool that converts input text into a series of lexical units with specific meanings according to predefined lexical rules. In this application, a lexical analyzer can be used to perform lexical parsing on an email protocol, segmenting and recognizing the email content according to certain rules.

[0057] Lexical analysis is the first step in email protocol parsing. Its main function is to break down the email content into meaningful lexical units, such as keywords, identifiers, and numbers. These lexical units serve as the foundational data for subsequent syntactic analysis and processing, providing support for further understanding the structure and semantics of the email content.

[0058] In practice, a series of lexical rules can be predefined to accurately describe the characteristics of various elements in the email protocol. For example, rules can be defined to identify fields such as sender, recipient, and subject for email header information; and rules can be defined to identify different types of content such as text, images, and attachments for email body content. The lexical analyzer will scan and analyze the email content line by line according to these rules, converting it into a sequence of lexical units to prepare for subsequent processing.

[0059] In another embodiment, when the parsing mode corresponding to the current part to be parsed is the single-mode matching algorithm parsing mode, the parsing mode matching the current part to be parsed is retrieved for parsing to generate a parsing result. This includes: searching for a predefined boundary identifier in the email protocol data; when the boundary identifier is matched, jumping to the position before the boundary identifier and continuing parsing based on the single-mode matching algorithm. Alternatively, for example, when the boundary identifier is not matched, all content of the current data packet is skipped, and the incomplete line data at the end is retained.

[0060] More specifically, predefined boundary identifiers (e.g., "--boundary_string" between MIME parts) can be searched in the email protocol data. When the boundary identifier is matched, the parser jumps to the position before the boundary identifier (i.e., the beginning of the current MIME part) and continues parsing the subsequent part or the next boundary based on the single-pattern matching algorithm. This method effectively avoids unnecessary line-by-line or character-by-character analysis of lengthy content within the email body, directly locating structural boundaries and achieving "jump parsing," thereby significantly accelerating the processing of email bodies (especially emails with attachments). Alternatively, for example, if the boundary identifier is not matched, all content of the current data packet can be skipped, and the incomplete line data at the end can be retained. This mechanism ensures that the parser remains synchronized even in cases of incomplete or abnormal data flow, preparing for the continued parsing of subsequent data packets and enhancing the robustness of the system.

[0061] The hybrid-mode accelerated matching email protocol parsing method of this application receives email protocol data to be parsed; identifies the data structure type corresponding to the current part to be parsed in the email protocol data according to predefined intelligent judgment rules; determines the parsing mode according to the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; and retrieves the parsing mode that matches the current part to be parsed for parsing to generate a parsing result. This method can solve the problem of insufficient efficiency of existing email protocol parsing technologies in high-performance scenarios and provides a core technical solution for realizing an efficient, intelligent, and reliable email processing system.

[0062] It should be clearly understood that this application describes how specific examples are formed and used, but the principles of this application are not limited to any details of these examples. Rather, based on the teachings of the disclosure of this application, these principles can be applied to many other embodiments.

[0063] Figure 2 This is a flowchart illustrating a hybrid mode accelerated matching email protocol parsing method according to an exemplary embodiment. Figure 2 The process shown in step 20 is... Figure 1The process shown in the diagram includes a detailed description in step S108: "When the parsing mode corresponding to the current part to be parsed is the single-mode matching algorithm parsing mode, the parsing mode that matches the current part to be parsed is retrieved for parsing to generate the parsing result."

[0064] like Figure 2 As shown, in S202, a predefined boundary identifier is searched in the email protocol data. Traditional rule matching methods are inefficient and difficult to meet practical needs when processing time-consuming rules such as email body. To improve parsing efficiency, a single-mode algorithm can be used for direct matching in cases with specific boundaries.

[0065] Single-pattern matching is a high-efficiency string matching algorithm. Its basic idea is to quickly find a specific pattern string within a text string. In email protocol parsing, the boundary identifiers of the email body can be used as pattern strings for searching within the email body.

[0066] In S204, is a boundary detected? In the email body, directly search for the boundary identifier.

[0067] In S206, when the boundary identifier is matched, the process jumps to the position before the boundary identifier and continues parsing based on the single-mode matching algorithm. If the boundary identifier is successfully found, the process jumps to the position before the boundary and continues with subsequent parsing operations.

[0068] In S208, if the boundary identifier is not matched, all content of the current data packet is skipped, and the incomplete line data at the end is retained. If no boundary identifier is found, all content of the current data packet is skipped.

[0069] During the skipping process, the last incomplete line needs to be retained to ensure that the email content can be correctly decoded later.

[0070] This single-pattern matching method effectively avoids unnecessary character-by-character matching of the email body, thus significantly improving parsing efficiency. Its advantages are particularly pronounced when processing email bodies containing large amounts of text and complex structures, greatly reducing parsing time.

[0071] Figure 3 This is a flowchart illustrating a hybrid mode accelerated matching email protocol parsing method according to another exemplary embodiment. Figure 3 The process shown in step 30 is... Figure 1 A detailed description of the process shown.

[0072] like Figure 3 As shown, in S302, the email protocol content is retrieved.

[0073] In S304, is the email content not yet finished?

[0074] In S306, intelligent rule judgment is used.

[0075] In S308, the lexical analyzer mode.

[0076] In S310, the single-mode algorithm mode.

[0077] In S312, the email protocol lexical unit is output.

[0078] In S314, the end.

[0079] At different stages of email protocol parsing, an appropriate parsing method is dynamically selected based on the complexity and time consumption of the rules. For complex or time-consuming rules, such as parsing multiple parts of the email body, a single-mode algorithm is used for accelerated processing; for simple or low-time-consuming rules, such as parsing email header information, a lexical analyzer is used.

[0080] In practical implementation, an intelligent rule-based judgment mechanism can be set up during the parsing process to dynamically adjust the parsing method based on the type and complexity of the rules. For example, when parsing email header information, since the structure of the header information is relatively fixed, a lexical analyzer can quickly and accurately parse each field; while when parsing the email body, for multi-part content with specific boundaries, we use a single-model algorithm to accelerate the process and improve parsing efficiency.

[0081] By combining a lexical analyzer and a single-pattern matching algorithm, this application can effectively improve the efficiency and performance of email protocol parsing, specifically in the following aspects: To reduce parsing time, the application of the single-mode algorithm significantly reduces unnecessary matching operations when processing time-consuming rules, thereby greatly reducing parsing time.

[0082] Improved system performance: Due to the reduced parsing time, the system can process emails faster, reducing system resource consumption and improving overall system performance. Especially under high concurrency, the method of this invention can better handle the parsing needs of a large number of emails, ensuring stable system operation and avoiding system lag or crashes.

[0083] Improving user experience, including faster system response times and enhanced performance, directly leads to a significant improvement in user experience. Users receive faster system responses when sending and receiving emails, reducing waiting time and thus increasing satisfaction and convenience when using the email system.

[0084] Those skilled in the art will understand that all or part of the steps of the above embodiments are implemented as a computer program executed by a CPU. When the computer program is executed by the CPU, it performs the functions defined by the method provided in this application. The program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk, or an optical disk.

[0085] Furthermore, it should be noted that the above figures are merely illustrative representations of the processes included in the method according to exemplary embodiments of this application, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0086] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0087] Figure 4 This is a block diagram illustrating a hybrid-mode accelerated matching email protocol parsing apparatus according to an exemplary embodiment. Figure 4 As shown, the mixed-mode accelerated matching email protocol parsing device 50 includes: a data module 402, an identification module 404, a pattern module 406, and a parsing module 408.

[0088] Data module 402 is used to receive email protocol data to be parsed; The identification module 404 is used to identify the data structure type corresponding to the currently unparsed part in the email protocol data according to the predefined intelligent judgment rules. The identification module 404 is also used to identify whether the data structure type of the currently unparsed part belongs to the email header or the email body according to the predefined intelligent judgment rules.

[0089] The mode module 406 is used to determine the parsing mode according to the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-pattern matching algorithm parsing mode; the mode module 406 is also used to determine the parsing mode as the lexical analyzer parsing mode when the current part to be parsed is the email header; and to determine the parsing mode as the single-pattern matching algorithm parsing mode when the current part to be parsed is the email body.

[0090] The parsing module 408 is used to retrieve the parsing pattern that matches the current part to be parsed and perform parsing to generate a parsing result. The parsing module 408 is also used to perform lexical analysis on the current part to be parsed based on the lexical analyzer, generating a lexical unit sequence; and to complete the parsing of the current part based on the lexical unit sequence. The parsing module 408 is also used to search for predefined boundary identifiers in the email protocol data; when a boundary identifier is matched, it jumps to the position before the boundary identifier and continues parsing based on the single-pattern matching algorithm. When no boundary identifier is matched, all content of the current data packet is skipped, and the incomplete line data at the end is retained.

[0091] The parsing module 408 is also used to retrieve the parsing mode that matches the current part to be parsed and perform parsing to generate partial parsing data; after all the email protocol data has been parsed, the final parsing result is generated based on the partial parsing data.

[0092] The hybrid-mode accelerated matching email protocol parsing device of this application receives email protocol data to be parsed; identifies the data structure type corresponding to the current part to be parsed in the email protocol data according to predefined intelligent judgment rules; determines the parsing mode according to the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; and retrieves the parsing mode that matches the current part to be parsed for parsing to generate a parsing result. This method can solve the problem of insufficient efficiency of existing email protocol parsing technologies in high-performance scenarios, and provides a core technical solution for realizing an efficient, intelligent and reliable email processing system.

[0093] Figure 5 This is a block diagram illustrating an electronic device according to an exemplary embodiment.

[0094] The following reference Figure 5 To describe an electronic device 500 according to this embodiment of the present application. Figure 5 The electronic device 500 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0095] like Figure 5 As shown, the electronic device 500 is presented in the form of a general-purpose computing device. The components of the electronic device 500 may include, but are not limited to: at least one processing unit 510, at least one storage unit 520, a bus 530 connecting different system components (including storage unit 520 and processing unit 510), a display unit 540, etc.

[0096] The storage unit stores program code that can be executed by the processing unit 510, causing the processing unit 510 to perform the steps described in this specification according to various exemplary embodiments of this application. For example, the processing unit 510 can perform actions such as... Figure 1 , Figure 2 , Figure 3 The steps are shown in the figure.

[0097] The storage unit 520 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 5201 and / or a cache storage unit 5202, and may further include a read-only memory unit (ROM) 5203.

[0098] The storage unit 520 may also include a program / utility 5204 having a set (at least one) program module 5205, such program module 5205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0099] Bus 530 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0100] Electronic device 500 can also communicate with one or more external devices 500' (e.g., keyboard, pointing device, Bluetooth device, etc.), enabling users to communicate with devices that interact with electronic device 500, and / or any device (e.g., router, modem, etc.) that allows electronic device 500 to communicate with one or more other computing devices. This communication can be performed via input / output (I / O) interface 550. Furthermore, electronic device 500 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 560. Network adapter 560 can communicate with other modules of electronic device 500 via bus 530. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0101] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software, or by combining software with necessary hardware. Therefore, as... Figure 6As shown, the technical solution according to the embodiments of this application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard drive, etc.) or on a network, and includes several instructions to cause a computing device (such as a personal computer, server, or network device, etc.) to execute the above-described method according to the embodiments of this application.

[0102] In summary, the hybrid-mode accelerated email protocol parsing method disclosed in this invention comprehensively improves the efficiency and performance of email protocol parsing by combining lexical analysis with a lexical analyzer and using a single-pattern matching algorithm to replace time-consuming rules. It uses a lexical analyzer for email protocol lexical parsing. A lexical analyzer is a commonly used tool that can convert input text content into a series of lexical units with specific meanings according to predefined lexical rules. In this invention, we use a lexical analyzer to perform lexical parsing of the email protocol, segmenting and recognizing the email content according to certain rules. Lexical analysis is the first step in email protocol parsing, and its main function is to decompose the email content into lexical units with independent meanings, such as keywords, identifiers, and numbers. These lexical units will serve as the basic data for subsequent syntactic analysis and processing, providing support for further understanding the structure and semantics of the email content. In specific implementation, a series of lexical rules need to be carefully defined to accurately describe the characteristics of various elements in the email protocol. For example, for email header information, we can define rules to identify fields such as sender, recipient, and subject; for email body content, we can define rules to identify different types of content such as text, images, and attachments. The lexical analyzer will scan and analyze the email content line by line according to these rules, converting it into a sequence of lexical units to prepare for subsequent processing. This disclosure uses a single-pattern algorithm to accelerate time-consuming rules. When processing time-consuming rules such as the email body, traditional rule matching methods are inefficient and difficult to meet practical needs. To improve parsing efficiency, this disclosure uses a single-pattern algorithm for direct matching in cases with specific boundaries. Single-pattern matching is an efficient string matching algorithm whose basic idea is to quickly find a specific pattern string in a text string. In email protocol parsing, we can use the boundary identifier of the email body as the pattern string and search for it in the email body. Specifically, in the email body, we directly search for the boundary identifier. If the boundary identifier is successfully found, we jump to the position before that boundary and continue with subsequent parsing operations; if the boundary identifier is not found, we skip all the content of the current data packet. During the skipping process, to ensure correct decoding of the email content later, we need to retain the last incomplete line. This single-pattern matching method effectively avoids unnecessary character-by-character matching of the email body, thus significantly improving parsing efficiency. Its advantages are particularly pronounced when processing email bodies containing large amounts of text and complex structures, greatly reducing parsing time. This disclosure uses hybrid pattern matching to dynamically select the appropriate parsing method at different stages of email protocol parsing, based on the complexity and time consumption of the rules. For complex or time-consuming rules, such as multi-part parsing of the email body, a single-pattern algorithm is used for acceleration; for simple or low-time-consuming rules, such as parsing email header information, a lexical analyzer is used.In practical implementation, this disclosure can set up an intelligent rule judgment mechanism during the parsing process to dynamically adjust the parsing method according to the type and complexity of the rules. For example, when parsing email header information, since the structure of the header information is relatively fixed, a lexical analyzer can quickly and accurately parse each field; while when parsing email body, for multi-part content with specific boundaries, we use a single-mode algorithm to accelerate the process and improve parsing efficiency.

[0103] The software product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0104] The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0105] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0106] The aforementioned computer-readable medium carries one or more programs. When these programs are executed by a device, the computer-readable medium performs the following functions: receiving email protocol data to be parsed; identifying the data structure type corresponding to the currently unparsed portion of the email protocol data according to predefined intelligent judgment rules; determining a parsing mode based on the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; and retrieving the parsing mode that matches the currently unparsed portion for parsing to generate a parsing result.

[0107] Those skilled in the art will understand that the above modules can be distributed in the device as described in the embodiments, or they can be modified accordingly and placed in one or more devices that are unique to this embodiment. The modules in the above embodiments can be combined into one module, or they can be further divided into multiple sub-modules.

[0108] Through the description of the above embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this application.

[0109] Exemplary embodiments of this application have been specifically shown and described above. It should be understood that this application is not limited to the detailed structures, arrangements, or implementation methods described herein; rather, this application is intended to cover various modifications and equivalent arrangements contained within the spirit and scope of the appended claims.

Claims

1. A method for accelerating email protocol parsing through hybrid patterns, characterized in that, include: Receive email protocol data to be parsed; Based on predefined intelligent judgment rules, identify the data structure type corresponding to the currently unparsed portion of the email protocol data; The parsing mode is determined based on the data structure type, wherein the parsing mode includes a lexical analyzer parsing mode and a single-mode matching algorithm parsing mode; Retrieve the parsing pattern that matches the current part to be parsed and parse it to generate the parsing result.

2. The method as described in claim 1, characterized in that, Also includes: The intelligent judgment rule is generated based on the historical parsing characteristics of various data structures in the email protocol, parsing time statistics, and preset rule templates.

3. The method as described in claim 1, characterized in that, Based on predefined intelligent judgment rules, the data structure type corresponding to the currently unparsed portion of the email protocol data is identified, including: Based on predefined intelligent judgment rules, it identifies whether the data structure type of the current part to be parsed belongs to the email header or the email body.

4. The method as described in claim 1, characterized in that, Determining the parsing mode based on the data structure type includes: When the current part to be parsed is the email header, the parsing mode is determined to be the lexical analyzer parsing mode; When the current part to be parsed is the email body, the parsing mode is determined to be the single-mode matching algorithm parsing mode.

5. The method as described in claim 1, characterized in that, When the parsing mode corresponding to the current part to be parsed is the lexical analyzer parsing mode. Retrieve the parsing pattern that matches the current part to be parsed, and parse it to generate the parsing result, including: The lexical analyzer performs lexical analysis on the current part to be parsed, generating a sequence of lexical units. The parsing of the current part to be parsed is completed based on the lexical unit sequence.

6. The method as described in claim 5, characterized in that, The lexical analyzer performs lexical analysis on the current part to be parsed, generating a sequence of lexical units, including: The lexical analyzer identifies the fields or content contained in the current part to be parsed based on preset lexical rules, and then divides it into a sequence of lexical units.

7. The method as described in claim 1, characterized in that, When the parsing mode corresponding to the current part to be parsed is the single-mode matching algorithm parsing mode. Retrieve the parsing pattern that matches the current part to be parsed, and parse it to generate the parsing result, including: Search for predefined boundary identifiers in the email protocol data; When the boundary identifier is matched, jump to the position before the boundary identifier and continue parsing based on the single-mode matching algorithm.

8. The method as described in claim 7, characterized in that, Also includes: If the boundary identifier is not matched, skip all content of the current data packet and retain the incomplete line data at the end.

9. The method as described in claim 1, characterized in that, Retrieve the parsing pattern that matches the current part to be parsed, and parse it to generate the parsing result, including: Retrieve the parsing pattern that matches the current part to be parsed, and generate partial parsed data; After all the email protocol data has been parsed, the final parsing result is generated based on the partially parsed data.

10. A hybrid-mode accelerated matching email protocol parsing device, characterized in that, include: The data module is used to receive email protocol data to be parsed; The identification module is used to identify the data structure type corresponding to the currently unparsed part of the email protocol data according to predefined intelligent judgment rules; A pattern module is used to determine a parsing pattern based on the data structure type, wherein the parsing pattern includes a lexical analyzer parsing pattern and a single-pattern matching algorithm parsing pattern; The parsing module is used to retrieve the parsing pattern that matches the part to be parsed and to generate the parsing result.