Text verification method and device, electronic equipment and storage medium

Through pinyin conversion and prefix tree matching technology, the accuracy problem of homophone similarity judgment of sensitive words in online game products is solved, and efficient sensitive word detection and memory savings are achieved.

CN119311886APending Publication Date: 2025-01-14NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411139085.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

When verifying the text input by users in the prior art online game products, it is difficult to accurately deal with homophones and similarities of sensitive words, resulting in inaccurate judgments and prone to synchronization and omissions in the word list.

Method used

The method of combining the sensitive word prefix tree and the pinyin prefix tree is adopted to directly match the sensitive word and pinyin combination through the key-value pair structure, so as to achieve rapid query and memory saving, and be able to handle the situation of pronunciation and special combinations.

Benefits of technology

It improves the accuracy and efficiency of sensitive word detection, reduces memory usage, and can effectively identify sensitive information in user input.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311886A_ABST
    Figure CN119311886A_ABST
Patent Text Reader

Abstract

The invention provides a text verification method and device, electronic equipment and a storage medium. A to-be-verified text is converted into pinyin to obtain target pinyin; in the process of traversing the to-be-verified text, determining whether a first word in the to-be-verified text is matched with a sensitive word in the sensitive word prefix tree or not to obtain a first matching result; the sensitive word prefix tree comprises a plurality of key value pairs, and sensitive words and sensitive word tags corresponding to the sensitive words are configured for different key value pairs respectively; in the process of traversing the target pinyin, determining whether a first pinyin combination in the target pinyin is matched with a pinyin combination in the pinyin prefix tree, and obtaining a second matching result; the pinyin prefix tree comprises a plurality of key value pairs, and pinyin and sensitive word tags corresponding to different sensitive words are configured for different key value pairs respectively; and based on the first matching result and the second matching result, determining whether the to-be-verified text is compliant or not. According to the method, sensitive word detection under the conditions of similar pronunciation, special combination and the like can be processed at the same time, and the sensitive word detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a text verification method, device, electronic device and storage medium. Background Art

[0002] Online game products often need to verify the texts input and published by users to determine whether they contain non-compliant content. Some rules or sensitive words are usually used in the judgment process. However, due to the large amount of online user input and the high degree of colloquialism, some homophones and variants are used to bypass sensitive words. Therefore, a judgment method that can handle homophones and similarities is needed to accurately determine sensitive information. In the related art, when checking sensitive words, homophones of sensitive words, and similar words of sensitive words, word lists are constructed separately, which is very cumbersome and prone to word list asynchrony or omissions, resulting in inaccurate sensitive word judgment. Summary of the invention

[0003] The purpose of the present disclosure is to provide a text verification method, device, electronic device and storage medium to improve the accuracy of sensitive word identification.

[0004] In a first aspect, the present disclosure provides a text verification method, the method comprising: obtaining a text to be verified, and performing pinyin conversion processing on the text to be verified to obtain a target pinyin corresponding to the text to be verified; traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches a sensitive word in a sensitive word prefix tree, and obtaining a first matching result; wherein the sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and whether the matching The sensitive word label corresponding to the first word; traverse the target pinyin, and in the process of traversing the target pinyin, determine whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree to obtain a second matching result; wherein the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; based on the first matching result and the second matching result, determine whether the text to be verified is compliant.

[0005] In a second aspect, the present disclosure provides a text verification device, which includes: a text acquisition module, which is used to obtain a text to be verified, and perform pinyin conversion processing on the text to be verified to obtain a target pinyin corresponding to the text to be verified; a first verification module, which is used to traverse the text to be verified, and in the process of traversing the text to be verified, determine whether the first word in the text to be verified matches a sensitive word in a sensitive word prefix tree, and obtain a first matching result; wherein the sensitive word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and whether the matching The second verification module is used to traverse the target pinyin, and in the process of traversing the target pinyin, determine whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree to obtain a second matching result; wherein the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; the verification result determination module is used to determine whether the text to be verified is compliant based on the first matching result and the second matching result.

[0006] In a third aspect, the present disclosure provides an electronic device, which includes a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned text verification method.

[0007] In a fourth aspect, the present disclosure provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned text verification method.

[0008] The embodiments of the present disclosure bring the following beneficial effects:

[0009] The present disclosure provides a text verification method, device, electronic device and storage medium, which first obtain a text to be verified, and perform pinyin conversion processing on the text to be verified to obtain a target pinyin corresponding to the text to be verified; then traverse the text to be verified, and in the process of traversing the text to be verified, determine whether the first word in the text to be verified matches a sensitive word in a sensitive word prefix tree to obtain a first matching result; wherein the sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and The sensitive word label corresponding to the first word when matching; then traverse the target pinyin, and in the process of traversing the target pinyin, determine whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree to obtain the second matching result; wherein, the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with different pinyins corresponding to sensitive words and sensitive word labels corresponding to pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; then based on the first matching result and the second matching result, determine whether the text to be verified is compliant. In this method, the sensitive word prefix tree and the pinyin prefix tree directly use the pinyin dictionary object, that is, the key-value pair, instead of the node connection method, which greatly saves memory; at the same time, this method can simultaneously handle sensitive word detection in cases such as similar-sounding pinyins and special combinations through the sensitive word prefix tree and the pinyin prefix tree, thereby improving the accuracy of sensitive word detection.

[0010] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.

[0011] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, the following specifically cites preferred implementation modes and describes them in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0013] Figure 1 A flowchart of a text verification method provided by an embodiment of the present disclosure;

[0014] Figure 2A text verification architecture diagram provided for an embodiment of the present disclosure;

[0015] Figure 3 A schematic diagram of the structure of a text verification device provided by an embodiment of the present disclosure;

[0016] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. The components of the embodiments of the present disclosure described and shown in the drawings here can be arranged and designed in various different configurations.

[0018] Therefore, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the present disclosure claimed for protection, but merely represents selected embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present disclosure.

[0019] The present disclosure provides a text verification method, device, electronic device and storage medium. The technology can be applied to scenarios where user input and published text is verified in game products, and can also be applied to scenarios where user input text is verified in other products.

[0020] In order to facilitate understanding of the embodiment of the present invention, a text verification method provided by the embodiment of the present invention is first described in detail. Figure 1 As shown, the method comprises the following specific steps:

[0021] Step S102, obtaining the text to be verified, and performing pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified.

[0022] In a specific implementation, the text to be verified can be any text content input or published by the user, and the text content can include Chinese characters, English, symbols or numbers, etc. After obtaining the text to be verified, all Chinese characters in the text to be verified need to be converted into pinyin to obtain the text to be verified after pinyin conversion, and the text to be verified after pinyin conversion is also the target pinyin.

[0023] Step S104, traverse the text to be verified, and in the process of traversing the text to be verified, determine whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtain a first matching result; wherein the sensitive word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and the sensitive word label corresponding to the first word when matching.

[0024] In specific implementation, after preparing the sensitive word list, a sensitive word prefix tree needs to be established based on the sensitive word list. The sensitive word list contains multiple sensitive words and sensitive word labels corresponding to each sensitive word. The sensitive word label is used to indicate the sensitive type corresponding to the sensitive word. The sensitive type may include but is not limited to politicians, insults, harm, etc. The sensitive word prefix tree contains multiple key-value pairs. The sensitive word prefix tree uses a prefix string as the key in the key-value pair. The prefix string is a sensitive word in the sensitive word list. The key value in the key-value pair is the sensitive word label. This method is different from the existing technology in which the prefix tree uses node connection to create multiple nodes. Instead, the prefix tree is created by creating key-value pairs, thereby reducing the establishment of node objects and greatly saving memory space.

[0025] In practical applications, the sensitive prefix tree can implement queries with O(1) time complexity, where the part to be queried is the key (the key is the key in the key-value pair), and the sensitive word label is in the value corresponding to the key (the value is the key value in the key-value pair). For example, in the sensitive word prefix tree, query the name of the person "Zhang San", and directly use self.preffix.get("Zhang San") to get the corresponding sensitive word label "political figure". The specific process is to traverse the text to be checked, determine whether it matches the sensitive word contained in the key-value pair in the sensitive word prefix tree, and return the corresponding sensitive word label when a sensitive word is matched.

[0026] Specifically, after obtaining the text to be verified, the text to be verified is traversed and in the process of traversing the text to be verified, it is determined whether there is a first word in the text to be verified that matches the sensitive word in the sensitive word prefix tree; if so, it is determined that there is a sensitive word in the text to be verified, and the sensitive word label corresponding to the sensitive word matching the first word in the sensitive word prefix tree needs to be determined as the sensitive word label corresponding to the first word, and the result of the existence of the sensitive word in the text to be verified, the first word and the sensitive word label corresponding to the first word are stored in the first matching result; if not, it is determined that there is no sensitive word in the text to be verified, and the result of the existence of the sensitive word in the text to be verified is taken as the first matching result.

[0027] It should be noted that the first word in the above text to be verified may be just one word or multiple words, the sensitive words corresponding to different first words may be the same or different, and different first words have different positions in the text to be verified.

[0028] Step S106, traverse the target pinyin, and in the process of traversing the target pinyin, determine whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree, and obtain a second matching result; wherein the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching.

[0029] In the specific implementation, in order to be able to process pinyin, it is necessary to build a pinyin prefix tree. The construction principle of the pinyin prefix tree is the same as that of the sensitive word prefix tree, except that the process of converting sensitive words to pinyin is added. Specifically, after preparing the sensitive word list, all sensitive words in the sensitive word list need to be converted into pinyin, and different characters in the same sensitive word are separated by separators to obtain the pinyin combination corresponding to each sensitive word, and the pinyin combination corresponding to all sensitive words is determined as a pinyin word list, and then a pinyin prefix tree is established based on the pinyin word list. The pinyin prefix tree contains multiple key-value pairs, the key in the key-value pair is the pinyin combination corresponding to the sensitive word in the pinyin word list, and the key value in the key-value pair is the sensitive word and sensitive word label corresponding to the pinyin combination. This method is different from the prior art in that the prefix tree uses node connection to create multiple nodes, but creates key-value pairs to create a prefix tree, thereby reducing the establishment of node objects and greatly saving memory space.

[0030] In practical applications, the Pinyin prefix tree can implement queries with O(1) time complexity, where the part to be queried is the key (the key is the key in the key-value pair), and the sensitive word label is in the value corresponding to the key (the value is the key value in the key-value pair). For example, in the Pinyin prefix tree, query the Pinyin of the person's name "zhang-san", and directly use self.preffix.get("zhang-san") to get the corresponding sensitive word "Zhang San" and the sensitive word label "political figure". The specific process is to traverse the target Pinyin, determine whether it matches the Pinyin combination contained in the key-value pair in the Pinyin prefix tree, and return the corresponding sensitive word label when the Pinyin combination corresponding to the sensitive word is matched.

[0031] Specifically, after obtaining the target pinyin corresponding to the text to be verified, traverse the target pinyin and in the process of traversing the target pinyin, determine whether there is a first pinyin combination in the target pinyin that matches the pinyin combination in the pinyin prefix tree; if so, determine that there is a sensitive word in the text to be verified, and it is necessary to determine the sensitive word label corresponding to the pinyin combination matching the first pinyin combination in the pinyin prefix tree as the sensitive word label corresponding to the first pinyin combination, and store the result of the existence of sensitive words in the text to be verified, the first pinyin combination, and the sensitive word label corresponding to the first pinyin combination in the second matching result; if not, determine that there is no sensitive word in the text to be verified, and use the result of the existence of sensitive words in the text to be verified as the second matching result.

[0032] It should be noted that the first pinyin combination in the target pinyin corresponding to the above-mentioned text to be verified can be only one pinyin combination or multiple pinyin combinations. The sensitive words corresponding to different first pinyin combinations can be the same or different, and the positions of different first pinyin combinations in the target pinyin are different.

[0033] Step S108: Determine whether the text to be checked is compliant based on the first matching result and the second matching result.

[0034] In the specific implementation, if the first matching result indicates that the first word matches the sensitive word in the sensitive word prefix, it is determined that the text to be verified contains sensitive words, that is, the text to be verified is non-compliant; if the second matching result indicates that the first pinyin combination matches the pinyin combination in the pinyin prefix, it is determined that the text to be verified contains sensitive words, that is, the text to be verified is non-compliant; if the first matching result indicates that the first word does not match the sensitive word in the sensitive word prefix tree, and the second matching result indicates that the first pinyin combination does not match the pinyin combination in the pinyin prefix tree, it is determined that there is no sensitive word in the text to be checked, that is, the text to be verified is compliant.

[0035] An embodiment of the present invention provides a text verification method, in which a sensitive word prefix tree and a pinyin prefix tree directly use dictionary objects, that is, key-value pairs, rather than a node-connected manner, which greatly saves memory; at the same time, this method can simultaneously process sensitive word detection in situations such as similar-sounding characters and special combinations through the sensitive word prefix tree and the pinyin prefix tree, thereby improving the accuracy of sensitive word detection.

[0036] The following embodiments are used to describe the creation method of the sensitive word prefix tree and the pinyin prefix tree.

[0037] Specifically, the above-mentioned sensitive word prefix tree is determined in the following manner: obtain a sensitive word list and establish an empty dictionary object; wherein the sensitive word list includes multiple sensitive words and sensitive word labels corresponding to the sensitive words; the sensitive words include at least one character; for each sensitive word in the sensitive word list, perform the following operations: traverse each character in the current sensitive word, and determine whether the target word composed of the current character and all characters before the current character in the current sensitive word is in the sensitive word prefix tree, if not, add the target word to the empty dictionary object to obtain the first object; wherein the first object is a key-value pair, the key in the key-value pair is the target word, and the key value corresponding to the target word is empty; determine whether the current word is the last character in the current sensitive word, if so, adjust the key value in the first object to the sensitive word label corresponding to the current sensitive word in the sensitive word list, and obtain the adjusted first object; add the first object and the adjusted first object to the sensitive word prefix tree.

[0038] In a specific implementation, the above-mentioned sensitive word list is pre-set, and the sensitive word list can be adjusted according to user needs. Specifically, in response to an adjustment operation on a sensitive word in the sensitive word list, based on the adjustment operation, the sensitive words included in the sensitive word list are added, modified or deleted. Among them, the specific operation corresponding to the adjustment operation can be determined according to research and development needs. For example, the adjustment operation can be an operation of adding a new sensitive word to the sensitive word list, an operation of deleting a sensitive word in the sensitive word list, or an operation of modifying a sensitive word in the sensitive word list.

[0039] In practical applications, after preparing the sensitive word list, an empty dictionary object needs to be created so that the dictionary object can be used directly to create a sensitive word prefix tree, thereby reducing the creation of node objects and saving memory space. Then, each sensitive word in the sensitive word list needs to be traversed so that each sensitive word and the sensitive word label corresponding to the sensitive word are added to a corresponding dictionary object to obtain multiple key-value pairs, where a key-value pair is also a dictionary object, and each key-value pair contains a sensitive word and the sensitive word label corresponding to the sensitive word. Different key-value pairs correspond to different sensitive words. When traversing the sensitive words in the sensitive word list, each sensitive word needs to be taken as a current sensitive word, and each word in the current sensitive word needs to be traversed to determine whether the sensitive word is in the sensitive word prefix tree. If not, the sensitive word and the sensitive word label corresponding to the sensitive word will be added to the empty dictionary object to obtain a key-value pair.

[0040] For example, if the current sensitive word is Zhang Yi'er, and the sensitive word tag corresponding to "Zhang Yi'er" is "political figure", then first it is necessary to determine whether "Zhang" is in the sensitive word prefix tree. If not, add "Zhang" to an empty dictionary object to obtain the first object "Zhang: []". At this time, the key in the first object is "Zhang" and the key value is empty. If "Zhang" is in the sensitive word prefix tree or the first object "Zhang: []" is obtained, then determine whether "Zhang Yi" is in the sensitive word prefix tree. If not, obtain a new first object "Zhang Yi: []". If "Zhang Yi" is in the sensitive word prefix tree or the first object "Zhang Yi: []" is obtained, then determine whether "Zhang Yi'er" is in the sensitive word prefix tree. If not, obtain a new first object "Zhang Yi'er: []". At this time, the end position of the current sensitive word is reached, and the sensitive word tag needs to be added, that is, adjust the first object to "Zhang Yi'er: [political figure]", and then add "Zhang: []", "Zhang Yi: []", and "Zhang Yi'er: [political figure]" to the sensitive word prefix tree.

[0041] Furthermore, the above-mentioned pinyin prefix tree is determined in the following way: convert the sensitive words in the sensitive word list into pinyin to obtain a pinyin word list; where the pinyin word list includes: pinyin combinations corresponding to multiple sensitive words, as well as the sensitive words and sensitive word tags corresponding to the pinyin combinations; for each pinyin combination in the pinyin word list, perform the following operations: traverse each pinyin in the current pinyin combination, and determine whether the target pinyin combination formed by the current pinyin and all the pinyins before the current pinyin in the current pinyin combination is in the pinyin prefix tree. If not, add the target pinyin combination to an empty dictionary object to obtain a second object; where the second object is a key-value pair, and the key in the key-value pair is the target pinyin combination, and the key value corresponding to the target pinyin combination is empty; determine whether the current pinyin is the last pinyin in the current pinyin combination. If so, adjust the key value in the second object to the sensitive word and sensitive word tag corresponding to the current pinyin combination in the pinyin word list to obtain an adjusted second object; add the second object and the adjusted second object to the pinyin prefix tree.

[0042] In specific implementation, the sensitive word list used for constructing the pinyin prefix tree and the sensitive word prefix tree is the same. After preparing the sensitive word list, each sensitive word in the sensitive word list needs to be converted into pinyin, and the pinyins corresponding to different characters in the same sensitive word are separated by a separator. For example, convert the sensitive word "Zhang Yi'er" into "zhang-san" or "zhang1-san2"; where the 1 in zhang1 represents that the tone of "Zhang" is the first tone, and the 2 in san2 represents that the tone of "san" is the second tone. After converting all the sensitive words in the sensitive word list into pinyin, the pinyin combination corresponding to each sensitive word can be obtained, thereby obtaining a pinyin word list, that is, the pinyin word list includes the pinyin combination corresponding to each sensitive word in the sensitive word list.

[0043] After obtaining the pinyin word list, it is necessary to traverse each pinyin combination in the pinyin word list so that each pinyin combination and the sensitive word and sensitive word label corresponding to the pinyin combination are added to a corresponding dictionary object, obtaining multiple key-value pairs. Among them, a key-value pair is also a dictionary object. Each key-value pair contains a pinyin combination, the sensitive word corresponding to the pinyin combination, and the sensitive word label corresponding to the sensitive word. Different key-value pairs correspond to different sensitive words. The key in the key-value pair is the pinyin combination, and the key-value in the key-value pair is the sensitive word corresponding to the pinyin combination and the sensitive word label corresponding to the sensitive word. When traversing the pinyin combinations in the pinyin word list, each pinyin combination needs to be used as the current pinyin combination once, and each pinyin in the current pinyin combination is traversed to determine whether the pinyin combination is in the pinyin prefix tree. If not, the pinyin combination, the sensitive word corresponding to the pinyin combination, and the sensitive word object corresponding to the sensitive word are added to an empty dictionary object, obtaining a key-value pair.

[0044] For example, if the current pinyin combination is "zhang1-yi1-er2", the sensitive word corresponding to the current pinyin combination is "张一二", and the sensitive word label corresponding to the sensitive word is "political figure", then first it is necessary to determine whether "zhang1" is in the pinyin prefix tree. If not, add "zhang1" to the empty dictionary object, obtaining the second object "zhang1: []". At this time, the key in the second object is "zhang1", and the key-value is empty. If "zhang1" is in the pinyin prefix tree or the second object "zhang1: []" is obtained, determine whether "zhang1-yi1" is in the pinyin prefix tree. If not, obtain the new second object "zhang1-yi1: []". If "zhang1-yi1" is in the pinyin prefix tree or the second object "zhang1-yi1: []" is obtained, determine whether "zhang1-yi1-er2" is in the pinyin prefix tree. If not, obtain the new second object "zhang1-yi1-er2: []". At this time, the end position of the current pinyin combination is reached, and it is necessary to add the sensitive word and sensitive word label corresponding to the current pinyin combination, that is, to adjust the second object to "zhang1-yi1-er2: [张一二, political figure]", so as to add "zhang1: []", "zhang1-yi1: []", and "zhang1-yi1-er2: [张一二, political figure]" to the pinyin prefix tree.

[0045] In the above method, constructing a sensitive word prefix tree can directly intercept sensitive words entered by users; at the same time, in order to prevent users from using homophones to attack the game system, it is necessary to construct a homophone interception ability, that is, to construct a pinyin prefix tree for homophone interception, so as to comprehensively intercept non-compliant texts.

[0046] The following embodiments are used to describe a method of performing text matching based on a sensitive word prefix tree.

[0047] Specifically, in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtaining the first matching result can be implemented by the following steps 10-17:

[0048] Step 10, determining the first word in the text to be verified as the starting traversal word.

[0049] Step 11, traverse the text to be verified starting from the starting traversal word; determine the starting traversal word as the first word, and determine whether the first word is in the sensitive word prefix tree. If the first word is in the sensitive word prefix tree, execute step 12, otherwise, execute step 15.

[0050] In the specific implementation, since the sensitive word prefix tree contains not only key-value pairs such as "sensitive word: sensitive word label", but also key-value pairs consisting of partial characters in sensitive words and empty key values, it is possible to determine whether each character in the text to be verified is in the sensitive word prefix tree, that is, to determine whether the character is the key in the key-value pair in the sensitive prefix tree.

[0051] Step 12, determine whether the first word in the sensitive word prefix tree corresponds to a sensitive word label; if so, execute step 13, otherwise, execute step 14.

[0052] Step 13, determine the sensitive word label as the sensitive word label corresponding to the first word; and execute step 14.

[0053] Step 14, determine whether the last character of the first word is the last character in the text to be verified, if so, execute step 15; otherwise, execute step 17.

[0054] Step 15, determine whether the starting traversal word is the last word in the text to be verified, if so, stop traversal; otherwise, execute step 16.

[0055] Step 16, determine the next word of the starting traversal word in the text to be verified as the updated starting traversal word, and execute step 11.

[0056] Step 17, combine the first word and the next word of the first word in the text to be verified to form an updated first word, and execute step 11.

[0057] In a specific implementation, while determining the sensitive word label corresponding to the first word, the starting position and the ending position of the first word in the text to be verified are recorded, and the starting position and the ending position corresponding to the first word are bound to the sensitive word label corresponding to the first word. This method can determine the position where the sensitive word appears in the text to be verified, and the sensitive label corresponding to the sensitive word.

[0058] When traversing the text to be verified, record the start position as start and the end position as end. start starts from 0 and continuously increases until the end of the text to be verified. end starts from start + 1 and continuously increases, so as to determine whether the fragment in the text to be verified corresponding to the start position to the end position (equivalent to the first word above) is in the sensitive word prefix tree. If it is in the sensitive word prefix tree and there is a sensitive word label, the fragment from start to end is a sensitive word; if it is in the sensitive word prefix tree, increase the end position by 1, that is, end is equal to the original end plus one. If it is not in the sensitive word prefix tree, jump out of the loop and increase the position of start by one.

[0059] For example, the text to be verified is "Listen to Zhang Yi'er's command". The sensitive word prefix tree includes key-value pairs: "Zhang: []", "Zhang Yi: []", and "Zhang Yi'er: [Political figure]". When starting to traverse the text to be verified, start is 0 and end is 1, and the first character "Listen" is obtained; "Listen" is not in the sensitive word prefix tree, skip start 0, adjust start to 1, end to 2, and get "Zhang", and "Zhang" is in the sensitive word prefix tree, so end is incremented by 1; start is 1, end is 3, and "Zhang Yi" is obtained, and "Zhang Yi" is in the sensitive word prefix tree, so end is incremented by 1; start is 1, end is 4, and "Zhang Yi'er" is obtained, and "Zhang Yi'er" is in the sensitive word prefix tree, so end is incremented by 1. At the same time, there is a sensitive word label, so it is determined that "Zhang Yi'er" is a sensitive word, and the start position 1, end position 4 corresponding to "Zhang Yi'er", and the sensitive word label are output. At this time, start is 1, end is 5, and "Zhang Yi'er commands" is obtained, and "Zhang Yi'er commands" is not in the sensitive word prefix tree, skip start 1, adjust start to 2, end to 3, and get "Yi", "Yi" is not in the sensitive word prefix tree, skip start 2, adjust start to 3, end to 4, and get "Er", "Er" is not in the sensitive word prefix tree, skip start 3, adjust start to 4, end to 5, and get "Command", "Command" is not in the sensitive word prefix tree, skip start 4, adjust start to 5, end to 6, and get "Wave", "Wave" is not in the sensitive word prefix tree, skip start 5, adjust start to 6, and end.

[0060] The above method can detect sensitive words in the text to be verified within a linear time complexity.

[0061] The following embodiments are used to describe the method of text matching based on the pinyin prefix tree.

[0062] Specifically, the specific process of converting the text to be verified into pinyin to obtain the target pinyin corresponding to the text to be verified may include: converting each character in the text to be verified into pinyin; connecting the pinyins corresponding to adjacent characters using designated characters to obtain the connected pinyin; and determining the connected pinyin as the target pinyin corresponding to the text to be verified. The designated characters may be determined according to R&D requirements, for example, the designated characters may be "-", "*" or ".", etc.

[0063] In an optional embodiment, the specific process of converting each character in the text to be verified into pinyin may further include: for each character in the text to be verified, converting the current character into a combination of pinyin and tone to obtain a pinyin combination, and determining the pinyin combination as the pinyin corresponding to the current character. Among them, the tone is usually represented by a number, and different tones correspond to different numbers, for example, the first tone is represented by 1, the second tone is represented by 2, the third tone is represented by 3, the fourth tone is represented by 4, etc.

[0064] For example, if the text to be verified is "I am Zhang San", the target pinyin corresponding to the text to be verified is "wo3-shi4-zhang1-san1"; if the text to be verified is "How are you", the target pinyin corresponding to the text to be verified is "ni3-hao3-ma1". In this way, the text is converted into pinyin, and the homophone replacement when the user attacks the system can be identified, thereby improving the accuracy of sensitive word detection.

[0065] In the specific implementation, in the process of traversing the target pinyin, it is determined whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree, and the specific process of obtaining the second matching result can be implemented by the following steps 20-27:

[0066] Step 20, determining the first pinyin in the target pinyin as the starting traversal pinyin.

[0067] Step 21, traverse the target pinyin starting from the starting traversal pinyin; determine the starting traversal pinyin as the first pinyin combination, determine whether the first pinyin combination is in the pinyin prefix tree, if the first pinyin combination is in the pinyin prefix tree, execute step 22; otherwise execute step 27.

[0068] In the specific implementation, since the pinyin prefix tree not only contains key-value pairs such as "pinyin combination: sensitive word, sensitive word label", but also includes key-value pairs consisting of partial pinyin corresponding to sensitive words and empty key values, it is possible to determine whether each pinyin in the target pinyin is in the pinyin prefix tree, that is, to determine whether the pinyin is the key in the key-value pair in the pinyin prefix tree.

[0069] Step 22, determine whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; if so, execute step 23, otherwise execute step 24.

[0070] Step 23, determine the sensitive word label as the sensitive word label corresponding to the first pinyin combination; execute step 24.

[0071] Step 24, determining whether the last pinyin of the first pinyin combination is the last pinyin in the target pinyin, if yes, executing step 25; otherwise, executing step 27.

[0072] Step 25, determining whether the starting traversal pinyin is the last pinyin in the target pinyin, if so, stop traversal; otherwise, execute step 26.

[0073] Step 26, determining the next pinyin of the starting traversal pinyin in the target pinyin as the updated starting traversal pinyin, and continuing to execute step 21.

[0074] Step 27, combining the first pinyin combination and the next pinyin of the first pinyin combination in the target pinyin to form an updated first pinyin combination, and continuing to execute step 21.

[0075] In a specific implementation, while determining the sensitive word label corresponding to the first pinyin combination, the starting position and ending position of the first pinyin combination in the text to be verified, as well as the sensitive word corresponding to the first pinyin combination, are recorded, and the sensitive word, starting position, and ending position corresponding to the first pinyin combination are bound to the sensitive word label corresponding to the first pinyin combination. This method can determine the position of the pinyin corresponding to the sensitive word in the target pinyin, as well as the sensitive label corresponding to the sensitive word.

[0076] When traversing the target pinyin, the starting position is recorded as start and the ending position is recorded as end. Start is incremented from 0 until the end of the target pinyin, and end is incremented from start+1 to determine whether the pinyin segment in the target pinyin corresponding to the starting position to the ending position is in the pinyin prefix tree. If it is in the pinyin prefix tree and there is a sensitive word label, the segment from start to end is the pinyin combination corresponding to the sensitive word; if it is in the pinyin prefix tree, the ending position is increased by 1, that is, end is equal to the original end plus one. If it is not in the pinyin prefix tree, jump out of the loop and increase the start position by one.

[0077] For example, the text to be verified is "Listen to Zhang Yier's command", and the target pinyin is "ting1-zhang1-yi1-er2-zhi3-hui1". The key-value pairs in the pinyin prefix tree include: "zhang1: []", "zhang1-yi1: []", and "zhang1-yi1-er2: [Zhang Yier, political figure]". When starting to traverse the target audio, start is 0 and end is 1, and the first pinyin "ting1" is obtained. Since "ting1" is not in the audio prefix tree, start0 is skipped, start is adjusted to 1, end is adjusted to 2, and "zhang1" is obtained. Since "zhang1" is in the pinyin prefix tree, end is incremented by 1; start is 1, end is 3, and "zhang1-yi1" is obtained. Since "zhang1-yi1" is in the pinyin prefix tree, end is incremented by 1; start is 1, end is 4, and "zhang1-yi1-er2" is obtained. Since "zhang1-yi1-er2" is in the pinyin prefix tree, end is incremented by 1. At the same time, there is a sensitive word label, so it is determined that "zhang1-yi1-er2" is a sensitive word, and the starting position 1, ending position 4 of "zhang1-yi1-er2", and the sensitive word label are output. At this time, start is 1, end is 5, and "zhang1-yi1-er2-zhi3" is obtained. Since "zhang1-yi1-er2-zhi3" is not in the pinyin prefix tree, start1 is skipped, start is adjusted to 2, end is adjusted to 3, and "yi1" is obtained. Since "yi1" is not in the pinyin prefix tree, start2 is skipped, start is adjusted to 3, end is adjusted to 4, and "er2" is obtained. Since "er2" is not in the pinyin prefix tree, start3 is skipped, start is adjusted to 4, end is adjusted to 5, and "zhi3" is obtained. Since "zhi3" is not in the pinyin prefix tree, start4 is skipped, start is adjusted to 5, end is adjusted to 6, and "hui1" is obtained. Since "hui1" is not in the pinyin prefix tree, start5 is skipped, start is adjusted to 6, and the traversal ends.

[0078] The above method can perform sensitive word detection on the target audio corresponding to the text to be verified within a linear time complexity, thereby preventing users from using homophonic attacks on the game system and constructing a homophonic interception ability.

[0079] The following embodiments are used to describe the method for sensitive word verification in multi-project access.

[0080] In different projects, the verification requirements vary greatly. That is to say, usually a security service will be provided for multiple business parties to use. Different business parties will have a basic security requirement, and at the same time, they will also have their own customized parts. At the same time, it should also be able to be updated in real time to solve online problems.

[0081] Specifically, after obtaining the text to be verified, determine the target project identifier corresponding to the text to be verified, and determine the target text verification method based on the target project identifier; wherein the target text verification method is the text verification method corresponding to the target project corresponding to the target project identifier, and the target project is a project in multiple preset projects; perform text verification on the text to be verified based on the target text verification method to obtain the verification result, and determine the updated text to be verified based on the verification result, and continue to perform pinyin conversion processing on the updated text to be verified to obtain the target pinyin corresponding to the text to be verified. Specifically, the text verification methods corresponding to different projects can be the same or different, which can be determined according to research and development needs.

[0082] In an optional embodiment, the specific process of performing text verification on the text to be verified based on the target text verification method, obtaining the verification result, and determining the updated text to be verified based on the verification result may include: traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the replacement word prefix tree; wherein the replacement word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and replacement words corresponding to the sensitive words; if they match, determining the target sensitive word in the replacement word prefix tree that matches the first word, and replacing the first word with the replacement word corresponding to the target sensitive word to obtain the replaced text to be verified; and determining the replaced text to be verified as the updated text to be verified.

[0083] Specifically, the present disclosure also provides a word replacement function. By constructing a proper word replacement table, the fragments in the text to be verified can be replaced with preset label fragments. Note that it cannot be set here to not detect if it contains proper words, so that the context will be risky. The specific process is as follows: first, a replacement word list needs to be prepared, and then a replacement word prefix tree is constructed based on the replacement word list. The method of constructing the replacement word prefix tree here is the same as the method of constructing the sensitive word prefix tree mentioned above, except that the two use different word lists, which will not be repeated here. In actual applications, the method of using the replacement word prefix tree is the same as the method of using the sensitive word prefix tree, the difference is that the second word matched in the text to be verified is replaced with a label in the replacement word list (equivalent to a key value). For example, xxx is in the sensitive word list, but a game with a background related to xxx is connected. The project party does not want to intercept this content, and can set a label such as "xxx->noun", which is the replacement word corresponding to xxx.

[0084] In an optional embodiment, after replacing the first word with the replacement word corresponding to the target sensitive word to obtain the replaced text to be verified, the replaced text to be verified can also be subjected to pinyin conversion processing to obtain the preset pinyin corresponding to the replaced text to be verified; traversing the replaced text to be verified, and in the process of traversing the replaced text to be verified, determining whether the second word in the replaced text to be verified matches the target sensitive word in the project sensitive word prefix tree to obtain a third matching result; wherein the project sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding project sensitive words and sensitive word labels corresponding to the project sensitive words; the number of project sensitive words in the project sensitive word prefix tree is less than the number of sensitive words in the sensitive word prefix tree, and the project sensitive words are updated in real time according to project requirements; the third matching result is used to indicate: whether the second word matches the project sensitive word The project sensitive words in the word prefix tree are matched, and the sensitive word label corresponding to the second word when matching; the preset pinyin is traversed, and in the process of traversing the preset pinyin, it is determined whether the second pinyin combination in the preset pinyin matches the project pinyin combination in the project pinyin prefix tree to obtain a fourth matching result; wherein the project pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different project sensitive words and sensitive word labels corresponding to the pinyins; the number of project pinyin combinations in the project pinyin prefix tree is less than the number of pinyin combinations in the pinyin prefix tree, and the project pinyin combinations are updated in real time according to project requirements; the fourth matching result is used to indicate: whether the second pinyin combination matches the pinyin combination in the project pinyin prefix tree, and the sensitive word label corresponding to the second pinyin combination when matching; based on the third matching result and the fourth matching result, the verification result is determined.

[0085] Specifically, the project sensitive word prefix tree and the project pinyin prefix tree contain relatively little content and are updated in real time. Only a small part of the content involved in the project needs to be paid attention to, so that the text can be verified in a targeted manner. At the same time, the method of performing text matching based on the project sensitive word prefix tree and the project pinyin prefix tree in the above target text verification method is the same as the method of performing text matching based on the sensitive word prefix tree and the pinyin prefix tree in the above embodiment, which will not be repeated here, and reference can be made to the above embodiment.

[0086] Furthermore, in response to the adjustment operation for the project sensitive words, based on the adjustment operation, the project sensitive words corresponding to the project sensitive word prefix tree and the project pinyin prefix tree can be added, modified or deleted. That is, this method can update the target sensitive words used to create the project sensitive word prefix tree and the pinyin prefix tree in real time according to the project requirements, so as to meet the personalized needs of the project. Among them, the creation method of the project sensitive word prefix tree is the same as the creation method of the above-mentioned sensitive word prefix tree, and the creation method of the project pinyin prefix tree is the same as the creation method of the pinyin prefix tree, which will not be repeated here.

[0087] Based on the above description, the present disclosure can be Figure 2 The text verification architecture shown in the text verification architecture diagram performs sensitive word detection. Figure 2 It includes multiple identification devices corresponding to the projects and a basic identification device. The text verification principles corresponding to different identification devices are the same, and all of them need to perform sensitive word verification through the project sensitive word prefix tree and the project pinyin prefix tree. Specifically, the implementation Figure 2 The architecture shown first requires R&D personnel to collect a large and comprehensive sensitive word list in advance as the basis for the basic identification device to build a sensitive word prefix tree and a pinyin prefix tree. Then each project can configure its own corresponding detection content and the parts that do not need to be detected through the page, so as to obtain the sensitive word list corresponding to each project.

[0088] When a text to be verified comes in, the project id (equivalent to the above-mentioned project identifier) ​​is read first. If it is project 1, it will first pass through the judgment device of project 1, and the text to be verified will be verified and rewritten based on the text verification method corresponding to project 1, and then enter the basic judgment device for verification; when the project party modifies the sensitive word content, it only needs to update the prefix tree of the judgment device corresponding to the project, which will not affect other businesses.

[0089] The above method can quickly provide the project party with sensitive word verification capabilities, while supporting customization and updates. In this method, the underlying prefix tree directly uses dictionary objects instead of connecting nodes, which greatly saves memory.

[0090] Corresponding to the above method embodiment, the embodiment of the present invention also provides a text verification device, such as Figure 3 As shown, the device comprises:

[0091] The text acquisition module 30 is used to acquire the text to be verified and perform pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified.

[0092] The first verification module 31 is used to traverse the text to be verified, and in the process of traversing the text to be verified, determine whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtain a first matching result; wherein the sensitive word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and the sensitive word label corresponding to the first word when matching.

[0093] The second verification module 32 is used to traverse the target pinyin, and in the process of traversing the target pinyin, determine whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree to obtain a second matching result; wherein the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching.

[0094] The verification result determination module 33 is used to determine whether the text to be verified is compliant based on the first matching result and the second matching result.

[0095] In the above-mentioned text verification device, the sensitive word prefix tree and the pinyin prefix tree directly use dictionary objects, that is, key-value pairs, rather than the node-connected method, which greatly saves memory; at the same time, this method can simultaneously process sensitive word detection of similar-sounding characters and special combinations through the sensitive word prefix tree and the pinyin prefix tree, thereby improving the accuracy of sensitive word detection.

[0096] Specifically, the above-mentioned device also includes a prefix tree determination module, which is used to: obtain a sensitive word list and establish an empty dictionary object; wherein the sensitive word list includes multiple sensitive words and sensitive word labels corresponding to the sensitive words; the sensitive words include at least one character; for each sensitive word in the sensitive word list, perform the following operations: traverse each character in the current sensitive word, and determine whether the target word composed of the current character and all characters before the current character in the current sensitive word is in the sensitive word prefix tree, if not, add the target word to the empty dictionary object to obtain a first object; wherein the first object is a key-value pair, the key in the key-value pair is the target word, and the key value corresponding to the target word is empty; determine whether the current word is the last word in the current sensitive word, if so, adjust the key value in the first object to the sensitive word label corresponding to the current sensitive word in the sensitive word list, and obtain the adjusted first object; add the first object and the adjusted first object to the sensitive word prefix tree.

[0097] Furthermore, the prefix tree determination module is also used to: convert sensitive words in the sensitive word list into pinyin to obtain a pinyin word list; wherein the pinyin word list includes: pinyin combinations corresponding to multiple sensitive words, and sensitive words and sensitive word labels corresponding to the pinyin combinations; for each pinyin combination in the pinyin word list, perform the following operations: traverse each pinyin in the current pinyin combination, and determine whether the target pinyin combination consisting of the current pinyin and all pinyins before the current pinyin in the current pinyin combination is in the pinyin prefix tree, if not, add the target pinyin combination to an empty dictionary object to obtain a second object; wherein the second object is a key-value pair, the key in the key-value pair is the target pinyin combination, and the key value corresponding to the target pinyin combination is empty; determine whether the current pinyin is the last pinyin in the current pinyin combination, if yes, adjust the key value in the second object to the sensitive word and sensitive word label corresponding to the current pinyin combination in the pinyin word list, to obtain the adjusted second object; add the second object and the adjusted second object to the pinyin prefix tree.

[0098] Furthermore, the above-mentioned device also includes a sensitive word adjustment module, which is used to: respond to the adjustment operation on the sensitive words in the sensitive word list, and based on the adjustment operation, add, modify or delete the sensitive words included in the sensitive word list.

[0099] In a specific implementation, the first verification module 31 is used to: determine the first word in the text to be verified as the starting traversal word, and traverse the text to be verified from the starting traversal word; determine the starting traversal word as the first word, determine whether the first word is in the sensitive word prefix tree, and if the first word is in the sensitive word prefix tree, determine whether the first word in the sensitive word prefix tree corresponds to a sensitive word label; if there is a corresponding sensitive word label, determine the sensitive word label as the sensitive word label corresponding to the first word; determine whether the last word of the first word is the last word in the text to be verified, if not, form the first word and the next word of the first word in the text to be verified into an updated first word, and continue to execute the step of determining whether the updated first word is in the sensitive word prefix tree; if the last word of the first word is the last word in the text to be verified, determine whether the starting traversal word is the last word in the text to be verified, and if so, stop traversal; if not, determine the next word of the starting traversal word in the text to be verified as the updated starting traversal word, and continue to execute the step of traversing the text to be verified from the updated starting traversal word.

[0100] Furthermore, the above-mentioned first verification module 31 is also used for: if the first word is not in the sensitive word prefix tree, determining whether the starting traversal word is the last word in the text to be verified, and if so, stopping the traversal; if not, determining the next word of the starting traversal word in the text to be verified as the updated starting traversal word, and continuing to execute the step of traversing the text to be verified starting from the updated starting traversal word.

[0101] Furthermore, the above-mentioned device also includes an information association module, which is used to: while determining the sensitive word label corresponding to the first word, record the starting position and ending position of the first word in the text to be verified, and bind the starting position and ending position corresponding to the first word with the sensitive word label corresponding to the first word.

[0102] Furthermore, the above-mentioned text acquisition module 30 is used to: convert each character in the text to be verified into pinyin; connect the pinyin corresponding to adjacent characters using specified characters to obtain connected pinyin; and determine the connected pinyin as the target pinyin corresponding to the text to be verified.

[0103] In a specific implementation, the text acquisition module 30 is also used to: for each character in the text to be verified, convert the current character into a combination of pinyin and tone to obtain a pinyin combination, and determine the pinyin combination as the pinyin corresponding to the current character.

[0104] In a specific implementation, the second verification module 32 is used to: determine the first pinyin in the target pinyin as the starting traversal pinyin, and traverse the target pinyin from the starting traversal pinyin; determine the starting traversal pinyin as the first pinyin combination, determine whether the first pinyin combination is in the pinyin prefix tree, and if the first pinyin combination is in the pinyin prefix tree, determine whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; if there is a corresponding sensitive word label, determine the sensitive word label as the sensitive word label corresponding to the first pinyin combination; determine whether the last pinyin of the first pinyin combination is the last pinyin in the target pinyin If not, the first pinyin combination and the next pinyin of the first pinyin combination in the target pinyin are combined into an updated first pinyin combination, and the step of determining whether the updated first pinyin combination is in the pinyin prefix tree is continued; if the last pinyin of the first pinyin combination is the last pinyin in the target pinyin, whether the starting traversal pinyin is the last pinyin in the target pinyin is determined, and if so, the traversal is stopped; if not, the next pinyin of the starting traversal pinyin in the target pinyin is determined as the updated starting traversal pinyin, and the step of traversing the target pinyin starting from the updated starting traversal pinyin is continued.

[0105] Furthermore, the above-mentioned second verification module 32 is also used for: if the first pinyin combination is not in the pinyin prefix tree, determining whether the starting traversal pinyin is the last pinyin in the target pinyin, and if so, stopping the traversal; if not, determining the next pinyin of the starting traversal pinyin in the target pinyin as the updated starting traversal pinyin, and continuing to execute the step of traversing the target pinyin starting from the updated starting traversal pinyin.

[0106] Furthermore, the above-mentioned information association module is also used to: while determining the sensitive word label corresponding to the first pinyin combination, record the starting position and ending position of the first pinyin combination in the text to be verified, and the sensitive word corresponding to the first pinyin combination, and bind the sensitive word, starting position and ending position corresponding to the first pinyin combination with the sensitive word label corresponding to the first pinyin combination.

[0107] Furthermore, the above-mentioned device also includes a project verification module, which is used to determine the target project identifier corresponding to the text to be verified after obtaining the text to be verified, and determine the target text verification method based on the target project identifier; wherein the target text verification method is a text verification method corresponding to the target project corresponding to the target project identifier, and the target project is a project among multiple preset projects; based on the target text verification method, text verification is performed on the text to be verified to obtain a verification result, and based on the verification result, an updated text to be verified is determined, and the step of performing pinyin conversion processing on the updated text to be verified is continued to be performed to obtain the target pinyin corresponding to the text to be verified.

[0108] In a specific implementation, the above-mentioned project verification module is also used to: traverse the text to be verified, and in the process of traversing the text to be verified, determine whether the first word in the text to be verified matches the sensitive word in the replacement word prefix tree; wherein the replacement word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and replacement words corresponding to the sensitive words; if they match, determine the target sensitive word that matches the first word in the replacement word prefix tree, and replace the first word with the replacement word corresponding to the target sensitive word to obtain the replaced text to be verified; and determine the replaced text to be verified as the updated text to be verified.

[0109] In an optional embodiment, the above-mentioned project verification module is also used to: after replacing the first word with the replacement word corresponding to the target sensitive word to obtain the replaced text to be verified, perform pinyin conversion processing on the replaced text to be verified to obtain the preset pinyin corresponding to the replaced text to be verified; traverse the replaced text to be verified, and in the process of traversing the replaced text to be verified, determine whether the second word in the replaced text to be verified matches the project sensitive word in the project sensitive word prefix tree to obtain a third matching result; wherein the project sensitive word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding project sensitive words and sensitive word labels corresponding to the project sensitive words; the number of project sensitive words in the project sensitive word prefix tree is less than the number of sensitive words in the sensitive word prefix tree, and the project sensitive words are updated in real time according to project requirements; the third matching result is used to indicate: whether the second word Matches the project sensitive words in the project sensitive word prefix tree, and the sensitive word label corresponding to the second word when matching; traverses the preset pinyin, and in the process of traversing the preset pinyin, determines whether the second pinyin combination in the preset pinyin matches the project pinyin combination in the project pinyin prefix tree, and obtains a fourth matching result; wherein the project pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with different pinyins corresponding to project sensitive words and sensitive word labels corresponding to the pinyins; the number of project pinyin combinations in the project pinyin prefix tree is less than the number of pinyin combinations in the pinyin prefix tree, and the project pinyin combinations are updated in real time according to project requirements; the fourth matching result is used to indicate: whether the second pinyin combination matches the pinyin combination in the project pinyin prefix tree, and the sensitive word label corresponding to the second pinyin combination when matching; based on the third matching result and the fourth matching result, determines the verification result.

[0110] Furthermore, the above device also includes a sensitive word updating module, which is used to: respond to the adjustment operation on the project sensitive words, and based on the adjustment operation, add, modify or delete the project sensitive words corresponding to the project sensitive word prefix tree and the project pinyin prefix tree.

[0111] The text verification device provided in the embodiment of the present disclosure has the same implementation principle and technical effects as those in the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0112] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, the electronic device includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned text verification method.

[0113] Specifically, the above-mentioned text verification method includes: obtaining the text to be verified, and performing pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified; traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtaining a first matching result; wherein the sensitive word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and if it matches, the first word Corresponding sensitive word labels; traversing the target pinyin, and in the process of traversing the target pinyin, determining whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree, and obtaining a second matching result; wherein the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; based on the first matching result and the second matching result, determining whether the text to be verified is compliant.

[0114] In the above text verification method, the sensitive word prefix tree and the pinyin prefix tree directly use dictionary objects, that is, key-value pairs, rather than node-connected methods, which greatly saves memory; at the same time, this method can simultaneously handle sensitive word detection in situations such as similar-sounding characters and special combinations through the sensitive word prefix tree and the pinyin prefix tree, thereby improving the accuracy of sensitive word detection.

[0115] In an optional embodiment, the above-mentioned sensitive word prefix tree is determined in the following manner: obtaining a sensitive word list and establishing an empty dictionary object; wherein the sensitive word list includes multiple sensitive words and sensitive word labels corresponding to the sensitive words; the sensitive words include at least one character; for each sensitive word in the sensitive word list, performing the following operations: traversing each character in the current sensitive word, and determining whether the target word composed of the current character and all characters before the current character in the current sensitive word is in the sensitive word prefix tree, if not, adding the target word to the empty dictionary object to obtain a first object; wherein the first object is a key-value pair, the key in the key-value pair is the target word, and the key value corresponding to the target word is empty; judging whether the current character is the last character in the current sensitive word, if so, adjusting the key value in the first object to the sensitive word label corresponding to the current sensitive word in the sensitive word list to obtain the adjusted first object; adding the first object and the adjusted first object to the sensitive word prefix tree.

[0116] In an optional embodiment, the pinyin prefix tree is determined in the following manner: sensitive words in the sensitive word list are converted into pinyin to obtain a pinyin word list; wherein the pinyin word list includes: pinyin combinations corresponding to multiple sensitive words, and sensitive words and sensitive word labels corresponding to the pinyin combinations; for each pinyin combination in the pinyin word list, the following operations are performed: traverse each pinyin in the current pinyin combination, and determine whether the target pinyin combination consisting of the current pinyin and all pinyins before the current pinyin in the current pinyin combination is in the pinyin prefix tree, if not, add the target pinyin combination to an empty dictionary object to obtain a second object; wherein the second object is a key-value pair, the key in the key-value pair is the target pinyin combination, and the key value corresponding to the target pinyin combination is empty; determine whether the current pinyin is the last pinyin in the current pinyin combination, if yes, adjust the key value in the second object to the sensitive word and sensitive word label corresponding to the current pinyin combination in the pinyin word list, and obtain the adjusted second object; add the second object and the adjusted second object to the pinyin prefix tree.

[0117] In an optional embodiment, the method further includes: responding to an adjustment operation on a sensitive word in the sensitive word list, and adding, modifying or deleting the sensitive words included in the sensitive word list based on the adjustment operation.

[0118] In an optional embodiment, the above-mentioned step of determining whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree during the process of traversing the text to be verified to obtain the first matching result includes: determining the first word in the text to be verified as the starting traversal word, and traversing the text to be verified from the starting traversal word; determining the starting traversal word as the first word, determining whether the first word is in the sensitive word prefix tree, and if the first word is in the sensitive word prefix tree, determining whether the first word in the sensitive word prefix tree corresponds to a sensitive word label; if there is a corresponding sensitive word label, determining the sensitive word label as the sensitive word label corresponding to the first word; judging the first Whether the last word of a word is the last word in the text to be verified. If not, the first word and the next word of the first word in the text to be verified are combined into an updated first word, and the step of determining whether the updated first word is in the sensitive word prefix tree is continued; if the last word of the first word is the last word in the text to be verified, it is determined whether the starting traversal word is the last word in the text to be verified. If so, the traversal is stopped; if not, the next word of the starting traversal word in the text to be verified is determined as the updated starting traversal word, and the step of traversing the text to be verified starting from the updated starting traversal word is continued.

[0119] In an optional embodiment, the above method also includes: if the first word is not in the sensitive word prefix tree, determining whether the starting traversal word is the last word in the text to be verified, and if so, stopping the traversal; if not, determining the next word of the starting traversal word in the text to be verified as the updated starting traversal word, and continuing to execute the step of traversing the text to be verified starting from the updated starting traversal word.

[0120] In an optional embodiment, the above method also includes: while determining the sensitive word label corresponding to the first word, recording the starting position and ending position of the first word in the text to be verified, and binding the starting position and ending position corresponding to the first word with the sensitive word label corresponding to the first word.

[0121] In an optional embodiment, the above-mentioned step of performing pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified includes: converting each character in the text to be verified into pinyin; connecting the pinyin corresponding to adjacent characters using specified characters to obtain the connected pinyin; and determining the connected pinyin as the target pinyin corresponding to the text to be verified.

[0122] In an optional embodiment, the above-mentioned step of converting each character in the text to be verified into pinyin includes: for each character in the text to be verified, converting the current character into a combination of pinyin and tone to obtain a pinyin combination, and determining the pinyin combination as the pinyin corresponding to the current character.

[0123] In an optional embodiment, the above step of determining whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree during the process of traversing the target pinyin to obtain a second matching result includes: determining the first pinyin in the target pinyin as the starting traversal pinyin, and traversing the target pinyin from the starting traversal pinyin; determining the starting traversal pinyin as the first pinyin combination, determining whether the first pinyin combination is in the pinyin prefix tree, and if the first pinyin combination is in the pinyin prefix tree, determining whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; if there is a corresponding sensitive word label, determining the sensitive word label as the sensitive word label corresponding to the first pinyin combination; judging the first pinyin combination as the first pinyin combination, determining whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; and determining whether the first pinyin combination is in the pinyin prefix tree. Whether the last pinyin of the combination is the last pinyin in the target pinyin. If not, the first pinyin combination and the next pinyin of the first pinyin combination in the target pinyin are combined into an updated first pinyin combination, and the step of determining whether the updated first pinyin combination is in the pinyin prefix tree is continued; if the last pinyin of the first pinyin combination is the last pinyin in the target pinyin, whether the starting traversal pinyin is the last pinyin in the target pinyin is determined. If so, the traversal is stopped; if not, the next pinyin of the starting traversal pinyin in the target pinyin is determined as the updated starting traversal pinyin, and the step of traversing the target pinyin starting from the updated starting traversal pinyin is continued.

[0124] In an optional embodiment, the above method also includes: if the first pinyin combination is not in the pinyin prefix tree, determining whether the starting traversal pinyin is the last pinyin in the target pinyin, and if so, stopping the traversal; if not, determining the next pinyin of the starting traversal pinyin in the target pinyin as the updated starting traversal pinyin, and continuing to execute the step of traversing the target pinyin starting from the updated starting traversal pinyin.

[0125] In an optional embodiment, the above method also includes: while determining the sensitive word label corresponding to the first pinyin combination, recording the starting position and ending position of the first pinyin combination in the text to be verified, and the sensitive word corresponding to the first pinyin combination, and binding the sensitive word, starting position and ending position corresponding to the first pinyin combination with the sensitive word label corresponding to the first pinyin combination.

[0126] In an optional embodiment, after obtaining the text to be verified, the above method also includes: determining a target project identifier corresponding to the text to be verified, and determining a target text verification method based on the target project identifier; wherein the target text verification method is a text verification method corresponding to a target project corresponding to the target project identifier, and the target project is an item among multiple preset items; performing text verification on the text to be verified based on the target text verification method to obtain a verification result, and determining an updated text to be verified based on the verification result, and continuing to perform pinyin conversion processing on the updated text to be verified to obtain the target pinyin corresponding to the text to be verified.

[0127] In an optional embodiment, the above-mentioned steps of performing text verification on the text to be verified based on the target text verification method, obtaining a verification result, and determining an updated text to be verified based on the verification result, include: traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the replacement word prefix tree; wherein the replacement word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and replacement words corresponding to the sensitive words; if they match, determining the target sensitive word in the replacement word prefix tree that matches the first word, and replacing the first word with the replacement word corresponding to the target sensitive word to obtain the replaced text to be verified; and determining the replaced text to be verified as the updated text to be verified.

[0128] In an optional embodiment, after the step of replacing the first word with a replacement word corresponding to the target sensitive word to obtain the replaced text to be verified, the method further includes: performing pinyin conversion processing on the replaced text to be verified to obtain a preset pinyin corresponding to the replaced text to be verified; traversing the replaced text to be verified, and in the process of traversing the replaced text to be verified, determining whether the second word in the replaced text to be verified matches the project sensitive word in the project sensitive word prefix tree to obtain a third matching result; wherein the project sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding project sensitive words and sensitive word labels corresponding to the project sensitive words; the number of project sensitive words in the project sensitive word prefix tree is less than the number of sensitive words in the sensitive word prefix tree, and the project sensitive words are updated in real time according to project requirements; the third matching result is used to indicate: whether the second word matches The project sensitive words in the project sensitive word prefix tree are matched, and the sensitive word label corresponding to the second word when matched; the preset pinyin is traversed, and in the process of traversing the preset pinyin, it is determined whether the second pinyin combination in the preset pinyin matches the project pinyin combination in the project pinyin prefix tree to obtain a fourth matching result; wherein the project pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with different pinyins corresponding to project sensitive words and sensitive word labels corresponding to the pinyins; the number of project pinyin combinations in the project pinyin prefix tree is less than the number of pinyin combinations in the pinyin prefix tree, and the project pinyin combinations are updated in real time according to project requirements; the fourth matching result is used to indicate: whether the second pinyin combination matches the pinyin combination in the project pinyin prefix tree, and the sensitive word label corresponding to the second pinyin combination when matched; based on the third matching result and the fourth matching result, the verification result is determined.

[0129] In an optional embodiment, the method further comprises: responding to an adjustment operation on the project sensitive words, and based on the adjustment operation, adding, modifying or deleting the project sensitive words corresponding to the project sensitive word prefix tree and the project pinyin prefix tree.

[0130] Further, Figure 4 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .

[0131] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0132] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 101 or the instruction in the form of software. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.

[0133] An embodiment of the present invention also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned text verification method. The specific implementation can be found in the method embodiment, which will not be repeated here.

[0134] Specifically, the above-mentioned text verification method includes: obtaining the text to be verified, and performing pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified; traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtaining a first matching result; wherein the sensitive word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and if it matches, the first word Corresponding sensitive word labels; traversing the target pinyin, and in the process of traversing the target pinyin, determining whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree, and obtaining a second matching result; wherein the pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; based on the first matching result and the second matching result, determining whether the text to be verified is compliant.

[0135] In the above text verification method, the sensitive word prefix tree and the pinyin prefix tree directly use dictionary objects, that is, key-value pairs, rather than node-connected methods, which greatly saves memory; at the same time, this method can simultaneously handle sensitive word detection in situations such as similar-sounding characters and special combinations through the sensitive word prefix tree and the pinyin prefix tree, thereby improving the accuracy of sensitive word detection.

[0136] In an optional embodiment, the above-mentioned sensitive word prefix tree is determined in the following manner: obtaining a sensitive word list and establishing an empty dictionary object; wherein the sensitive word list includes multiple sensitive words and sensitive word labels corresponding to the sensitive words; the sensitive words include at least one character; for each sensitive word in the sensitive word list, performing the following operations: traversing each character in the current sensitive word, and determining whether the target word composed of the current character and all characters before the current character in the current sensitive word is in the sensitive word prefix tree, if not, adding the target word to the empty dictionary object to obtain a first object; wherein the first object is a key-value pair, the key in the key-value pair is the target word, and the key value corresponding to the target word is empty; judging whether the current character is the last character in the current sensitive word, if so, adjusting the key value in the first object to the sensitive word label corresponding to the current sensitive word in the sensitive word list to obtain the adjusted first object; adding the first object and the adjusted first object to the sensitive word prefix tree.

[0137] In an optional embodiment, the pinyin prefix tree is determined in the following manner: sensitive words in the sensitive word list are converted into pinyin to obtain a pinyin word list; wherein the pinyin word list includes: pinyin combinations corresponding to multiple sensitive words, and sensitive words and sensitive word labels corresponding to the pinyin combinations; for each pinyin combination in the pinyin word list, the following operations are performed: traverse each pinyin in the current pinyin combination, and determine whether the target pinyin combination consisting of the current pinyin and all pinyins before the current pinyin in the current pinyin combination is in the pinyin prefix tree, if not, add the target pinyin combination to an empty dictionary object to obtain a second object; wherein the second object is a key-value pair, the key in the key-value pair is the target pinyin combination, and the key value corresponding to the target pinyin combination is empty; determine whether the current pinyin is the last pinyin in the current pinyin combination, if yes, adjust the key value in the second object to the sensitive word and sensitive word label corresponding to the current pinyin combination in the pinyin word list, and obtain the adjusted second object; add the second object and the adjusted second object to the pinyin prefix tree.

[0138] In an optional embodiment, the method further includes: responding to an adjustment operation on a sensitive word in the sensitive word list, and adding, modifying or deleting the sensitive words included in the sensitive word list based on the adjustment operation.

[0139] In an optional embodiment, the above-mentioned step of determining whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree during the process of traversing the text to be verified to obtain the first matching result includes: determining the first word in the text to be verified as the starting traversal word, and traversing the text to be verified from the starting traversal word; determining the starting traversal word as the first word, determining whether the first word is in the sensitive word prefix tree, and if the first word is in the sensitive word prefix tree, determining whether the first word in the sensitive word prefix tree corresponds to a sensitive word label; if there is a corresponding sensitive word label, determining the sensitive word label as the sensitive word label corresponding to the first word; judging the first Whether the last word of a word is the last word in the text to be verified. If not, the first word and the next word of the first word in the text to be verified are combined into an updated first word, and the step of determining whether the updated first word is in the sensitive word prefix tree is continued; if the last word of the first word is the last word in the text to be verified, it is determined whether the starting traversal word is the last word in the text to be verified. If so, the traversal is stopped; if not, the next word of the starting traversal word in the text to be verified is determined as the updated starting traversal word, and the step of traversing the text to be verified starting from the updated starting traversal word is continued.

[0140] In an optional embodiment, the above method also includes: if the first word is not in the sensitive word prefix tree, determining whether the starting traversal word is the last word in the text to be verified, and if so, stopping the traversal; if not, determining the next word of the starting traversal word in the text to be verified as the updated starting traversal word, and continuing to execute the step of traversing the text to be verified starting from the updated starting traversal word.

[0141] In an optional embodiment, the above method also includes: while determining the sensitive word label corresponding to the first word, recording the starting position and ending position of the first word in the text to be verified, and binding the starting position and ending position corresponding to the first word with the sensitive word label corresponding to the first word.

[0142] In an optional embodiment, the above-mentioned step of performing pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified includes: converting each character in the text to be verified into pinyin; connecting the pinyin corresponding to adjacent characters using specified characters to obtain the connected pinyin; and determining the connected pinyin as the target pinyin corresponding to the text to be verified.

[0143] In an optional embodiment, the above-mentioned step of converting each character in the text to be verified into pinyin includes: for each character in the text to be verified, converting the current character into a combination of pinyin and tone to obtain a pinyin combination, and determining the pinyin combination as the pinyin corresponding to the current character.

[0144] In an optional embodiment, the above step of determining whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree during the process of traversing the target pinyin to obtain a second matching result includes: determining the first pinyin in the target pinyin as the starting traversal pinyin, and traversing the target pinyin from the starting traversal pinyin; determining the starting traversal pinyin as the first pinyin combination, determining whether the first pinyin combination is in the pinyin prefix tree, and if the first pinyin combination is in the pinyin prefix tree, determining whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; if there is a corresponding sensitive word label, determining the sensitive word label as the sensitive word label corresponding to the first pinyin combination; judging the first pinyin combination as the first pinyin combination, determining whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; and determining whether the first pinyin combination is in the pinyin prefix tree. Whether the last pinyin of the combination is the last pinyin in the target pinyin. If not, the first pinyin combination and the next pinyin of the first pinyin combination in the target pinyin are combined into an updated first pinyin combination, and the step of determining whether the updated first pinyin combination is in the pinyin prefix tree is continued; if the last pinyin of the first pinyin combination is the last pinyin in the target pinyin, whether the starting traversal pinyin is the last pinyin in the target pinyin is determined. If so, the traversal is stopped; if not, the next pinyin of the starting traversal pinyin in the target pinyin is determined as the updated starting traversal pinyin, and the step of traversing the target pinyin starting from the updated starting traversal pinyin is continued.

[0145] In an optional embodiment, the above method also includes: if the first pinyin combination is not in the pinyin prefix tree, determining whether the starting traversal pinyin is the last pinyin in the target pinyin, and if so, stopping the traversal; if not, determining the next pinyin of the starting traversal pinyin in the target pinyin as the updated starting traversal pinyin, and continuing to execute the step of traversing the target pinyin starting from the updated starting traversal pinyin.

[0146] In an optional embodiment, the above method also includes: while determining the sensitive word label corresponding to the first pinyin combination, recording the starting position and ending position of the first pinyin combination in the text to be verified, and the sensitive word corresponding to the first pinyin combination, and binding the sensitive word, starting position and ending position corresponding to the first pinyin combination with the sensitive word label corresponding to the first pinyin combination.

[0147] In an optional embodiment, after obtaining the text to be verified, the above method also includes: determining a target project identifier corresponding to the text to be verified, and determining a target text verification method based on the target project identifier; wherein the target text verification method is a text verification method corresponding to a target project corresponding to the target project identifier, and the target project is an item among multiple preset items; performing text verification on the text to be verified based on the target text verification method to obtain a verification result, and determining an updated text to be verified based on the verification result, and continuing to perform pinyin conversion processing on the updated text to be verified to obtain the target pinyin corresponding to the text to be verified.

[0148] In an optional embodiment, the above-mentioned steps of performing text verification on the text to be verified based on the target text verification method, obtaining a verification result, and determining an updated text to be verified based on the verification result, include: traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the replacement word prefix tree; wherein the replacement word prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and replacement words corresponding to the sensitive words; if they match, determining the target sensitive word in the replacement word prefix tree that matches the first word, and replacing the first word with the replacement word corresponding to the target sensitive word to obtain the replaced text to be verified; and determining the replaced text to be verified as the updated text to be verified.

[0149] In an optional embodiment, after the step of replacing the first word with a replacement word corresponding to the target sensitive word to obtain the replaced text to be verified, the method further includes: performing pinyin conversion processing on the replaced text to be verified to obtain a preset pinyin corresponding to the replaced text to be verified; traversing the replaced text to be verified, and in the process of traversing the replaced text to be verified, determining whether the second word in the replaced text to be verified matches the project sensitive word in the project sensitive word prefix tree to obtain a third matching result; wherein the project sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding project sensitive words and sensitive word labels corresponding to the project sensitive words; the number of project sensitive words in the project sensitive word prefix tree is less than the number of sensitive words in the sensitive word prefix tree, and the project sensitive words are updated in real time according to project requirements; the third matching result is used to indicate: whether the second word matches The project sensitive words in the project sensitive word prefix tree are matched, and the sensitive word label corresponding to the second word when matched; the preset pinyin is traversed, and in the process of traversing the preset pinyin, it is determined whether the second pinyin combination in the preset pinyin matches the project pinyin combination in the project pinyin prefix tree to obtain a fourth matching result; wherein the project pinyin prefix tree includes multiple key-value pairs, and different key-value pairs are respectively configured with different pinyins corresponding to project sensitive words and sensitive word labels corresponding to the pinyins; the number of project pinyin combinations in the project pinyin prefix tree is less than the number of pinyin combinations in the pinyin prefix tree, and the project pinyin combinations are updated in real time according to project requirements; the fourth matching result is used to indicate: whether the second pinyin combination matches the pinyin combination in the project pinyin prefix tree, and the sensitive word label corresponding to the second pinyin combination when matched; based on the third matching result and the fourth matching result, the verification result is determined.

[0150] In an optional embodiment, the method further includes: responding to an adjustment operation on the project sensitive words, and based on the adjustment operation, adding, modifying or deleting the project sensitive words corresponding to the project sensitive word prefix tree and the project pinyin prefix tree.

[0151] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a terminal device, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0152] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0153] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A text verification method, characterized in that: The method comprises: Acquire the text to be verified, and perform pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified; Traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtaining a first matching result; wherein the sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and the sensitive word label corresponding to the first word when matching; Traversing the target pinyin, and in the process of traversing the target pinyin, determining whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree, and obtaining a second matching result; wherein the pinyin prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with different pinyins corresponding to sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; Based on the first matching result and the second matching result, determine whether the text to be verified is compliant.

2. The method according to claim 1, characterized in that The sensitive word prefix tree is determined in the following manner: Obtain a sensitive word list and create an empty dictionary object; wherein the sensitive word list includes a plurality of sensitive words and sensitive word labels corresponding to the sensitive words; the sensitive words include at least one character; For each of the sensitive words in the sensitive word list, perform the following operations: Traverse each character in the current sensitive word, and determine whether the target word composed of the current character and all characters before the current character in the current sensitive word is in the sensitive word prefix tree, if not, add the target word to the empty dictionary object to obtain a first object; wherein the first object is a key-value pair, the key in the key-value pair is the target word, and the key value corresponding to the target word is empty; Determine whether the current word is the last word in the current sensitive word, and if so, adjust the key value in the first object to the sensitive word label corresponding to the current sensitive word in the sensitive word table to obtain the adjusted first object; The first object and the adjusted first object are added to the sensitive word prefix tree.

3. The method according to claim 2, characterized in that The pinyin prefix tree is determined in the following manner: The sensitive words in the sensitive word list are converted into pinyin to obtain a pinyin word list; wherein the pinyin word list includes: pinyin combinations corresponding to a plurality of sensitive words, and sensitive words and sensitive word labels corresponding to the pinyin combinations; For each of the pinyin combinations in the pinyin vocabulary, perform the following operations: Traverse each pinyin in the current pinyin combination, and determine whether the target pinyin combination consisting of the current pinyin and all the pinyins before the current pinyin in the current pinyin combination is in the pinyin prefix tree, if not, add the target pinyin combination to the empty dictionary object to obtain a second object; wherein the second object is a key-value pair, the key in the key-value pair is the target pinyin combination, and the key value corresponding to the target pinyin combination is empty; Determine whether the current pinyin is the last pinyin in the current pinyin combination, and if so, adjust the key value in the second object to the sensitive word and sensitive word label corresponding to the current pinyin combination in the pinyin word table to obtain the adjusted second object; Add the second object and the adjusted second object into the pinyin prefix tree.

4. The method according to claim 3, characterized in that The method further comprises: In response to an adjustment operation on the sensitive words in the sensitive word list, based on the adjustment operation, the sensitive words included in the sensitive word list are added, modified or deleted.

5. The method according to claim 1, characterized in that: The step of determining whether the first word in the text to be verified matches a sensitive word in the sensitive word prefix tree during traversing the text to be verified to obtain a first matching result includes: Determine the first word in the text to be verified as the starting traversal word, and start traversing the text to be verified from the starting traversal word; Determine the starting traversal character as the first word, determine whether the first word is in the sensitive word prefix tree, and if the first word is in the sensitive word prefix tree, determine whether the first word in the sensitive word prefix tree corresponds to a sensitive word label; If there is a corresponding sensitive word label, determining the sensitive word label as the sensitive word label corresponding to the first word; Determine whether the last character of the first word is the last character in the text to be verified, if not, combine the first word and the next character of the first word in the text to be verified to form an updated first word, and continue to perform the step of determining whether the updated first word is in the sensitive word prefix tree; If the last character of the first word is the last character in the text to be verified, determine whether the starting traversal character is the last character in the text to be verified, and if so, stop traversing; if not, determine the next character of the starting traversal character in the text to be verified as the updated starting traversal character, and continue to execute the step of traversing the text to be verified starting from the updated starting traversal character.

6. The method according to claim 5, characterized in that The method further comprises: If the first word is not in the sensitive word prefix tree, determine whether the starting traversal word is the last word in the text to be verified, and if so, stop traversing; if not, determine the next word of the starting traversal word in the text to be verified as the updated starting traversal word, and continue to execute the step of traversing the text to be verified starting from the updated starting traversal word.

7. The method according to claim 5 or 6, characterized in that: The method further comprises: While determining the sensitive word label corresponding to the first word, the starting position and the ending position of the first word in the text to be verified are recorded, and the starting position and the ending position corresponding to the first word are bound to the sensitive word label corresponding to the first word.

8. The method according to claim 1, characterized in that The step of performing pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified includes: Convert each word in the text to be verified into pinyin; Connect the pinyins corresponding to adjacent characters using the specified characters to obtain the connected pinyins; The concatenated pinyin is determined as the target pinyin corresponding to the text to be verified.

9. The method according to claim 8, characterized in that The step of converting each character in the text to be verified into pinyin comprises: For each character in the text to be verified, the current character is converted into a combination of pinyin and tone to obtain a pinyin combination, and the pinyin combination is determined as the pinyin corresponding to the current character.

10. The method according to claim 1, characterized in that The step of determining whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree during the process of traversing the target pinyin to obtain a second matching result comprises: Determine the first pinyin in the target pinyin as the starting traversal pinyin, and start traversing the target pinyin from the starting traversal pinyin; Determine the starting traversal pinyin as the first pinyin combination, determine whether the first pinyin combination is in the pinyin prefix tree, and if the first pinyin combination is in the pinyin prefix tree, determine whether the first pinyin combination in the pinyin prefix tree corresponds to a sensitive word label; If there is a corresponding sensitive word label, determining the sensitive word label as the sensitive word label corresponding to the first pinyin combination; Determine whether the last pinyin of the first pinyin combination is the last pinyin in the target pinyin, if not, form an updated first pinyin combination with the first pinyin combination and the next pinyin of the first pinyin combination in the target pinyin, and continue to perform the step of determining whether the updated first pinyin combination is in the pinyin prefix tree; If the last pinyin of the first pinyin combination is the last pinyin in the target pinyin, determine whether the starting traversal pinyin is the last pinyin in the target pinyin, and if so, stop traversing; if not, determine the next pinyin of the starting traversal pinyin in the target pinyin as the updated starting traversal pinyin, and continue to execute the step of traversing the target pinyin starting from the updated starting traversal pinyin.

11. The method according to claim 10, characterized in that The method further comprises: If the first pinyin combination is not in the pinyin prefix tree, determine whether the starting traversal pinyin is the last pinyin in the target pinyin. If so, stop traversal; if not, determine the next pinyin of the starting traversal pinyin in the target pinyin as the updated starting traversal pinyin, and continue to execute the step of traversing the target pinyin starting from the updated starting traversal pinyin.

12. The method according to claim 10 or 11, characterized in that: The method further comprises: While determining the sensitive word label corresponding to the first pinyin combination, the starting position and the ending position of the first pinyin combination in the text to be verified, and the sensitive word corresponding to the first pinyin combination are recorded, and the sensitive word corresponding to the first pinyin combination, the starting position and the ending position are bound to the sensitive word label corresponding to the first pinyin combination.

13. The method according to claim 1, characterized in that After obtaining the text to be verified, the method further includes: Determine the target project identifier corresponding to the text to be verified, and determine the target text verification method based on the target project identifier; wherein the target text verification method is a text verification method corresponding to the target project corresponding to the target project identifier, and the target project is a project among multiple preset projects; The text to be verified is verified based on the target text verification method to obtain a verification result, and an updated text to be verified is determined based on the verification result, and the step of performing pinyin conversion processing on the updated text to be verified is continued to obtain the target pinyin corresponding to the text to be verified.

14. The method according to claim 13, characterized in that The step of performing text verification on the text to be verified based on the target text verification method to obtain a verification result, and determining an updated text to be verified based on the verification result includes: Traversing the text to be verified, and in the process of traversing the text to be verified, determining whether the first word in the text to be verified matches the sensitive word in the replacement word prefix tree; wherein the replacement word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and replacement words corresponding to the sensitive words; If there is a match, determining a target sensitive word that matches the first word in the replacement word prefix tree, and replacing the first word with a replacement word corresponding to the target sensitive word to obtain a replaced text to be verified; The replaced text to be verified is determined as the updated text to be verified.

15. The method according to claim 14, characterized in that After the step of replacing the first word with a replacement word corresponding to the target sensitive word to obtain the replaced text to be verified, the method further includes: Performing pinyin conversion processing on the replaced text to be verified to obtain the preset pinyin corresponding to the replaced text to be verified; Traversing the replaced text to be verified, and in the process of traversing the replaced text to be verified, determining whether the second word in the replaced text to be verified matches the project sensitive word in the project sensitive word prefix tree, and obtaining a third matching result; wherein the project sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding project sensitive words and sensitive word labels corresponding to the project sensitive words; the number of project sensitive words in the project sensitive word prefix tree is less than the number of sensitive words in the sensitive word prefix tree, and the project sensitive words are updated in real time according to project requirements; the third matching result is used to indicate: whether the second word matches the project sensitive word in the project sensitive word prefix tree, and the sensitive word label corresponding to the second word when matching; Traversing the preset pinyin, and in the process of traversing the preset pinyin, determining whether the second pinyin combination in the preset pinyin matches the project pinyin combination in the project pinyin prefix tree, and obtaining a fourth matching result; wherein the project pinyin prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different project sensitive words and sensitive word labels corresponding to the pinyins; the number of project pinyin combinations in the project pinyin prefix tree is less than the number of pinyin combinations in the pinyin prefix tree, and the project pinyin combination is updated in real time according to project requirements; the fourth matching result is used to indicate: whether the second pinyin combination matches the pinyin combination in the project pinyin prefix tree, and the sensitive word label corresponding to the second pinyin combination when matching; The verification result is determined based on the third matching result and the fourth matching result.

16. The method according to claim 15, characterized in that The method further comprises: In response to the adjustment operation on the project sensitive words, based on the adjustment operation, the project sensitive words corresponding to the project sensitive word prefix tree and the project pinyin prefix tree are added, modified or deleted.

17. A text verification device, characterized in that: The device comprises: The text acquisition module is used to acquire the text to be verified and perform pinyin conversion processing on the text to be verified to obtain the target pinyin corresponding to the text to be verified; A first verification module is used to traverse the text to be verified, and in the process of traversing the text to be verified, determine whether the first word in the text to be verified matches the sensitive word in the sensitive word prefix tree, and obtain a first matching result; wherein the sensitive word prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with corresponding sensitive words and sensitive word labels corresponding to the sensitive words; the first matching result is used to indicate: whether the first word matches the sensitive word in the sensitive word prefix tree, and the sensitive word label corresponding to the first word when matching; A second verification module is used to traverse the target pinyin, and in the process of traversing the target pinyin, determine whether the first pinyin combination in the target pinyin matches the pinyin combination in the pinyin prefix tree, and obtain a second matching result; wherein the pinyin prefix tree includes a plurality of key-value pairs, and different key-value pairs are respectively configured with pinyins corresponding to different sensitive words and sensitive word labels corresponding to the pinyins; the second matching result is used to indicate: whether the first pinyin combination matches the pinyin combination in the pinyin prefix tree, and the sensitive word label corresponding to the first pinyin combination when matching; A verification result determination module is used to determine whether the text to be verified is compliant based on the first matching result and the second matching result.

18. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the text verification method described in any one of claims 1 to 16.

19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the text verification method described in any one of claims 1 to 16.