A Retrieval Method Based on Software Testing Knowledge Graph
By employing a retrieval method based on software testing knowledge graphs, utilizing the updating and maintenance of multi-level thesaurus and IDF model files, and combining word segmentation and template adaptive techniques, the problem of intelligent retrieval of software testing documents was solved, improving retrieval accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-01
- Publication Date
- 2026-03-06
AI Technical Summary
Existing software test documents have low reusability and cannot be intelligently retrieved. Keyword extraction is inaccurate, the level of intelligent retrieval is low, and nodes with little relevance are detected, affecting the retrieval rate.
It adopts a retrieval method based on software testing knowledge graphs, and through the updating and maintenance of multi-level thesaurus and IDF model files, it combines Hidden Markov and Viterbi algorithms for word segmentation, establishes the association between keywords and synonyms, uses the surrounding centrality algorithm for retrieval and recommendation, and supports template adaptive technology for data extraction and storage.
It improved the relevance and hit rate of search results, enhanced the accuracy of keyword extraction and word segmentation, realized the intelligent storage and retrieval of software testing knowledge, and reduced the workload of coding.
Smart Images

Figure CN115422371B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge graph technology, and in particular to a retrieval method based on a software testing knowledge graph. Background Technology
[0002] Software testing is not only a primary means of ensuring software quality but also a crucial component of software testing and evaluation. Improving the intelligence and standardization of software product testing is a vital way to enhance testing efficiency and quality, thereby strengthening software testing and evaluation capabilities. The data and experience accumulated during testing should also have a degree of inheritability. While test data increases year by year, this accumulated data often remains unused and dormant. How to transform historical test cases into test knowledge is a pressing issue that needs to be addressed.
[0003] Knowledge graphs are widely used in various fields. Enterprises and organizations in these fields are beginning to combine knowledge graph technologies to extract knowledge entities and relationship data from information resources in their respective fields, and construct their own knowledge graphs for information resource retrieval and recommendation. This enables convenient and rapid acquisition of relevant knowledge, improves the way information resources are used, and increases efficiency.
[0004] However, existing knowledge graph corpora are sourced from a single source, making it impossible to distinguish the weight of words. The level of intelligence in retrieval is low, and nodes with little relevance are detected, affecting the retrieval rate. Keyword extraction is inaccurate and lacks a reasonable update mechanism. Summary of the Invention
[0005] Based on the above analysis, the embodiments of the present invention aim to provide a retrieval method based on software testing knowledge graphs to solve the problems of low reusability and inability to intelligently retrieve existing software testing documents.
[0006] This invention provides a retrieval method based on a software testing knowledge graph, comprising the following steps:
[0007] The search criteria input by the user are segmented into words to obtain search terms; based on the stop word library and the thesaurus in the multi-level thesaurus, stop words in the search terms are removed, and the synonyms in the remaining search terms are obtained and added to the search terms.
[0008] Keyword matching is performed sequentially on the search terms in the software testing knowledge graph to obtain the keywords and the knowledge entities and synonyms associated with the keywords; the knowledge entities associated with the keywords are used as the search results.
[0009] Based on the weight and position of keywords and synonyms in the thesaurus, as well as the similarity of synonyms, the score of each search result is summarized; based on the software testing template, the software testing knowledge corresponding to the search results is displayed in descending order of score.
[0010] Based on further improvements to the above method, the retrieval method also includes: when the number of retrieval results is less than the first quantity threshold, or when the number of retrieval results with scores exceeding the score threshold is less than the second quantity threshold, performing a full-text retrieval based on the word segmentation results to obtain supplementary results and their scores, and adding them to the retrieval results.
[0011] Based on the further improvement of the above method, the score of each search result is summarized according to the weight and position weight of the thesaurus to which the keywords and synonyms belong, as well as the similarity of the synonyms. The score is calculated by taking each search result as the central node, the keywords and synonyms as the surrounding nodes of the central node, and the second-level path as the boundary, and the surrounding centrality of the central node is used as the score of the search result.
[0012] Based on a further improvement of the above method, the surrounding centrality of the center node is obtained using the following formula:
[0013]
[0014] C C (N p ) = Dict p ×Pos p
[0015] C′ C (N q ) = Dict q ×Pos q ×sim q
[0016] Where g is the number of keywords directly related to the central node C, and r is the number of synonyms of the keywords directly related to C; Dict p The keyword N p The weight of the thesaurus, Pos p The keyword N p Position weight, Dict q It is the weight of the thesaurus, Pos q It is a synonym N q Position weights, sim q This represents the similarity between synonyms.
[0017] Based on the above method, further improvements are made to the software testing template, displaying the corresponding software testing knowledge according to the search results from high to low, including:
[0018] Based on the search results, obtain the corresponding software test template;
[0019] Based on the fields bound in the software test template, the field content is retrieved from the corresponding records in the search results and populated into the software test template; if the field content contains an image identifier, the image information is retrieved from the file library and inserted into the software test template to obtain software test knowledge; the software test knowledge is then displayed in a visual manner.
[0020] Based on further improvements to the above method, the software testing knowledge graph is constructed using software testing templates and software testing documents. The construction steps are as follows:
[0021] Based on the software test template, the received software test documents are preprocessed and segmented. The new vocabulary in the multi-level vocabulary is updated according to the segmentation results, and the IDF model files of various research directions are updated according to the segmentation results and the research direction to which the document belongs. The preprocessed documents are parsed to obtain basic data.
[0022] Based on the basic data, knowledge entities and their attributes are extracted periodically, and the relationships between knowledge entities, their attributes, and the relationships between them are established.
[0023] Based on multi-level thesaurus and IDF model files for various research directions, keywords are extracted from the attributes of knowledge entities, keyword entities and the relationship between keyword entities and knowledge entities are established to obtain a knowledge graph.
[0024] Based on further improvements to the above method, the multi-level thesaurus includes: a first-level standard thesaurus, a second-level hot word thesaurus, a third-level new word thesaurus, a fourth-level synonym thesaurus, and a fifth-level stop word thesaurus. The first-level standard thesaurus is pre-configured by analyzing domain standards and software testing standards; the second-level hot word thesaurus is dynamically updated based on user-input search criteria, as well as pre-configured frequency and time thresholds; the third-level new word thesaurus is updated based on the word segmentation results of all successfully preprocessed software test documents; and the fourth-level synonym thesaurus and the fifth-level stop word thesaurus are updated based on user maintenance.
[0025] Based on further improvements to the above method, the IDF model files for various research directions are updated according to the word segmentation results and the research direction to which the document belongs:
[0026] Based on the stop word library, stop words are removed from the word segmentation results of each document under each research direction;
[0027] The inverse document frequency (IDF) of each word in the segmentation results after removing stop words is calculated using the following formula for each research direction, and the IDF model files for each research direction are composed of each word and its corresponding IDF:
[0028]
[0029] Among them, idf i,jTC is the inverse document frequency of the i-th word in the j-th research direction; i,j Let be the word frequency of the i-th word in the document of the j-th research direction; MC i Let be the number of times the i-th word appears in the built-in corpus.
[0030] Based on further improvements to the above method, keywords are extracted from the attributes of knowledge entities using multi-level thesaurus and IDF model files for various research directions, including:
[0031] The attributes of each knowledge entity are used to form the current text, which is then segmented into words. Stop words are removed from the segmented results to obtain the words to be extracted.
[0032] Based on a multi-level thesaurus, the thesaurus to which each word to be extracted belongs is identified. Words belonging to the first-level standard thesaurus or the second-level hot word thesaurus are directly used as keywords. For each remaining word to be extracted, the following steps are performed:
[0033] The TF frequency of each remaining word to be extracted is obtained based on the number of times each remaining word appears in the current text and the number of times it appears in all preprocessed software test documents.
[0034] Based on the IDF model file of the research direction to which the knowledge entity belongs, obtain the IDF inverse document frequency of each remaining word to be extracted;
[0035] Identify the source attributes and corresponding weights of each remaining word to be extracted, and obtain the position weight and lexicon weight of each remaining word to be extracted based on the lexicon to which each remaining word to be extracted belongs;
[0036] The score for each remaining word to be extracted is obtained by multiplying the TF term frequency, IDF inverse document frequency, position weight, and lexicon weight.
[0037] Sort the scores from highest to lowest, and extract the top-scoring words from the remaining words to be extracted as keywords, based on a preset number of words.
[0038] Based on further improvements to the above method, the secondary hot word database is dynamically updated according to the user-input search criteria, as well as preset frequency and time thresholds, including:
[0039] The search criteria input by the user are segmented into words, and the segmented results are used to remove stop words and words that are already in any word database.
[0040] The system sequentially checks whether the remaining words already exist in the user's habitual phrase cache. If they do, the word frequency is incremented by 1. If the word frequency reaches a preset threshold, the word is added to the secondary hot word library and removed from the user's habitual phrase cache. If the words do not exist, the word is added to the user's habitual phrase cache, and the time is updated.
[0041] Based on the update time of each word in the user's habitual phrase cache, and compared with the current time, words that exceed the preset time threshold are removed from the user's habitual phrase cache.
[0042] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0043] 1. Based on keywords and synonyms, and taking into account the number of paths and path weights, we propose a surrounding centrality algorithm to retrieve and recommend knowledge, improve the relevance of retrieval results, and maximize the use of dormant test knowledge.
[0044] 2. Establish multi-level thesauruses and their respective update and maintenance methods to improve word segmentation accuracy and retrieval hit rate.
[0045] 3. Improve the IDF calculation method. When training the IDF model on all software test documents, generate IDF models for different research directions. During the keyword extraction process, extract the research direction corresponding to the text and use the corresponding IDF model to extract keywords, thereby improving the accuracy of keyword extraction.
[0046] 4. Adopting template adaptive technology, after each change to the software test document, only the new template needs to be uploaded to the server, and the template can be automatically parsed into the corresponding HTML according to the unified modeling language of the test document. At the same time, dynamic binding of database fields is supported. The entire process does not require rewriting of the code.
[0047] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0048] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.
[0049] Figure 1 This is a flowchart of a retrieval method based on a software testing knowledge graph in an embodiment of the present invention;
[0050] Figure 2 This is a schematic diagram of the knowledge subgraph obtained according to the retrieval conditions in an embodiment of the present invention. Detailed Implementation
[0051] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0052] One specific embodiment of the present invention discloses a retrieval method based on a software testing knowledge graph, primarily addressing the problem of ineffective utilization of software testing data assets for electronic countermeasures equipment. The method performs retrieval based on a constructed software testing knowledge graph. For example... Figure 1 As shown, it includes the following steps:
[0053] S11: Perform word segmentation on the user-input search criteria to obtain search terms; based on the stop word library and the thesaurus in the multi-level thesaurus, remove stop words from the search terms and obtain the synonyms from the remaining search terms, and add them to the search terms.
[0054] It should be noted that, in order to balance retrieval hit rate and word segmentation accuracy in the field of electronic warfare, this embodiment establishes a multi-level thesaurus. The multi-level thesaurus includes: a level-one standard thesaurus, a level-two hot word thesaurus, a level-three new word thesaurus, a level-four synonym thesaurus, and a level-five stop word thesaurus; wherein:
[0055] The first-level standard thesaurus is pre-built by analyzing domain standards and software testing standards. Specifically, it is a 2,000-word electronic warfare equipment software testing standard library with the highest weight, formed by experts in the field of electronic warfare equipment software testing analyzing military standards, engineering standards, military standards in the field of evaluation, and test document system templates.
[0056] The secondary hot word database is dynamically updated based on the search criteria entered by the user, as well as preset frequency and time thresholds, to improve the success rate of word segmentation of popular online words.
[0057] The Level 3 new vocabulary database is updated by preprocessing and segmenting user-uploaded software test documents, and then extracting new words from the segmentation results. In other words, it uses Hidden Markov and Viterbi algorithms in the segmentation process to perform unsupervised learning on the software test documents. Its vocabulary capacity exceeds 5,000 words and belongs to the vocabulary database of electronic countermeasures equipment software testing. It can significantly improve the accuracy of word segmentation and the success rate of segmenting professional terms.
[0058] The fourth-level synonym library and the fifth-level stop word library are updated according to user maintenance. That is, the user customizes and configures multiple synonyms and similarity degrees for the words in the first-level standard word library, the second-level hot word library, and the third-level new word library to improve the retrieval hit rate; customizes and configures stop words, including meaningless auxiliary words, modal particles, and interfering word groups, such as "test", "environment", etc., to improve the word segmentation efficiency.
[0059] It should be noted that the word segmentation process uses the hidden Markov model, with the position of the character in the word as the state, and generates the initial probability matrix, state transition matrix, and emission probability matrix based on the multi-level word library; takes the retrieval condition as the observation sequence, and uses the Viterbi algorithm to obtain the optimal state sequence, and outputs the word segmentation result according to the optimal state sequence.
[0060] When performing word segmentation, the corpus can be selected from the first-level standard word library and the second-level hot word library in the multi-level word library as the corpus, or the multi-level word library can be combined with the general online corpus. Taking the position of the character in the word as the state, including: the starting position B of the character in a word with more than 1 character, the ending position E of the character in a word with more than 1 character, the middle position M of the character in a word with more than 1 character, and the single-character word S. Exemplarily, "serving the country with loyalty" is represented as BMME, "I" is represented as S, and "China" is represented as BE. It can be seen from this that a word cannot start with M and B, and the initial probability matrix PI is obtained. Exemplarily, the initial probability matrix PI starting with BMES is set to [0.7, 0, 0, 0.3].
[0061] According to the Markov hypothesis, the state at time t + 1 depends only on the state at time t. Based on the fact that only M or E can follow B, only M or E can follow M, only S or B can follow S, and only S or B can follow E, a 4×4 state transition matrix A is obtained, which represents the probability matrix for the current state to transition to the next state. Based on the fact that the current observation depends only on the current state, an emission probability matrix B is established for the probability of each character in each state.
[0062] The initial state probability matrix PI, the transition probability matrix A, and the emission probability matrix B have all been trained and are known. The input text is taken as the observation sequence, and the optimal state sequence (i.e., the one with the maximum probability) obtained by using the Viterbi algorithm is used to output the word segmentation result according to the optimal state sequence.
[0063] This word segmentation method can be reused. Just replace the retrieval condition in the above word segmentation process with the text to be segmented in other scenarios. For example, when constructing a knowledge graph, it can be used for word segmentation of software test documents and word segmentation of knowledge entity attributes.
[0064] Since there are a large number of synonyms in the actual Chinese language, the search hit rate will be greatly reduced if synonyms cannot be searched simultaneously in the search results. Therefore, in this step, after removing stop words from the search terms, synonyms from the remaining search terms are obtained from the thesaurus and added to the search terms for use in subsequent searches.
[0065] S12: Perform keyword matching on the search terms in the software testing knowledge graph in sequence to obtain the keywords and the knowledge entities and synonyms associated with the keywords; the knowledge entities associated with the keywords are used as the search results.
[0066] It should be noted that the software testing knowledge graph is based on software testing templates and constructed according to software testing documents.
[0067] Specifically, based on the analysis of test-related data generated during the requirements analysis, test planning, and test execution phases of electronic warfare equipment software testing, and taking projects as the dimension, the software testing knowledge for each project is determined to include: test items, test cases, and test defects. The software testing knowledge graph is constructed by uniformly storing and managing electronic warfare equipment software testing knowledge, using a unified modeling language for preprocessing, followed by knowledge extraction, representation, and fusion. Constructing the knowledge graph is step S10, which is further subdivided into steps S101-S103.
[0068] S101: Based on the software test template, preprocess and segment the received software test documents, update the new lexicon in the multi-level lexicon according to the segmentation results, and update the IDF model files of various research directions according to the segmentation results and the research direction to which the document belongs; parse the preprocessed documents to obtain basic data.
[0069] S102: Based on the basic data, extract knowledge entities and their attributes periodically, and establish knowledge entities, their attributes, and the relationships between knowledge entities.
[0070] S103: Based on multi-level thesaurus and IDF model files for various research directions, extract keywords from the attributes of knowledge entities, establish keyword entities and the relationship between keyword entities and knowledge entities, and obtain a knowledge graph.
[0071] In step S101, while acquiring software testing knowledge, word segmentation is performed, and the new word library in the multi-level word library is updated according to the word segmentation results. The IDF model files of various research directions are also updated. Finally, the software testing knowledge information is stored in the database to facilitate the subsequent construction of the knowledge graph.
[0072] Software testing knowledge includes both structured and unstructured data. Structured data is relatively conventional and can be obtained through system interfaces, database synchronization, import, and export. Unstructured software testing knowledge is generally stored in Word documents. In the field of electronic warfare, due to differences in the understanding of the system among various military branches and testing units, and even variations in test system document templates within the same testing center from different years, the traditional approach is to create different document templates or convert the templates to JSON or XML for knowledge extraction and storage. However, once the template is adjusted, functions involving template changes need to be rewritten, including document extraction, document validation, document content retrieval, and even adjustments to database table fields, resulting in a large amount of coding work after each change.
[0073] This embodiment employs a highly flexible template adaptive technology. After each change to the test class document, only the new template needs to be uploaded to the server; no rewriting of the code is required. The entire process is as follows:
[0074] ① Upload and parse the software test template, and convert the template into an HTML table.
[0075] It should be noted that the software test template includes the testing center name, document type, version number, and one or more tables. The uploaded software test template is saved in a file library. Simultaneously, OpenXML technology is used to parse the user-uploaded software test template, obtain row and column information, create an HTML file, determine whether cells need to be merged based on the software test template, and if so, merge cells using CSS styles. The column width is parsed based on the cell attributes obtained from OpenXML, and the corresponding CSS styles are set. HTML is generated based on the row and column information and column width. At the same time, the corresponding basic data field list is obtained based on the template type, and a field list dropdown is generated for each cell in the table within the HTML file.
[0076] ② Establish the mapping relationship between software test templates and fields, as well as the constraints of the fields.
[0077] By manually binding fields, select the field dropdown list in each cell of the software testing template and bind the corresponding field information. It should be noted that the basic data includes extended fields used to associate newly added information in the template.
[0078] Considering that the software testing documentation for electronic countermeasures equipment is manually edited by testers, a large number of errors are inevitably introduced, including incorrect table formats, non-compliant defect identifiers, and duplicate unique identifiers. If the documents are not validated before extraction, the extracted data will contain a large amount of dirty data, affecting the subsequent establishment of defect correlations. Therefore, it is necessary to establish constraints for special fields in the documents to preprocess the documents before extraction and improve data quality.
[0079] Specifically, constraints can be set for bound fields through the field attribute editing interface, including unique constraints and regular expression conditions. Unique constraints are created for non-repeating fields such as test knowledge identifiers and titles, primarily used to prevent incorrect relationships from being established due to document errors during relationship extraction. Regular expressions validate the rules for all fields; only fields that satisfy the regular expression will be extracted; otherwise, an error message will be displayed.
[0080] ③ Upload the document to be processed and preprocess the received software test document according to the software test template.
[0081] Upload one or more documents to be processed according to the template type. Parse the uploaded software test documents to obtain document element information, including: document type, research direction of the document, total number of rows in the table, total number of columns in the table, and data in each cell of the table. According to the software test template corresponding to the document, check whether the total number of rows and columns in the table are consistent with the software test template. Check whether the data in each cell of the table meets the constraints of the fields in the software test template (unique constraints or regular expression conditions). If all checks pass, the preprocessing is successful and the documents are classified and stored according to their research direction. Otherwise, record and report the error log, and the preprocessing fails.
[0082] For pre-processed and identified files, the OnlyOffice plugin allows users to directly edit the document online before performing further pre-processing.
[0083] After converting all successfully preprocessed documents into text, the Hidden Markov Model and Viterbi algorithm described above are used as input text for word segmentation. The word segmentation results are obtained by combining the characters corresponding to consecutive single-character words SS to form new words. If the new words do not exist in the new vocabulary of the multi-level vocabulary, they are added to the new vocabulary.
[0084] For example, when the obtained optimal state sequence is BESSBE, the characters corresponding to SS are combined to form a new word.
[0085] Next, based on the word segmentation results and the research direction to which the document belongs, update the IDF model files for various research directions, including:
[0086] Based on the stop word library, stop words are removed from the word segmentation results of each document under each research direction;
[0087] The inverse document frequency (IDF) of each word in the segmentation results after removing stop words is calculated using the following formula for each research direction, and the IDF model files for each research direction are composed of each word and its corresponding IDF:
[0088]
[0089] Among them, idf i,j TC is the inverse document frequency of the i-th word in the j-th research direction; i,j Let be the word frequency of the i-th word in the document of the j-th research direction; MC i Let be the number of times the i-th word appears in the built-in corpus.
[0090] It should be noted that the built-in corpus is used for keyword extraction, and the New Era People's Daily word segmentation corpus (NEPD) can be selected.
[0091] Compared to existing technologies, the traditional TF-IDF algorithm calculates IDF by dividing the total number of documents in the corpus by the number of documents containing the current word. This method only calculates the inverse frequency of the current word at the document level, without considering the impact of word frequency on inverse frequency. This embodiment considers a word to have a high frequency in a specific type of text (documents related to a specific research direction) and a low frequency in ordinary text, thus indicating that the word has a high discriminative power for that specific type of text. Therefore, the concept of research direction is incorporated into the IDF calculation, resulting in finer granularity and higher accuracy when applied to keyword extraction.
[0092] It should be noted that upon receiving user-uploaded software test documents and successfully preprocessing them, the system will perform word segmentation on all successfully preprocessed documents. Based on the segmentation results, the system will update the new lexicon and IDF model files for various research directions. When multiple users upload simultaneously, or when a user uploads while the lexicon or IDF model file is being updated, the system determines whether an update operation can proceed by setting the operation status. By recording the number of user uploads and the upload time, once the lexicon and IDF model files are updated, the system will then update the lexicon and model files for all previously uploaded and successfully preprocessed documents based on the latest upload time.
[0093] After successful preprocessing of the software test documents, the information in the documents is saved in the database to obtain the basic data. This step has no execution order restriction with updating the new thesaurus and updating the IDF model file; they can be executed simultaneously or after the updates are completed.
[0094] Considering that software testing documentation often includes images of the testing process, the preprocessed documents are separated into text and images and stored separately in the database, including:
[0095] Obtain the document element information of the successfully preprocessed document, determine whether there is image information, if so, extract the image information, assign a unique identifier to the image, insert the identifier at the image location, save the image to the file library, save the document element information and the relationship between the document and the image to the basic database, and generate basic data, including: project, test item, test case and test defect.
[0096] For example, the file library is MiniIO.
[0097] Through the above steps, unstructured document information is converted into structured data and extracted into the basic database, while document templates and image information in the document are saved to the file library.
[0098] In step S102, knowledge entities and attributes are extracted from the basic database, and relationships between knowledge entities are established. Since the data was already saved according to various types of basic data in step S101, and these basic data directly correspond to various knowledge entities in the knowledge graph, with relevant field information in the basic data directly mapped to the attributes of the knowledge entities, the extraction process of knowledge entities and attributes includes:
[0099] The knowledge graph database periodically monitors the updates of the basic database, retrieves newly saved structured data from the basic database, and creates corresponding knowledge entity nodes in the graph database according to the corresponding knowledge entity type. It then populates the relevant field information from the structured data into the attributes of the knowledge entity nodes. The knowledge entity nodes include: projects, test items, test cases, and test defects.
[0100] For example, if the knowledge graph database detects a new test defect in the base database, it creates a knowledge entity node for the test defect in the graph database. The knowledge entity node name is the "test defect title" of the test defect in the base database, and other field information, such as test defect description, tester, monitoring personnel, and cause of the problem, is used as the attributes of the knowledge entity node.
[0101] Each project has a unique test item identifier, defect identifier, and test case identifier. When creating knowledge entities and attributes, the relationships between knowledge entities are established based on the association identifiers in the attributes, including:
[0102] Based on the one-to-many relationship between test items and projects, when establishing a test item knowledge entity, the project identifier of the test item is obtained, the corresponding project knowledge entity is retrieved based on the project identifier, and the relationship between the test item knowledge entity and the project knowledge entity is established.
[0103] Based on the one-to-many relationship between test items and test cases, when establishing a test case knowledge entity, the test item identifier associated with the test case is obtained, and the corresponding test item knowledge entity is queried based on the test item identifier. If a test item knowledge entity exists, the relationship between the test case knowledge entity and the test item knowledge entity is established; otherwise, the test case knowledge entity is deleted and the relationship is canceled.
[0104] Based on the many-to-many relationship between test cases and test defects, when creating a test defect knowledge entity, the test case identifier associated with the test defect is obtained. The corresponding test case knowledge entity is queried based on the test case identifier. If a test case entity exists, the relationship between the test defect knowledge entity and the test case knowledge entity is established; otherwise, the test defect knowledge entity is deleted and the relationship is canceled.
[0105] In step S103, to achieve accurate retrieval of test knowledge, keywords are extracted from the attributes of knowledge entities, and keyword entities are established using these keywords. Multiple keywords can be extracted for each piece of test knowledge, and a many-to-many relationship is established between the keywords and the knowledge entities.
[0106] Furthermore, the core attributes of knowledge entities are divided into three categories: title, description, and content. Each category has a different weight. The positional weight of keywords extracted from different categories is the attribute category weight of the keyword source. Among them, the title includes: test item title, test case title, and test defect title; the description includes: test item description, test item tracking, test case description, and test defect description; the content includes: test item sufficiency, test method, test case input / output / expected results, detailed description of test defect, cause of problem, and modification method.
[0107] Specifically, based on a multi-level thesaurus and IDF model files for various research directions, keywords are extracted from the attributes of knowledge entities, including:
[0108] 1) Assemble the current text from the attributes of the knowledge entities, perform word segmentation, and remove stop words from the segmentation results to obtain the words to be extracted;
[0109] 2) Based on a multi-level thesaurus, identify the thesaurus to which each word to be extracted belongs. Words belonging to the first-level standard thesaurus or the second-level hot word thesaurus are directly used as keywords. For the remaining words to be extracted, perform the following steps:
[0110] ①The TF frequency of the remaining words to be extracted is obtained based on the number of times each word appears in the current text and the number of times it appears in all successfully preprocessed documents;
[0111] It should be noted that the TF term frequency is calculated using the following formula:
[0112]
[0113] Where, n k,m For the remaining words to be extracted t k In text d m The number of times it appears in ∑ l n k,l For the remaining words to be extracted t k The sum of the number of times it appears in all successfully preprocessed documents.
[0114] ② Based on the IDF model file of the research direction to which the knowledge entity belongs, obtain the IDF inverse document frequency of each remaining word to be extracted;
[0115] It should be noted that if the IDF model file is being updated, the IDF inverse document frequency of the corresponding words will be obtained based on the IDF model file before the update.
[0116] ③ Based on the attributes of the source of each remaining word to be extracted and the weights corresponding to those attributes, and based on the vocabulary to which each remaining word to be extracted belongs, obtain the position weight and vocabulary weight of each remaining word to be extracted;
[0117] It should be noted that the word obtained after word segmentation is partly determined by the word library and its location source. In this embodiment, default values are set for different levels of word libraries and different attribute sources, which can be adjusted in real time.
[0118] For example, the weight information of the lexicon and attribute positions is shown in Table 1.
[0119] Table 1 Example of Permission Assignment
[0120] Thesaurus Lexicon weight Title weight Describing weights Content weight Level 1 Standard Thesaurus 0.5 1.0 0.5 0.1 Secondary hot word database 0.3 0.5 0.25 0.05 Level 3 New Dictionary 0.1 0.1 0.05 0.01 Level 4 Thesaurus 0.1 0.1 0.05 0.01
[0121] ④ The score for each remaining word to be extracted is obtained by multiplying the TF term frequency, IDF inverse document frequency, position weight, and lexicon weight;
[0122] It should be noted that the scores calculated using four dimensions—TF term frequency, IDF inverse document frequency, lexicon weight, and position weight—reflect not only the importance of the keywords but also the characteristics of the electronic warfare field, while also taking into account the impact of keyword position.
[0123] ⑤ Sort the scores from high to low, and extract the top-scoring words from the remaining words to be extracted as keywords, based on the preset number of words.
[0124] The extracted keywords are used as entity names for retrieval. If they do not exist, a new keyword entity node is created, and a many-to-many relationship is established between the keyword entity node and the knowledge entity. If they already exist, it is further determined whether a relationship between the keyword entity node and the knowledge entity already exists. If no relationship exists, a many-to-many relationship is established between them.
[0125] Based on the above steps, a knowledge graph is constructed, including: knowledge entities and their attributes, relationships between knowledge entities, keyword entities, and the relationship between keywords and knowledge entities.
[0126] Preferably, based on a thesaurus, synonyms of the extracted keywords are obtained; the synonyms are used as entity names for retrieval; when the synonym entity does not exist, a many-to-many relationship is established between the synonym entity and the keyword entity and the synonym entity.
[0127] In this embodiment, the knowledge graph base G = (E, R) for electronic countermeasures equipment software testing is represented as a triple S = {(h, r, t)}. Each triple consists of a pair of entities h, t ∈ E and their direct relation r ∈ R. (h, r, t) represents an entity pair and a multi-step relation path between them, where p = (h, r... 1 ,r 2 ,…r m (h,t) are the starting / ending entities, r 1 ,r 2 ,…r m It is a relationship along a path, and each entity describes specific characteristics through multiple attributes.
[0128] While structuring the test data enables retrieval and utilization through techniques such as full-text search and precise lookup, the low level of intelligence results in low data detection rates and slow retrieval speeds. This is due to the requirement for a perfect match between query conditions and data content, the inability to search for synonyms, and the inability to directly analyze long sentences. Steps S101-S103 transform the structured test knowledge into semi-structured graph data, enabling intelligent storage of test knowledge in graph form and improving the overall utilization rate of the data.
[0129] Based on the constructed software testing knowledge graph, the search terms obtained in step S11 are used as keyword entity names to match the keyword entity names established in the knowledge graph, thereby obtaining keywords that match the search terms, and then obtaining knowledge entities and synonym entities associated with the keywords. Among them, the knowledge entities associated with the keywords are used as search results.
[0130] S13: Summarize the score of each search result based on the weight and position of the keywords and synonyms in the thesaurus, as well as the similarity of the synonyms; based on the software testing template, display the software testing knowledge corresponding to the search results in descending order of score.
[0131] It should be noted that the score for each search result is calculated based on the weight and position weight of the thesaurus to which the keywords and synonyms belong, as well as the similarity of the synonyms. The score is calculated by taking each search result as the central node, the surrounding nodes of the central node as the keywords and synonyms, and the boundary of the second-level path.
[0132] The surrounding centrality of the center node is obtained using the following formula:
[0133]
[0134] C C (N p ) = Dict p ×Pos p Formula (4)
[0135] C′ C (N q ) = Dict q ×Pos q ×sim q Formula (5)
[0136] Where g is the number of keywords directly related to the central node C, and r is the number of synonyms of the keywords directly related to C; Dict p The keyword N p The weight of the thesaurus, Pos p The keyword N p Position weight, Dict q It is the weight of the thesaurus, Pos q It is a synonym N q Position weights, sim q This represents the similarity score between synonyms. The positional weight of synonyms can be the same as the positional weight of the associated keywords, or it can be configured custom-to-size.
[0137] For example, when the user inputs the search term "signal interception and processing", the matching keyword entities are signal, interception, and processing. Based on the keyword entities, the associated knowledge entities are obtained, such as... Figure 2 As shown. In Figure 2 The connections between entity nodes in the middle are marked with the thesaurus level to which the keyword belongs, as well as its location source.
[0138] Based on the surrounding centrality algorithm and the weights in Table 1, we obtain... Figure 2 The surrounding centrality of the three test items are as follows:
[0139] Signal processing:
[0140]
[0141] Signal interception:
[0142]
[0143] Full pulse acquisition:
[0144]
[0145] Therefore, the test item "signal interception" which is most relevant to the search criteria scored the highest.
[0146] Preferably, when the number of search results is less than the first quantity threshold, or the number of search results with scores exceeding the score threshold is less than the second quantity threshold, a full-text search is performed based on the word segmentation results to obtain supplementary results and their scores, which are then added to the search results.
[0147] For example, Elasticsearch is used for full-text search.
[0148] Furthermore, after obtaining the search results, based on the software testing template, the software testing knowledge corresponding to the search results is displayed in descending order of score. This involves restoring the content and format of the testing knowledge to provide an intuitive feedback to the end user. The specific process includes:
[0149] Based on the search results, obtain the corresponding software test template;
[0150] Based on the fields bound in the software test template, the field content is retrieved from the corresponding records in the search results and populated into the software test template; if the field content contains an image identifier, the image information is retrieved from the file library and inserted into the software test template to obtain software test knowledge;
[0151] Present software testing knowledge in a visual way.
[0152] Preferably, the knowledge entities and relationships associated with the search result are obtained from the knowledge graph database, and the search result is traced throughout its entire lifecycle.
[0153] While performing searches based on user-input search criteria, the secondary hot keyword database is updated. The process includes:
[0154] The search criteria input by the user are segmented into words, and the segmented results are used to remove stop words and words that are already in any word database.
[0155] The system sequentially checks whether the remaining words already exist in the user's habitual phrase cache. If they do, the word frequency is incremented by 1. If the word frequency reaches a preset threshold, the word is added to the secondary hot word library and removed from the user's habitual phrase cache. If the words do not exist, the word is added to the user's habitual phrase cache, and the time is updated.
[0156] Based on the update time of each word in the user's habitual phrase cache, and compared with the current time, words that exceed the preset time threshold are removed from the user's habitual phrase cache.
[0157] For example, words that have not been updated for more than 3 months are removed from the user's habitual phrase cache.
[0158] Compared with existing technologies, this embodiment provides a knowledge graph construction method based on software testing. It employs template adaptive technology, requiring only the uploading of a new template to the server after each software test document change. The template is then automatically parsed into corresponding HTML using the Unified Modeling Language for Test Documents, while also supporting dynamic binding of database fields. The entire process requires no rewriting of code. It establishes multi-level thesauruses and their respective update and maintenance methods to improve word segmentation accuracy and retrieval hit rate. The method also improves the IDF calculation method by generating IDF models for different research directions during IDF model training for all software test documents. During keyword extraction, the research direction corresponding to the text is extracted, and the corresponding IDF model is used for keyword extraction to improve accuracy. Based on keywords and synonyms, and considering both path quantity and path weight, a surrounding centrality algorithm is proposed for knowledge retrieval and recommendation, improving the relevance of retrieval results and maximizing the utilization of dormant test knowledge.
[0159] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0160] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1.A retrieval method based on a software test knowledge graph, characterized in that, The method comprises the following steps: The search condition input by the user is subjected to word segmentation processing to obtain search words; based on the stop word library and the synonym library in the multi-level word library, the stop words in the search words are removed, and the synonyms in the remaining search words are obtained and added to the search words; The search words are sequentially subjected to keyword matching in the software testing knowledge graph to obtain keywords and knowledge entities and synonyms associated with the keywords; the knowledge entities associated with the keywords are taken as search results; According to the word library weight and position weight of the keywords and synonyms, and the similarity of the synonyms, the scores of each search result are summarized, the keywords and synonyms are taken as the surrounding nodes of the center node of each search result, and the 2-level path is taken as the boundary to calculate the surrounding center degree of the center node as the score of the search result; Based on the software testing template, the software testing knowledge corresponding to the search results is displayed in descending order of the scores; The surround centrality C of the central node is obtained using the formula C (N p,q ): C C (N p )=Dict p ×Pos p C′ C (N q )=Dict q ×Pos q ×sim q where g is the number of keywords having a direct relationship with the center node C, and r is the number of synonyms of the keywords having a direct relationship with C; Dict p is the weight of the keyword N p in the dictionary, Pos p is the position weight of the keyword N p in the dictionary, Dict q is the weight of the synonym N q in the synonym dictionary, Pos q is the position weight of the synonym N q in the synonym dictionary, sim 2.The software test knowledge graph-based retrieval method according to claim 1, characterized in that, The search method further comprises: when the number of search results is less than a first quantity threshold, or the number of search results with scores exceeding a score threshold is less than a second quantity threshold, performing full-text search according to the word segmentation result to obtain supplementary results and their scores, and adding the supplementary results to the search results. 3.The software test knowledge graph-based retrieval method according to claim 1 or 2, characterized in that, The method of displaying the software testing knowledge corresponding to the search results in descending order of the scores based on the software testing template comprises: According to the search results, the corresponding software testing template is obtained; According to the fields bound in the software testing template, the field content is obtained from the records corresponding to the search results and filled into the software testing template; if the field content contains a picture identifier, the picture information is obtained from the file library and inserted into the software testing template to obtain the software testing knowledge; the software testing knowledge is displayed in a visual manner. 4.The software test knowledge graph-based retrieval method according to claim 1, characterized in that, The software testing knowledge graph is constructed based on the software testing template and the software testing documents, and the construction steps are as follows: Based on the software testing template, the received software testing documents are preprocessed and subjected to word segmentation processing, the new word library in the multi-level word library is updated according to the word segmentation result, and the IDF model files of various research directions are updated according to the word segmentation result and the research direction to which the documents belong; the preprocessed documents are parsed to obtain basic data; Based on the basic data, knowledge entities and their attributes are extracted at regular intervals, and the relationships among the knowledge entities and their attributes are established; According to the multi-level word library and the IDF model files of various research directions, the keywords are extracted from the attributes of the knowledge entities, the keyword entities and the relationships between the keyword entities and the knowledge entities are established, and the knowledge graph is obtained. 5.The software test knowledge graph-based retrieval method according to claim 4, characterized in that, The multi-level word library comprises a first-level standard word library, a second-level hot word library, a third-level new word library, a fourth-level synonym library and a fifth-level stop word library; the first-level standard word library is preconfigured by analyzing field standards and software testing standards; the second-level hot word library is dynamically updated according to the search condition input by the user and the preset number threshold and time threshold; the third-level new word library is updated according to the word segmentation results of all successfully preprocessed software testing documents; the fourth-level synonym library and the fifth-level stop word library are updated according to user maintenance. 6.The software test knowledge graph-based retrieval method according to claim 5, characterized in that, The IDF model files of various research directions are updated according to the word segmentation result and the research direction to which the documents belong: Based on the stop word library, the stop words are removed from the word segmentation results of each document under each research direction; The inverse document frequency of each word in the word segmentation results after removing the stop words in each research direction is calculated using the following formula, and each word and the corresponding inverse document frequency form the IDF model file of each research direction: where idf i,j is the inverse document frequency of the ith word in the jth research direction; TC i,j is the term frequency of the ith word in the document of the jth research direction; MC i is the number of times the ith word appears in the built-in corpus. 7.The software test knowledge graph-based retrieval method according to claim 6, characterized in that, The key words are extracted from the attributes of the knowledge entity according to the multi-level word library and the IDF model file of each research direction, including: The attributes of each knowledge entity form the current text, and the word segmentation processing is performed to obtain the to-be-extracted words after removing the stop words from the word segmentation results; Based on the multi-level word library, the word library to which each to-be-extracted word belongs is recognized, and the to-be-extracted words belonging to the first-level standard word library or the second-level hot word library are directly used as the key words. For the remaining to-be-extracted words, the following steps are performed: The TF word frequency of each remaining to-be-extracted word is obtained according to the number of times of occurrence of each remaining to-be-extracted word in the current text and the number of times of occurrence of each remaining to-be-extracted word in all preprocessed software test documents; The IDF inverse document frequency of each remaining to-be-extracted word is obtained according to the IDF model file of the research direction to which the knowledge entity belongs; The attributes from which each remaining to-be-extracted word originates and the weights corresponding to the attributes are recognized, and the position weight and the word library weight of each remaining to-be-extracted word are obtained according to the word library to which each remaining to-be-extracted word belongs; The score of each remaining to-be-extracted word is obtained according to the product of the TF word frequency, the IDF inverse document frequency, the position weight, and the word library weight; The scores are sorted from high to low, and the preset number of words with high scores are extracted from the remaining to-be-extracted words as the key words. 8.The software test knowledge graph-based retrieval method according to claim 5, characterized in that, The second-level hot word library is dynamically updated according to the search conditions input by the user and the preset number threshold and time threshold, including: The search conditions input by the user are subjected to word segmentation processing, the stop words are removed from the word segmentation results, and the words already in any word library are removed; It is judged in turn whether the remaining words exist in the user's habitual word group cache area. If they exist, the word frequency of the words is increased by 1. If the word frequency reaches the preset number threshold, the words are added to the second-level hot word library, and the words are removed from the user's habitual word group cache area. If they do not exist, the words are added to the user's habitual word group cache area, and the update time is updated; According to the update time of each word in the user's habitual word group cache area and the current time, the words exceeding the preset time threshold are removed from the user's habitual word group cache area.