Method and device for constructing adverse keyword knowledge graph and storage medium
By constructing a knowledge graph of inappropriate keywords and analyzing the substitution and derivation relationships between keywords, the problem that keyword strategies are difficult to be utilized and shared by algorithms in existing technologies is solved. This enables the explicitness and standardization of inappropriate keywords, thereby improving identification efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE GROUP DESIGN INST
- Filing Date
- 2022-11-01
- Publication Date
- 2026-07-21
AI Technical Summary
Existing bad keyword strategies are difficult for algorithms to exploit and cannot be shared externally, thus failing to effectively describe bad keyword knowledge.
Constructing a knowledge graph of problematic keywords involves analyzing substitution and derivation relationships in keyword strategies to make keyword knowledge explicit and standardized. This includes constructing knowledge graphs based on homophones, similar-looking characters, and semantics, and incorporating substitution and derivation relationships.
It has made the keyword strategy explicit and standardized, solved the problem of algorithm utilization and sharing, and improved the efficiency and accuracy of identifying bad keywords.
Smart Images

Figure CN117992616B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of content security, and in particular to a method, apparatus and storage medium for constructing a knowledge graph of harmful keywords. Background Technology
[0002] Existing knowledge of harmful keywords is primarily carried out through keyword strategies: those responsible for managing harmful information identify online content by customizing keyword strategies. A keyword strategy may contain several keywords and define the Boolean logic relationships between the keywords. Common logics include "AND" and "OR". A typical keyword strategy takes the form (A|B) and (C|D). This means that if A or B appears in the text, and C or D also appears, the text is considered harmful information.
[0003] Current knowledge graph research focuses primarily on extracting general knowledge from natural language: With the advancement of natural language processing technology, it has become possible to extract entities from natural language and analyze various universal relationships between entities, which is also the current research focus of knowledge graph technology.
[0004] Existing malicious keyword strategies are mainly aimed at identifying malicious text content, but they cannot well describe malicious keyword knowledge and are not convenient for direct use by algorithms or external sharing. Summary of the Invention
[0005] This application provides a method, apparatus, and storage medium for constructing a knowledge graph of bad keywords, which solves the problem that keyword strategies are difficult to be utilized by algorithms and cannot be shared externally.
[0006] The first aspect of this application provides a method for constructing a knowledge graph of harmful keywords, which may include:
[0007] A basic knowledge graph is constructed based on a set of keyword strategies. Each keyword strategy includes N keywords, and the N keywords are related by Boolean logic, where N is an integer greater than or equal to 1.
[0008] Based on the aforementioned basic knowledge graph and the aforementioned keyword strategy set, determine the substitution and derivation relationships corresponding to each keyword strategy in the keyword strategy set;
[0009] The substitution relationship and the derivation relationship are integrated into the basic knowledge graph to obtain the bad keyword knowledge graph.
[0010] A second aspect of this application provides an apparatus for constructing a knowledge graph of harmful keywords, comprising:
[0011] A construction unit is used to construct a basic knowledge graph based on a set of keyword strategies. Each keyword strategy includes N keywords, and the N keywords are related by Boolean logic, where N is an integer greater than or equal to 1.
[0012] The determining unit is used to determine the substitution relationship and the derivation relationship corresponding to each keyword strategy in the keyword strategy set based on the basic knowledge graph and the keyword strategy set;
[0013] An integration unit is used to integrate the substitution relationship and the derivation relationship into the basic knowledge graph to obtain the bad keyword knowledge graph.
[0014] In one possible design, the substitution relationship is a variant substitution relationship, and the determining unit is specifically used for:
[0015] The keywords corresponding to the first target keyword strategy are combined in pairs to obtain the target combination. The first target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the first target logic.
[0016] If the target combination matches the target basic knowledge graph, it is determined that the keywords in the target combination have a variant substitution relationship, and the target basic knowledge graph is included in the basic knowledge graph.
[0017] In one possible design, the substitution relationship is a general substitution relationship, and the determining unit is further specifically used for:
[0018] If the keywords in the target combination do not have the variant substitution relationship, then it is determined that the bad keywords in the target combination have an association relationship in other basic knowledge graphs, and the other basic knowledge graphs are knowledge graphs other than the target basic knowledge graph in the basic knowledge graphs;
[0019] If the negative keywords in the target combination have a correlation in the other basic knowledge graph, then it is determined that the two negative keywords in the target combination have the general substitution relationship.
[0020] In one possible design, the determining unit is further specifically used for:
[0021] Construct a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set;
[0022] The context-related knowledge graph is pruned to obtain the extended relationships corresponding to the bad keyword database.
[0023] In one possible design, the determining unit constructs a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set, including:
[0024] Normalize all keywords in the second target keyword strategy. The second target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the second target logic.
[0025] If the first target logic exists in the normalized second target keyword strategy, then the second target keyword strategy is split.
[0026] The keywords in the split second target keyword strategy are combined in pairs to obtain a combination set, which includes multiple keyword combinations in pairs;
[0027] The context-related knowledge graph is constructed based on the keywords in the combination set and the frequency of occurrence of each keyword in the combination set.
[0028] In one possible design, the determining unit prunes the context-related knowledge graph to obtain the extended relationships corresponding to the bad keyword database, including:
[0029] Remove keywords and related edges that appear in the combination set with a frequency higher than a preset threshold.
[0030] Then, after removing keywords that exceed the preset threshold and isolated nodes in the context association knowledge graph, the target association knowledge graph is obtained.
[0031] Each edge in the target-related knowledge graph is identified as the extended relationship corresponding to the second target keyword strategy.
[0032] In one possible design, the basic knowledge graph includes a homophonic knowledge graph, a similar-looking knowledge graph, and a semantic knowledge graph, and the construction unit is specifically used for:
[0033] Convert each inappropriate keyword in the keyword strategy set into pinyin;
[0034] Aggregate inappropriate keywords with the same pinyin to obtain the homophonic knowledge graph;
[0035] Calculate the stroke order edit distance between each bad keyword in the keyword strategy set;
[0036] The negative keywords in the keyword strategy set are aggregated based on the stroke order edit distance between the negative keywords to obtain the similarity knowledge graph;
[0037] Determine the vector cosine similarity between any two inappropriate keywords in the keyword strategy set;
[0038] The semantic knowledge graph is constructed based on the vector cosine similarity of any two inappropriate keywords.
[0039] In one possible design, the construction unit calculates the stroke order edit distance between each bad keyword in the keyword strategy set, including:
[0040] Determine the first stroke order corresponding to the first keyword, where the first keyword is any keyword in the keyword strategy set;
[0041] Determine the second stroke order corresponding to the second keyword, where the second keyword is any keyword in the keyword strategy set that is different from the first keyword;
[0042] Determine the minimum number of edits required to convert the first stroke order to the second stroke order;
[0043] The minimum number of edits is determined as the stroke order editing distance between the first keyword and the second keyword.
[0044] A third aspect of this application provides a computer-readable storage medium storing at least one executable instruction that, when executed on a computing device, causes the computing device to perform the method for constructing a knowledge graph of harmful keywords as described in the first aspect of this application.
[0045] The fourth aspect of this application discloses a computer program product that, when run on a computer, causes the computer to execute the method for constructing a knowledge graph of harmful keywords as described in the first aspect of this application.
[0046] The fifth aspect of this application discloses an application publishing platform for publishing computer program products, wherein when the computer program products are run on a computer, the computer executes the method for constructing a knowledge graph of harmful keywords as described in the first aspect of this application.
[0047] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0048] By analyzing the substitution and derivation relationships between keywords in the keyword strategy and constructing a knowledge graph of bad keywords, the bad keyword knowledge contained in the strategy is made explicit and standardized, thus solving the problem that keyword strategies are difficult to be used by algorithms and cannot be shared externally. Attached Figure Description
[0049] The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0050] Figure 1 A flowchart illustrating the method for constructing a knowledge graph of harmful keywords provided in this application embodiment;
[0051] Figure 2 A schematic diagram of the homophonic keyword aggregation method provided in the embodiments of this application.
[0052] Figure 3 This is a schematic diagram illustrating a method for aggregating similar-looking but undesirable keywords as provided in an embodiment of this application.
[0053] Figure 4 This is a schematic diagram illustrating the semantically inappropriate keyword aggregation method provided in the embodiments of this application;
[0054] Figure 5 A schematic diagram of the virtual structure of the apparatus for constructing a knowledge graph of bad keywords provided in the embodiments of this application;
[0055] Figure 6 This is a schematic diagram of the server structure in an embodiment of this application. Detailed Implementation
[0056] To enable those skilled in the art to better understand the present application, the technical solutions of the embodiments of the present application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. All embodiments based on the present application should fall within the scope of protection of the present application.
[0057] The following describes in detail the method for constructing the knowledge graph of bad keywords provided in this application from the perspective of the device for constructing the knowledge graph of bad keywords. The device for constructing the knowledge graph of bad keywords can be a server or a service unit in the server.
[0058] Please see Figure 1 , Figure 1 A schematic diagram illustrating an embodiment of the method for constructing a knowledge graph of harmful keywords provided in this application includes:
[0059] 101. Construct a basic knowledge graph based on the keyword strategy set.
[0060] In this embodiment, the device for constructing a knowledge graph of inappropriate keywords can first determine a set of keyword strategies. This set of keyword strategies is associated with inappropriate content scenarios, and each keyword strategy in the keyword group strategy includes N keywords. The N keywords are related by Boolean logic, that is, the keywords in the keyword strategy include "AND" and "OR" Boolean logic relationships, where N is an integer greater than or equal to 1. Then, a basic knowledge graph is constructed based on the set of keyword strategies. The construction of the basic knowledge graph includes the construction of three knowledge graphs: a homophonic knowledge graph, a similar-looking knowledge graph, and a semantic knowledge graph.
[0061] In one embodiment, the apparatus for constructing a knowledge graph of harmful keywords includes constructing a basic knowledge graph based on a set of keyword strategies, comprising:
[0062] Convert each problematic keyword in the keyword strategy set into pinyin;
[0063] Aggregate inappropriate keywords with the same pinyin to obtain a homophonic knowledge graph;
[0064] Calculate the stroke order edit distance between each bad keyword in the keyword strategy set;
[0065] Based on the stroke order edit distance between each bad keyword, the bad keywords in the keyword strategy set are aggregated to obtain a similar knowledge graph;
[0066] Determine the vector cosine similarity between any two inappropriate keywords in the keyword strategy set;
[0067] Construct a semantic knowledge graph based on the vector cosine similarity of any two inappropriate keywords.
[0068] In this embodiment, the device for constructing a knowledge graph of harmful keywords can construct a homophonic knowledge graph, a similar-looking knowledge graph, and a semantic knowledge graph, which will be described below:
[0069] 1. Construct a homophonic knowledge graph:
[0070] Constructing a homophonic knowledge graph involves two steps. First, each problematic keyword in the keyword strategy set is converted into pinyin. Then, keywords with the same pinyin are grouped together (tones are not considered). The relationships between keywords with the same pinyin are marked as "variants," thus obtaining the homophonic knowledge graph. There are two specific aggregation methods. For example... Figure 2 As shown, aggregation method one introduces two types of nodes: the pinyin of the inappropriate keyword and the inappropriate keyword itself. All inappropriate keyword nodes are connected to their corresponding pinyin nodes. Aggregation method two introduces only one type of node: inappropriate keywords. One inappropriate keyword is selected as the central node, and all other nodes are connected to it.
[0071] 2. Construct a knowledge graph with similar shapes:
[0072] To construct a knowledge graph of similar shapes, it is necessary to calculate the stroke edit distance between each bad keyword in the keyword strategy set. Then, based on the stroke edit distances between the bad keywords, the bad keywords in the bad keyword library are aggregated to obtain a knowledge graph of similar shapes. That is, the bad keywords with a stroke edit distance less than or equal to 3 are grouped into one category. The relationship between the bad keywords with a stroke edit distance less than or equal to 3 is "similar in shape". Thus, a knowledge graph of similar shapes can be obtained. Among them, the edit distance of strokes is a quantitative measurement of the difference in the stroke orders of two strings. The measurement method is to calculate the minimum number of edits required to convert the stroke order of one string into the stroke order of the other string. For example, the stroke edit distance between the character "目" and the character "日" is 1, and the stroke edit distance between the character "目" and the character "口" is 2. As Figure 3 shown, after calculating the stroke edit distance between the bad keyword nodes, if the stroke edit distance is less than or equal to 3, the bad keywords with a stroke edit distance less than or equal to 3 are grouped into one category, and their relationship is marked as "similar in shape"; when the edit distance is greater than 3, it is determined that they do not belong to the bad keywords with similar shapes and do not participate in the clustering.
[0073] It should be noted that the above edit distance less than or equal to 3 is only for illustrative purposes. Of course, there can also be other values, such as 4, and no specific limitation is made.
[0074] 3. Construct a semantic knowledge graph:
[0075] In the context of the governance of bad text information, a professional semantic knowledge graph specifically refers to a bad semantic knowledge graph. The construction device of the bad keyword knowledge graph can use the Word2Vec model to calculate semantic relevance. Word2Vec is an unsupervised word vector training method that maps words to word vectors of a fixed dimension. When the cosine similarity of the vectors of two bad keywords is close to 1, it means that the two bad keywords often appear in the same context. When it is close to 0, it means that the semantic differences between the two bad keywords are large. As Figure 4 shown, it is stipulated that when the cosine similarity of two bad keywords is greater than 0.8, a relationship of "semantically related" is added between the two bad keyword nodes and they are aggregated into one category; if the cosine similarity is less than or equal to 0.8, it is determined that they do not belong to the bad keywords with semantic relevance and do not participate in the clustering; thus, a semantic knowledge graph is obtained.
[0076] 102. Determine the substitution relationship and extension relationship corresponding to each keyword strategy in the keyword strategy set according to the basic knowledge graph and the keyword strategy set.
[0077] In this embodiment, substitution relationships include two types: variant substitution relationships and general substitution relationships. Some keyword strategies in the keyword strategy set contain a large number of undesirable keyword variants, where the ontology and each variant word are substitutes for each other. For example, in "(Baccarat|Baccarat|Baijiale)," the words "Baccarat," "Baccarat," and "Baijiale" are variants of each other and substitute for each other. By calculating for each keyword strategy, the variant substitution relationships between undesirable keywords can be obtained. For each keyword strategy, the variant relationship calculation can be completed through the following steps:
[0078] The keywords corresponding to the first target keyword strategy are paired to obtain the target combination. The first target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the logic of the first target. If the target combination matches the target basic knowledge graph, it is determined that there is a variant substitution relationship between the keywords in the target combination, and the target basic knowledge graph is included in the basic knowledge graph. In other words, the device for constructing the knowledge graph of bad keywords can check whether each keyword strategy in the keyword strategy set contains "OR" logic (i.e., the first target logic). If there is no "OR" logic, it stops directly; if there is "OR" logic, it combines the keywords in each "OR" logic of the first target keyword strategy containing "OR" logic in pairs to obtain the target combination, and matches the target combination with the basic knowledge graph. If the target combination can find a relationship in the homophonic knowledge graph or the similar-looking knowledge graph, then the two bad keywords that make up the target combination have a variant substitution relationship, and the two bad keywords are marked as a "variant substitution" relationship. Then, the frequency of bad keywords in "OR" logic in the accumulated bad text data is counted, and the word with the highest frequency is selected as the ontology. The knowledge graph is adjusted into a directed graph with a star structure with the ontology as the center.
[0079] Normally, substitution relationships can be directly extracted from the "OR" logic of keyword strategies. For example, in a keyword strategy set, "(Taobao|JD.com) and (brushing orders)," "Taobao" and "JD.com" are substitutes for each other. However, in actual keyword strategies, some bad keywords defined in the "OR" logic are not strictly guaranteed to have a substitution relationship. Therefore, it is necessary to remove keywords that do not have a substitution relationship. For each keyword strategy, if the keyword strategy is not a variant substitution relationship, the general substitution relationship can be calculated through the following steps:
[0080] If the keywords in the target combination do not have variant substitution relationships, it is determined that the bad keywords in the target combination have association relationships in other basic knowledge graphs. Other basic knowledge graphs are knowledge graphs in the basic knowledge graphs other than the target basic knowledge graph.
[0081] If the negative keywords in the target combination have related relationships in other basic knowledge graphs, then it is determined that the two negative keywords in the target combination have a general substitution relationship.
[0082] In other words, the mechanism for constructing the knowledge graph of bad keywords can check whether there is an "OR" logic in the first target keyword strategy. If not, it stops; if there is an "OR" logic, it normalizes the keyword variants in the first target keyword strategy that contain "OR" logic. Normalization means that whenever a bad keyword is given, it queries the basic knowledge graph to see if the bad keyword is a root node. If not, it finds the root node corresponding to the bad keyword and outputs it. This process is called the normalization processing of bad keywords. If two bad keywords in a pairwise combination are the same ontology after normalization, they are removed; if two keywords in the "OR" logic have a relationship in the semantic knowledge graph, then the two keywords have a general substitution relationship, and a "general substitution" relationship is added between the two bad keywords.
[0083] The above explains the substitution relationships between keywords for each keyword strategy. The following explains the indirect relationships between keywords for each keyword strategy:
[0084] The device for constructing a knowledge graph of harmful keywords determines the extended relationships between keywords in each keyword strategy within the keyword strategy set based on the basic knowledge graph and the keyword strategy set, including:
[0085] Construct a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set;
[0086] The context-related knowledge graph is pruned to obtain the extended relationships corresponding to the bad keyword database.
[0087] In other words, the device for constructing the knowledge graph of bad keywords can first normalize all keywords in the second target keyword strategy (normalization has been explained in detail above and will not be repeated here). The second target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the second target logic. If the first target logic exists in the normalized second target keyword strategy, then the second target keyword strategy is split. The keywords in the split second target keyword strategy are combined in pairs to obtain a combination set, which includes multiple pairwise keyword combinations. A context-related knowledge graph is constructed based on the keywords in the combination set and the frequency of each keyword in the combination set. The details are as follows:
[0088] Generally, in keyword strategies using AND logic, some problematic keywords are more important, directly establishing the theme of the problematic text information identified by the entire keyword strategy. Other problematic keywords play a supporting role, refining the theme and enabling the keyword strategy to achieve higher identification accuracy. For example, in the strategy "(brushing orders, earning money daily, and WeChat)," "brushing orders" is the main keyword, "earning money daily" is a related term derived from "brushing orders," while "WeChat" can appear in various types of problematic text and is not a derivative term of "brushing orders."
[0089] The construction device for the knowledge graph of harmful keywords can first construct a context-related knowledge graph through the "AND" logic (second target logic) of each keyword strategy before establishing the extended relationships between keywords in each keyword strategy. The meaning of context-related relationship is that harmful keywords with an "AND" logical relationship must appear simultaneously in the harmful text information. The specific construction method of the context-related keyword knowledge graph is as follows: Check whether there are keyword strategies with "AND" logic in the second target keyword strategy. If not, stop; if so, normalize all keywords in the second target keyword strategy containing "AND" logic using the similar-form knowledge graph or homophone knowledge graph in the basic knowledge graph; for each normalized keyword strategy, if each keyword strategy contains "OR" logic, then split the keyword combination with "OR" logic into several strategies containing only "AND" logic. For example, for the normalized strategy " After splitting "(A|B) and (C|D)", we get "(A and C)|(B and C)|(A and D)|(B and D)". Then, we extract the keywords and pair them, adding each pair to a combination set S. We count the frequency of each keyword in combination set S, generating key-value pairs where the key is the keyword and the value is a dictionary of the keyword's frequency in combination set S, denoted as D. For each combination in combination set S, we use the keyword with the smaller value in dictionary D (i.e., the one with the lower frequency in combination set S) as the central node, pointing to the keyword with the larger value in dictionary D. This allows us to construct a context-related knowledge graph.
[0090] After constructing the context association knowledge graph, the device for constructing the bad keyword knowledge graph can remove keywords and related edges that appear more frequently than a preset threshold in the combination set; and remove isolated nodes in the context association knowledge graph after removing keywords and related edges that appear more frequently than the preset threshold to obtain the target association knowledge graph; and determine each edge in the target association knowledge graph as the extended relationship corresponding to the second target keyword strategy.
[0091] In other words, extended relationships can be obtained by pruning the contextual knowledge graph. Specifically, keywords and related edges that appear in dictionary D with a frequency higher than a set threshold will be removed, and isolated nodes after pruning will also be removed. This step can remove high-frequency words such as "WeChat". In the pruned contextual knowledge graph, each edge represents an "extended" relationship. Finally, based on the topic of inappropriate information defined by the strategy specialist, the corresponding keywords can be adjusted to become the central nodes.
[0092] 103. Integrate substitution and derivation relationships into the basic knowledge graph to obtain a knowledge graph of bad keywords.
[0093] In this embodiment, after determining the substitution and derivation relationships, the device for constructing the knowledge graph of harmful keywords can integrate these relationships into the basic knowledge graph to ultimately obtain the knowledge graph of harmful keywords. That is, the knowledge graph of harmful keywords constructed by the device for constructing the knowledge graph of harmful keywords contains six main relationships: "variant," "similar in form," "related," "variant substitution," "general substitution," and "derivation."
[0094] In summary, it can be seen that the embodiments provided in this application analyze the substitution and derivation relationships between keywords in the keyword strategy and construct a knowledge graph of bad keywords, making the bad keyword knowledge contained in the strategy explicit and standardized, thus solving the problem that the keyword strategy is difficult to be used by the algorithm and cannot be shared externally.
[0095] The embodiments of this application have been described above from the perspective of the method for constructing a knowledge graph of harmful keywords. The embodiments of this application will now be described from the perspective of the apparatus for constructing a knowledge graph of harmful keywords:
[0096] Please see Figure 5 , Figure 5 This is a schematic diagram of an embodiment of the apparatus for constructing a knowledge graph of harmful keywords provided in this application. The apparatus 500 for constructing a knowledge graph of harmful keywords includes:
[0097] Construction unit 501 is used to construct a basic knowledge graph based on a set of keyword strategies. Each keyword strategy includes N keywords, and the N keywords are related by Boolean logic, where N is an integer greater than or equal to 1.
[0098] The determining unit 502 is used to determine the substitution and derivation relationships between keywords of each keyword strategy in the keyword strategy set based on the basic knowledge graph and the keyword strategy set;
[0099] Integration unit 503 is used to integrate the substitution relationship and the derivation relationship into the basic knowledge graph to obtain the bad keyword knowledge graph.
[0100] In one possible design, the substitution relationship is a variant substitution relationship, and the determining unit 502 is specifically used for:
[0101] The keywords corresponding to the first target keyword strategy are combined in pairs to obtain the target combination. The first target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the first target logic.
[0102] If the target combination matches the target basic knowledge graph, it is determined that the keywords in the target combination have a variant substitution relationship, and the target basic knowledge graph is included in the basic knowledge graph.
[0103] In one possible design, the substitution relationship is a general substitution relationship, and the determining unit 502 is further specifically used for:
[0104] If the keywords in the target combination do not have the variant substitution relationship, then it is determined that the bad keywords in the target combination have an association relationship in other basic knowledge graphs, and the other basic knowledge graphs are knowledge graphs other than the target basic knowledge graph in the basic knowledge graphs;
[0105] If the negative keywords in the target combination have a correlation in the other basic knowledge graph, then it is determined that the two negative keywords in the target combination have the general substitution relationship.
[0106] In one possible design, the determining unit 502 is further specifically used for:
[0107] Construct a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set;
[0108] The context-related knowledge graph is pruned to obtain the extended relationships corresponding to the bad keyword database.
[0109] In one possible design, the determining unit 502 constructs a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set, including:
[0110] Normalize all keywords in the second target keyword strategy. The second target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the second target logic.
[0111] If the first target logic exists in the normalized second target keyword strategy, then the second target keyword strategy is split.
[0112] The keywords in the split second target keyword strategy are combined in pairs to obtain a combination set, which includes multiple keyword combinations in pairs;
[0113] The context-related knowledge graph is constructed based on the keywords in the combination set and the frequency of occurrence of each keyword in the combination set.
[0114] In one possible design, the determining unit 502 prunes the context-related knowledge graph to obtain the extended relationships corresponding to the bad keyword database, including:
[0115] Remove keywords and related edges that appear in the combination set with a frequency higher than a preset threshold.
[0116] Then, after removing keywords that exceed the preset threshold and isolated nodes in the context association knowledge graph, the target association knowledge graph is obtained.
[0117] Each edge in the target-related knowledge graph is identified as the extended relationship corresponding to the second target keyword strategy.
[0118] In one possible design, the basic knowledge graph includes a homophonic knowledge graph, a similar-looking knowledge graph, and a semantic knowledge graph, and the construction unit 501 is specifically used for:
[0119] Convert each inappropriate keyword in the keyword strategy set into pinyin;
[0120] Aggregate inappropriate keywords with the same pinyin to obtain the homophonic knowledge graph;
[0121] Calculate the stroke order edit distance between each bad keyword in the keyword strategy set;
[0122] The negative keywords in the keyword strategy set are aggregated based on the stroke order edit distance between the negative keywords to obtain the similarity knowledge graph;
[0123] Determine the vector cosine similarity between any two inappropriate keywords in the keyword strategy set;
[0124] The semantic knowledge graph is constructed based on the vector cosine similarity of any two inappropriate keywords.
[0125] In one possible design, the construction unit 501 calculates the stroke order edit distance between each bad keyword in the keyword strategy set, including:
[0126] Determine the first stroke order corresponding to the first keyword, where the first keyword is any keyword in the keyword strategy set;
[0127] Determine the second stroke order corresponding to the second keyword, where the second keyword is any keyword in the keyword strategy set that is different from the first keyword;
[0128] Determine the minimum number of edits required to convert the first stroke order to the second stroke order;
[0129] The minimum number of edits is determined as the stroke order editing distance between the first keyword and the second keyword.
[0130] This application also provides another apparatus for constructing a knowledge graph of harmful keywords, which is deployed on a server. Please refer to [link to relevant documentation]. Figure 6 , Figure 6 This is a schematic diagram of a server structure provided in an embodiment of the present invention. The server 600 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 622 (e.g., one or more processors) and a memory 632, and one or more storage media 630 (e.g., one or more mass storage devices) for storing application programs 642 or data 644. The memory 632 and storage media 630 can be temporary or persistent storage. The program stored in the storage media 630 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 622 may be configured to communicate with the storage media 630 to execute a series of instruction operations stored in the storage media 630 on the server 600.
[0131] Server 600 may also include one or more power supplies 626, one or more wired or wireless network interfaces 650, one or more input / output interfaces 658, and / or one or more operating systems 641, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0132] The steps performed by the device for constructing a knowledge graph of harmful keywords in the above embodiments can be based on this... Figure 4 The server structure shown.
[0133] This application also provides a computer-readable storage medium storing at least one executable instruction, which, when executed on a computing device, causes the computing device to perform the method for constructing a knowledge graph of bad keywords as described in any of the above embodiments.
[0134] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0135] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0136] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0137] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0138] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0139] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0140] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0141] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for constructing a knowledge graph of harmful keywords, characterized in that, include: A basic knowledge graph is constructed based on a set of keyword strategies. Each keyword strategy in the set includes N keywords, which are related by Boolean logic, where N is an integer greater than or equal to 1. The basic knowledge graph includes a homophone knowledge graph, a similar-looking knowledge graph, and a semantic knowledge graph. The construction of the basic knowledge graph based on the set of keyword strategies includes: converting each bad keyword in the set of keyword strategies into pinyin; aggregating bad keywords with the same pinyin to obtain the homophone knowledge graph; calculating the stroke order edit distance between each bad keyword in the set of keyword strategies; aggregating bad keywords in the set of keyword strategies based on the stroke order edit distance to obtain the similar-looking knowledge graph; determining the vector cosine similarity between any two bad keywords in the set of keyword strategies; and constructing the semantic knowledge graph based on the vector cosine similarity between any two bad keywords. Based on the aforementioned basic knowledge graph and the aforementioned keyword strategy set, determine the substitution and derivation relationships corresponding to each keyword strategy in the keyword strategy set; The substitution relationship and the derivation relationship are integrated into the basic knowledge graph to obtain the bad keyword knowledge graph.
2. The method according to claim 1, characterized in that, The substitution relationship is a variant substitution relationship, and determining the substitution relationship between keywords of each keyword strategy in the keyword strategy set based on the basic knowledge graph and the keyword strategy set includes: The keywords corresponding to the first target keyword strategy are combined in pairs to obtain the target combination. The first target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the first target logic. If the target combination matches the target basic knowledge graph, it is determined that the keywords in the target combination have a variant substitution relationship, and the target basic knowledge graph is included in the basic knowledge graph.
3. The method according to claim 2, characterized in that, The substitution relationship is a general substitution relationship. Determining the substitution relationship corresponding to each keyword strategy in the keyword strategy set based on the basic knowledge graph and the keyword strategy set includes: If the keywords in the target combination do not have the variant substitution relationship, then it is determined that the bad keywords in the target combination have an association relationship in other basic knowledge graphs, and the other basic knowledge graphs are knowledge graphs other than the target basic knowledge graph in the basic knowledge graphs; If the negative keywords in the target combination have a correlation in the other basic knowledge graph, then it is determined that the two negative keywords in the target combination have the general substitution relationship.
4. The method according to claim 1, characterized in that, The step of determining the extended relationship corresponding to each keyword strategy in the keyword strategy set based on the basic knowledge graph and the keyword strategy set includes: Construct a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set; The context-related knowledge graph is pruned to obtain the extended relationships corresponding to the bad keyword database.
5. The method according to claim 4, characterized in that, The step of constructing a context-related knowledge graph based on the basic knowledge graph and the keyword strategy set includes: Normalize all keywords in the second target keyword strategy. The second target keyword strategy is the keyword strategy in the keyword strategy set that satisfies the second target logic. If the second target keyword strategy after normalization contains the first target logic, then the second target keyword strategy is split. The keywords in the split second target keyword strategy are combined in pairs to obtain a combination set, which includes multiple keyword combinations in pairs; The context-related knowledge graph is constructed based on the keywords in the combination set and the frequency of occurrence of each keyword in the combination set.
6. The method according to claim 5, characterized in that, The pruning of the context-related knowledge graph to obtain the extended relationships corresponding to the bad keyword database includes: Remove keywords and related edges that appear in the combination set with a frequency higher than a preset threshold. Then, after removing keywords that exceed the preset threshold and isolated nodes in the context association knowledge graph, the target association knowledge graph is obtained. Each edge in the target-related knowledge graph is identified as the extended relationship corresponding to the second target keyword strategy.
7. The method according to claim 1, characterized in that, The calculation of the stroke order edit distance between each bad keyword in the keyword strategy set includes: Determine the first stroke order corresponding to the first keyword, where the first keyword is any keyword in the keyword strategy set; Determine the second stroke order corresponding to the second keyword, where the second keyword is any keyword in the keyword strategy set that is different from the first keyword; Determine the minimum number of edits required to convert the first stroke order to the second stroke order; The minimum number of edits is determined as the stroke order editing distance between the first keyword and the second keyword.
8. A device for constructing a knowledge graph of harmful keywords, characterized in that, include: A construction unit is used to construct a basic knowledge graph based on a keyword strategy set. Each keyword strategy includes N keywords, and the N keywords are related by Boolean logic, where N is an integer greater than or equal to 1. The basic knowledge graph includes a homophonic knowledge graph, a similar-looking knowledge graph, and a semantic knowledge graph. The construction of the basic knowledge graph based on the keyword strategy set includes: converting each bad keyword in the keyword strategy set into pinyin; aggregating bad keywords with the same pinyin to obtain the homophonic knowledge graph; calculating the stroke order edit distance between each bad keyword in the keyword strategy set; aggregating bad keywords in the keyword strategy set according to the stroke order edit distance to obtain the similar-looking knowledge graph; determining the vector cosine similarity between any two bad keywords in the keyword strategy set; and constructing the semantic knowledge graph based on the vector cosine similarity between any two bad keywords. The determining unit is used to determine the substitution relationship and the derivation relationship corresponding to each keyword strategy in the keyword strategy set based on the basic knowledge graph and the keyword strategy set; An integration unit is used to integrate the substitution relationship and the derivation relationship into the basic knowledge graph to obtain the bad keyword knowledge graph.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one executable instruction, which, when executed on a computing device, causes the computing device to perform the method for constructing a knowledge graph of bad keywords as described in any one of claims 1 to 7.