Control code generation method and device
By combining control titles and function names in the low-code platform, controlling encoding is generated according to preset rules, and sensitive word matching and disk searches are carried out, the problems of high usage thresholds and security risks in the control encoding generation method in the existing technology are solved, and the compliance and uniqueness of the generated control encoding are achieved, and development efficiency and system stability are improved.
Patent Information
- Application Number
- CN202311335460.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-16
- Publication Date
- 2025-04-18
AI Technical Summary
The existing low-code platform control encoding generation methods have problems such as high usage threshold, difficulty in understanding, reliability and security risks.
By combining the control title and function name, the to-determined control encoding is obtained according to the preset naming rules, and sensitive word matching and disk search are performed to ensure the compliance and uniqueness of the encoding.
The generated control encoding is consistent and standardized, easy to understand and maintain, improves the level of development standardization, and ensures the stability and security of the system.
Smart Images

Figure CN119847528A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method and a device for generating a control code. Background Art
[0002] As the name implies, low-code platforms require developers to write very little code, and use the visual orchestration tools such as interfaces, logic, objects, and processes provided by low-code platforms to complete a large amount of development work, reduce uncertainty and complexity in software development, and thus greatly improve development efficiency, allowing companies to reduce development costs, lower technical barriers, quickly innovate applications, and achieve rapid trial and error and agile iteration. One of its core functions is to provide various controls so that users can quickly use various functions. However, low-code platforms are not without disadvantages. They have high barriers to use, limited users, risks in reliability and security, and difficulties in secondary development.
[0003] There are three types of control code generation methods in the prior art: 1. No rules + no repetition. This method completely leaves the control code generation process to the system without considering any rules. The system will randomly generate a string of garbled codes, and only ensure that the generated code is not repeated in the system; 2. Blank + custom. This method allows users to define a part of the control code when generating it, usually a prefix or suffix, and the system will fill in the remaining part to ensure the uniqueness of the code; 3. Translate the control name into Chinese pinyin. This method translates the control name into Chinese pinyin and uses the pinyin as the control code. Summary of the invention
[0004] In order to obtain a regular and more understandable control code, an embodiment of the present invention provides a method and device for generating a control code.
[0005] In a first aspect, an embodiment of the present invention provides a method for generating a control code, the method comprising:
[0006] According to the obtained control title and function name, the pending control code is obtained by splicing according to the preset naming rules;
[0007] Perform sensitive word matching on the pending control code to determine whether there is a sensitive word in the pending control code;
[0008] If so, re-execute the steps of splicing to obtain the pending control code and matching sensitive words;
[0009] Otherwise, determine whether the pending control code already exists in the disk;
[0010] If yes, the steps of splicing to obtain the pending control code and matching sensitive words are executed again; if no, the pending control code is used as the control code.
[0011] In one or some optional implementations of the embodiment of the present application, performing sensitive word matching on the pending control code to determine whether a sensitive word exists in the pending control code includes:
[0012] Get the list of sensitive words;
[0013] Establish a directed graph of sensitive words based on the sensitive word list;
[0014] Obtaining a sensitive word matching list according to the sensitive word directed graph and the pending control code;
[0015] If the sensitive word matching list is empty, it is determined that there is no sensitive word in the pending control code;
[0016] If the sensitive word matching list is not empty, it is determined whether sensitive words exist in the pending control code.
[0017] In one or some optional implementations of the embodiment of the present application, the step of establishing a directed graph of sensitive words according to the sensitive word list includes:
[0018] Obtain a sensitive word in the sensitive word list as the current sensitive word;
[0019] Update the sensitive word directed graph in the following way:
[0020] Create the first node of the sensitive word directed graph corresponding to the first character of the current sensitive word, and use the first node as the current node;
[0021] Determine whether the next character of the current sensitive word corresponds to the current node;
[0022] If so, construct a self-loop edge of the current node;
[0023] If not, create a node corresponding to the next character of the current sensitive word, build an edge from the current node to the next node, and use the next node as the new current node;
[0024] Determine whether the next character of the current sensitive word corresponds to any node;
[0025] If so, construct an edge between the current node and the corresponding node;
[0026] If not, create a node corresponding to the next character of the current sensitive word, build an edge from the current node to the next node, and use the next node as the new current node;
[0027] Repeat the above steps of determining whether there is a corresponding node for the next character of the current sensitive word and updating the directed graph of the sensitive words until all characters of the current sensitive word are traversed and the metadata of the current sensitive word is stored in the node corresponding to the last character;
[0028] Re-obtain the next sensitive word in the sensitive word list as the current sensitive word, and repeat the above steps of determining whether the next character of the current sensitive word corresponds to any previous node and updating the sensitive word directed graph, until all sensitive words in the sensitive word list are traversed to obtain the sensitive word directed graph.
[0029] In one or some optional implementations of the embodiment of the present application, obtaining a sensitive word matching list according to the sensitive word directed graph and the pending control code includes:
[0030] Matching all nodes of the sensitive word directed graph according to the arrangement order of the characters in the pending control code until a character corresponding to any node of the sensitive word directed graph is determined, and using the character as the current character;
[0031] The node corresponding to the current character is set as a marking node, a process list is established according to the marking node, and according to the sensitive words and process list stored in the marking node, matching sensitive words are added to the sensitive word matching list;
[0032] Determine whether there is a node corresponding to the next character of the current character in the directed graph of the sensitive word, and whether there is an edge from the marked node to the node;
[0033] If not, re-execute the above step of matching all nodes of the sensitive word directed graph according to the arrangement order of the subsequent characters of the current character in the pending control code;
[0034] If yes, set the node corresponding to the next character of the current character as a new marking node, add the marking node to the process list, and add the matching sensitive words to the sensitive word matching list according to the sensitive words and process list stored in the marking node;
[0035] Repeat the above process of determining whether there is a node corresponding to the next character of the current character in the sensitive word directed graph to update the sensitive word matching list until all characters of the pending control encoding are traversed to obtain the sensitive word matching list.
[0036] In one or some optional implementations of the embodiment of the present application, the matching of all nodes of the sensitive word directed graph according to the arrangement order of characters in the pending control code also includes:
[0037] If there is no correspondence between the characters in the pending control code and all the nodes of the sensitive word directed graph, the sensitive word matching list is empty.
[0038] In one or some optional implementations of the embodiments of the present application, before the splicing according to the preset naming rules to obtain the pending control code, the following method is further included:
[0039] If an instruction to translate the control title is obtained, the control title is translated to obtain a translated control title.
[0040] In one or some optional implementations of the embodiment of the present application, before determining whether the pending control code already exists in the disk, the process further includes:
[0041] Determine whether the pending control code exists in the constant pool;
[0042] If yes, then obtain the address of the pending control code in the constant pool as part of the pending control code data;
[0043] If not, a character string whose data is the pending control code is created in the constant pool, and the address of the character string is obtained as a part of the pending control code data.
[0044] In one or some optional implementations of the embodiment of the present application, the determining whether the pending control code already exists in the disk includes:
[0045] Obtaining a root node of a tree consisting of all data in the disk from the memory; the root node includes key value ranges and corresponding pointers of multiple first child nodes;
[0046] Obtaining a corresponding pointer of the first sub-node according to the pending control code and the key value range of the plurality of first sub-nodes;
[0047] According to the corresponding pointer of the first child node, the data of the first child node is loaded from the disk into the memory; the first child node includes the key value ranges and corresponding pointers of multiple second child nodes;
[0048] Repeat the above steps to determine the corresponding pointer of the child node according to the pending control code, and load the next layer of child nodes into the memory until a leaf node is loaded;
[0049] Determine whether the data in the leaf node is equal to the pending control code;
[0050] If yes, the pending control code already exists in the disk;
[0051] If not, the pending control code does not exist on the disk.
[0052] In a second aspect, an embodiment of the present invention provides a device for generating a control code, the device comprising:
[0053] The first generation module is used to obtain the pending control code by splicing the acquired control title and function name according to the preset naming rules;
[0054] A first judgment module is used to match the sensitive words of the pending control code to determine whether there are sensitive words in the pending control code; if so, re-execute the steps of splicing to obtain the pending control code and matching the sensitive words;
[0055] The second judgment module is used to judge whether the pending control code already exists in the disk; if so, re-execute the steps of splicing to obtain the pending control code and matching sensitive words; if not, use the pending control code as the control code.
[0056] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the control code generation method as described above.
[0057] In a fourth aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the control code generation method as described above when executing the computer program.
[0058] In a fifth aspect, an embodiment of the present invention provides a computer program product comprising instructions, which, when executed on a computer device, enables the computer device to execute the control code generation method as described above.
[0059] In a sixth aspect, an embodiment of the present invention provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the control code generation method as described above.
[0060] The beneficial effects of the above technical solution provided by the embodiment of the present invention include at least:
[0061] The control code generation method provided by the embodiment of the present invention obtains the pending control code according to the naming rules by combining the control title and the function name. The control code generated by this fixed rule method has consistency and standardization, making the generated control code easier to understand, allowing developers to quickly understand the meaning of the control code, improving the standardization level in development, and performing sensitive word matching and disk search on the pending control code to determine that there are no sensitive words in the control code and it is not repeated with other control codes, ensuring the compliance and uniqueness of the control code, and the sensitive word matching algorithm used occupies little memory during operation and has a simple structure. This control code generation method will have a positive effect in the secondary development of functions, allowing developers to understand and use these control codes more easily, improving development efficiency, and also ensuring the stability and security of the system.
[0062] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0063] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0065] Figure 1 It is a flowchart of a method for generating a control code provided in an embodiment of the present application;
[0066] Figure 2 It is a schematic diagram of the low-code platform interface provided in the embodiment of the present application;
[0067] Figure 3 is an example schematic diagram of a directed graph of sensitive words provided in an embodiment of the present application;
[0068] Figure 4 is an example schematic diagram of a traditional sensitive word matching algorithm provided in an embodiment of the present application;
[0069] Figure 5 It is a schematic diagram of the failure function in the traditional sensitive word matching algorithm provided in the embodiment of the present application;
[0070] Figure 6 A schematic diagram of the structure of a device for generating control codes provided in an embodiment of the present application. DETAILED DESCRIPTION
[0071] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0072] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0073] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0074] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0075] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0076] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0077] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0078] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0079] The inventor found that in the prior art, there are three ways to generate control codes in the prior art: 1. No rules + no repetition; 2. Blank + custom; 3. Translate the component name into Chinese pinyin. The first method is characterized by the fact that there are no specific rules for the generated code, but it is guaranteed that there will be no repetition. Although this method can ensure uniqueness, it may become difficult to understand and maintain for secondary developers. This is because the way the code is generated lacks structure and is not easy to interpret, resulting in development difficulties; in the second method, users have free space to define the control code. This method takes into account individual differences and allows each user to customize the control code according to their own needs. However, it is this personalized feature that may cause confusion. Since everyone's habits and understandings are different, the generated code may vary from person to person, which will increase the complexity of the work of secondary developers; the third method attempts to translate the component name into Chinese pinyin as the code. Although this method can make the code readable to a certain extent, it does not meet strict development specifications, and the pinyin translation may not necessarily reflect the characteristics or functions of the component.
[0080] At the same time, existing sensitive word matching methods, such as the traditional sensitive word filtering method Aho-Corasick, are implemented by maintaining a sensitive word dictionary. When a user enters a text content, the string matching algorithm is used to find out whether the text entered by the user contains sensitive words. The steps include: constructing all sensitive words into a Trie tree (dictionary tree) structure; next, constructing a data structure called "mismatch transfer function" to guide the algorithm to jump to the correct state when the match fails; starting from the beginning of the string to be detected, processing one character at a time; moving in the Trie tree according to the current character and the current state, if the current character can match, it will be transferred to the corresponding next state, if it cannot match, it will jump to a new state according to the failure transfer function; in each state transfer step, check whether the leaf node in the Trie tree is reached. If so, it means that one or more sensitive words have been matched, record the matching position and continue matching. After the matching is completed, output all the matching positions found or the number of occurrences of sensitive words and other information to complete the sensitive word matching task. Although this algorithm is relatively stable, it occupies a large amount of memory during operation, has a relatively complex structure, and has many inconveniences in application.
[0081] Based on this, through further research and development, the inventor made the present invention and provided a method and device for generating control codes.
[0082] Embodiment 1
[0083] An embodiment of the present invention provides a method for generating a control code. Referring to Figure 1 as shown, the method includes:
[0084] S101: According to the obtained control title and function name, splice them according to a preset naming rule to obtain a pending control code.
[0085] In an embodiment of the present application, in the above step S101, obtain the control title input by the user and the corresponding function name, and splice them according to a preset naming rule to obtain a pending control code.
[0086] Splice according to a fixed rule, use 26 English letters as the random number seed, randomly select a fixed number of random letters from them, and then based on the control title, function name and random letters, form a string of "the first letter of the function name + underscore + random letters + underscore + control title", and this string is the pending control code. Among them, if an instruction to translate the control title is obtained, that is, if the control title input by the user is in Chinese, then translate the control title and then perform subsequent processing. The translation operation can directly call an interface, such as the Baidu Translate developer interface, and the parameters include the control title to be translated, request parameters (ch to en), appid (unique identifier), and random number.
[0087] In a specific embodiment, the development interface in the low-code platform is as Figure 2 shown, the function name of this interface is "换届选举" (general election), Figure 2 the control title is displayed in the basic attribute bar on the right in
[0088] it, and the control title is "届次" (session). The pending control code spliced according to the fixed rule is "hj_iekwe_session", where "hj" is the first letter of "换届" (general election), "iekwe" represents 5 random letters, and "session" is the translation result of "届次" (session).
[0089] S102: Perform a sensitive word match on the pending control code to determine whether there is a sensitive word in the pending control code; if so, re-execute the steps of splicing to obtain a pending control code and performing a sensitive word match.
[0090] In the embodiment of the present application, the sensitive word matching is performed on the pending control code in the above step S102 to determine whether there is a sensitive word in the pending control code, including:
[0091] Get the list of sensitive words;
[0092] Establish a directed graph of sensitive words based on the sensitive word list;
[0093] According to the directed graph of sensitive words and the pending control codes, a sensitive word matching list is obtained;
[0094] If the sensitive word matching list is empty, it is determined that there are no sensitive words in the pending control code;
[0095] If the sensitive word matching list is not empty, it is determined that there are sensitive words in the pending control code.
[0096] Among them, a directed graph of sensitive words is established according to the sensitive word list, including:
[0097] Get a sensitive word in the sensitive word list as the current sensitive word;
[0098] Update the sensitive word directed graph in the following way:
[0099] Create the first node of the sensitive word directed graph corresponding to the first character of the current sensitive word, and use the first node as the current node;
[0100] Determine whether the next character of the current sensitive word corresponds to the current node;
[0101] If so, construct a self-loop edge of the current node;
[0102] If not, create a node corresponding to the next character of the current sensitive word, build an edge from the current node to the next node, and use the next node as the new current node;
[0103] Determine whether the next character of the current sensitive word corresponds to any node;
[0104] If so, construct an edge between the current node and the corresponding node;
[0105] If not, create a node corresponding to the next character of the current sensitive word, build an edge from the current node to the next node, and use the next node as the new current node;
[0106] Repeat the above steps of determining whether there is a corresponding node for the next character of the current sensitive word and updating the directed graph of sensitive words until all characters of the current sensitive word are traversed and the metadata of the current sensitive word is stored in the node corresponding to the last character;
[0107] Re-obtain the next sensitive word in the sensitive word list as the current sensitive word, and repeat the above steps of determining whether the next character of the current sensitive word corresponds to any previous node and updating the sensitive word directed graph, until all sensitive words in the sensitive word list are traversed to obtain the sensitive word directed graph.
[0108] Wherein, according to the directed graph of sensitive words and the pending control code, a sensitive word matching list is obtained, including:
[0109] Match all nodes of the sensitive word directed graph according to the order of characters in the pending control code until a character corresponding to any node of the sensitive word directed graph is determined, and the character is used as the current character;
[0110] Set the node corresponding to the current character as a marking node, create a process list based on the marking node, and add the matched sensitive words to the sensitive word matching list based on the sensitive words and process list stored in the marking node;
[0111] Determine whether there is a node corresponding to the next character of the current character in the directed graph of sensitive words, and whether there is an edge from the marked node to the node;
[0112] If not, re-execute the above step of matching all nodes of the sensitive word directed graph according to the arrangement order of the subsequent characters of the current character in the pending control code;
[0113] If yes, set the node corresponding to the next character of the current character as a new marking node, add the marking node to the process list, and add the matching sensitive words to the sensitive word matching list according to the sensitive words and process list stored in the marking node;
[0114] Repeat the above process of determining whether there is a node corresponding to the next character of the current character in the sensitive word directed graph to updating the sensitive word matching list until all characters of the pending control encoding are traversed to obtain the sensitive word matching list.
[0115] This also includes that if there is no correspondence between the characters in the pending control code and all the nodes of the sensitive word directed graph, the sensitive word matching list is empty.
[0116] In the embodiment of the present application, after obtaining the pending control code obtained in step S101, sensitive word matching is performed on the pending control code to confirm whether there is a sensitive word in the pending control code. If there is a sensitive word in the pending control code, return to step S101 to obtain a new pending control code.
[0117] The sensitive word matching algorithm specifically includes: obtaining a sensitive word list, establishing a sensitive word directed graph based on the sensitive word list, searching for sensitive words in the pending control code based on the sensitive word directed graph, and obtaining a sensitive word matching list. If the sensitive word matching list is empty, it means that there are no sensitive words in the pending control code. If the sensitive word matching list is not empty, it means that there are sensitive words in the pending control code, and a new pending control code needs to be regenerated.
[0118] Among them, the process of establishing a sensitive word directed graph according to the sensitive word list specifically includes: processing multiple sensitive words in the sensitive word list in sequence, first selecting a sensitive word in the sensitive word list as the current sensitive word, at this time the sensitive word directed graph is empty, creating the first node of the sensitive word directed graph according to the first character of the current sensitive word, the value of the node is the first character of the current sensitive word, and the first node is used as the current node; next, coming to the second character of the current sensitive word, judging whether the second character is equal to the value of the current node (the first character), if equal, creating a self-loop edge of the current node, if not equal, creating a second node, the value of the second node is the second character, and creating an edge from the current node to the second node, and then setting the second node as the current node; next, processing the third character of the current sensitive word, judging whether the third character is the same as the value of any node created before, that is, judging whether the third character has the same value as the first two characters , if the same characters exist, create an edge from the current node to the node with the same character as the third character; if the same characters do not exist, create a third node whose value is the third character, and create an edge from the current node to the third node, and then set the third node as the current node; repeat the above processing method starting from the second character, that is, each time it is necessary to determine whether the newly processed character is the same as any node created before, until all characters of the current sensitive word are processed, and the metadata of the current sensitive word is stored in the node corresponding to the last character; the above is the processing method for the first sensitive word, and then take the next sensitive word in the sensitive word list, and repeat the above processing method starting from the second character of the first sensitive word, that is, each time it is necessary to determine whether the newly processed character is the same as any node created before, until all sensitive words in the sensitive word list are traversed, and a sensitive word directed graph that records all sensitive word data is obtained.
[0119] After obtaining the sensitive word directed graph, the steps of determining whether there are sensitive words in the pending control code according to the sensitive word directed graph specifically include: the first step is to first create an empty process list and an empty sensitive word matching list; the second step is to start processing the pending control code, and match all the nodes of the sensitive word directed graph in the order of the characters in the pending control code, until the first character with the same value as any node of the sensitive word directed graph is found, and the same character is used as the current character; the third step is to set the node corresponding to the current character in the sensitive word directed graph as a marked node, and add the marked node to the process list, and at the same time check whether there is metadata of the sensitive word in the marked node. If there is a sensitive word, it is determined whether the node in the process list at this time contains all the characters of the sensitive word in the node. If it is contained, the sensitive word is matched and the sensitive word is added to the sensitive word matching list. If not, Then continue the subsequent processing; Step 4, then process the next character of the current character in the pending control code, and determine whether there is a node with the same value in the sensitive word directed graph for the character, and there is an edge from the marked node to the same node. If not, return to Step 2 and re-execute the above step of matching all nodes of the sensitive word directed graph according to the arrangement order of the subsequent characters of the current character in the pending control code. If it exists, set the next node of the current character as a new marked node, and add the marked node to the process list. If the marked node stores a sensitive word, repeat the above process of adding the matched sensitive word to the sensitive word matching list according to the sensitive word and process list; Step 5, repeat the above process of determining whether there is a node corresponding to the next character of the current character in the sensitive word directed graph to updating the sensitive word matching list, until all characters of the pending control code are traversed to obtain the sensitive word matching list. Among them, in the above second step, if the value of the character in the pending control code is different from that of all nodes of the sensitive word directed graph, an empty sensitive word matching list is directly returned.
[0120] For ease of understanding, the process of establishing the directed graph of sensitive words and matching sensitive words to the code of a given control according to the directed graph of sensitive words is illustrated by an example. The list of sensitive words includes {'he', 'she', 'his', 'hers'}, and the string of sensitive words to be detected is 'ushers'. Figure 3 The process of establishing a directed graph of sensitive words is as follows: process the first sensitive word 'he', create the first node H, the second character 'e' is different from 'h', create the second node E, and establish an edge from H to E, and store the metadata of the sensitive word 'he' in the E node, as shown in Figure 3As shown in the figure, the nodes containing sensitive words are marked in gray. Next, the second sensitive word 'she' is processed. The first character 's' is different from 'h' and 'e'. A new node S is created. The second character 'h' of 'she' already exists. An edge is created from node S to node H. The third character 'e' of 'she' also already exists, and the edge also exists. There is no need to add it repeatedly. The metadata of the sensitive word 'she' is stored in node E. Similarly, after processing the four sensitive words in the sensitive word list, we get Figure 3 The directed graph of sensitive words shown.
[0121] The string of sensitive words to be detected is 'ushers'. Next, sensitive word matching is performed. For the convenience of subsequent explanation, the function g(x)=X is set, where x is a character and X is a node. From node S to node H, g(s)+g(h) can be used to represent the process. The process includes: first, the characters in 'ushers' are detected in turn. In the directed graph of sensitive words, the character 'u' does not exist. The character 's' is matched as the current character. Node S is set as the marked node, and g(s) is added to the process list. The sensitive words stored in node S do not match the current process list. Continue to predict the next character 'h' of the character 's' in the string. There is a node H in the directed graph of sensitive words, and there is also a node S pointing to node H. Edge, set node H as a marked node, add g(h) to the process list, now the process list is g(s)+g(h), node H does not store sensitive words, continue, to predict the next character 'e' of the character 'h' in the string, there is a node E in the sensitive word directed graph, and there is also an edge from node H to node E, set node E as a marked node, add g(e) to the process list, now the process list is g(s)+g(h)+g(e), node E stores sensitive words 'he' and 'she', these two sensitive words exist in the process list, g(s)+g(h)+g(e) and g(h)+g(e), add sensitive words 'he' and 'she' to the sensitive word matching list. And so on, the final sensitive word matching list contains 'he', 'she', and 'hers'.
[0122] In an embodiment of the present application, after completing the above-mentioned sensitive word matching operation, if there is no sensitive word in the pending control code, it also includes determining whether the pending control code exists in the constant pool. If the pending control code exists in the constant pool, the address of the pending control code in the constant pool is obtained as part of the pending control code data; if the pending control code does not exist in the constant pool, a string with data of the pending control code is created in the constant pool, and the address of the string is obtained as part of the pending control code data.
[0123] The sensitive word matching method used in the embodiment of the present application is different from the traditional sensitive word filtering method (such as the Aho-Corasick algorithm, which is an example of the algorithm. Figure 4 , Figure 5 As shown in the figure, the sensitive word matching method adopted by the present invention has a series of significant advantages. The data structure design is clearer, the algorithm is simpler and easier to understand, the execution steps are more streamlined, and the query speed is excellent. These advantages make the sensitive word matching method of the present invention show excellent performance and efficiency in many aspects.
[0124] S103: Determine whether the pending control code already exists in the disk; if so, re-execute the steps of splicing to obtain the pending control code and performing sensitive word matching; if not, use the pending control code as the control code.
[0125] In the embodiment of the present application, in the above step S103, the operation of determining whether there is a pending control code in the disk includes:
[0126] Get the root node of the tree consisting of all the data in the disk from the memory; the root node contains the key value ranges and corresponding pointers of multiple first child nodes;
[0127] According to the pending control code and the key value ranges of the plurality of first child nodes, a corresponding pointer of the first child node is obtained;
[0128] According to the corresponding pointer of the first child node, the data of the first child node is loaded from the disk into the memory; the first child node includes the key value ranges and corresponding pointers of multiple second child nodes;
[0129] Repeat the above steps to determine the corresponding pointer of the child node according to the pending control code, and load the next layer of child nodes into the memory until a leaf node is loaded;
[0130] Determine whether the data in the leaf node is equal to the pending control code;
[0131] If so, the pending control code already exists on disk;
[0132] If not, the pending control code does not exist on disk.
[0133] In an embodiment of the present application, the operation of determining whether there is a pending control code in the disk specifically includes: obtaining the root node of the tree consisting of all the data in the disk from the memory, the search process starts with the root node of the tree, and the root node is usually in the memory; starting from the root node, according to the key value to be searched, searching in the current node, each node contains multiple key values and corresponding pointers, and the goal of the search is to find a child node whose key value range contains or matches the key value to be searched; if a matching key value is not found in the current node, select a suitable child node according to the size of the key value to continue searching, in this process, it may be necessary to traverse downward along the branches of the tree; continue searching until reaching the leaf node of the tree, the leaf node contains the actual data record, and the leaf node will no longer have a child node; in the leaf node, compare with the key value to be searched, if a matching key value is found, the target data is successfully found; if matching data is found, the data is returned to the application; if matching data is not found, the corresponding identifier of the data not found is returned.
[0134] The method for generating control codes provided in the embodiment of the present invention obtains pending control codes according to naming rules by combining the control title and function name, and generates control codes according to certain rules. The control codes generated by this method are consistent and standardized, so that developers can quickly understand their meanings, thereby improving the level of development standardization. At the same time, sensitive word matching and disk search are adopted to ensure that the control codes neither contain sensitive words nor repeat with other control codes, so as to ensure the compliance and uniqueness of the control codes. Compared with the traditional sensitive word matching method, the sensitive word matching method has a clearer data structure design, a simple and easy-to-understand algorithm, a streamlined execution step, and a fast running speed, so that the sensitive word matching method of the present invention exhibits excellent performance and efficiency in many aspects. The present invention actively affects the secondary development of functions, enables developers to understand and use these control codes more easily, improves development efficiency, and ensures the stability and security of the system.
[0135] Embodiment 2
[0136] Based on the same inventive concept, the embodiment of the present invention also provides a control code generation device, referring to Figure 6 As shown, the device comprises:
[0137] The first generation module 101 is used to obtain the pending control code according to the acquired control title and function name and the preset naming rules.
[0138] The first judgment module 102 is used to perform sensitive word matching on the pending control code to determine whether there is a sensitive word in the pending control code; if so, re-execute the steps of splicing to obtain the pending control code and performing sensitive word matching;
[0139] The second judgment module 103 is used to judge whether the pending control code already exists in the disk; if so, re-execute the steps of splicing to obtain the pending control code and performing sensitive word matching; if not, use the pending control code as the control code.
[0140] Embodiment 3
[0141] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for generating a control code as described in the above-mentioned embodiment 1 is implemented.
[0142] Embodiment 4
[0143] Based on the same inventive concept, an embodiment of the present invention also provides a computer device, including 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 method for generating control code as described in the above-mentioned embodiment 1 is implemented.
[0144] Embodiment 5
[0145] Based on the same inventive concept, an embodiment of the present invention further provides a computer program product comprising instructions. When the computer program product is run on a computer device, the computer device executes the method for generating control codes as described in the above-mentioned embodiment 1.
[0146] Embodiment 6
[0147] Based on the same inventive concept, an embodiment of the present invention also provides a chip, the chip includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the control code generation method described in the above embodiment one.
[0148] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0149] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0150] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0152] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for generating a control code, characterized in that: include: According to the obtained control title and function name, the pending control code is obtained by splicing according to the preset naming rules; Perform sensitive word matching on the pending control code to determine whether there is a sensitive word in the pending control code; If so, re-execute the steps of splicing to obtain the pending control code and matching sensitive words; Otherwise, determine whether the pending control code already exists in the disk; If yes, the steps of splicing to obtain the pending control code and matching sensitive words are executed again; if no, the pending control code is used as the control code.
2. The method according to claim 1, characterized in that The performing sensitive word matching on the pending control code to determine whether a sensitive word exists in the pending control code includes: Get the list of sensitive words; Establish a directed graph of sensitive words based on the sensitive word list; Obtaining a sensitive word matching list according to the sensitive word directed graph and the pending control code; If the sensitive word matching list is empty, it is determined that there is no sensitive word in the pending control code; If the sensitive word matching list is not empty, it is determined whether sensitive words exist in the pending control code.
3. The method according to claim 2, characterized in that The step of establishing a directed graph of sensitive words according to the sensitive word list includes: Obtaining a sensitive word in the sensitive word list as the current sensitive word; Update the sensitive word directed graph in the following way: Create the first node of the sensitive word directed graph corresponding to the first character of the current sensitive word, and use the first node as the current node; Determine whether the next character of the current sensitive word corresponds to the current node; If so, construct a self-loop edge of the current node; If not, create a node corresponding to the next character of the current sensitive word, build an edge from the current node to the next node, and use the next node as the new current node; Determine whether the next character of the current sensitive word corresponds to any node; If so, construct an edge between the current node and the corresponding node; If not, create a node corresponding to the next character of the current sensitive word, build an edge from the current node to the next node, and use the next node as the new current node; Repeat the above steps of determining whether there is a corresponding node for the next character of the current sensitive word and updating the directed graph of the sensitive words until all characters of the current sensitive word are traversed and the metadata of the current sensitive word is stored in the node corresponding to the last character; Re-obtain the next sensitive word in the sensitive word list as the current sensitive word, and repeat the above steps of determining whether the next character of the current sensitive word corresponds to any previous node and updating the sensitive word directed graph, until all sensitive words in the sensitive word list are traversed to obtain the sensitive word directed graph.
4. The method according to claim 2, characterized in that The step of obtaining a sensitive word matching list according to the sensitive word directed graph and the pending control code includes: Matching all nodes of the sensitive word directed graph according to the arrangement order of the characters in the pending control code until a character corresponding to any node of the sensitive word directed graph is determined, and using the character as the current character; The node corresponding to the current character is set as a marking node, a process list is established according to the marking node, and according to the sensitive words and process list stored in the marking node, matching sensitive words are added to the sensitive word matching list; Determine whether there is a node corresponding to the next character of the current character in the directed graph of the sensitive word, and whether there is an edge from the marked node to the node; If not, re-execute the above step of matching all nodes of the sensitive word directed graph according to the arrangement order of the subsequent characters of the current character in the pending control code; If yes, set the node corresponding to the next character of the current character as a new marking node, add the marking node to the process list, and add the matching sensitive words to the sensitive word matching list according to the sensitive words and process list stored in the marking node; Repeat the above process of determining whether there is a node corresponding to the next character of the current character in the sensitive word directed graph to update the sensitive word matching list until all characters of the pending control encoding are traversed to obtain the sensitive word matching list.
5. The method according to claim 4, characterized in that The matching of all nodes of the sensitive word directed graph according to the arrangement order of characters in the pending control code also includes: If there is no correspondence between the characters in the pending control code and all the nodes of the sensitive word directed graph, the sensitive word matching list is empty.
6. The method according to claim 1, characterized in that Before the pending control code is obtained by splicing according to the preset naming rules, it also includes: If an instruction to translate the control title is obtained, the control title is translated to obtain a translated control title.
7. The method according to claim 1, characterized in that Before determining whether the pending control code already exists in the disk, the method further includes: Determine whether the pending control code exists in the constant pool; If yes, then obtain the address of the pending control code in the constant pool as part of the pending control code data; If not, a character string whose data is the pending control code is created in the constant pool, and the address of the character string is obtained as a part of the pending control code data.
8. The method according to claim 1, characterized in that The determining whether the pending control code already exists in the disk includes: Obtaining a root node of a tree consisting of all data in the disk from the memory; the root node includes key value ranges and corresponding pointers of multiple first child nodes; Obtaining a corresponding pointer of the first sub-node according to the pending control code and the key value range of the plurality of first sub-nodes; According to the corresponding pointer of the first child node, the data of the first child node is loaded from the disk into the memory; the first child node includes the key value ranges and corresponding pointers of multiple second child nodes; Repeat the above steps to determine the corresponding pointer of the child node according to the pending control code, and load the next layer of child nodes into the memory until a leaf node is loaded; Determine whether the data in the leaf node is equal to the pending control code; If yes, the pending control code already exists in the disk; If not, the pending control code does not exist on the disk.
9. A device for generating a control code, characterized in that: include: The first generation module is used to obtain the pending control code by splicing the acquired control title and function name according to the preset naming rules; A first judgment module is used to match sensitive words to the pending control code to determine whether there are sensitive words in the pending control code; If so, re-execute the steps of splicing to obtain the pending control code and matching sensitive words; The second judgment module is used to judge whether the pending control code already exists in the disk; if so, re-execute the steps of splicing to obtain the pending control code and matching sensitive words; if not, use the pending control code as the control code.
10. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal, the terminal executes the method for generating a control code according to any one of claims 1 to 8.
11. A computer device, characterized in that: It comprises 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 method for generating the control code as described in any one of claims 1 to 8 is implemented.
12. A computer program product comprising instructions, which, when executed on a computer device, enables the computer device to execute the method for generating a control code as claimed in any one of claims 1 to 8.
13. A chip, comprising a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the method for generating a control code as described in any one of claims 1 to 8.