Sensitive word filtering method, device, computer equipment and readable storage medium
By obtaining the user input content in the game project, first match it with the local thesaurus, and if it does not match, compare it with the background database, combine the white thesaurus and the black thesaurus, and merge the input content to reduce the frequency of online comparison and solve the problem of sensitive word updates The problems of timeliness and high cost have been solved, and sensitive word filtering has been achieved with high efficiency, low cost and high reliability.
Patent Information
- Application Number
- CN202011074973.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-09
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-10-09
AI Technical Summary
While ensuring the timeliness of sensitive word updates, the cost of filtering and detecting sensitive words in game projects is high, and existing technology cannot effectively solve this problem.
By obtaining the user input content, it is first matched with the local thesaurus. If it does not match, it is compared with the backend database through the Internet filtering interface, and the comparison information is stored in the local thesaurus. Combined with the matching mechanism of the white thesaurus and the black thesaurus, As well as setting matching strategies with validity periods, merging multiple inputs to reduce the frequency of online comparisons.
It achieves the timeliness of sensitive word updates, reduces the cost of filtering and detecting sensitive words in game projects, reduces the call rate of Internet filtering interfaces, improves risk resistance, and reduces operation and maintenance costs.
Smart Images

Figure CN112287385B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a sensitive word filtering method, apparatus, computer equipment and readable storage medium. Background Art
[0002] Usually, naming and chatting in games require sensitive word filtering and detection. Filtering the user's input content with sensitive words can prevent malicious users from making inappropriate remarks. Currently, the sensitive word filtering methods on the market include local word library matching algorithms and real-time Internet filtering interface methods.
[0003] In the related art, the local vocabulary matching algorithm performs detection locally, and the detection effect depends on the richness of the local vocabulary. It cannot intercept the latest sensitive words in time, and requires additional local vocabulary maintenance work. Only when new sensitive words are discovered will they be added to the local vocabulary. Therefore, the update and maintenance of the local vocabulary is naturally lagging; the real-time Internet filtering interface method can intercept various sensitive words and variant sensitive words in time, but the method is charged according to the number of detections, which is a considerable additional expense for highly active game projects.
[0004] At present, in the related technology, no effective solution has been proposed for the problem of high cost of filtering and detecting sensitive words in game projects while ensuring the timeliness of sensitive word updates. Summary of the invention
[0005] The embodiments of the present application provide a sensitive word filtering method, apparatus, computer device and readable storage medium to at least solve the problem in the related art that the cost of sensitive word filtering detection in game projects is high while ensuring the timeliness of sensitive word updates.
[0006] In a first aspect, an embodiment of the present application provides a sensitive word filtering method, the method comprising:
[0007] Get the user's input;
[0008] Matching the input content with words in a local vocabulary;
[0009] If there is no match, the input content is compared with the words in the backend database through an Internet filtering interface, and the comparison information of the comparison is stored in the local word library.
[0010] In some of the embodiments, after the input content does not match the words in the local vocabulary, before comparing the input content with the words in the backend database through the Internet filtering interface, the method includes: merging multiple input contents into one input content within a preset time period.
[0011] In some embodiments, the local word library includes a white word library and a black word library, and matching the input content with the local word library includes:
[0012] Matching the input content with white words in the white word library;
[0013] If the input content matches the white word, the input content is filtered through;
[0014] If the input content does not match the white word, match the input content with the black word in the black word library. If the input content matches the black word, intercept the input content. If the input content does not match the black word, it means that the input content does not match the word in the local word library.
[0015] In some embodiments, the words in the local vocabulary are set with an effective period, and matching the input content with the words in the local vocabulary includes: matching the input content with the words in the local vocabulary that are within the effective period.
[0016] In a second aspect, an embodiment of the present application provides a sensitive word filtering device, the device comprising:
[0017] The acquisition module is used to obtain the user's input content;
[0018] A matching module, used for matching the input content with words in a local word library;
[0019] The filtering module is used to compare the input content with the words in the background database through the Internet filtering interface when the input content does not match the words in the local word library, and store the comparison information in the local word library.
[0020] In some embodiments, the filtering module further comprises:
[0021] A merging unit is used to merge multiple pieces of input content into one piece of input content within a preset time period after the input content does not match the words in the local word library and before the input content is compared with the words in the background database through the Internet filtering interface.
[0022] In some embodiments, the local vocabulary includes a white vocabulary and a black vocabulary, and the matching module is further used to match the input content with the white words in the white vocabulary. If the input content matches the white words, the input content is filtered through; if the input content does not match the white words, the input content is matched with the black words in the black vocabulary. If the input content matches the black words, the input content is intercepted. If the input content does not match the black words, it means that the input content does not match the words in the local vocabulary.
[0023] In some embodiments, the words in the local word library are set with an effective period, and the matching module is further used to match the input content with the words in the local word library that are within the effective period.
[0024] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the sensitive word filtering method as described in the first aspect above is implemented.
[0025] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the sensitive word filtering method as described in the first aspect above is implemented.
[0026] Compared with the related art, the sensitive word filtering method provided in the embodiment of the present application obtains the user's input content and matches the input content with the words in the local word library. If there is no match, the input content is compared with the words in the background database through the Internet filtering interface, and the comparison information of the comparison is stored in the local word library, which solves the problem of high cost of sensitive word filtering detection in game projects while ensuring the timeliness of sensitive word updates, and achieves the effect of reducing the cost of sensitive word filtering detection in game projects while ensuring the timeliness of sensitive word updates. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0028] Figure 1 is a schematic diagram of an application environment of a sensitive word filtering method according to an embodiment of the present application;
[0029] Figure 2 is a flow chart of a sensitive word filtering method according to an embodiment of the present application;
[0030] Figure 3is a flow chart of matching input content with a local vocabulary according to an embodiment of the present application;
[0031] Figure 4 is a structural block diagram of a sensitive word filtering device according to an embodiment of the present application;
[0032] Figure 5 is a structural block diagram of another sensitive word filtering device according to an embodiment of the present application;
[0033] Figure 6 It is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0035] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0036] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0037] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0038] The sensitive word filtering method provided by this application can be applied to Figure 1 In the application environment shown, Figure 1 is a schematic diagram of an application environment of the sensitive word filtering method according to an embodiment of the present application, such as Figure 1 As shown, the terminal 101 communicates with the server 102 through the network, and the server 102 obtains the user's input content through the terminal 101, wherein the terminal 101 can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 102 can be implemented by an independent server or a server cluster composed of multiple servers.
[0039] This embodiment provides a sensitive word filtering method. Figure 2 is a flow chart of a sensitive word filtering method according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:
[0040] Step S201, obtaining user input content, such as game names and chat content;
[0041] Step S202, matching the input content with words in the local vocabulary. For example, when the input content is a set of multiple words, the input content is first decomposed into multiple single words, and then the decomposed single words are traversed one by one in the local vocabulary. When the input content is a single word, the single word is directly traversed in the local vocabulary.
[0042] Step S203, if there is no match, the input content is compared with the words in the background database through the Internet filtering interface, and the comparison information of the comparison is stored in the local vocabulary. It should be noted that the comparison information includes: the words in the input content that do not match the local vocabulary, and the attributes of the words that do not match, wherein the attributes of the words include white words or black words, white words are legal texts allowed to pass, and black words are sensitive words, which are illegal texts and / or confidential texts that are prohibited from passing. For example, if the traversal result is that the single word does not exist in the local vocabulary, the single word is compared with the words in the background database through the Internet filtering interface, and the single word and the attributes corresponding to the single word (white words / black words) are stored in the local vocabulary.
[0043] Through the above steps S201 to S203, compared with the problem in the prior art that the local word library matching algorithm cannot timely intercept the latest sensitive words, and the real-time Internet filtering interface method needs to pay a high detection fee, this embodiment first matches the input content with the words in the local word library, and then compares the unmatched input content online. A considerable part of the input content is matched and processed by the local word library in advance, thereby reducing the call rate of the Internet filtering interface, solving the problem of high sensitive word filtering detection cost caused by frequent calls to the Internet filtering interface, and achieving the effect of reducing the sensitive word filtering detection cost in the game project while ensuring the timeliness of sensitive word updates. In addition, Since the Internet filtering interface has the risk of failure, by reducing the interface call rate, the risk resistance of this method is made higher; this embodiment also updates the comparison information of the online comparison to the local vocabulary, completes the automatic update of the local vocabulary, ensures the timeliness of the sensitive word update, and does not need to manually maintain the local vocabulary, reducing the operation and maintenance cost. It should be noted that before the first use of this method, some commonly used words can be preset in the local vocabulary. With the repeated use of this method, the local vocabulary will continue to improve itself, thereby increasing the matching success rate between the input content and the words in the local vocabulary, greatly reducing the number of calls to the online interface, and further achieving the effect of reducing the cost of sensitive word filtering detection in game projects.
[0044] In some of the embodiments, after the input content does not match the words in the local vocabulary, before the input content is compared with the words in the background database through the Internet filtering interface, the method includes: within a preset time period, merging multiple input contents into one input content. For example, if the traversal result is that the single word does not exist in the local vocabulary, the single word is marked as a pending word. When the preset time is reached, the pending words accumulated within the preset time period are merged and a call request is generated, and then the Internet filtering interface is called; as an optional implementation, the preset time period is taken as 200 milliseconds; when multiple words are input in a short time, by merging the multiple input contents within the preset time period into one input content, the call rate of the Internet filtering interface can be further reduced, thereby further reducing the cost of sensitive word filtering detection.
[0045] In some embodiments, the local word library includes a white word library and a black word library. Figure 3 is a flow chart of matching input content with a local vocabulary according to an embodiment of the present application, such as Figure 3 As shown, the following steps are included:
[0046] Step S301, matching the input content with the white words in the white word library. For example, when the input content is a set of multiple words, the input content is first decomposed into multiple single words, and then the decomposed single words are traversed one by one in the white word library. When the input content is a single word, the single word is directly traversed in the white word library.
[0047] Step S302: if the input content matches the white word, the input content is filtered through. For example, if the traversal result shows that the single word exists in the white word library, the single word is filtered through.
[0048] Step S303, if the input content does not match the white word, match the input content with the black word in the black word library. If the input content matches the black word, intercept the input content. If the input content does not match the black word, it means that the input content does not match the word in the local word library. For example, if the traversal result is that the single word does not exist in the white word library, traverse the single word in the black word library. If the traversal result is that the single word exists in the black word library, intercept the single word. If the traversal result is that the single word does not exist in the black word library, it means that the single word does not exist in both local word libraries.
[0049] Through the above steps S301 to S303, the present embodiment sets up two local word libraries, namely the white word library and the black word library, and connects the two local word libraries in series in a chain manner. If the input content matches the white words of the white word library, the input content is filtered through; if the input content matches the black words of the black word library, the input content is intercepted. Therefore, compared with the related art that matches the input content from a single aspect of white words or black words, the present embodiment matches the input content from both legal text and illegal text, which can further reduce the probability that the local word library does not match the input content, thereby reducing the number of requests reaching the Internet filtering interface and greatly reducing the number of calls to the networking interface. After preliminary testing, the present embodiment has achieved good results, from the initial 100% call to the Internet filtering interface, to a comprehensive reduction of 50% call to the Internet detection interface, and a maximum reduction of 13%.
[0050] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here. For example, since the two local lexicons, the white lexicon and the black lexicon, are connected in series in a chain manner, in other embodiments, the input content can also be matched with the black words in the black lexicon first. If the input content matches the black word, the input content is intercepted; if the input content does not match the black word, the input content is matched with the white word in the white lexicon. If the input content matches the white word, the input content is filtered through; if the input content does not match the white word, it means that the input content does not match the word in the local lexicon.
[0051] Taking into account that white words and black words have time attributes, as time goes by, white words may evolve into black words, and black words may also be transformed into white words. Therefore, in some embodiments, the words in the local vocabulary are set with an effective period, and the matching of the input content with the words in the local vocabulary includes: matching the input content with the words in the local vocabulary that are within the effective period, for example, filtering out the words within the effective period in the local vocabulary, and then traversing the single word in the set of words within the effective period; it should be noted that when updating the comparison information of the online comparison to the local vocabulary, the black words and / or white words, as well as the effective periods corresponding to the black words and / or white words, need to be stored or updated in the local vocabulary.
[0052] This embodiment also provides a sensitive word filtering device, which is used to implement the above embodiment. Figure 4 is a structural block diagram of a sensitive word filtering device according to an embodiment of the present application, such as Figure 4 As shown, the device includes: an acquisition module 41, a matching module 42 and a filtering module 43.
[0053] The acquisition module 41 is used to obtain the user's input content; the matching module 42 is used to match the input content with the words in the local vocabulary; the filtering module 43 is used to compare the input content with the words in the background database through the Internet filtering interface when the input content does not match the words in the local vocabulary, and store the comparison information in the local vocabulary.
[0054] As an optional implementation, the words in the local word library are set with an effective period, and the matching module 42 is further used to match the input content with the words in the local word library that are within the effective period.
[0055] As an optional implementation, the local vocabulary includes a white vocabulary and a black vocabulary, and the matching module 42 is also used to match the input content with the white words in the white vocabulary. If the input content matches the white words, the input content is filtered through; if the input content does not match the white words, the input content is matched with the black words in the black vocabulary. If the input content matches the black words, the input content is intercepted. If the input content does not match the black words, it means that the input content does not match the words in the local vocabulary.
[0056] Figure 5 is a structural block diagram of another sensitive word filtering device according to an embodiment of the present application. Figure 5 As shown, the device comprises Figure 4 All modules shown, and the filtering module 43 also includes: a merging unit 51, which is used to merge multiple input contents into one input content within a preset time period after the input content does not match the words in the local vocabulary and before the input content is compared with the words in the background database through the Internet filtering interface.
[0057] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0058] In addition, in combination with the sensitive word filtering method in the above embodiment, the present application embodiment can provide a storage medium for implementation. The storage medium stores a computer program; when the computer program is executed by a processor, any sensitive word filtering method in the above embodiment is implemented.
[0059] In one embodiment, Figure 6is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, such as Figure 6 As shown, an electronic device is provided, which may be a server, and its internal structure diagram may be as shown in Figure 6 As shown. The electronic device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is used to store data. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for filtering sensitive words is implemented.
[0060] Those skilled in the art will understand that Figure 6 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0061] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0062] Those skilled in the art should understand that the technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0063] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A sensitive word filtering method, characterized in that: include: Get the user's input; Matching the input content with words in a local vocabulary; In a preset time period, multiple input contents are merged into one input content. When the input content is a collection of multiple words, the input content is first disassembled into multiple single words, and then the disassembled single words are traversed one by one in the local word library. If the traversal result shows that the single word does not exist in the local word library, the single word is marked as a word to be processed. When the preset time is reached, the words to be processed accumulated in the preset time period are merged and a call request is generated, and then the Internet filtering interface is called; the preset time period is 200 milliseconds; If there is no match, the input content is compared with the words in the backend database through the Internet filtering interface, and the comparison information of the comparison is stored in the local word library; The local word library includes a white word library and a black word library, and the two local word libraries are connected in series in a chain manner. The matching of the input content with the local word library includes: Matching the input content with white words in the white word library; If the input content matches the white word, the input content is filtered through; If the input content does not match the white word, match the input content with the black word in the black word library. If the input content matches the black word, intercept the input content. If the input content does not match the black word, it means that the input content does not match the word in the local word library. The words in the local word library are set with an effective period, and the matching the input content with the words in the local word library includes: matching the input content with the words in the local word library that are within the effective period; When the comparison information of the online comparison is updated to the local word library, the black words and / or white words, and the validity periods corresponding to the black words and / or white words are stored in or updated to the local word library.
2. A sensitive word filtering device, characterized in that: The device comprises: The acquisition module is used to obtain the user's input content; A matching module, used for matching the input content with words in a local word library; In a preset time period, multiple input contents are merged into one input content. When the input content is a collection of multiple words, the input content is first disassembled into multiple single words, and then the disassembled single words are traversed one by one in the local word library. If the traversal result shows that the single word does not exist in the local word library, the single word is marked as a word to be processed. When the preset time is reached, the words to be processed accumulated in the preset time period are merged and a call request is generated, and then the Internet filtering interface is called; the preset time period is 200 milliseconds; A filtering module, for comparing the input content with the words in the background database through an Internet filtering interface when the input content does not match the words in the local word library, and storing the comparison information in the local word library; The local word library includes a white word library and a black word library, and the two local word libraries are connected in series in a chain manner. The matching of the input content with the local word library includes: Matching the input content with white words in the white word library; If the input content matches the white word, the input content is filtered through; If the input content does not match the white word, match the input content with the black word in the black word library. If the input content matches the black word, intercept the input content. If the input content does not match the black word, it means that the input content does not match the word in the local word library. The words in the local word library are set with an effective period, and the matching the input content with the words in the local word library includes: matching the input content with the words in the local word library that are within the effective period; When the comparison information of the online comparison is updated to the local word library, the black words and / or white words, and the validity periods corresponding to the black words and / or white words are stored in or updated to the local word library.
3. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the sensitive word filtering method as described in any one of claim 1 is implemented.
4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the sensitive word filtering method as described in any one of claim 1 is implemented.
Citation Information
Patent Citations
Method and device providing searching advices
CN103473326A
Text information oriented sensitive word filtering method
CN104850574A
Systems and methods for multilingual document filtering
CN108027813A
Matrix-based sensitive word filtering method and device, electronic equipment and storage medium
CN111241389A
