Test data generation method and device based on atlas and electronic equipment
By receiving graph configuration information, generating multiple entities and constructing the target graph, and using SQL scripts to automatically generate test data, the problem of low testing efficiency in existing technologies is solved, and flexible and efficient graph test data generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
- Filing Date
- 2025-12-03
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies require manual input or repeated script editing when generating spectral test data, resulting in low testing efficiency and a lack of flexibility and accuracy.
By receiving graph configuration information, multiple entities are generated and a target graph is constructed based on relationship type and weight information. Test data is automatically generated using structured query language scripts.
It enables the batch generation of diverse entities, simulates real networks, improves the accuracy and efficiency of test data, and enhances the consistency and flexibility of the testing process.
Smart Images

Figure CN121880174A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of testing, and more specifically, to a method, apparatus, and electronic device for generating test data based on a graph. Background Technology
[0002] Graph technology has been widely adopted in various industries such as social networks, financial services, and healthcare, providing a powerful tool for data analysis. However, to ensure the functionality and stability of a graph platform, in-depth testing is required, which typically necessitates generating large amounts of graph data to simulate various use cases. Existing technologies have significant limitations in generating test graph data: entity creation often relies on manual input or simple scripts, which is both time-consuming and inflexible. Relationship types need to be configured one by one, and weights cannot be set according to the relationship distribution in real-world scenarios, making it difficult for the generated graph to reflect the characteristics of actual data.
[0003] There is currently no effective solution to the problem that when testing a graph platform with a large amount of test data, it is necessary to manually enter or repeatedly edit scripts to generate a large amount of test data, resulting in low testing efficiency. Summary of the Invention
[0004] The main objective of this application is to provide a method, apparatus, and electronic device for generating test data based on a graph, in order to solve the problem in related technologies where a large amount of test data needs to be manually entered or repeatedly edited to generate a large amount of test data when testing a graph platform, resulting in low testing efficiency.
[0005] To achieve the above objectives, according to one aspect of this application, a graph-based test data generation method is provided. The method includes: receiving graph configuration information input by a target object, wherein the graph configuration information includes at least: multiple relation types, weight information of the multiple relation types, entity creation methods, and target database types; generating multiple entities according to the entity creation methods; determining the relationships between the multiple entities based on the multiple relation types and the weight information to obtain a target graph; generating a structured query language script based on the target database type and the target graph; and executing the structured query language script through the target database to generate test data.
[0006] Further, determining the relationships between the multiple entities based on the multiple relationship types and the weight information to obtain the target graph includes: receiving the target depth, target breadth, and total number of entities input by the target object, wherein the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level; determining the entities contained in each level of the graph to be generated based on the target depth, the target breadth, the total number of entities, and the multiple entities; constructing multiple entity pairs based on the entities contained in each level, and determining the relationship type of the multiple entity pairs based on the multiple relationship types and the weight information; constructing triple information for each entity pair based on the multiple entity pairs and the relationship type of the multiple entity pairs, and constructing the target graph based on the triple information.
[0007] Further, determining the entities contained in each level of the graph to be generated based on the target depth, the target breadth, the total number of entities, and the plurality of entities includes: calculating the number of entities in each level based on the target depth, the target breadth, and the total number of entities; randomly selecting from the plurality of entities based on the number of entities in each level to obtain the initial entities contained in each level; and performing deduplication processing on the initial entities contained in each level based on a hash algorithm to obtain the entities contained in each level of the graph to be generated.
[0008] Further, calculating the number of entities at each level based on the target depth, the target breadth, and the total number of entities includes: constructing compensation parameters for each level based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels in the graph to be generated is not less than the target depth; calculating intermediate variables based on the compensation parameters for each level and the total number of entities; comparing the values of the intermediate variables and the target breadth, and determining the number of entities at each level based on the comparison result.
[0009] Further, determining the relationship type of the multiple entity pairs based on the multiple relationship types and the weight information includes: normalizing the weight information to obtain a probability distribution, and constructing a cumulative probability distribution based on the probability distribution; generating multiple random numbers using a random number generation algorithm, and determining the relationship type of each entity pair based on the correspondence between each random number and the cumulative probability distribution; determining the proportion of each relationship type based on the relationship type of each entity pair; and adjusting the relationship types of the multiple entity pairs based on the proportion of each relationship type and the weight information of that relationship type to obtain the relationship type of the multiple entity pairs.
[0010] Furthermore, after determining the relationship types of the multiple entity pairs based on the multiple relationship types and the weight information, the method further includes: determining relationship constraint rules based on domain knowledge between entities in the domain knowledge base; modifying the relationship types of the multiple entity pairs according to the relationship constraint rules to obtain modified relationship types of the multiple entity pairs; and updating the relationship types of the multiple entity pairs according to the modified relationship types of the multiple entity pairs.
[0011] Furthermore, generating multiple entities according to the entity creation method includes: when the entity creation method is a file import, receiving the target file uploaded by the target object, extracting entities from the target file, and deduplicating the extracted entities to obtain the multiple entities; when the entity creation method is a function call, randomly generating the multiple entities by calling a preset function; when the entity creation method is a knowledge base association, extracting the multiple entities from a domain knowledge base using a deep learning model.
[0012] To achieve the above objectives, according to another aspect of this application, a graph-based test data generation apparatus is provided. The apparatus includes: a receiving unit for receiving graph configuration information input by a target object, wherein the graph configuration information includes at least: multiple relation types, weight information of the multiple relation types, entity creation methods, and a target database type; a first generation unit for generating multiple entities according to the entity creation methods; a determining unit for determining the relationships between the multiple entities based on the multiple relation types and the weight information, thereby obtaining a target graph; and a second generation unit for generating a structured query language script based on the target database type and the target graph, and executing the structured query language script through the target database to generate test data.
[0013] Further, the determining unit includes: a receiving subunit, configured to receive the target depth, target breadth, and total number of entities input by the target object, wherein the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level; a first determining subunit, configured to determine the entities contained in each level of the graph to be generated based on the target depth, the target breadth, the total number of entities, and the multiple entities; a second determining subunit, configured to construct multiple entity pairs based on the entities contained in each level, and determine the relationship type of the multiple entity pairs based on the multiple relationship types and the weight information; and a constructing subunit, configured to construct triple information for each entity pair based on the multiple entity pairs and the relationship type of the multiple entity pairs, and construct the target graph based on the triple information.
[0014] Further, the first determining subunit includes: a calculation module, used to calculate the number of entities at each level based on the target depth, the target breadth, and the total number of entities; a selection module, used to randomly select from the plurality of entities based on the number of entities at each level to obtain the initial entities contained in each level; and a first processing module, used to perform deduplication processing on the initial entities contained in each level based on a hash algorithm to obtain the entities contained in each level in the graph to be generated.
[0015] Furthermore, the calculation module includes: a construction submodule, used to construct compensation parameters for each level based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels of the map to be generated is not less than the target depth; a calculation submodule, used to calculate intermediate variables based on the compensation parameters of each level and the total number of entities; and a comparison submodule, used to compare the numerical values of the intermediate variables and the target breadth, and determine the number of entities at each level based on the comparison result.
[0016] Further, the second determining subunit includes: a second processing module, used to normalize the weight information to obtain a probability distribution, and construct a cumulative probability distribution based on the probability distribution; a generation module, used to generate multiple random numbers using a random number generation algorithm, and determine the relationship type of each entity pair based on the correspondence between each random number and the cumulative probability distribution; a determining module, used to determine the proportion value of each relationship type based on the relationship type of each entity pair; and an adjustment module, used to adjust the relationship types of the multiple entity pairs based on the proportion value of each relationship type and the weight information of that relationship type, to obtain the relationship types of the multiple entity pairs.
[0017] Furthermore, the determining unit further includes: a third determining subunit, configured to determine relation constraint rules based on domain knowledge between entities in the domain knowledge base after determining the relation types of the multiple entity pairs based on the multiple relation types and the weight information; a modifying subunit, configured to modify the relation types of the multiple entity pairs according to the relation constraint rules to obtain the modified relation types of the multiple entity pairs; and an updating subunit, configured to update the relation types of the multiple entity pairs according to the modified relation types of the multiple entity pairs.
[0018] Further, the first generation unit includes: a first extraction subunit, configured to receive a target file uploaded by the target object when the entity creation method is file import, extract entities from the target file, and deduplicate the extracted entities to obtain the plurality of entities; a generation subunit, configured to randomly generate the plurality of entities by calling a preset function when the entity creation method is function call; and a second extraction subunit, configured to extract the plurality of entities from a domain knowledge base using a deep learning model when the entity creation method is knowledge base association.
[0019] To achieve the above objectives, according to one aspect of this application, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the graph-based test data generation method described in any of the above-described methods, and when executed by a processor, implements the steps of the graph-based test data generation method described in various embodiments of this application.
[0020] To achieve the above objectives, according to one aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including stored computer instructions, wherein, when the computer instructions are executed by a processor, the graph-based test data generation method described in any one of the above claims is implemented.
[0021] To achieve the above objectives, according to one aspect of this application, an electronic device is provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the graph-based test data generation method described in any one of the above claims.
[0022] This application employs the following steps: receiving graph configuration information input by a target object, wherein the graph configuration information includes at least: multiple relationship types, weight information of the multiple relationship types, entity creation method, and target database type; generating multiple entities according to the entity creation method; determining the relationships between the multiple entities based on the multiple relationship types and the weight information to obtain a target graph; generating a structured query language script based on the target database type and the target graph, and executing the structured query language script through the target database to generate test data. This solves the problem in related technologies where, when testing a graph platform with a large amount of test data, it is necessary to manually input or repeatedly edit scripts to generate a large amount of test data, resulting in low testing efficiency.
[0023] By receiving graph configuration information from the target object, including relation type, weight, entity creation method, and database type, the system can generate multiple entities based on the entity creation method. This allows the system to quickly acquire multiple entities from the graph data, achieving batch generation of diverse entities and flexibly generating the entities required for the graph. Furthermore, determining the relationship types between entities based on relation type and weight information can simulate complex networks in the real world, enabling the construction of the target graph and improving the accuracy and validity of the test data. Finally, generating SQL scripts based on the target database type and executing them through the target database achieves automated data import, further enhancing the coherence and flexibility of the testing process and improving the overall efficiency of the test plan. Attached Figure Description
[0024] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0025] Figure 1 This is a flowchart of a spectrum-based test data generation method provided in Embodiment 1 of this application;
[0026] Figure 2 This is a flowchart illustrating the generation of relational graph data using the optional test data generation system provided in Embodiment 1 of this application;
[0027] Figure 3 This is a schematic diagram of a spectrum-based test data generation device provided according to Embodiment 2 of this application;
[0028] Figure 4 This is a schematic diagram of an electronic device generated based on the spectrum-based test data provided in Embodiment 5 of this application. Detailed Implementation
[0029] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0030] It should be noted that the user information (including but not limited to user device information, user personal information, collected data, used data, generated data, processed data, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, collected information, used information, generated information, processed information, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with the relevant laws, regulations, and standards of the relevant countries and regions, have taken necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse. For example, this system has interfaces with relevant users or organizations. Before obtaining relevant information, it needs to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information only after receiving consent from the aforementioned user or organization.
[0031] It should be noted that this application provides users with a corresponding entry point for choosing to agree to or reject the automated decision-making results; if the user chooses to reject, the process will proceed to the expert decision-making process.
[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] Example 1
[0035] The present invention will now be described in conjunction with preferred implementation steps. Figure 1 This is a flowchart of a spectrum-based test data generation method according to Embodiment 1 of this application, as shown below. Figure 1 As shown, the method includes the following steps:
[0036] Step S101: Receive graph configuration information input by the target object, wherein the graph configuration information includes at least: multiple relation types, weight information of multiple relation types, entity creation method, and target database type.
[0037] The execution entity in this embodiment can be a test data generation system. Its function is to automatically generate graph test data suitable for the target database type based on user-defined parameters, including graph depth, graph breadth, relation type, and relation type weight. The system integrates entity creation, relation configuration, dynamic adjustment, and data format conversion to ensure that the generated data not only meets complex depth-breadth coupling requirements but can also be directly imported into various databases, making it suitable for testing in multiple fields such as social relationships, enterprise knowledge, or medical association graphs.
[0038] In this first embodiment, the test data generation system receives graph configuration information from the target object. This information includes, but is not limited to, diverse relationship types and their corresponding weight data, entity generation methods, and specified target database types. By parsing these configurations, the system can clearly define the specific requirements for constructing the graph, such as the proportion of different relationship types, entity source mechanisms, and data storage formats, thereby ensuring that the generated graph data meets the preset test scenarios and storage compatibility requirements.
[0039] Step S102: Generate multiple entities according to the entity creation method.
[0040] In this first embodiment, the system executes the entity generation process based on the entity creation method input by the target object. This method can be document import, intelligent function generation, or knowledge base association. For example, document import involves parsing user-submitted files, such as Excel, extracting entity information, and ensuring its uniqueness. Each method aims to generate a diverse and sufficient number of entities for subsequent graph construction.
[0041] Step S103: Determine the relationships between multiple entities based on multiple relationship types and weight information to obtain the target graph.
[0042] In this first embodiment, the test data generation system establishes the relationship types between entities based on various defined relationship types and their weight information. This process involves using a probabilistic model to link entities according to the weight information of each relationship type set for the target object. For example, for entities A and B, based on the weight information, the "friends / relatives" relationship is more likely to be selected than the "colleagues" relationship. By repeatedly applying this rule to other entities in the entity set, the target graph is constructed.
[0043] Step S104: Generate a structured query language script based on the target database type and target graph, and generate test data by executing the structured query language script through the target database.
[0044] In this first embodiment, based on the target database type and target graph, the test data generation system generates corresponding Structured Query Language (SQL) scripts. These scripts contain instructions for database operations to insert entity and relation data from the target graph, thereby automating the storage of entity and relation data and constructing a graph database for testing. This process eliminates the need for manual data migration, ensures seamless integration of test data with the target database environment, and improves testing efficiency and data accuracy.
[0045] In summary, the graph-based test data generation method provided in Embodiment 1 of this application receives graph configuration information input by a target object. This graph configuration information includes at least: multiple relationship types, weight information for each relationship type, entity creation method, and target database type. Multiple entities are generated based on the entity creation method. The relationships between the multiple entities are determined based on the multiple relationship types and weight information to obtain the target graph. A structured query language script is generated based on the target database type and the target graph. Test data is generated by executing the structured query language script through the target database. This solves the problem in related technologies where testing a graph platform with a large amount of test data requires manual input or repeated script editing, resulting in low testing efficiency.
[0046] By receiving graph configuration information from the target object, including relation type, weight, entity creation method, and database type, the system can generate multiple entities based on the entity creation method. This allows the system to quickly acquire multiple entities from the graph data, achieving batch generation of diverse entities and flexibly generating the entities required for the graph. Furthermore, determining the relationship types between entities based on relation type and weight information can simulate complex networks in the real world, enabling the construction of the target graph and improving the accuracy and validity of the test data. Finally, generating SQL scripts based on the target database type and executing them through the target database achieves automated data import, further enhancing the coherence and flexibility of the testing process and improving the overall efficiency of the test plan.
[0047] Optionally, in the graph-based test data generation method provided in Embodiment 1 of this application, the relationship between multiple entities is determined based on multiple relation types and weight information to obtain a target graph, including: receiving the target depth, target breadth, and total number of entities input by the target object, wherein the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level; determining the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities; constructing multiple entity pairs based on the entities contained in each level, and determining the relation type of the multiple entity pairs based on multiple relation types and weight information; constructing triple information for each entity pair based on the multiple entity pairs and the relation type of the multiple entity pairs, and constructing the target graph based on the triple information.
[0048] In this first embodiment, to generate a relational graph that meets specific requirements for depth, breadth, and number of entities, the test data generation system first receives the user-defined graph depth (i.e., the target depth), graph breadth (i.e., the target breadth), and total number of entities. The target depth defines the maximum value of the graph hierarchy, while the target breadth sets the maximum number of entities per hierarchy. Based on this, the system comprehensively analyzes the target depth, breadth, and total number of entities to accurately calculate the number of entities that each hierarchy should contain, ensuring that the graph data volume is neither overloaded nor has any gaps, thus maintaining data balance.
[0049] Then, the system constructs entity pairs based on the number of entities at each level. Entity pairs are formed by combining entities from the previous level with entities from the next level, generating combinations of entities to be associated. For example, combining entities from level N with entities from level N+1, where N is a positive integer. After the entity pairs are determined, the system randomly determines the relationship type between each pair based on preset relation types and weight information. This process simulates the distribution ratio of various relationships in a real-world scenario through weight allocation, improving the realism and accuracy of the graph data.
[0050] Secondly, the system constructs triple information for entity pairs. Each entity pair is integrated with its corresponding relation type to form a triple format of "Entity A - Relation - Entity B," which is the basic building block of the graph data. Through the construction of triples, the structure of the graph is made concrete, and the relationships between entities are clearly expressed, laying the data foundation for subsequent test data generation.
[0051] Finally, the system constructs a target graph based on the triple information. By summarizing all triple information and visualizing the relationships between entities using a graph algorithm, the target graph is formed. This graph not only reflects the user-defined depth and breadth requirements but also constructs a logically sound entity network that conforms to weight distribution based on entity attributes and relationship types, effectively supporting testing requirements.
[0052] Through the above steps, the system achieves full automation from user parameter input to entity pair construction, triplet information generation, and finally, the formation of the target graph. This achieves the technical effect of efficiently generating customized graph data and supporting depth and breadth testing. By precisely controlling the number of hierarchical entities in the graph, rationally configuring relationship weights, and automating data generation, this solution significantly improves the efficiency and applicability of test data generation, providing data support for the reliability testing of the graph platform.
[0053] Optionally, in the graph-based test data generation method provided in Embodiment 1 of this application, determining the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities includes: calculating the number of entities in each level based on the target depth, target breadth, and total number of entities; randomly selecting from multiple entities based on the number of entities in each level to obtain the initial entities contained in each level; and performing deduplication processing on the initial entities contained in each level based on a hash algorithm to obtain the entities contained in each level of the graph to be generated.
[0054] In this first embodiment, to ensure that the generated relationship graph data meets the user-defined depth and breadth while avoiding data redundancy, the test data generation system first calculates the number of entities that each level should contain based on the target depth, target breadth, and the preset total number of entities using a specific algorithm. This calculation result forms the basis for subsequent entity selection and deduplication processing, and its key lies in dynamically balancing the data volume to prevent overload or underload.
[0055] Then, based on the calculated number of entities at each level, the system randomly selects from the entity pool (i.e., the multiple entities created according to the entity creation method) to generate an initial entity set. This random selection process ensures that entities are evenly distributed in the graph, avoids pre-existing bias in the data, and enhances the randomness and realism of the test data.
[0056] Secondly, to further improve data quality, the system uses a hash algorithm to deduplicate the initial entities selected at each level. The hash algorithm is primarily used here to identify and remove duplicate entities within the same level, ensuring entity uniqueness, avoiding overlap between levels, maintaining data purity, reducing storage requirements, and improving data processing efficiency.
[0057] Finally, after deduplication, the system identifies the processed entities as those contained in each level of the generated graph. This identification process is a crucial step in graph construction, ensuring that the number of entities at each level matches the user's settings and is logically distinct, providing a clear and hierarchical data foundation for graph generation.
[0058] Through the above steps, the system achieves precise control over the number of hierarchical entities, ensuring a proper coupling and matching of depth and breadth in the generated graph data. Simultaneously, by using random selection and hash deduplication, it improves data purity and processing efficiency, achieving the technical effect of generating high-quality, high-efficiency graph data that meets specific depth and breadth requirements. This technical solution not only simplifies the test data generation process but also significantly improves the reliability and applicability of the test data, providing graph platform testing with test data that better meets user testing needs.
[0059] Optionally, in the graph-based test data generation method provided in Embodiment 1 of this application, the number of entities at each level is calculated based on the target depth, target breadth, and total number of entities. This includes: constructing compensation parameters for each level based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels in the graph to be generated is not less than the target depth; calculating intermediate variables based on the compensation parameters of each level and the total number of entities; comparing the values of the intermediate variables and the target breadth, and determining the number of entities at each level based on the comparison results.
[0060] In this first embodiment, to ensure that the generated relationship graph strictly meets the user-defined depth standard and avoids affecting the comprehensiveness of the test due to insufficient depth, the test data generation system first constructs a compensation parameter based on the target depth and the level identifiers of each level. This compensation parameter is designed to compensate for potential depth reduction issues caused by the breadth setting, ensuring that the actual number of levels in the graph is not lower than the user-expected target depth.
[0061] For example, the calculation formula for the compensation parameter can be expressed as: (D-k+1), where D represents the target depth, k represents the k-th level in the graph, and 1≤k≤D. The compensation parameter is used to ensure that there are still sufficient entity quotas for relation expansion in deeper layers of the graph, effectively avoiding data gaps. For example, when D=20, if k=10, the compensation factor is 11; if k=20, the compensation factor is 1, to ensure that even in the last layer, the number of entities does not drop to zero.
[0062] Then, the system performs mathematical calculations based on the compensation parameters for each level and the total number of entities to derive intermediate variables. These intermediate variables provide the basic values for subsequent entity count calculations, and their calculation logic takes into account the role of compensation parameters in depth maintenance, as well as the constraints of the total number of entities.
[0063] For example, the formula for calculating intermediate variables can be expressed as: Where P represents the total number of entities mentioned above, serving as a global resource constraint for the entire data generation process, fundamentally preventing data scale from spiraling out of control, D represents the target depth, k represents the k-th level in the graph, and 1≤k≤D. This is the attenuation coefficient, typically ranging from 0.8 to 0.95, used to achieve a non-linear, smooth attenuation of the number of entities from the upper to the lower layers of the map.
[0064] Secondly, the system compares the values of the intermediate variable and the target breadth to determine whether to determine the number of entities in each layer of the graph based on the value of the intermediate variable, ensuring that it does not exceed the target breadth limit. If the intermediate variable is found to be greater than or equal to the target breadth, the number of entities in that layer of the graph is determined according to the target breadth to meet the breadth requirement and avoid data quality issues caused by an excessive number of entities in a single layer; if the intermediate variable is found to be less than the target breadth, the number of entities in that layer of the graph is determined according to the value of the intermediate variable.
[0065] Finally, the system determines the actual number of entities that each level should contain based on the comparison. This process ensures that the distribution of entities in the map follows both the user-defined target breadth and depth requirements, thereby avoiding excessive expansion or gaps in the hierarchical data and maintaining the overall balance and rationality of the map data.
[0066] For example, the number of entities in the k-th layer of the graph The calculation formula can be expressed as: Where P represents the total number of entities mentioned above, serving as a global resource constraint for the entire data generation process to fundamentally prevent data scale from spiraling out of control; D represents the target depth; B represents the target breadth; k represents the k-th level in the graph; 1 ≤ k ≤ D. The above refers to the attenuation coefficient.
[0067] Through the above steps, the system achieves dynamic coupling control between depth and breadth, enabling precise regulation of the number of entities at each graph level. This avoids data redundancy while ensuring that the generated test data meets the dual testing requirements of depth and breadth, improving the generation efficiency and quality of graph test data. This mechanism overcomes the data imbalance problem caused by independent control of depth and breadth in traditional generation methods, providing a solid data foundation for the performance testing of the graph platform.
[0068] Optionally, in the graph-based test data generation method provided in Embodiment 1 of this application, determining the relationship type of multiple entity pairs based on multiple relationship types and weight information includes: normalizing the weight information to obtain a probability distribution, and constructing a cumulative probability distribution based on the probability distribution; generating multiple random numbers using a random number generation algorithm, and determining the relationship type of each entity pair based on the correspondence between each random number and the cumulative probability distribution; determining the proportion of each relationship type based on the relationship type of each entity pair; and adjusting the relationship types of multiple entity pairs based on the proportion of each relationship type and the weight information of that relationship type to obtain the relationship types of multiple entity pairs.
[0069] In this first embodiment, to ensure that the distribution of various relationships in the graph closely matches the real-world proportions, the weight information of each relationship type is first normalized and converted into a probability distribution model. Each relationship type corresponds to a probability value in the interval [0, 1], ensuring that the sum of the probabilities of all relationship types equals 1. Then, a cumulative probability distribution (CPD) is constructed based on this probability distribution. The CPD assigns a cumulative probability interval to each relationship type to guide the mapping relationship between random numbers and relationship types.
[0070] For example, suppose there are three relationship types between entities in a relationship graph: "relatives and friends," "colleagues," and "classmates," with weights of 60%, 30%, and 10%, respectively. This means that when generating relationships, the system has a 60% probability of selecting the "relatives and friends" relationship, a 30% probability of selecting the "colleagues" relationship, and a 10% probability of selecting the "classmates" relationship. The weights of all relationship types are converted into cumulative probabilities. First, the cumulative probability of the "relatives and friends" relationship is 60% because it is the first relationship type. This means that the "relatives and friends" relationship is covered by a 60% probability. Next, the weight of the "colleagues" relationship (30%) is added to the existing cumulative probability. Therefore, the cumulative probability of the "colleagues" relationship is 90% (60% + 30%). This means that when a random number falls within the interval [0.6, 0.9], the system will select the "colleagues" relationship type. Finally, the weight of the "classmates" relationship (10%) is added to the current cumulative probability, forming a complete cumulative probability distribution of [0.9, 1].
[0071] Based on the aforementioned cumulative probability distribution, when the system needs to randomly generate a relationship type, it generates a random number between 0 and 1. The relationship type is then determined by the cumulative probability interval within which this random number falls. For example, if the generated random number is 0.4, the system will generate a "friend / family" relationship because 0.4 falls within the cumulative probability interval (0 to 0.6) for "friend / family." If the random number is 0.85, it will generate a "colleague" relationship because it falls within the cumulative probability interval (0.6 to 0.9) for "colleague." Based on the cumulative probability distribution, the system can accurately generate various relationship types according to preset weight ratios, thereby achieving a reasonable allocation of different relationship types during the relationship graph data generation process.
[0072] Secondly, a series of random numbers in the interval [0, 1] are generated using a random number generation algorithm. These random numbers are used to simulate the uncertainty in the graph construction process and ensure the random allocation of relationships between entities. For each generated random number, its corresponding relationship type is determined by comparing it with the cumulative probability distribution interval. For example, if the "friend / family" relationship occupies [0, 0.6] in the cumulative probability distribution, then when the random number falls within this interval, the relationship type of the entity pair is defined as "friend / family".
[0073] Finally, the actual proportion of each type of relationship in the entity pair is calculated and compared with the preset weight information. If the actual proportion deviates from the initial weight setting, the system will readjust the relationship types of the entity pair according to the degree of deviation until the actual proportion of each relationship type is consistent with the initially set weight information (or the actual proportion of each relationship type is within the preset deviation from the initially set weight information). Through this series of adjustments, the system ensures that the distribution of various relationship types in the generated graph is uniform and reflects the set weight ratios.
[0074] Through the steps described above, this first embodiment achieves the goal of rationally allocating relationship types in the graph, ensuring that the generated test data reflects the complex relationship networks of the real world, and improving the representativeness of the test data and the effectiveness of the test. This algorithmic weight allocation and adjustment mechanism avoids the subjectivity of human intervention, guarantees the consistency and controllability of data generation, and provides accurate test data for subsequent graph testing.
[0075] Optionally, in the graph-based test data generation method provided in Embodiment 1 of this application, after determining the relation types of multiple entity pairs based on multiple relation types and weight information, the method further includes: determining relation constraint rules based on domain knowledge between entities in the domain knowledge base; modifying the relation types of multiple entity pairs based on the relation constraint rules to obtain the modified relation types of multiple entity pairs; and updating the relation types of multiple entity pairs based on the modified relation types of multiple entity pairs.
[0076] In this first embodiment, to ensure the logical consistency and authenticity of the generated graph data, the test data generation system first extracts constraint rules for the relationships between entities based on information in the domain knowledge base. These rules reflect the necessity and rationality of the relationships between entities within a specific domain, such as the age difference constraint between parents and children in the social relations domain, and the equity ratio rules between shareholders and the company in the corporate domain.
[0077] Then, the system checks and modifies the generated entity pairs and their relationship types according to these constraint rules. For each entity pair, the system compares its relationship type to the corresponding relationship constraint rules in the domain knowledge base. If it does not meet the requirements, the system corrects the relationship type according to the rules to ensure the logical correctness of the relationships between entities. This process may involve the conversion or deletion of relationship types to maintain the internal logical consistency of the graph data. For example, a constraint rule requires that the age difference between the parent and child entities in a parent relationship be greater than a preset value. Based on this rule, entity pairs of parent relationships that do not meet the age difference requirement are removed from the generated entity pairs.
[0078] Finally, the system updates the relationship types of all entity pairs, applying the rule-checked and modified relationship types to the entity pairs, replacing the original relationship type settings. This update process is comprehensive, ensuring that the relationship settings of all entity pairs conform to the constraints of domain knowledge and avoiding logical contradictions within the data. After the system completes the modification and update of the relationship types of all entity pairs, the generated graph data meets the constraints of domain knowledge, its internal relational logic is corrected and optimized, and the data quality is improved.
[0079] Through the above steps, this embodiment achieves the technical effect of automatically verifying and correcting the relationship types between entities based on the constraint rules in the domain knowledge base when generating relation graph data, ensuring the logical consistency and authenticity of the generated data, improving the accuracy and reliability of the test data, and thus enhancing the effectiveness of the graph platform testing.
[0080] Optionally, in the graph-based test data generation method provided in Embodiment 1 of this application, multiple entities are generated according to the entity creation method, including: when the entity creation method is file import, receiving the target file uploaded by the target object, extracting entities from the target file, and deduplicating the extracted entities to obtain multiple entities; when the entity creation method is function call, randomly generating multiple entities by calling a preset function; when the entity creation method is knowledge base association, extracting multiple entities from the domain knowledge base through a deep learning model.
[0081] In this first embodiment, to create an entity set that meets the testing requirements, the system first determines the type of entity creation method and then decides on the subsequent steps based on the user's selection. If the entity creation method is specified as file import, the system receives the target file uploaded by the user. This file typically contains the entity names and attributes, and the system then parses and extracts the entity information from the file. To ensure the uniqueness of entities, deduplication is performed immediately after the extraction step. By comparing the unique identifiers of the entities, duplicates are removed, ultimately resulting in a set that does not contain duplicate entities, which serves as the basis for subsequent relation generation.
[0082] Then, if the entity creation method is set to function call, the system will invoke a pre-designed entity generation function. The function generates random entities based on user-defined parameters, such as the number and type of entities, and adds them to the entity collection. This step eliminates the need for users to manually input entity information, simplifying the entity creation process and improving generation efficiency.
[0083] Secondly, in scenarios where entities are created through knowledge base association, if the knowledge base already contains a set of entity information related to the user's needs domain, multiple entities can be directly imported from the knowledge base. If the knowledge base does not yet contain a set of entity information related to the user's needs domain, the system uses a deep learning model to analyze the domain knowledge base of the user's needs domain. Based on the entity attributes and relational logic in the knowledge base, the model selects entities that meet the testing requirements. This process relies on the model's training results to ensure that the created entities not only meet the quantity requirements but also that their attributes and types are consistent with the domain knowledge, enhancing the logical consistency and realism of the entity set.
[0084] Finally, regardless of the entity creation method used, the system will integrate the generated entity set to ensure that it meets the input conditions for subsequent relation generation and graph construction.
[0085] Through the above steps, this embodiment achieves the technical effect of flexibly creating entity sets to meet the requirements of different sources and creation methods. Whether through file import, function calls, or knowledge base association, the system can automatically generate unique entity sets that conform to domain knowledge, providing a high-quality entity foundation for subsequent graph data generation and effectively supporting the needs of deep and broad coupled graph testing.
[0086] Optionally, in this first embodiment, Figure 2 This is a flowchart illustrating the generation of relational graph data using the optional test data generation system provided in Embodiment 1 of this application. For example... Figure 2 As shown, firstly, the test data generation system receives key parameters set by the user, including graph depth, breadth, total number of entities, relation type weights, and target database type. These parameters constitute the framework and standards for generating graph data. Then, a diverse entity pool is constructed through three methods: document import, function generation, and knowledge base association, ensuring the richness and diversity of entities and providing sufficient entity resources for the construction of the relation graph.
[0087] Secondly, the system configures relationships, including importing relationship types, configuring relationship weights, and setting logical constraints. Through this series of configurations, the system can generate various relationships in a specified proportion, while ensuring the logical rationality of relationships between entities and avoiding the generation of contradictory relationships. Finally, based on the above settings, the system determines the entities at each level of the graph, selects entities from the entity pool according to the calculated number of entities, performs relationship matching, and generates corresponding triple data. Subsequently, the system automatically converts the triple data into data suitable for the target database format, such as SQL scripts, JSON, or CSV files, facilitating the import and application of test data.
[0088] Finally, the test data generation system supports direct connection to the target database to execute generated SQL statements, quickly deploying the test data, or allows users to download data files, process them, and import them into the database themselves. At this point, the entire process of constructing the graph test data is successfully completed. The generated data meets the user-defined depth, breadth, and relationship weight requirements and can be used for functional and performance testing of the relationship graph.
[0089] Through the above steps Figure 2 It demonstrates the entire process of generating relation graph data, from importing requirement parameters, building entity pools, configuring relationships, to data adaptation, and finally to data output and application, providing a complete and effective solution for graph testing.
[0090] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0091] Example 2
[0092] Embodiment 2 of this application also provides a spectrum-based test data generation apparatus. It should be noted that the spectrum-based test data generation apparatus of Embodiment 2 can be used to execute the spectrum-based test data generation method provided in Embodiment 1 of this application. The spectrum-based test data generation apparatus provided in Embodiment 2 of this application will be described below.
[0093] Figure 3 This is a schematic diagram of a spectrum-based test data generation device provided according to Embodiment 2 of this application. Figure 3 As shown, the device includes: a receiving unit 301, a first generating unit 302, a determining unit 303, and a second generating unit 304.
[0094] Specifically, the receiving unit 301 is used to receive graph configuration information input by the target object, wherein the graph configuration information includes at least: multiple relation types, weight information of multiple relation types, entity creation method, and target database type.
[0095] The first generation unit 302 is used to generate multiple entities according to the entity creation method.
[0096] The determination unit 303 is used to determine the relationships between multiple entities based on multiple relationship types and weight information, thereby obtaining the target graph.
[0097] The second generation unit 304 is used to generate a structured query language script based on the target database type and the target graph, and to generate test data by executing the structured query language script through the target database.
[0098] The graph-based test data generation device provided in Embodiment 2 of this application receives graph configuration information input by a target object through a receiving unit 301. The graph configuration information includes at least: multiple relationship types, weight information of multiple relationship types, entity creation method, and target database type. A first generation unit 302 generates multiple entities according to the entity creation method. A determining unit 303 determines the relationships between the multiple entities based on the multiple relationship types and weight information to obtain the target graph. A second generation unit 304 generates a structured query language script based on the target database type and the target graph, and generates test data by executing the structured query language script through the target database. This solves the problem in related technologies where a large amount of test data is used to test a graph platform, requiring manual input or repeated editing of scripts to generate a large amount of test data, resulting in low testing efficiency.
[0099] By receiving graph configuration information from the target object, including relation type, weight, entity creation method, and database type, the system can generate multiple entities based on the entity creation method. This allows the system to quickly acquire multiple entities from the graph data, achieving batch generation of diverse entities and flexibly generating the entities required for the graph. Furthermore, determining the relationship types between entities based on relation type and weight information can simulate complex networks in the real world, enabling the construction of the target graph and improving the accuracy and validity of the test data. Finally, generating SQL scripts based on the target database type and executing them through the target database achieves automated data import, further enhancing the coherence and flexibility of the testing process and improving the overall efficiency of the test plan.
[0100] Optionally, in the graph-based test data generation device provided in Embodiment 2 of this application, the determination unit 303 includes: a receiving subunit, used to receive the target depth, target breadth, and total number of entities input by the target object, wherein the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level; a first determination subunit, used to determine the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities; a second determination subunit, used to construct multiple entity pairs based on the entities contained in each level, and determine the relationship type of the multiple entity pairs based on multiple relationship types and weight information; and a construction subunit, used to construct the triple information of each entity pair based on the multiple entity pairs and the relationship type of the multiple entity pairs, and construct the target graph based on the triple information.
[0101] Optionally, in the graph-based test data generation apparatus provided in Embodiment 2 of this application, the first determining subunit includes: a calculation module, used to calculate the number of entities at each level based on the target depth, target breadth, and total number of entities; a selection module, used to randomly select from multiple entities based on the number of entities at each level to obtain the initial entities contained in each level; and a first processing module, used to perform deduplication processing on the initial entities contained in each level based on a hash algorithm to obtain the entities contained in each level of the graph to be generated.
[0102] Optionally, in the graph-based test data generation device provided in Embodiment 2 of this application, the above-mentioned calculation module includes: a construction submodule, used to construct compensation parameters for each level based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels of the graph to be generated is not less than the target depth; a calculation submodule, used to calculate intermediate variables based on the compensation parameters of each level and the total number of entities; and a comparison submodule, used to compare the numerical values of the intermediate variables and the target breadth, and determine the number of entities in each level based on the comparison results.
[0103] Optionally, in the graph-based test data generation device provided in Embodiment 2 of this application, the aforementioned second determining subunit includes: a second processing module, used to normalize the weight information to obtain a probability distribution, and construct a cumulative probability distribution based on the probability distribution; a generation module, used to generate multiple random numbers through a random number generation algorithm, and determine the relationship type of each entity pair based on the correspondence between each random number and the cumulative probability distribution; a determining module, used to determine the proportion value of each relationship type based on the relationship type of each entity pair; and an adjustment module, used to adjust the relationship types of multiple entity pairs based on the proportion value of each relationship type and the weight information of that relationship type, to obtain the relationship types of multiple entity pairs.
[0104] Optionally, in the graph-based test data generation device provided in Embodiment 2 of this application, the determination unit 303 further includes: a third determination subunit, used to determine relation constraint rules based on domain knowledge between entities in the domain knowledge base after determining the relation types of multiple entity pairs based on multiple relation types and weight information; a modification subunit, used to modify the relation types of multiple entity pairs according to the relation constraint rules to obtain the modified relation types of multiple entity pairs; and an update subunit, used to update the relation types of multiple entity pairs according to the modified relation types of multiple entity pairs.
[0105] Optionally, in the graph-based test data generation device provided in Embodiment 2 of this application, the first generation unit 302 includes: a first extraction subunit, used to receive a target file uploaded by a target object when the entity creation method is file import, extract entities from the target file, and deduplicate the extracted entities to obtain multiple entities; a generation subunit, used to randomly generate multiple entities by calling a preset function when the entity creation method is function call; and a second extraction subunit, used to extract multiple entities from a domain knowledge base by using a deep learning model when the entity creation method is knowledge base association.
[0106] The test data generation device based on the spectrum includes a processor and a memory. The receiving unit 301, the first generation unit 302, the determining unit 303, and the second generation unit 304 mentioned above are all stored in the memory as program units. The processor executes the program units stored in the memory to realize the corresponding functions.
[0107] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can improve the testing efficiency of spectral data.
[0108] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0109] Embodiment 3 of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements a method for generating test data based on a graph.
[0110] Embodiment 4 of the present invention provides a processor for running a program, wherein the program executes a graph-based test data generation method during runtime.
[0111] Figure 4 This is a schematic diagram of an electronic device generated based on the spectrum-based test data provided in Embodiment 5 of this application. For example... Figure 4 As shown, Embodiment 5 of the present invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: receiving graph configuration information input by a target object, wherein the graph configuration information includes at least: multiple relation types, weight information of multiple relation types, entity creation method, and target database type; generating multiple entities according to the entity creation method; determining the relationships between the multiple entities based on the multiple relation types and weight information to obtain the target graph; generating a structured query language script according to the target database type and the target graph, and generating test data by executing the structured query language script through the target database.
[0112] When the processor executes the program, it also performs the following steps: determining the relationships between multiple entities based on multiple relation types and weight information to obtain a target graph, including: receiving the target depth, target breadth, and total number of entities input by the target object, where the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level; determining the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities; constructing multiple entity pairs based on the entities contained in each level, and determining the relation types of the multiple entity pairs based on multiple relation types and weight information; constructing triple information for each entity pair based on the multiple entity pairs and the relation types of the multiple entity pairs, and constructing the target graph based on the triple information.
[0113] When the processor executes the program, it also performs the following steps: determining the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities, including: calculating the number of entities in each level based on the target depth, target breadth, and total number of entities; randomly selecting from multiple entities based on the number of entities in each level to obtain the initial entities contained in each level; and performing deduplication processing on the initial entities contained in each level based on a hash algorithm to obtain the entities contained in each level of the graph to be generated.
[0114] When the processor executes the program, it also performs the following steps: calculating the number of entities at each level based on the target depth, target breadth, and total number of entities, including: constructing compensation parameters for each level based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels of the map to be generated is not less than the target depth; calculating intermediate variables based on the compensation parameters of each level and the total number of entities; comparing the values of the intermediate variables and the target breadth, and determining the number of entities at each level based on the comparison results.
[0115] When the processor executes the program, it also performs the following steps: determining the relationship type of multiple entity pairs based on multiple relationship types and weight information, including: normalizing the weight information to obtain a probability distribution, and constructing a cumulative probability distribution based on the probability distribution; generating multiple random numbers using a random number generation algorithm, and determining the relationship type of each entity pair based on the correspondence between each random number and the cumulative probability distribution; determining the proportion of each relationship type based on the relationship type of each entity pair; and adjusting the relationship types of multiple entity pairs based on the proportion of each relationship type and the weight information of that relationship type to obtain the relationship types of multiple entity pairs.
[0116] When the processor executes the program, it also performs the following steps: After determining the relation types of multiple entity pairs based on multiple relation types and weight information, the above method further includes: determining relation constraint rules based on domain knowledge between entities in the domain knowledge base; modifying the relation types of multiple entity pairs based on the relation constraint rules to obtain the modified relation types of multiple entity pairs; and updating the relation types of multiple entity pairs based on the modified relation types of multiple entity pairs.
[0117] When the processor executes the program, it also performs the following steps: generating multiple entities based on the entity creation method, including: when the entity creation method is file import, receiving the target file uploaded by the target object, extracting entities from the target file, and deduplicating the extracted entities to obtain multiple entities; when the entity creation method is function call, randomly generating multiple entities by calling a preset function; when the entity creation method is knowledge base association, extracting multiple entities from the domain knowledge base through a deep learning model.
[0118] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0119] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: receiving graph configuration information input by a target object, wherein the graph configuration information includes at least: multiple relation types, weight information of multiple relation types, entity creation method, and target database type; generating multiple entities according to the entity creation method; determining the relationships between the multiple entities based on the multiple relation types and weight information to obtain a target graph; generating a structured query language script according to the target database type and the target graph, and executing the structured query language script through the target database to generate test data.
[0120] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: determining the relationships between multiple entities based on multiple relation types and weight information to obtain a target graph, including: receiving the target depth, target breadth, and total number of entities input by the target object, where the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level; determining the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities; constructing multiple entity pairs based on the entities contained in each level, and determining the relation types of the multiple entity pairs based on multiple relation types and weight information; constructing triple information for each entity pair based on the multiple entity pairs and the relation types of the multiple entity pairs, and constructing the target graph based on the triple information.
[0121] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: determining the entities contained in each level of the graph to be generated based on the target depth, target breadth, total number of entities, and multiple entities, including: calculating the number of entities in each level based on the target depth, target breadth, and total number of entities; randomly selecting from multiple entities based on the number of entities in each level to obtain the initial entities contained in each level; and performing deduplication processing on the initial entities contained in each level based on a hash algorithm to obtain the entities contained in each level of the graph to be generated.
[0122] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: calculating the number of entities at each level based on the target depth, target breadth, and total number of entities, including: constructing compensation parameters for each level based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels of the map to be generated is not less than the target depth; calculating intermediate variables based on the compensation parameters of each level and the total number of entities; comparing the values of the intermediate variables and the target breadth, and determining the number of entities at each level based on the comparison result.
[0123] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: determining the relation types of multiple entity pairs based on multiple relation types and weight information, including: normalizing the weight information to obtain a probability distribution, and constructing a cumulative probability distribution based on the probability distribution; generating multiple random numbers using a random number generation algorithm, and determining the relation type of each entity pair based on the correspondence between each random number and the cumulative probability distribution; determining the proportion of each relation type based on the relation type of each entity pair; and adjusting the relation types of multiple entity pairs based on the proportion of each relation type and the weight information of that relation type to obtain the relation types of multiple entity pairs.
[0124] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: after determining the relation types of multiple entity pairs based on multiple relation types and weight information, the above method further includes: determining relation constraint rules based on domain knowledge between entities in the domain knowledge base; modifying the relation types of multiple entity pairs based on the relation constraint rules to obtain the modified relation types of multiple entity pairs; and updating the relation types of multiple entity pairs based on the modified relation types of multiple entity pairs.
[0125] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: generating multiple entities based on the entity creation method, including: when the entity creation method is file import, receiving the target file uploaded by the target object, extracting entities from the target file, and deduplicating the extracted entities to obtain multiple entities; when the entity creation method is function call, randomly generating multiple entities by calling a preset function; when the entity creation method is knowledge base association, extracting multiple entities from the domain knowledge base through a deep learning model.
[0126] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0127] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0128] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0129] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0130] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0131] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0132] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0133] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0134] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0135] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for generating test data based on a graph, characterized in that, include: Receive graph configuration information input by the target object, wherein the graph configuration information includes at least: multiple relation types, weight information of the multiple relation types, entity creation method, and target database type; Multiple entities are generated according to the entity creation method described above; Based on the multiple relationship types and the weight information, the relationships between the multiple entities are determined to obtain the target graph; A structured query language script is generated based on the target database type and the target graph, and test data is generated by executing the structured query language script through the target database.
2. The method according to claim 1, characterized in that, Based on the multiple relationship types and the weight information, the relationships between the multiple entities are determined to obtain the target graph, including: The system receives the target depth, target breadth, and total number of entities input from the target object, wherein the target depth is the maximum number of levels in the graph to be generated, and the target breadth refers to the maximum number of entities in each level. The entities contained in each level of the graph to be generated are determined based on the target depth, the target breadth, the total number of entities, and the multiple entities. Multiple entity pairs are constructed based on the entities contained in each level, and the relationship type of the multiple entity pairs is determined based on the multiple relationship types and the weight information; Based on the multiple entity pairs and their relationship types, triplet information for each entity pair is constructed, and the target graph is constructed based on the triplet information.
3. The method according to claim 2, characterized in that, Based on the target depth, the target breadth, the total number of entities, and the multiple entities, the entities included in each level of the graph to be generated are determined, including: The number of entities at each level is calculated based on the target depth, the target breadth, and the total number of entities; Based on the number of entities at each level, the initial entities contained in each level are randomly selected from the multiple entities to obtain the initial entities; The initial entities contained in each level are deduplicated based on a hash algorithm to obtain the entities contained in each level of the graph to be generated.
4. The method according to claim 3, characterized in that, The number of entities at each level is calculated based on the target depth, the target breadth, and the total number of entities, including: Compensation parameters for each level are constructed based on the target depth and the level identifier of each level, wherein the compensation parameters are used to ensure that the number of levels of the map to be generated is not less than the target depth; Intermediate variables are calculated based on the compensation parameters for each level and the total number of entities; The numerical values of the intermediate variable and the target breadth are compared, and the number of entities at each level is determined based on the comparison results.
5. The method according to claim 2, characterized in that, Determining the relationship type of the multiple entity pairs based on the multiple relationship types and the weight information includes: The weight information is normalized to obtain a probability distribution, and a cumulative probability distribution is constructed based on the probability distribution. Multiple random numbers are generated using a random number generation algorithm, and the relationship type of each entity pair is determined based on the correspondence between each random number and the cumulative probability distribution. The percentage of each relation type is determined based on the relation type of each entity pair; The relationship types of the multiple entity pairs are adjusted based on the proportion value and weight information of each relationship type to obtain the relationship types of the multiple entity pairs.
6. The method according to claim 2, characterized in that, After determining the relationship types of the multiple entity pairs based on the multiple relationship types and the weight information, the method further includes: Determine relationship constraint rules based on domain knowledge between entities in the domain knowledge base; The relation types of the multiple entity pairs are modified according to the relation constraint rules to obtain the modified relation types of the multiple entity pairs; The relation types of the multiple entity pairs are updated based on the modified relation types of the multiple entity pairs.
7. The method according to claim 1, characterized in that, Multiple entities are generated according to the entity creation method, including: When the entity creation method is file import, the target file uploaded by the target object is received, entities are extracted from the target file, and the extracted entities are deduplicated to obtain the multiple entities; When the entity creation method is a function call, the multiple entities are randomly generated by calling a preset function; When the entity creation method is related to a knowledge base, the multiple entities are extracted from the domain knowledge base using a deep learning model.
8. A test data generation device based on a graph, characterized in that, include: A receiving unit is used to receive graph configuration information input by a target object, wherein the graph configuration information includes at least: multiple relation types, weight information of the multiple relation types, entity creation method, and target database type; The first generation unit is used to generate multiple entities according to the entity creation method; A determining unit is configured to determine the relationships between the multiple entities based on the multiple relationship types and the weight information, thereby obtaining a target graph; The second generation unit is used to generate a structured query language script based on the target database type and the target graph, and to generate test data by executing the structured query language script through the target database.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes stored computer instructions, wherein, when the computer instructions are executed by a processor, the graph-based test data generation method of any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the graph-based test data generation method according to any one of claims 1 to 7.