Spam detection method, device, storage medium and computer program product
By using the spam detection algorithm of Webassembly technology on the sending end of the web-based mailbox, emails to be sent are detected in real time, which solves the problems of spam detection complexity and computing resource occupation in the existing technology, and improves detection efficiency and security.
Patent Information
- Application Number
- CN202211193674.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-09-28
AI Technical Summary
Existing spam detection methods run computationally intensive classification algorithms on the backend of the mail server, occupying valuable computing resources, and additional network request interactions between senders and servers increase complexity, affecting user experience and security.
Generate high-frequency email word frequency tables through training, use Webassembly technology to compile and generate spam detection algorithms, and detect emails to be sent in real time on the sending end of the web mailbox, reducing front-end and back-end interactions, reducing back-end calculations, and improving detection efficiency and security. sex.
It realizes spam detection on the web mailbox sending end, reduces front-end and back-end interactions, reduces back-end calculations, improves detection efficiency and security, and avoids the risk of criminals bypassing detection.
Smart Images

Figure CN115567476B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a spam detection method, a spam detection device, a processor and a storage medium. Background Art
[0002] With the development of Internet technology, email has become a way for people to communicate and obtain information in their daily lives. Since a large number of emails can be sent to one or more email recipients in a short period of time without obtaining the consent of the email recipients in advance, email provides a low-cost and wide-reaching communication platform for advertising. Some businesses and criminals will use spam emails to spread advertising information and even obtain information such as the consumption behavior of email recipients. This seriously affects the work efficiency of email mailboxes, occupies the storage space of mailboxes, and directly affects the user experience of mailboxes. Therefore, identifying these spam emails will greatly improve the user's communication experience using email and destroy the attempt of criminals to use spam emails to gain benefits.
[0003] In the prior art, the spam detection method is to detect spam at the email receiving end. If it is detected that the email received by the email recipient is spam, the email is directly intercepted or deleted, or an alarm is sent to the email recipient to remind the email recipient that the email received is spam. However, after the sender sends the email in the web version of the mailbox, the email server backend calculates whether the email is spam. If it is spam, it is returned to the sender, which adds additional network request interactions between the sender and the server, and between the server and the receiver. In addition, the email server backend runs a computationally intensive spam classification algorithm, which will occupy valuable backend computing resources. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a spam detection method, device, processor and storage medium.
[0005] In order to achieve the above-mentioned objectives, the first aspect of the present application provides a spam detection method, which includes: training to generate a frequency table of high-frequency words in emails; using the frequency table of high-frequency words in emails to generate a spam detection algorithm based on Webassembly technology; when a send click action is detected for an email to be sent in a web version of the mailbox, calling the spam detection algorithm based on Webassembly technology to perform spam detection on the email to be sent that has undergone a send click action; and generating a spam detection result.
[0006] In an embodiment of the present application, the training generates an email high-frequency word frequency table, including: selecting an email training set, the emails in the email training set include spam emails and normal emails; performing word segmentation processing on the emails in the email training set to obtain a vocabulary list; counting the high-frequency words in the vocabulary list; calculating the number of times the high-frequency words appear in the spam emails and the normal emails to obtain the email high-frequency word frequency table.
[0007] In an embodiment of the present application, before performing word segmentation processing on the emails in the email training set, the method further includes: removing non-Chinese characters and stop words from each email in the email training set.
[0008] In an embodiment of the present application, the use of the email high-frequency word frequency table to generate a spam detection algorithm based on Webassembly technology includes: using the email high-frequency word frequency table and a programming language supported by Webassembly technology to compile a spam detection algorithm; using Webassembly technology to compile the spam detection algorithm into a .wasm binary file.
[0009] In an embodiment of the present application, calling a spam detection algorithm based on Webassembly technology to perform spam detection on an email to be sent that has a send click action, includes: calling a spam detection algorithm based on Webassembly technology to calculate a spam probability and a normal email probability of the email to be sent that has a send click action; when the spam probability is greater than the normal email probability, determining that the email to be sent that has a send click action is a spam.
[0010] In the embodiment of the present application, the spam probability of the email to be sent in which the send click action occurs is calculated in the following manner:
[0011] ;
[0012] ;
[0013] in, is the probability of spam, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, High frequency words in spam S The probability of occurrence, The high frequency words in spam S The number of occurrences, The probability of spam in the training set of emails.
[0014] In the embodiment of the present application, the probability of a normal email for an email to be sent that has a send click action is calculated in the following manner:
[0015] ;
[0016] ;
[0017] in, is the probability of normal email, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, For normal mail Medium and high frequency words The probability of occurrence, M is a high frequency word in normal emails The number of occurrences, is the probability of a normal email in the email training set.
[0018] In the embodiment of the present application, the method further includes: when the spam detection result shows that the email to be sent on which the send click action occurs is a spam, prohibiting the sending operation of the email to be sent.
[0019] A second aspect of the present application provides a spam detection device, which includes: a generation module, which is used to train and generate a frequency table of high-frequency words in emails; a Webassembly module, which is used to use the high-frequency word frequency table of emails to generate a spam detection algorithm based on Webassembly technology; a detection module, which is used to call the spam detection algorithm based on Webassembly technology to perform spam detection on the email to be sent that has undergone a send click action when a send click action is detected in a web version of the mailbox, and generate a spam detection result.
[0020] A third aspect of the present application provides a processor configured to execute the spam detection method described above.
[0021] A fourth aspect of the present application provides a machine-readable storage medium having instructions stored thereon, which, when executed by a processor, configure the processor to execute the spam detection method described above.
[0022] A fifth aspect of the present application provides a computer program product, including a computer program, which implements the spam detection method described above when executed by a processor.
[0023] Through the technical solution provided by this application, this application has at least the following technical effects:
[0024] The spam detection method of the present application generates a frequency table of high-frequency words in the email in advance, and then uses the frequency table of high-frequency words in the email to generate a spam detection algorithm of Webassembly technology, and detects in real time whether a send click action occurs in the email in the web version mailbox. When it is detected that a send click action occurs in the email to be sent in the web version mailbox, the spam detection algorithm based on Webassembly technology is called to perform spam detection on the email to be sent that has a send click action, and generates a spam detection result. The spam detection method provided by the present application is applied to the sending end of the web version mailbox. When the sending end detects that a send click action occurs in the email, the spam detection algorithm based on Webassembly technology is called to perform spam detection on the email to be sent, which reduces the front-end and back-end interactions and reduces the back-end calculation amount. Moreover, the spam detection algorithm based on Webassembly technology has high execution efficiency in spam detection, can accurately detect spam, and the spam detection algorithm is invisible to users, which can avoid the exposure of detection logic, prevent criminals from bypassing spam detection, and improve the security of spam detection.
[0025] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0027] Figure 1 A flowchart of a spam detection method according to an embodiment of the present application is schematically shown;
[0028] Figure 2 A schematic diagram of a spam detection device according to an embodiment of the present application is schematically shown;
[0029] Figure 3 The internal structure of a computer device according to an embodiment of the present application is schematically shown.
[0030] Description of reference numerals:
[0031] 201 - generation module; 202 - Webassembly module; 203 - detection module; A01 - processor; A02 - network interface; A03 - internal memory; A04 - non-volatile storage medium; B01 - operating system; B02 - computer program. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0033] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), such directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0034] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0035] Figure 1 The flowchart of the spam detection method according to the embodiment of the present application is schematically shown. Figure 1 As shown, in one embodiment of the present application, a spam detection method is provided, comprising the following steps: Step 101: training and generating a frequency table of high-frequency words in emails; Step 102: using the frequency table of high-frequency words in emails to generate a spam detection algorithm based on Webassembly technology; Step 103: in the case of detecting that a click action to send has occurred on an email to be sent in a web version mailbox, calling a spam detection algorithm based on Webassembly technology to perform spam detection on the email to be sent that has undergone a click action to send; Step 104: generating a spam detection result.
[0036] Specifically, a frequency table of high-frequency words in emails is generated in advance, and then the Webassembly technology is used to compile and generate a spam detection algorithm. The web version of the mailbox detects in real time whether a click action to send the email has occurred. When it is detected that a click action to send has occurred on an email to be sent in the web version of the mailbox, the spam detection algorithm based on the Webassembly technology is called to perform spam detection on the email to be sent that has undergone a click action to send, and a spam detection result is generated.
[0037] The spam detection method provided by the present application is applied to the sending end of the web version of the mailbox. When the sending end detects that a click action has been made on the email, the spam detection algorithm based on the Webassembly technology is called to perform spam detection on the email to be sent, which reduces the front-end and back-end interactions and reduces the amount of back-end calculations. Moreover, the spam detection algorithm based on the Webassembly technology has high execution efficiency in spam detection and can accurately detect spam. The spam detection algorithm is invisible to users, which can avoid the exposure of the detection logic, prevent criminals from bypassing spam detection, and improve the security of spam detection.
[0038] In an embodiment of the present application, the training generates an email high-frequency word frequency table, including: selecting an email training set, the emails in the email training set include spam emails and normal emails; performing word segmentation processing on the emails in the email training set to obtain a vocabulary list; counting the high-frequency words in the vocabulary list; calculating the number of times the high-frequency words appear in the spam emails and the normal emails to obtain the email high-frequency word frequency table.
[0039] In an embodiment of the present application, before performing word segmentation processing on the emails in the email training set, the method further includes: removing non-Chinese characters and stop words from each email in the email training set.
[0040] Specifically, in the embodiment of the present application, a public email corpus, such as trec06c, is used as a training corpus, from which spam emails and normal emails are selected as an email training set, and the ratio of spam emails to normal emails is 1:1, for example, 5,000 emails are selected for each. The email training set is marked as L = (L 1 , L 2 ,L 3 ... L 10000), spam is marked as S, and normal mail is marked as M. First, use regular expressions to remove all non-Chinese characters, such as punctuation marks, English characters, numbers, website links and other special characters. Secondly, use the stop word dictionary publicly available on the Internet to filter out stop words, such as modal particles, adverbs, prepositions, conjunctions, etc. Finally, use the Jieba word segmentation to segment the content of each email to obtain a vocabulary list. The frequency of occurrence of each word in the vocabulary list in the email training set L is counted, and the x words with the highest frequency of occurrence are taken as the high-frequency words, denoted as W = (W 1 , W 2 , W 3 , ...W x ), statistical high frequency words W = (W 1 , W 2 , W 3 , ...W x ) appears in spam emails S and normal emails M, and the frequency table of high-frequency words in emails is obtained. Among them, the high-frequency words W in spam emails S i The number of occurrences is recorded as Y i . High frequency words W in normal emails M i The number of occurrences is recorded as Z i .
[0041] In an embodiment of the present application, the use of the email high-frequency word frequency table to generate a spam detection algorithm based on Webassembly technology includes: using the email high-frequency word frequency table and a programming language supported by Webassembly technology to compile a spam detection algorithm; using Webassembly technology to compile the spam detection algorithm into a .wasm binary file.
[0042] In the embodiment of the present application, the programming languages supported by the Webassembly technology include: C language, C++ language, Go language and Rust language.
[0043] Specifically, in the embodiment of the present application, a frequency table of high-frequency words in emails is preset in the Naive Bayes algorithm, and a programming language supported by Webassembly is used to encode the Naive Bayes algorithm to form a spam detection algorithm, and then the spam detection algorithm is compiled into a .wasm binary file using Webassembly technology. When a click action is detected for sending an email to be sent in the web version of the mailbox, the .wasm binary file is directly called to perform spam detection on the email to be sent. Merchants and criminals cannot read the .wasm binary file on the web page, so the detection logic of the spam detection algorithm will not be exposed, and merchants and criminals will not be able to circumvent the spam detection algorithm, ensuring the security of the web page code, thereby improving the security of spam detection.
[0044] In an embodiment of the present application, calling a spam detection algorithm based on Webassembly technology to perform spam detection on an email to be sent that has a send click action, includes: calling a spam detection algorithm based on Webassembly technology to calculate a spam probability and a normal email probability of the email to be sent that has a send click action; when the spam probability is greater than the normal email probability, determining that the email to be sent that has a send click action is a spam.
[0045] In the embodiment of the present application, the spam probability of the email to be sent in which the send click action occurs is calculated in the following manner:
[0046] ;
[0047] ;
[0048] in, is the probability of spam, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, High frequency words in spam S The probability of occurrence, The high frequency words in spam S The number of occurrences, The probability of spam in the training set of emails.
[0049] In the embodiment of the present application, the probability of a normal email for an email to be sent that has a send click action is calculated in the following manner:
[0050] ;
[0051] ;
[0052] in, is the probability of normal email, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, For normal mail Medium and high frequency words The probability of occurrence, M is a high frequency word in normal emails The number of occurrences, is the probability of a normal email in the email training set.
[0053] Specifically, in the embodiments of the present application, when a send click action occurs for an email to be sent in the web version of the email, the high-frequency words W = (W 1 , W 2 , W 3 ,...W x ) that appear in the word segmentation of the email to be tested are counted, and are denoted as w = (w 1 , w 2 ,...w m ), where m < x, which serves as the feature vector of the current email to be tested. The spam detection algorithm based on the Webassembly technology is called to calculate the occurrence probabilities of the feature vector w = (w 1 , w 2 ,...w m ) in the spam emails S and the normal emails M respectively, that is, the spam probability and the normal email probability of the email to be sent.
[0054] The spam probability of the email to be sent is:
[0055] ;
[0056] ;
[0057] Among them, is the spam probability, x is the number of high-frequency words, ( ) are the high-frequency words that appear in the email to be sent with the send click action, and m < x. is the probability of the high-frequency word appearing in the spam email S, is the number of times the high-frequency word appearing in the spam email S determined by using the preset email high-frequency word frequency table, is the probability of the spam emails in the email training set. To avoid being 0, resulting in the final probability being 0, a Laplace smoothing coefficient a is introduced, where a is a specified coefficient and is usually set to 1.
[0058] The normal email probability of the email to be sent is:
[0059] ;
[0060] ;
[0061] Among them, is the normal email probability, x is the number of high-frequency words, ( ) are the high-frequency words that appear in the email to be sent with the send click action, and m < x. is the normal email in which the high-frequency word The probability of occurrence, The high-frequency words in the normal email M determined by using the preset email high-frequency word frequency table The number of occurrences, is the probability of a normal email in the email training set. is 0, resulting in a final probability of 0, and introducing a Laplace smoothing coefficient a, where a is a specified coefficient usually set to 1.
[0062] If the probability of spam Less than or equal to the probability of normal mail , then the email to be sent that has the send click action is determined to be a normal email. If the spam probability Greater than normal email probability , it is determined that the email to be sent for which the send click action has occurred is a spam email.
[0063] In the embodiment of the present application, the method further includes: when the spam detection result shows that the email to be sent on which the send click action occurs is a spam, prohibiting the sending operation of the email to be sent.
[0064] Specifically, in the embodiment of the present application, when it is determined that the email to be sent on which the send click action occurs is a spam, the sending operation of the email to be sent is prohibited. Furthermore, a prompt message can be issued at the front end to remind the user to modify the email to be sent, so as to prevent the user from accidentally writing sensitive high-frequency words in the email. After the user re-modifies the email content, it can be sent again. When it is detected as a normal email, the sending operation of the email to be sent is allowed, and the email can be sent smoothly.
[0065] The spam detection method provided by the present application is applied to the sending end of the web version of the mailbox. When the sending end detects that a click action has been made on the email, the spam detection algorithm based on the Webassembly technology is called to perform spam detection on the email to be sent, which reduces the front-end and back-end interactions and reduces the amount of back-end calculations. Moreover, the spam detection algorithm based on the Webassembly technology has high execution efficiency in spam detection and can accurately detect spam. The spam detection algorithm is invisible to users, which can avoid the exposure of the detection logic, prevent criminals from bypassing spam detection, and improve the security of spam detection.
[0066] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0067] In one embodiment, Figure 2 As shown, a spam detection device is provided, and the spam detection device 200 includes: a generation module 201, which is used to train and generate a frequency table of high-frequency words in emails; a Webassembly module 202, which is used to generate a spam detection algorithm based on the Webassembly technology by using the frequency table of high-frequency words in emails; a detection module 203, which is used to call the spam detection algorithm based on the Webassembly technology to perform spam detection on the email to be sent that has a send click action when a send click action is detected in a web version mailbox, and generate a spam detection result.
[0068] In an embodiment of the present application, the training generates an email high-frequency word frequency table, including: selecting an email training set, the emails in the email training set include spam emails and normal emails; performing word segmentation processing on the emails in the email training set to obtain a vocabulary list; counting the high-frequency words in the vocabulary list; calculating the number of times the high-frequency words appear in the spam emails and the normal emails to obtain the email high-frequency word frequency table.
[0069] In the embodiment of the present application, before performing word segmentation processing on the emails in the email training set, it also includes: removing non-Chinese characters and stop words from each email in the email training set.
[0070] In an embodiment of the present application, the use of the email high-frequency word frequency table to generate a spam detection algorithm based on Webassembly technology includes: using the email high-frequency word frequency table and a programming language supported by Webassembly technology to compile a spam detection algorithm; using Webassembly technology to compile the spam detection algorithm into a .wasm binary file.
[0071] In the embodiment of the present application, the programming languages supported by the Webassembly technology include: C language, C++ language, Go language and Rust language.
[0072] In an embodiment of the present application, calling a spam detection algorithm based on Webassembly technology to perform spam detection on an email to be sent that has a send click action, includes: calling a spam detection algorithm based on Webassembly technology to calculate a spam probability and a normal email probability of the email to be sent that has a send click action; when the spam probability is greater than the normal email probability, determining that the email to be sent that has a send click action is a spam.
[0073] In the embodiment of the present application, the spam probability of the email to be sent in which the send click action occurs is calculated in the following manner:
[0074] ;
[0075] ;
[0076] in, is the probability of spam, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, High frequency words in spam S The probability of occurrence, The high frequency words in spam S The number of occurrences, The probability of spam in the training set of emails.
[0077] In the embodiment of the present application, the probability of a normal email for an email to be sent that has a send click action is calculated in the following manner:
[0078] ;
[0079] ;
[0080] in, is the probability of normal email, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, For normal mail Medium and high frequency words The probability of occurrence, M is a high frequency word in normal emails The number of occurrences, is the probability of a normal email in the email training set.
[0081] In the embodiment of the present application, the detection module 203 is further configured to: when the spam detection result shows that the email to be sent on which the send click action occurs is a spam, prohibit the sending operation of the email to be sent.
[0082] The spam detection device includes a processor and a memory. The generation module, Webassembly module and detection module are stored in the memory as program units. The processor executes the program modules stored in the memory to implement corresponding functions.
[0083] The processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and spam detection can be achieved by adjusting kernel parameters.
[0084] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0085] An embodiment of the present application provides a processor configured to execute the spam detection method described above.
[0086] An embodiment of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the spam detection method described above.
[0087] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3 shown. Figure 3 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a spam detection method is implemented.
[0088] Those skilled in the art will understand that Figure 3The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0089] The embodiment of the present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: training to generate a frequency table of high-frequency words in emails; using the frequency table of high-frequency words in emails to generate a spam detection algorithm based on Webassembly technology; when a send click action is detected for an email to be sent in a web version of the mailbox, calling the spam detection algorithm based on Webassembly technology to perform spam detection on the email to be sent that has undergone a send click action; and generating a spam detection result.
[0090] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0091] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0092] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0093] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0094] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0095] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0096] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0097] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0098] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A spam detection method, characterized in that: Applied to the sending end of the web version mailbox, the spam detection method includes: Train and generate a frequency table of high-frequency words in emails; Generate a spam detection algorithm based on Webassembly technology by using the email high-frequency word frequency table; the spam detection algorithm is compiled into a .wasm binary file by using Webassembly technology; When the sending end of the web version mailbox detects that a click action has occurred on an email to be sent in the web version mailbox, a spam detection algorithm based on the Webassembly technology is called to perform spam detection on the email to be sent on which the click action has occurred; wherein, calling the spam detection algorithm based on the Webassembly technology to perform spam detection on the email to be sent on which the click action has occurred includes: calling the spam detection algorithm based on the Webassembly technology to calculate the spam probability and normal mail probability of the email to be sent on which the click action has occurred; when the spam probability is greater than the normal mail probability, determining that the email to be sent on which the click action has occurred is a spam email; wherein, the normal mail probability of the email to be sent on which the click action has occurred is calculated in the following manner: ; ;in, is the probability of normal email, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, For normal mail Medium and high frequency words The probability of occurrence, M is a high frequency word in normal emails The number of occurrences, is the probability of normal emails in the email training set; Generate spam detection results.
2. The spam detection method according to claim 1, characterized in that: The training generates a frequency table of high-frequency words in emails, including: Selecting an email training set, where the emails in the email training set include spam emails and normal emails; Performing word segmentation processing on the emails in the email training set to obtain a vocabulary list; Counting high-frequency words in the vocabulary; The number of times the high-frequency words appear in the junk mails and the normal mails is calculated to obtain a frequency table of high-frequency words in the mails.
3. The spam detection method according to claim 2, characterized in that: Before performing word segmentation processing on the emails in the email training set, the method further includes: The non-Chinese characters and stop words of each email in the email training set are removed.
4. The spam detection method according to claim 1, characterized in that: The method of using the email high-frequency word frequency table to generate a spam detection algorithm based on Webassembly technology includes: Compile a spam detection algorithm using the email high-frequency word frequency table and a programming language supported by Webassembly technology; The spam detection algorithm is compiled into a .wasm binary file using Webassembly technology.
5. The spam detection method according to claim 1, characterized in that: The spam probability of the email to be sent with the send click action is calculated as follows: ; ; in, is the probability of spam, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, High frequency words in spam S The probability of occurrence, The high frequency words in spam S The number of occurrences, The probability of spam in the training set of emails.
6. The spam detection method according to claim 1, characterized in that: The method further comprises: When the spam detection result shows that the email to be sent for which the send click action has occurred is a spam, the sending operation of the email to be sent is prohibited.
7. A spam detection device, characterized in that: Applied to the sending end of the web version mailbox, the spam detection device includes: Generation module, used to train and generate the frequency table of high-frequency words in emails; A Webassembly module is used to generate a spam detection algorithm based on the Webassembly technology by using the email high-frequency word frequency table; the spam detection algorithm is compiled into a .wasm binary file by using the Webassembly technology; The detection module is used for, when the sending end of the webpage version mailbox detects that a send click action has occurred on the email to be sent in the webpage version mailbox, calling a spam detection algorithm based on the Webassembly technology to perform spam detection on the email to be sent that has undergone the send click action, and generating a spam detection result; wherein, calling the spam detection algorithm based on the Webassembly technology to perform spam detection on the email to be sent that has undergone the send click action includes: calling the spam detection algorithm based on the Webassembly technology to calculate the spam probability and normal mail probability of the email to be sent that has undergone the send click action; when the spam probability is greater than the normal mail probability, determining that the email to be sent that has undergone the send click action is a spam email; wherein, the normal mail probability of the email to be sent that has undergone the send click action is calculated in the following manner: ; ;in, is the probability of normal email, x is the number of high-frequency words, ( ) is the high-frequency word that appears in the email to be sent when the send click action occurs, m<x, a is the Laplace smoothing coefficient, For normal mail Medium and high frequency words The probability of occurrence, M is a high frequency word in normal emails The number of occurrences, is the probability of a normal email in the email training set.
8. A spam detection device, characterized in that: The spam detection device comprises: a processor and a memory, wherein the processor is configured to execute the spam detection method according to any one of claims 1 to 6.
9. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the spam detection method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the spam detection method according to any one of claims 1 to 6 is implemented.
