Similarity threshold acquisition method, data processing method and product
Through the self-updated similarity threshold adjustment method, combined with historical similarity and verification results, the deviation problem caused by fixed thresholds in software version repair is solved, and the accuracy and success rate of repair is improved.
Patent Information
- Application Number
- CN202210896361.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-27
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-07-27
AI Technical Summary
During the software development process, the prior art uses a fixed similarity threshold to determine whether the software version needs to be repaired, resulting in repair deviations due to the large discrete similarity when there are many software versions, which reduces the accuracy of repair.
By obtaining historical similarity and verification results, dynamically adjust the similarity threshold to make it self-update, and determine the repair strategy based on the verification results of each repair, and use the self-updated similarity threshold to determine whether to perform repair.
Improve the accuracy and success rate of software version repair, and avoid repair bias caused by similarity discreteness.
Smart Images

Figure CN115291932B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development, and in particular to a method for obtaining a similarity threshold, a data processing method, and a product. Background Art
[0002] During the software development process, as Enterprise Resource Planning (ERP) products are iterated and upgraded, the number of software versions increases. Typically, a single software release may generate dozens or even hundreds of different versions. After a software release, some deeply hidden defects may exist. When these defects exist in multiple versions, and each customer may not use the same software version, manually fixing these defects requires individual repairs for each active software version. This approach results in a massive workload and a high risk of vulnerability discovery during the repair process.
[0003] Typically, the repair software automatically determines the similarity between the defective source file and the file to be repaired, and compares the similarity with a manually set threshold. If the similarity exceeds the threshold, the file to be repaired is deemed to be defective and can be repaired.
[0004] However, the above-mentioned artificially set threshold is a fixed threshold. When there are many software versions to be repaired, the similarities corresponding to different software versions may be more discrete. The method of determining whether repair is needed based on such a fixed threshold will make it impossible to repair some defective software versions normally, resulting in deviations in the repair and reducing the accuracy of the repair. Summary of the Invention
[0005] The present application provides a method for obtaining a similarity threshold, a data processing method, an apparatus, a computer device, a computer-readable storage medium, and a computer program product, which can improve the accuracy of version repair.
[0006] In a first aspect, a method for obtaining a similarity threshold is provided, the method comprising: obtaining at least one historical similarity; obtaining a first correct number and a first error number corresponding to the first historical similarity, the first historical similarity being any one of the at least one historical similarity, when the software version corresponding to the first historical similarity passes verification after repair, the first correct number is 1, and the first error number is 0; when the software version corresponding to the first historical similarity fails verification after repair, the first correct number is 0, and the first error number is 1; obtaining a total correct number and a total error number, the total correct number being the sum of at least one first correct number, and the total error number being at least one The sum of the first number of errors, at least one first correct number, at least one first number of errors and at least one historical similarity have a one-to-one correspondence; a similarity threshold is determined based on at least one historical similarity, at least one first correct number, at least one first number of errors, the total number of correct numbers and the total number of errors; wherein the similarity threshold is negatively correlated with the absolute value of the difference between the total number of correct numbers and the total number of errors, and the similarity threshold is positively correlated with the absolute value of the first sum value, the first sum value is the sum of at least one first product, the first product is the product of the first historical similarity and the difference between the corresponding first correct number and the first number of errors, and at least one first product has a one-to-one correspondence with at least one historical similarity.
[0007] The computer device determines a similarity threshold based on the historical similarities obtained during the aforementioned software version repair process, combining each historical similarity obtained with the corresponding verification results. The computer device can modify the similarity threshold so that the similarity threshold incorporates the verification results of the aforementioned repairs, thereby achieving self-updating of the similarity threshold. When the similarities corresponding to different software versions are highly discrete, the self-updating similarity threshold in the embodiments of the present application is used to determine whether a repair is necessary. Compared to the traditional fixed threshold method, this avoids the deviation caused by the repair of the software version, thereby improving the accuracy of the repaired software version.
[0008] In some possible implementations, the similarity threshold is inversely proportional to the difference between the total number of correct answers and the total number of errors, and the similarity threshold is proportional to the first sum.
[0009] In some possible implementations, the similarity threshold is a ratio of the first sum to the difference between the total number of correct answers and the total number of errors.
[0010] In some possible implementations, the similarity threshold V s The expression is:
[0011]
[0012] Among them, V1 to Vn are all historical similarities, NS1 to NSn are the first correct numbers corresponding to V1 to Vn respectively, Nf1 to Nfn are the first incorrect numbers corresponding to V1 to Vn respectively, Nts represents the total correct number of historical similarities, Nts is the sum of NS1 to NSn, Ntf represents the total incorrect number of historical similarities, Ntf is the sum of Nf1 to Nfn.
[0013] In some possible implementations, if the similarity threshold is less than 0 or greater than 1, the similarity threshold is updated to a fixed value, and the fixed value ranges from 0.95 to 0.99.
[0014] When the calculated similarity threshold is greater than 1 or less than 0, directly updating the similarity threshold to a fixed value can avoid the above-mentioned abnormal situation, improve the success rate and accuracy of software version repair, and adopt a value between 0.95 and 0.99, which is highly reasonable.
[0015] In a second aspect, a data processing method is provided, including: obtaining a file to be repaired and a defective source file; when determining that the defect type of the defective source file is a type that matches the code segment, obtaining the content to be repaired in the file to be repaired; determining the similarity between the content to be repaired and the defective code segment in the defective source file; when the similarity is greater than a similarity threshold, using the repaired code segment corresponding to the defective code segment in the defective source file to replace the content to be repaired to repair the software version; wherein the similarity threshold is any one of the similarity thresholds described in the first aspect.
[0016] During the code segment repair process, the computer device uses the similarity threshold provided by the above-mentioned solution to determine whether to perform the repair operation. Because the above-mentioned similarity threshold is determined by the computer device based on the historical similarity obtained during the previous software version repair process, and the similarity threshold is determined by combining the historical similarity obtained each time and the corresponding verification result, the similarity threshold can be modified so that the similarity threshold incorporates the verification results of the above-mentioned repair, thereby achieving self-updating of the similarity threshold. When the similarities corresponding to different software versions are highly discrete, the computer device determines whether the software version needs to be repaired based on the self-updating similarity threshold during the code segment repair process. Compared with the traditional method of judging based on a fixed threshold, this avoids the deviation caused by the repair of the software version, thereby improving the accuracy of the repaired software version.
[0017] In some possible implementations, the method further includes: obtaining a verification result, where the verification result is used to indicate whether the repaired software version has passed the verification; and updating the similarity threshold according to the verification result.
[0018] After repairing the software version, the computer device obtains the verification result of the repaired software version and rewrites the similarity threshold based on the verification result. The verification result of this repair can be integrated into the similarity threshold, thereby improving the matching degree between the similarity threshold and the actual situation and further improving the accuracy of the software version repair.
[0019] In some possible implementations, the historical similarity is a similarity training value used for training, the number of similarity training values is multiple, and the similarity threshold is a threshold obtained by training using multiple similarity training values and the first correct number and the first incorrect number corresponding to each similarity training value.
[0020] The computer device can determine a similarity threshold based on multiple similarity training values and the verification results corresponding to each similarity training value. The similarity threshold can be modified based on each verification result, allowing the similarity threshold to learn from multiple repair verification results, thereby improving the robustness of the similarity threshold. When the similarities corresponding to different software versions are highly discrete, a similarity threshold obtained through training with multiple sets of training data is used to determine whether a software version needs to be repaired. Compared with the traditional fixed threshold method, this avoids the deviation caused by repairing the software version, thereby improving the accuracy of the repaired software version.
[0021] In a third aspect, a device for obtaining a similarity threshold is provided, comprising a unit composed of software and / or hardware, and the unit is used to execute any one of the methods in the technical solution described in the first aspect.
[0022] In a fourth aspect, a data processing device is provided, comprising a unit composed of software and / or hardware, which is used to execute any one of the methods in the technical solution described in the second aspect.
[0023] In a fifth aspect, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, any one of the methods in the technical solutions described in the first or second aspect is implemented.
[0024] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any one of the methods in the technical solutions described in the first aspect or the second aspect is implemented.
[0025] In a seventh aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the steps of any one of the methods in the technical solutions described in the first or second aspect above.
[0026] It can be understood that the beneficial effects of the third, fourth, fifth, sixth and seventh aspects mentioned above can be found in the relevant descriptions of the first and second aspects mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0028] Figure 1 This is a flowchart of a method for repairing a software version provided in an embodiment of the present application;
[0029] Figure 2 This is a flowchart of a process for accurate matching of a code segment provided in an embodiment of the present application;
[0030] Figure 3 This is a flowchart of a method for obtaining a similarity threshold value provided in an embodiment of the present application;
[0031] Figure 4 This is a flowchart of a process of obtaining a similarity threshold by training, provided in an embodiment of the present application;
[0032] Figure 5 This is a flowchart of a fuzzy matching process of a code segment provided in an embodiment of the present application;
[0033] Figure 6 This is a flowchart of a method for repairing software versions for various defect types provided in an embodiment of the present application;
[0034] Figure 7 1 is a schematic structural diagram of a device for obtaining a similarity threshold value provided in an embodiment of the present application;
[0035] Figure 8 is a structural diagram of a data processing device provided in an embodiment of the present application;
[0036] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application; DETAILED DESCRIPTION
[0037] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0038] It should be understood that the “multiple” mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; “and / or” in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, words such as “first” and “second” are used to distinguish between identical or similar items with basically the same functions and effects. Those skilled in the art can understand that words such as “first” and “second” do not limit the quantity and execution order, and words such as “first” and “second” do not necessarily limit them to be different.
[0039] Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are first explained.
[0040] During the software development process, as ERP products are iterated and upgraded, the number of software versions increases. Typically, a single software may generate dozens or even hundreds of different software versions during development. To manage different versions of software in an orderly manner, each software version can be distinguished by a version number, such as using version numbers such as V1.2, V1.3, and V1.4 to distinguish different software versions. After a software version is released, some hidden defects may exist in the released software version. When this defect exists in multiple versions, and the software version used by each customer is not necessarily the same, manually fixing such defects requires manual repair for each software version in use. This approach results in a huge workload and a high risk of vulnerabilities during repair.
[0041] Typically, repairing a software version involves automatically obtaining the similarity between the defective source file and the file to be repaired through a computer device, and comparing the similarity to a manually set similarity threshold. When the similarity exceeds the manually set similarity threshold, the file to be repaired is deemed to be defective, and the computer device can perform a repair on the software version corresponding to the file to be repaired. However, this manually set similarity threshold is a fixed threshold. Using this fixed threshold to determine whether a repair is necessary can lead to a large dispersion of similarities between different software versions, resulting in some defective software versions being unable to be properly repaired. This can lead to deviations in the repair process and reduce the accuracy of the repair. For example, if the manually set similarity threshold is 0.99, when there are too many software versions, and the similarity between the file to be repaired and the defective source file in some software versions reaches 0.94 but not 0.99, repair is still required. If the manually set threshold of 0.99 is used to determine whether a repair is necessary, the software version in question is not included in the repair and cannot be successfully repaired.
[0042] The embodiment of the present application introduces a method for obtaining a similarity threshold, which can be combined with the historical similarity threshold and verification results used in the previous software version repair to determine the current similarity threshold, so that the currently used similarity threshold can be updated based on the actual situation of whether the software version repair is successful or not. Compared with the traditional method of using a fixed threshold, it can avoid deviations even when the similarities of each software version are highly discrete, thereby improving the success rate of software version repair.
[0043] The following first provides a detailed description of the software version repair process. Figure 1 A flow chart of a method for repairing a software version for a computer device, comprising:
[0044] S101. Obtain defect source files.
[0045] First, a user operates a computer device, or the computer device receives a repair instruction, to launch a repair tool. This repair tool can be an application installed on the computer device. When the repair tool is launched, it first loads the defective source file. The defective source file can be stored in the local computer device's memory or on a cloud server. The computer device accesses the cloud server via the network to obtain the defective source file.
[0046] S102: Determine the defect type of the defective source file.
[0047] It should be noted that defect source files have multiple defect types, and each defect type can correspond to a different repair mode. Generally, repair modes can include full file matching, keyword matching, code line matching, code segment matching, and other types. The number of defect source files for each defect type can be one or more. Among them, each defect source file can include repaired code and corresponding defective code. Defective code is usually code with defects; repaired code is code that can repair the corresponding defective code and can be used to replace the corresponding defective code to ensure the functionality of the software version. Therefore, the repaired code does not have defects.
[0048] The defective source files can be in the format of CS files (CS stands for C# source code files), JavaScript files (a lightweight, interpreted or just-in-time compiled programming language with function priority, referred to as JS), or Cascading Style Sheets (CSS) files. Each defective source file format can use a different repair mode. For example, CS files can be repaired using the full file match, keyword match, code line match, or code segment match repair mode; JS files can be repaired using the full file match, keyword match, or code line match repair mode; and CSS files support the full file match, keyword match, or code line match repair mode.
[0049] Specifically, the computer device can determine the defect type based on the defect identifier carried by the defect source file. For example, the computer device obtains the value assigned to the defect identifier BugType carried by defect source file A. Typically, the value assigned to BugType can be 0, 1, 2, 3, etc., where 0 represents the defect type is a full-text match, 1 represents a keyword match, 2 represents a code line match, and 3 represents a code segment match. When the computer device reads the value assigned to the defect identifier BugType as 0, it determines that the defect type of defect source file A is a full-text match.
[0050] S103: Obtain the file to be repaired.
[0051] The above-mentioned files to be repaired refer to files that exist in the software version and cause defects and need to be repaired. When the repair tool is started, the computer device can read the files to be repaired stored in the local memory or read the files to be repaired stored in the cloud server.
[0052] Specifically, the computer device can obtain the folder paths of the folders where the files to be repaired are located in different software versions, and read the corresponding folder names according to these folder paths. The computer device judges the standardization of the obtained folder names one by one. For example, when the version specification is: major version number.medium version number.minor version number.YYMMDD, the folder name obtained by the computer device is 1.0.4.20220730, where the first "1" represents the major version number; the first "0" represents the medium version number; the first "4" represents the minor version number; "20220730" corresponds to "YYMMDD", which represents the release date of the software version. If the computer device determines that the folder name does not meet the pre-set version specification, it will not be processed.
[0053] If the computer device determines that the folder name meets the pre-set version specification, the folder can be added to the list, thereby forming a list of folders to be repaired. The computer device obtains the file to be repaired by reading the list of folders to be repaired.
[0054] The execution order of step S103 may also be before the above-mentioned S101 and S102, which is not limited in the embodiment of the present application.
[0055] S104: Repair the file to be repaired according to the defect type of the defective source file.
[0056] Each defect type corresponds to a different repair mode. Here we introduce the different repair modes corresponding to different defect types:
[0057] 1. Full file matching
[0058] Full file matching is achieved by encrypting the defective source file and the file to be repaired using the Message-Digest Algorithm (MD5) algorithm, then comparing the encrypted results. If the encryption results of the defective source file and the file to be repaired are identical, the defective source file is used to repair the file to be repaired, replacing the file to be repaired with the defective source file. If the encryption results of the defective source file and the file to be repaired are different, an error log is recorded for subsequent analysis by R&D personnel.
[0059] 2. Keyword matching
[0060] The defect source file contains defect keywords and corresponding fixed keywords. The defect keywords are keywords that contain defects and can be one or more, with each defect keyword corresponding to a fixed keyword. These defect keywords can be a set of strings. Defect keywords can also carry a navigation path, which indicates the location of the defect keyword in the defect source file. For example, the naming convention for the defect keyword navigation path is: namespace - class name - method name - number and type of method parameters - keyword.
[0061] Keyword matching is achieved by reading the navigation path of the defect keyword in the defect source file, searching in the file to be repaired based on the navigation path, accurately locating the location of the specific method name, and then reading the content in the located method name. The computer device then formats the read content and splits the words by spaces to form a standardized character array. The standardized character array can be one or more groups. The standardized character array obtained here has deleted invalid strings and interpretations and has become streamlined. Each character array is a keyword. The computer device can then use the streamlined character array to perform a cyclic match with one or more defect keywords in the defect source file one by one.
[0062] If the match is successful, it means that the keyword positioning is successful, and the computer device can replace the corresponding character array (i.e., keyword) in the file to be repaired with the repaired keyword in the defective source file; if the match is unsuccessful, it means that the positioning has failed, and the computer device can record an error log. For example, the streamlined character array includes A1, B1, C1, and D1, and the defective keywords include A2, B2, and C2. The computer device can use A1 to compare with A2, B2, and C2 respectively. If A1 and A2 are the same, it means that the match is successful, and the computer device can use the repaired keyword A3 corresponding to the defective keyword A2 to replace A1 in the file to be repaired. If A1 and B2 are different, it means that the match failed, and the computer device can record an error log. The computer device uses B1, C1, and D1 to compare with A2, B2, and C2 respectively, obtains matching results one by one, and performs replacement operations or records error logs based on the matching results.
[0063] 3. Code line matching
[0064] A defective source file can also include defective code lines and corresponding fixed code lines. The defective code lines can carry a navigation path, which indicates the location of the defective code line within the defective source file. For example, the navigation path for a defective code line follows the following pattern: namespace - class name - method name - code line.
[0065] Code line matching is achieved by reading the navigation path of the defective code line in the defective source file, searching in the file to be repaired according to the navigation path, accurately locating the location of the specific method name, and then reading the content in the located method name. The computer device then formats the read content and splits the words by spaces to form a character array NewNum1, and then removes invalid characters in NewNum1 to form a standardized character array NewNum2. The computer device can also split the above-mentioned defective code line by spaces to form a character array OriginNum1. The computer device uses the streamlined NewNum2 and OriginNum1 to match, matching the keywords and the order of the keywords. If the keywords in the two are fully matched and the order is consistent, the repaired code line corresponding to the defective code line in the defective source file is used to replace the code line at the corresponding position in the file to be repaired. If the match fails, the computer device records an error log.
[0066] 4. Code snippet matching
[0067] Code segment matching can be divided into two repair modes: exact matching and fuzzy matching. Among them, exact matching can be used when the defective source file carries an exact navigation path. The exact navigation path can accurately locate the position of the defective code segment, such as locating the parameter type under a specific method. Fuzzy matching can be used when the defective source file carries a navigation path, but the navigation path can only locate a specific method, and is not specific to the parameter type under the method. The method may exist in multiple places, that is, the method exists in multiple navigation paths. At this time, it is not certain under which navigation path the defective code segment is located.
[0068] First, the specific process of exact matching is described, such as Figure 2 As shown, including:
[0069] S201: Obtain a defective code segment in a defective source file and a navigation path corresponding to the defective code segment.
[0070] Specifically, the computer device reads the defective code segment and the navigation path corresponding to the defective code segment in the defective source file. The naming rule of the navigation path is: namespace-class name-method name-number and type of method parameters. Optionally, the defective source file can be a CS file.
[0071] S202: Determine the content to be repaired in the file to be repaired according to the navigation path of the defective code segment.
[0072] The computer device can read the navigation path of the defective code segment in the defective source file and search in the file to be repaired according to the navigation path to accurately locate the location of the specific method. The content in the located specific method is the content to be repaired.
[0073] For example, the defective source file includes the method YuYunCrudAppService, which has 6 parameters, namely TEntity, TGetOutputDto, TGetListOutputDto, Tkey, TGetLisIntput and TGreateOrUpdateInput.
[0074] If the method named YuYunCrudAppService also exists in the file to be repaired, and it also has six parameters, and these six parameters have the same number and type as the method with the same name in the defect source file, then the location is successful. The computer device can determine that the content of the method named YuYunCrudAppService in the file to be repaired is the content to be repaired.
[0075] S203: Determine the similarity between the content to be repaired and the defective code segment.
[0076] The computer device can first process the content to be repaired, for example, by reading the content of the specific method name located and grouping it by line, then grouping it by space and removing invalid characters. During the grouping process, the order of the files remains unchanged, thereby forming an array of files to be repaired, which includes multiple valid strings arranged in sequence. For example, the array of files to be repaired can be (A, B, C, D), where A, B, C, and D are each a valid string.
[0077] The computer device can also process defective code segments within the defective source file, for example by grouping them by line, then by space, and removing invalid characters. During the grouping process, the order of the segments remains unchanged, thereby forming a defective source file array containing multiple valid character strings arranged in sequence. For example, the defective source file array could be (A, B, C, E), where A, B, C, and E each constitute a valid character string.
[0078] In some embodiments, the similarity V between two arrays can be calculated using formula (1) or a variation of formula (1).
[0079]
[0080] Where Nvt is the number of valid strings in the array of files to be repaired, Ovt is the number of valid strings in the array of defective source files, Ns1, Ns2, ..., Nsn are the serial numbers of the valid strings in the array of files to be repaired, Os1, Os2, ..., Osn are the serial numbers of the valid strings in the array of defective source files, and Nm is the number of successful matches between the valid strings in the array of files to be repaired and the valid strings in the array of defective source files.
[0081] For example, the array of files to be repaired is ['A', 'C', 'B', 'D'], and the array of defective source files is ['A', 'B', 'C', 'E']. In the above array of files to be repaired ['A', 'B', 'B', 'D'], the sequence number of the valid string 'A' is 1, the sequence number of the valid string 'C' is 2, the sequence number of the valid string 'B' is 3, and the sequence number of the valid string 'D' is 4. In the above array of defective source files ['A', 'B', 'C', 'E'], the sequence number of the valid string 'A' is 1, the sequence number of the valid string 'B' is 2, the sequence number of the valid string 'C' is 3, and the sequence number of the valid string 'E' is 4. Substituting the above sequence numbers into formula (1), the similarity V is:
[0082]
[0083] S204: Determine whether the similarity is 100%. If so, execute S205A; if not, execute S205B.
[0084] S205A: Replace the content to be repaired in the file to be repaired with the repaired code segment corresponding to the defective code segment in the defective source file. Optionally, S207 may be executed afterwards.
[0085] S205B: Determine whether the similarity is greater than or equal to the similarity threshold. If so, execute S205A; alternatively, if not, execute S206.
[0086] Optionally, the similarity threshold may be a preset value, such as 0.98, 0.96, etc., which is set by the user based on experience. Optionally, the similarity threshold may also be the following: Figure 3 The similarity threshold obtained in the embodiment shown. Figure 3 This is a flowchart of a method for obtaining a similarity threshold value provided in an embodiment of the present application. Figure 3 As shown, including:
[0087] S301: Obtain at least one historical similarity.
[0088] The above historical similarity threshold is a similarity threshold used in the previous code segment repair process. The number of historical similarities can be one or more. For example, if the historical similarities used in the previous code segment repair process are V1, V2, V3, V4, and V5, the computer device obtains V1, V2, V3, V4, and V5.
[0089] S302. Obtain a first correct number and a first error number corresponding to a first historical similarity, where the first historical similarity is any one of at least one historical similarity. When the software version corresponding to the first historical similarity passes verification after repair, the first correct number is 1 and the first error number is 0. When the software version corresponding to the first historical similarity fails verification after repair, the first correct number is 0 and the first error number is 1.
[0090] After each code segment repair, the computer device will verify the software version repaired at that time. If the verification passes, the first correct number corresponding to the similarity between the content to be repaired and the defective code segment calculated at that time is determined to be 1, and the first error number is 0; if the verification fails, the first correct number corresponding to the similarity between the content to be repaired and the defective code segment calculated at that time is determined to be 0, and the first error number is 1. For example, during the first code segment repair process, if the historical similarity V1 used is 0.95, and after the repair, the software version verification passes, then the first correct number NS1 corresponding to V1 is 1, and the first error number Nf1 is 0. For another example, during the second code segment repair process, if the historical similarity V2 used is 0.95, and after the repair, the software version verification fails, then the first correct number NS2 corresponding to V2 is 0, and the first error number Nf2 is 1.
[0091] S303: Obtain a total correct number and a total incorrect number, where the total correct number is the sum of at least one first correct number, and the total incorrect number is the sum of at least one first incorrect number. The at least one first correct number, the at least one first incorrect number, and the at least one historical similarity have a one-to-one correspondence.
[0092] Each of the aforementioned historical similarities corresponds to a first number of correct answers and a first number of errors. Therefore, when there is at least one historical similarity, there is also at least one first number of correct answers and at least one first number of errors, with the three being in a one-to-one correspondence. The computer device calculates the sum of the first numbers of correct answers corresponding to each historical similarity as the total number of correct answers. The computer device also calculates the sum of the first numbers of errors corresponding to each historical similarity as the total number of errors.
[0093] S304: Determine a similarity threshold based on at least one historical similarity, at least one first correct number, at least one first incorrect number, the total correct number, and the total incorrect number. The similarity threshold is negatively correlated with the absolute value of the difference between the total correct number and the total incorrect number, and positively correlated with the absolute value of a first sum. The first sum is the sum of at least one first product, where the first product is the product of the first historical similarity and the difference between the corresponding first correct number and the first incorrect number. The at least one first product has a one-to-one correspondence with the at least one historical similarity.
[0094] Specifically, the computer device can use formula (2) to calculate the similarity threshold V s .
[0095]
[0096] Wherein, V1 to Vn are the similarities obtained during the n code segment matching process, wherein V1 is the similarity between the content to be repaired and the defective code segment determined during the first code segment matching, and Vn is the similarity between the content to be repaired and the defective code segment determined during the nth code segment matching; NS1 to NSn are the first correct numbers corresponding to V1 to Vn respectively; Nf1 to Nfn are the first error numbers corresponding to V1 to Vn respectively; Nts represents the sum of NS1 to NSn, that is, the total correct number, and Ntf represents the sum of Nf1 to Nfn, that is, the total error number. The above n can be a positive integer. In the above formula (2), the similarity threshold is the ratio of the first sum value V1×(NS1-Nf1)+…+Vn×(NSn-Nfn) to the difference between the total correct number and the total error number (Nts-Ntf).
[0097] For example, the number of historical similarities is 4, where V1 is 0.92, V2 is 0.93, V3 is 0.94, and V4 is 0.95. When NS1 is 0, Nf1 is 1, NS2 is 1, Nf2 is 0, NS3 is 1, Nf3 is 0, NS4 is 1, and Nf4 is 0, these values are substituted into the above formula (2) to obtain the similarity threshold V s for:
[0098]
[0099] Optionally, a variation of the above formula (2), ie, formula (3), may be used to determine the similarity threshold.
[0100]
[0101] Alternatively, in the above formula (3), k can be a positive constant and b can be a constant. k and b can be used to modify the similarity threshold. For example, k can be a value close to 1, such as 1.01, 1.02, 0.99, or 0.98, and b can be a smaller value, such as 0.01, -0.01, 0.02, -0.02, 0.003, or -0.003. b can also be 0, in which case formula (3) becomes formula (4).
[0102]
[0103] In the above formula (4), the similarity threshold V s The similarity threshold is inversely proportional to the difference between the total correct number and the total incorrect number (Nts-Ntf), and is proportional to the first sum value V1×(NS1-Nf1)+…+Vn×(NSn-Nfn).
[0104] Optionally, in the above formula (3), k can also be 1, then formula (3) evolves into formula (5).
[0105]
[0106] In the above formulas (2) to (5), the similarity threshold is negatively correlated with the absolute value of the difference between the total correct number and the total incorrect number, and the similarity threshold is positively correlated with the absolute value of the first sum.
[0107] above Figure 3 In the illustrated embodiment, the computer device determines a similarity threshold based on the historical similarities obtained during the aforementioned software version repair process, combining each historical similarity obtained with the corresponding verification results. This similarity threshold can be modified so that the similarity threshold incorporates the verification results of the aforementioned repairs, thereby achieving self-updating of the similarity threshold. When the similarities corresponding to different software versions are highly discrete, the self-updating similarity threshold in the embodiment of the present application is used to determine whether a repair is necessary. Compared to the traditional fixed threshold method, this avoids the deviation caused by the repair of the software version, thereby improving the accuracy of the repaired software version.
[0108] In some embodiments, there may be abnormal situations, and the similarity threshold is calculated to be a value greater than 1 or less than 0. For example, V1 is 0.92, V2 is 0.99, and V3 is 0.98. When NS1 is 0, Nf1 is 1, NS2 is 1, Nf2 is 0, NS3 is 1, and Nf3 is 0. Substituting these values into the above formula (2), the similarity threshold is 1.05. According to the physical meaning of similarity, the minimum similarity between the two is 0 and the maximum is 1. Therefore, the similarity threshold greater than 1 or less than 0 is an illegal value. Such an illegal value cannot measure the similarity normally. In this case, the similarity threshold is directly updated to a fixed value, for example, updated to 0.99. The implementation of this embodiment can also be achieved through the formula V s =(V s <0‖V s >1)? 0.99:V s To express it, that is, when the calculated similarity threshold is greater than 1 or less than 0, the similarity threshold is directly updated to a fixed value of 0.99. When the calculated similarity threshold is not greater than 1 or less than 0 (that is, greater than or equal to 0 and less than or equal to 1), the calculated similarity threshold shall prevail.
[0109] In the above embodiment, if V s Less than 0, because no matter how high or low the similarity between the file to be repaired and the defective code segment is, it will be greater than V s , if based on such V s To determine whether to repair the software version, all software versions meet the repair requirements, even the files to be repaired that do not need to be repaired (for example, the files to be repaired that have very low similarity with the defective code segment) will be repaired, which will lead to the situation of incorrect repair. s Greater than 0, regardless of whether the similarity between the file to be repaired and the defective code segment is high or low, it will be less than V s , if based on such V s Even if the file to be repaired is identical to the defective code segment, it will not be repaired, thus defeating the purpose of repairing the software version. Therefore, when the calculated similarity threshold is greater than 1 or less than 0, directly updating the similarity threshold to a fixed value can avoid such anomalies, improving the success rate and accuracy of software version repair. The value between 0.95 and 0.99 is highly reasonable.
[0110] Optionally, when determining whether V1 is greater than a similarity threshold during the first code segment matching, the similarity threshold can also be obtained by training with multiple training samples. Figure 4 The embodiments shown are not described in detail here.
[0111] above Figure 2In the embodiment shown, the computer device uses the Figure 3 The similarity threshold provided in the embodiment and related embodiments is used to determine whether to perform the repair operation. Figure 3 In related embodiments thereof, the computer device determines a similarity threshold based on the historical similarities obtained during the aforementioned software version repair processes, combining each historical similarity obtained with the corresponding verification results. The computer device can modify the similarity threshold so that the similarity threshold incorporates the verification results of the aforementioned repairs, thereby achieving self-updating of the similarity threshold. When the similarities corresponding to different software versions are highly discrete, the computer device determines whether a software version repair is necessary during the code segment repair process based on the self-updating similarity threshold. Compared to the traditional method of determining based on a fixed threshold, this method avoids deviations caused by repairing the software version, thereby improving the accuracy of the repaired software version.
[0112] Optionally, the specific process of exact matching may further include the following steps:
[0113] S206. Record the error log for analysis by R&D personnel.
[0114] S207: Obtain verification results.
[0115] After the software version is repaired, the repaired software version can be verified. For example, manual verification or automatic execution of test cases by computer equipment can be used to verify whether the defects that need to be overcome are successfully overcome. If the verification passes, a verification result of passing the verification can be recorded. For example, if this is the record of the nth repair, the similarity between the content to be repaired and the defective code segment can be recorded as Vn, and the corresponding first correct number NSn is 1, and the first error number Nfn is 0. If the verification fails, a verification result of failing the verification can be recorded. For example, if this is the record of the nth repair, the similarity between the content to be repaired and the defective code segment can be recorded as Vn, and the corresponding first correct number NSn is 0, and the first error number Nfn is 1.
[0116] S208: Update the similarity threshold according to the verification result.
[0117] When a verification result is obtained, the computer device can update the similarity threshold according to the verification result. The computer device can also update the similarity threshold according to a preset number of verification results, for example, when three verification results are recorded. The computer device can also update the similarity threshold according to the newly recorded verification results at a fixed period. Optionally, the fixed period can be set as needed, such as one hour, two hours or other period, which is not limited in the embodiment of the present application. For example, Vs It is determined according to the above formula (2). If the n+1th verification result is generated at this time, the verification result can be substituted into the above formula (2) to form formula (6).
[0118]
[0119] In the above embodiment, after the computer device repairs the software version, it obtains the verification result of the repaired software version and rewrites the similarity threshold based on the verification result. The verification result of this repair can be integrated into the similarity threshold, thereby improving the matching degree between the similarity threshold and the actual situation, and further improving the accuracy of the software version repair.
[0120] Next, we will describe how to obtain the initial similarity threshold through training multiple training samples. Figure 4 As shown, the method includes:
[0121] S401: Acquire multiple similarity training values.
[0122] S402. Obtain a first correct training quantity and a first incorrect training quantity corresponding to a first similarity training value, where the first similarity training value is any one of a plurality of similarity training values. When a software version repaired based on the first similarity training value passes verification, the first correct training quantity is 1, and the first incorrect training quantity is 0. When a software version repaired based on the similarity training value fails verification, the first correct training quantity is 0, and the first incorrect training quantity is 1.
[0123] Specifically, the computer device may pre-acquire multiple sets of training data, each set of training data including a similarity training value and a first number of correct training results and a first number of incorrect training results corresponding to each similarity training value. For example, one thousand or more pieces of training data may be used. The greater the amount of training data, the more robust the resulting similarity threshold, and the greater the accuracy of repairing the software version based on the similarity threshold.
[0124] It should be noted that any similarity training value is a numerical similarity value obtained by comparing a set of training content to be repaired with the defective code segment in the defect source file. When the software version is repaired based on the set of training content to be repaired, if the verification passes, the first correct training number is 1 and the first incorrect training number is 0. If the software version repaired by the similarity training value fails the verification, the first correct training number is 0 and the first incorrect training number is 1.
[0125] S403: Obtain a total number of correct training results and a total number of incorrect training results, wherein the total number of correct training results is the sum of multiple first correct training results, and the total number of incorrect training results is the sum of multiple first incorrect training results, and the multiple first correct training results, the multiple first incorrect training results, and the multiple similarity training values correspond to each other.
[0126] Specifically, the computer device counts the sum of all first correct training numbers as the total correct training number, and counts the sum of all first incorrect training numbers as the total incorrect training number.
[0127] S404: Determine a ratio of the second sum to the difference between the total number of correct training sets and the total number of incorrect training sets as a similarity threshold, wherein the second sum is the sum of a plurality of second products, where the second product is the product of the first similarity training value and the difference between the first number of correct training sets and the first number of incorrect training sets corresponding to the first similarity training value, and the plurality of first products correspond one-to-one to the plurality of similarity training values.
[0128] The computer device can use any one of the above formulas (2) to (5) to calculate the similarity threshold. In this embodiment, the first similarity training value can be represented by Vn, the first error training number corresponding to Vn can be represented by Nfn, and the first correct training number corresponding to Vn can be represented by Nsn. Among them, n can be a positive integer greater than or equal to 1. The above multiple similarity training values can be represented by V1 to Vn, the first error training numbers corresponding to V1 to Vn can be represented by Nf1 to Nfn respectively, and the first correct training number corresponding to Vn can be represented by Ns1 to Nsn respectively.
[0129] above Figure 4 In the technical solution of the embodiment, the computer device can determine the similarity threshold based on multiple similarity training values obtained and the verification results corresponding to each similarity training value. The computer device can modify the similarity threshold based on each verification result, so that the similarity threshold learns the verification results of multiple repairs, thereby improving the robustness of the similarity threshold. When the similarities corresponding to different software versions are highly discrete, the similarity threshold in the embodiment of the present application is used to determine whether the software version needs to be repaired. Compared with the traditional fixed threshold method, this avoids the deviation caused by the repair of the software version, thereby improving the accuracy of the repaired software version.
[0130] The previous article describes the specific process of exact matching and details how to obtain the similarity threshold. This similarity threshold can also be applied to the fuzzy matching process of code segments. The following describes the fuzzy matching process of code segments. Figure 5 The process shown includes:
[0131] S501: Obtain a defective code segment in a defective source file and a navigation path corresponding to the defective code segment.
[0132] The naming rule of the navigation path here can be: namespace-class name-method name, which does not include the specific number and type of method parameters.
[0133] S502: Determine the content to be repaired in the file to be repaired according to the navigation path of the defective code segment.
[0134] The computer device can search in the file to be repaired according to the navigation path of the defective code segment, find the location of the method in the navigation path, and the content in the method is the content to be repaired.
[0135] Since the naming of the above navigation path does not include the specific number and type of method parameters, it is impossible to distinguish different contents in methods with the same method name. The method located by the computer device by reading the navigation path of the defective code segment in the defective source file may be in one place or multiple places, and the located content to be repaired may exist in one place or multiple places. For example, the method name in the navigation path of the defective code segment in the defective source file is YuYunCrudAppService. If the above method YuYunCrudAppService also exists in the file to be repaired, the positioning is successful. The computer device can determine that the content in the method named YuYunCrudAppService in the file to be repaired is the content to be repaired. At this time, the content to be repaired may include content in multiple places in the file to be repaired, and the method names corresponding to these contents are the same.
[0136] S503: Determine the similarity between the content to be repaired and the defective code segment.
[0137] The computer device can first process the content to be repaired in each location. Take one of the contents to be repaired as the first content to be repaired as an example for description: the computer device locates one of the specific method names according to the navigation path, and obtains the first content to be repaired in the method name here, and then groups the first content to be repaired by line, and then groups by space and removes invalid characters. During the grouping process, the order remains unchanged, thereby forming an array of files to be repaired, which includes multiple valid character strings arranged in sequence. For example, the array of files to be repaired can be ['A', 'B', 'C', 'D'], where A, B, C and D are all valid character strings. Similarly, the computer device can perform the above processing for each content to be repaired, and obtain the array of files to be repaired generated by each content to be repaired.
[0138] The computer device can also process defective code segments within the defective source file, for example by grouping them by line, then by space, and removing invalid characters. During the grouping process, the order of the segments remains unchanged, thereby forming a defective source file array containing multiple valid character strings arranged in sequence. For example, the defective source file array could be ['A', 'B', 'C', 'E'], where A, B, C, and E are each valid character strings.
[0139] In some embodiments, the computer device may use the above formula (1) or a variation of formula (1) to respectively calculate the similarity between each array of files to be repaired and the array of defective source files, and generate a similarity array.
[0140] For example, the above content to be repaired includes two contents. The array of files to be repaired M1 generated by the content to be repaired in one place is ['A', 'B', 'C', 'D'], the array of files to be repaired M2 generated by the content to be repaired in the other place is ['A', 'E', 'C', 'D'], and the defect source file array M3 is ['A', 'B', 'C', 'E']. Then the computer device first calculates the similarity Vm between M1 and M3. 13 , and then calculate the similarity Vm between M2 and M3 23 , the similarity array formed can be expressed as [Vm 13 , Vm 23 】. The computer equipment uses the above formula (1) to calculate Vm 13 is 0.75, Vm 23 is 0.625, then the similarity array is [0.75, 0.625].
[0141] S504: Determine whether the repair mode corresponding to the defective source file supports multi-code update. If yes, execute S505A; if not, execute S505B.
[0142] The computer device obtains the functional parameter of the defective source file, which is used to indicate whether the repair mode corresponding to the defective source file supports multiple code segment updates. The computer device can determine whether the defective source file supports multiple code segment updates based on the assigned value of the functional parameter.
[0143] For example, when the function parameter is true, it indicates that the repair mode corresponding to the defective source file supports the function of updating multiple code segments; when the function parameter is false, it indicates that the repair mode corresponding to the defective source file does not support multiple code updates.
[0144] S505A: Determine whether the first similarity in the similarity array is 100%. The first similarity is any similarity in the similarity array. If yes, execute S506A; if not, execute S506B.
[0145] S505B: The computer device selects the maximum similarity from the similarity array as the first similarity, and determines whether the first similarity is 100%. If so, execute S506A; otherwise, execute S506B.
[0146] S506A: Replace the content to be repaired corresponding to the first similarity value in the file to be repaired with the repaired code segment corresponding to the defective code segment in the defective source file. Optionally, S508 is then executed.
[0147] S506B: Determine whether the first similarity is greater than or equal to the similarity threshold. If so, execute S506A. Optionally, if not, execute S507.
[0148] It should be noted that the method for obtaining the similarity threshold and its beneficial effects can be found in Figure 3 Examples and Figure 3 The description of other improved embodiments will not be repeated here.
[0149] S507: Record an error log.
[0150] S508: Obtain verification results.
[0151] The technical principles and beneficial effects of the above S507 and S508 can be found in the description of S207 and S208 respectively, and will not be repeated here.
[0152] The above describes in detail an example of the method provided by the present application. It is understandable that, in order to implement the above functions, the corresponding device includes a hardware structure and / or software module corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a hardware or computer software driven hardware manner depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0153] The present application can divide the functional modules of the similarity threshold acquisition device and the data processing device according to the above method example. For example, each function can be divided into each functional module, or two or more functions can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in this application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0154] Figure 7 The schematic diagram of the structure of a similarity threshold acquisition device 700 provided by the present application is shown. The device 700 includes:
[0155] The first acquisition module 701 is configured to acquire at least one historical similarity.
[0156] The second acquisition module 702 is used to obtain a first correct number and a first error number corresponding to a first historical similarity, where the first historical similarity is any one of at least one historical similarity. When the software version corresponding to the first historical similarity passes the verification after repair, the first correct number is 1 and the first error number is 0. When the software version corresponding to the first historical similarity fails the verification after repair, the first correct number is 0 and the first error number is 1.
[0157] The third acquisition module 703 is used to obtain the total correct number and the total incorrect number, where the total correct number is the sum of at least one first correct number, and the total incorrect number is the sum of at least one first incorrect number. The at least one first correct number, the at least one first incorrect number, and the at least one historical similarity have a one-to-one correspondence.
[0158] The first determination module 704 is configured to determine a similarity threshold based on at least one historical similarity, at least one first correct number, at least one first incorrect number, the total correct number, and the total incorrect number. The similarity threshold is negatively correlated with the absolute value of the difference between the total correct number and the total incorrect number, and is positively correlated with the absolute value of a first sum, wherein the first sum is the sum of at least one first product, where the first product is the product of the first historical similarity and the difference between the corresponding first correct number and the first incorrect number, and the at least one first product has a one-to-one correspondence with the at least one historical similarity.
[0159] In some embodiments, the similarity threshold is inversely proportional to the difference between the total correct number and the total incorrect number, and the similarity threshold is proportional to the first sum.
[0160] In some embodiments, the similarity threshold is a ratio of the first sum to the difference between the total correct number and the total incorrect number.
[0161] In some embodiments, the similarity threshold V s The expression is:
[0162]
[0163] Among them, V1 to Vn are all historical similarities, NS1 to NSn are the first correct numbers corresponding to V1 to Vn respectively, Nf1 to Nfn are the first incorrect numbers corresponding to V1 to Vn respectively, Nts represents the total correct number of historical similarities, Nts is the sum of NS1 to NSn, Ntf represents the total incorrect number of historical similarities, Ntf is the sum of Nf1 to Nfn.
[0164] In some embodiments, the determination module 704 is further configured to update the similarity threshold to a fixed value when the similarity threshold is less than 0 or greater than 1, and the fixed value ranges from 0.95 to 0.99.
[0165] The specific manner in which the apparatus 700 executes the method for obtaining the similarity threshold value and the beneficial effects produced can be found in the relevant description in the method embodiment, which will not be repeated here.
[0166] Figure 8 FIG2 shows a schematic diagram of the structure of a data processing device 800 provided by the present application. The device 800 includes:
[0167] The fourth acquisition module 801 is used to acquire the file to be repaired and the defective source file.
[0168] The second determining module 802 is configured to obtain the content to be repaired in the file to be repaired when determining that the defect type of the defective source file is a type that matches the code segment.
[0169] The third determining module 803 is used to determine the similarity between the content to be repaired and the defective code segment in the defective source file.
[0170] The repair module 804 is configured to replace the content to be repaired with the repaired code segment corresponding to the defective code segment in the defective source file to repair the software version when the similarity is greater than a similarity threshold. The similarity threshold is the similarity threshold described in the above method embodiment.
[0171] In some embodiments, the apparatus 800 further includes:
[0172] The updating module 805 is used to obtain the verification result and update the similarity threshold according to the verification result. The verification result is used to indicate whether the repaired software version has passed the verification.
[0173] In some embodiments, the historical similarity is a similarity training value used for training, the number of similarity training values is multiple, and the similarity threshold is a threshold obtained by training using multiple similarity training values and the first correct number and the first incorrect number corresponding to each similarity training value.
[0174] The specific manner in which the device 800 executes the data processing method and the beneficial effects produced can be found in the relevant description of the method embodiment, which will not be repeated here.
[0175] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 9 As shown, the computer device 900 includes: a processor 910, a memory 920, and a computer program 921 stored in the memory 920 and executable on the processor 910. When the processor 910 executes the computer program 920, the steps of the method for obtaining the similarity threshold or the data processing method in the above-mentioned embodiment are implemented.
[0176] The computer device 900 may be a general-purpose computer device or a dedicated computer device. In a specific implementation, the computer device 900 may be a desktop computer, a portable computer, a network server, a PDA, a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device. The embodiment of the present application does not limit the type of the computer device 900. Those skilled in the art will understand that Figure 9 This is merely an example of the computer device 900 and does not constitute a limitation on the computer device 900 . The computer device 900 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device 900 may also include input and output devices, network access devices, etc.
[0177] The processor 910 may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0178] In some embodiments, the memory 920 may be an internal storage unit of the computer device 900, such as a hard disk or memory of the computer device 900. In other embodiments, the memory 920 may also be an external storage device of the computer device 900, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on the computer device 900. Furthermore, the memory 920 may also include both an internal storage unit of the computer device 900 and an external storage device. The memory 920 is used to store an operating system, application programs, a boot loader, data, and other programs. The memory 920 may also be used to temporarily store data that has been output or is about to be output.
[0179] The above-mentioned computer device includes: at least one processor, a memory, and a computer program stored in the memory and capable of running on the at least one processor, and when the processor executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.
[0180] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0181] An embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the steps in the above-mentioned various method embodiments.
[0182] If the integrated unit is implemented as a software functional unit and sold or used as a standalone product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the processes in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can at least include: any entity or device capable of carrying the computer program code to the camera / terminal device, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, and optical data storage device. The computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, a non-transitory storage medium.
[0183] It should be understood that all or part of the steps for implementing the above embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the steps may be implemented in the form of a computer program product. The computer program product may include one or more computer instructions. The computer instructions may be stored in the above-mentioned computer-readable storage medium.
[0184] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0185] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0186] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely schematic. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which can be electrical, mechanical or other forms.
[0187] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0188] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A method for obtaining a similarity threshold, characterized in that: The method comprises: Obtaining at least one historical similarity, where the similarity is the similarity between the content to be repaired in the file to be repaired and the defective code segment in the defective source file; Obtaining a first correct number and a first error number corresponding to a first historical similarity, where the first historical similarity is any one of the at least one historical similarity, and when the software version corresponding to the first historical similarity passes verification after repair, the first correct number is 1 and the first error number is 0; and when the software version corresponding to the first historical similarity fails verification after repair, the first correct number is 0 and the first error number is 1; Obtaining a total number of correct answers and a total number of errors, where the total number of correct answers is the sum of at least one first number of correct answers, and the total number of errors is the sum of at least one first number of errors, and the at least one first number of correct answers, the at least one first number of errors, and the at least one historical similarity have a one-to-one correspondence; determining the similarity threshold according to the at least one historical similarity, the at least one first correct number, the at least one first incorrect number, the total correct number, and the total incorrect number; In which, the similarity threshold is negatively correlated with the absolute value of the difference between the total correct number and the total incorrect number, and the similarity threshold is positively correlated with the absolute value of the first sum value, the first sum value is the sum of at least one first product, the first product is the product of the first historical similarity and the corresponding difference between the first correct number and the first incorrect number, and the at least one first product corresponds one-to-one to the at least one historical similarity.
2. The method according to claim 1, wherein The similarity threshold is inversely proportional to the difference between the total correct number and the total incorrect number, and the similarity threshold is proportional to the first sum value.
3. The method according to claim 2, wherein The similarity threshold is a ratio of the first sum value to a difference between the total correct number and the total incorrect number.
4. The method according to claim 3, wherein The similarity threshold V s The expression is: Among them, V1 to Vn are all historical similarities, NS1 to NSn are the first correct numbers corresponding to V1 to Vn respectively, Nf1 to Nfn are the first incorrect numbers corresponding to V1 to Vn respectively, Nts represents the total correct number of historical similarities, Nts is the sum of NS1 to NSn, Ntf represents the total incorrect number of historical similarities, Ntf is the sum of Nf1 to Nfn.
5. The method according to any one of claims 1 to 4, characterized in that If the similarity threshold is less than 0 or greater than 1, the similarity threshold is updated to a fixed value, and the fixed value ranges from 0.95 to 0.
99.
6. A data processing method, characterized in that: include: Obtain files to be repaired and defect source files; When it is determined that the defect type of the defective source file is a type that matches the code segment, obtaining the content to be repaired in the file to be repaired; Determining the similarity between the content to be repaired and the defective code segment in the defective source file; When the similarity is greater than a similarity threshold, the content to be repaired is replaced with a repaired code segment corresponding to the defective code segment in the defective source file to repair the software version; The similarity threshold is the similarity threshold according to any one of claims 1 to 5.
7. The method according to claim 6, characterized in that The method further comprises: Obtaining a verification result, wherein the verification result is used to indicate whether the repaired software version has passed the verification; The similarity threshold is updated according to the verification result.
8. The method according to claim 6, wherein The historical similarity is a similarity training value used for training, the number of the similarity training values is multiple, and the similarity threshold is a threshold obtained by training using the multiple similarity training values and the first correct number and the first incorrect number corresponding to each similarity training value.
9. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method according to any one of claims 1 to 8 when executed by the processor.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Dynamic threshold generation method and device, equipment and storage medium
CN115563180A