CN115629745A - Code modification method and device, storage medium and computer equipment - Google Patents

Code modification method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN115629745A
CN115629745A CN202211394970.5A CN202211394970A CN115629745A CN 115629745 A CN115629745 A CN 115629745A CN 202211394970 A CN202211394970 A CN 202211394970A CN 115629745 A CN115629745 A CN 115629745A
Authority
CN
China
Prior art keywords
target
information
modification
historical
demand information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211394970.5A
Other languages
Chinese (zh)
Inventor
何辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202211394970.5A priority Critical patent/CN115629745A/en
Publication of CN115629745A publication Critical patent/CN115629745A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a code modification method, a code modification device, a storage medium and computer equipment, relates to the technical field of information and digital medical treatment, and mainly aims to improve the efficiency and accuracy of code modification. The method comprises the following steps: acquiring target modification demand information and a preset historical modification information list corresponding to a method to be modified; similarity matching is carried out on the target modification demand information and each historical modification demand information in the preset historical modification information list, and target historical modification demand information matched with the target modification demand information is obtained; determining the position information of the code segment corresponding to the target historical modification requirement information, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and modifying the target code segment based on the target position information and the target modification demand information. The invention is suitable for modifying codes.

Description

Code modification method and device, storage medium and computer equipment
Technical Field
The present invention relates to the field of information technologies, and in particular, to a code modification method, apparatus, storage medium, and computer device.
Background
If a certain function in the application program needs to be improved, the method in the application program needs to be changed, and the basis of the method change is to change a certain section of code in the method.
Currently, when a method in a program is modified, the code that needs to be modified in the method is usually determined manually. However, this method requires a worker to search all codes corresponding to the method for codes to be modified, resulting in inefficient code modification, and at the same time, due to the fact that the skill level of the worker is uneven or due to the carelessness of the worker, a code search error condition is caused, resulting in low accuracy of code modification.
Disclosure of Invention
The invention provides a code modification method, a code modification device, a storage medium and computer equipment, and mainly aims to improve the efficiency and accuracy of code modification.
According to a first aspect of the present invention, there is provided a code modification method comprising:
acquiring target modification demand information corresponding to a method to be modified, and acquiring a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list;
similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information;
determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified;
and modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
According to a second aspect of the present invention, there is provided a code modification apparatus comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring target modification demand information corresponding to a method to be modified and acquiring a preset historical modification information list corresponding to the method to be modified, and the preset historical modification information list records each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified;
a similarity matching unit, configured to perform similarity matching between the target modification requirement information and each piece of historical modification requirement information to obtain target historical modification requirement information matched with the target modification requirement information;
a determining unit, configured to determine, in the preset history modification information list, location information of a code segment corresponding to the target history modification requirement information, and determine the location information as target location information of a target code segment corresponding to the target modification requirement information in the method to be modified;
and the modifying unit is used for modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
According to a third aspect of the present invention, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
acquiring target modification demand information corresponding to a method to be modified, and acquiring a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list;
similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information;
determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified;
and modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
According to a fourth aspect of the present invention, there is provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the program:
acquiring target modification demand information corresponding to a method to be modified, and acquiring a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list;
similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information;
determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified;
and modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
According to the code modification method, the code modification device, the storage medium and the computer equipment, compared with the mode of manually determining the code to be modified in the existing method, the target modification requirement information corresponding to the method to be modified is obtained, and the preset historical modification information list corresponding to the method to be modified is obtained, wherein each piece of historical modification requirement information corresponding to the method to be modified and the position information of the code segment corresponding to each piece of historical modification requirement information in the method to be modified are recorded in the preset historical modification information list; similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information; meanwhile, determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and finally, modifying the target code segment in the method to be modified based on the target position information and the target modification demand information, so that target historical modification demand information matched with the target modification demand information is determined in each piece of historical modification demand information corresponding to the method to be modified, the position information of the code segment corresponding to the target modification demand information in the method to be modified is determined as the target position information of the target code segment corresponding to the target modification demand information in the method to be modified, and finally, the target code segment in the method to be modified is modified based on the target position information and the target modification demand information, so that the code modification efficiency is improved, and meanwhile, the condition that the technical level of workers is uneven or the codes are searched for wrongly due to negligence of the workers is avoided, so that the code modification accuracy is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow chart of a code modification method provided by an embodiment of the invention;
FIG. 2 is a flow chart of another code modification method provided by the embodiment of the invention;
FIG. 3 is a schematic structural diagram of a code modification apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of another code modification apparatus provided in the embodiment of the present invention;
fig. 5 shows a physical structure diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The invention will be described in detail hereinafter with reference to the accompanying drawings in conjunction with embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Currently, the method of manually determining the code to be modified in the method results in low efficiency of code modification, and at the same time, due to the fact that technical levels of workers are uneven or due to carelessness of workers, a situation of code search error is caused, and thus the accuracy of code modification is low.
In order to solve the above problem, an embodiment of the present invention provides a code modification method, as shown in fig. 1, the method including:
101. the method comprises the steps of obtaining target modification demand information corresponding to a method to be modified, and obtaining a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list.
When a certain function in the application needs to be improved, the method to be modified corresponds to the function, for example, when the query function in the medical insurance information management application needs to be improved, the method to be modified is called by the query function. The target modification requirement information is description information that a user using an application expects that the application should add some functions, or should improve some functions, that is, the target modification requirement information is requirement information of the user using the application. The preset historical modification information list records information such as historical modification modes, historical change reasons and the like in addition to the information of the historical modification requirements corresponding to the method to be modified and the position information of code segments corresponding to the historical modification requirements in the method to be modified.
For the embodiment of the present invention, in order to overcome the problems of low code modification efficiency and low modification accuracy in the prior art, the embodiment of the present invention determines, in each piece of historical modification demand information corresponding to a method to be modified, target historical modification demand information matched with the target modification demand information, determines position information of a code segment corresponding to the target modification demand information in the method to be modified as target position information of a target code segment corresponding to the target modification demand information in the method to be modified, and finally modifies the target code segment in the method to be modified based on the target position information and the target modification demand information, so as to improve code modification efficiency.
Specifically, a history-management plug-in is developed and installed in code writing software, the code writing software may be IntelliJ IDEA software, if a certain function in an application is to be modified, all source codes in a method corresponding to the function in the application need to be uploaded to the code writing software, when the history-management plug-in is installed in the code writing software, a preset identification button is displayed in a code writing main interface of the code writing software, when a method to be modified is uploaded to the code writing software, a preset history modification information list corresponding to the method to be modified can be popped up by clicking the preset identification button, each piece of history modification information corresponding to the method to be modified is recorded in the list, target modification demand information corresponding to the method to be modified is obtained from a user at the same time, target modification demand information corresponding to the method is determined by the target modification demand information and the preset history modification information list corresponding to the method, and the target modification demand information in the code segment corresponding to the target modification demand information is determined, and the target modification efficiency of the code segment is improved based on the target modification demand information in the target code segment.
102. And performing similarity matching on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information.
For the embodiment of the present invention, generally, functions that a user desires to modify for an application are several fixed functions, for example, for a login function in a medical insurance information management application, if first-time historical modification requirement information generated by the user for the function is a username or password login error 5 times, the medical insurance information management application is prohibited from logging in within a preset time, if second-time historical modification requirement information generated by the user for the function is a username or password login error 4 times, the medical insurance information management application is prohibited from logging in within the preset time, if target modification requirement information generated by the user for the function is a username or password login error 3 times, the medical insurance information management application is prohibited from logging in the preset time, and for the first-time historical modification requirement information, the second-time historical modification requirement information and the target modification requirement information, the positions of the corresponding codes in the method to be modified are the same, meanwhile, a plurality of same requirement descriptions exist among the first-time historical modification requirement information, the second-time historical modification requirement information and the target modification requirement information, therefore, the target modification requirement information can be subjected to similarity matching with each historical modification requirement information recorded in a preset modification information list, the historical modification requirement information with the maximum similarity is determined as the target historical modification requirement information matched with the target modification requirement information, then the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified is determined through the target historical modification requirement information, and finally the target code segment in the method to be modified is modified based on the target position information and the target modification requirement information, the method and the device can avoid the situation that the position of the target code segment is determined wrongly due to the uneven technical level of workers or the carelessness of the workers, so that the code is modified wrongly, and further improve the code modification accuracy.
103. And determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified.
The target code segment is a code segment which needs to be modified according to the target modification requirement information.
For the embodiment of the present invention, after similarity matching is performed between the target modification demand information and each piece of history modification demand information to obtain target history modification demand information matched with the target modification demand information, position information of a code segment corresponding to the target modification demand information in the method to be modified is determined in the preset history modification information list, the position information is determined as target position information of a target code segment corresponding to the target modification demand information in the method to be modified, and finally the target code segment in the method to be modified is modified based on the target position information and the target modification demand information.
104. And modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
For the embodiment of the present invention, after determining the target position information of the target code segment corresponding to the target modification demand information in the power modification method, a developer may determine the target code segment in the power modification method based on the target position information, and finally modify the target code segment based on the target modification demand information, so that by determining the target historical modification demand information matched with the target modification demand information in each historical modification demand information corresponding to the power modification method, and determining the position information of the code segment corresponding to the target modification demand information in the power modification method as the target position information of the target code segment corresponding to the target modification demand information in the power modification method, and finally modifying the target code segment in the power modification method based on the target position information and the target modification demand information, the efficiency of code modification is improved, and meanwhile, the situation that the technical level of a worker is different, or the code is found carelessly and incorrectly due to the worker is avoided, thereby improving the accuracy of code modification.
According to the code modification method, compared with the mode of manually determining the codes to be modified in the existing method, the target modification requirement information corresponding to the method to be modified is obtained, and the preset historical modification information list corresponding to the method to be modified is obtained, wherein the historical modification requirement information corresponding to the method to be modified and the position information of the code segments corresponding to the historical modification requirement information in the method to be modified are recorded in the preset historical modification information list; similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information; meanwhile, determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and finally, modifying the target code segment in the method to be modified based on the target position information and the target modification demand information, so that target historical modification demand information matched with the target modification demand information is determined in each piece of historical modification demand information corresponding to the method to be modified, the position information of the code segment corresponding to the target modification demand information in the method to be modified is determined as the target position information of the target code segment corresponding to the target modification demand information in the method to be modified, and finally, the target code segment in the method to be modified is modified based on the target position information and the target modification demand information, so that the code modification efficiency is improved, and meanwhile, the condition that the technical level of workers is uneven or the codes are searched for wrongly due to negligence of the workers is avoided, so that the code modification accuracy is improved.
Further, in order to better explain the above process of modifying the code, as a refinement and extension to the above embodiment, another code modification method is provided in an embodiment of the present invention, as shown in fig. 2, where the method includes:
201. the method comprises the steps of obtaining target modification demand information corresponding to a method to be modified, and obtaining a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list.
For the embodiment of the present invention, when a user or a tester, etc., puts forward a demand for a certain function in an application program, collecting information that the user or the tester puts forward a demand for a certain function in the application program, that is, the obtained target modification demand information, further, in order to determine target position information of a target code segment corresponding to the target modification demand information in the method to be modified, a preset historical modification information list corresponding to the method to be modified needs to be obtained, based on which step 201 specifically includes: receiving an acquisition instruction of a preset historical modification information list corresponding to the method to be modified, wherein the acquisition instruction carries identification information corresponding to the method to be modified; and determining a preset historical modification information list corresponding to the method to be modified in a list database based on the identification information.
The identification information may be icon information or character information corresponding to the method to be modified, and as long as the method to be modified can be uniquely determined by the identification information, the embodiment of the present invention does not specifically limit the form of the identification information. Meanwhile, different methods correspond to different preset historical modification information lists.
Specifically, identification information corresponding to different methods and different preset historical modification information lists are stored in a list database in a corresponding manner, a mapping relation is established between the list database and code compiling software in advance, after all codes corresponding to the methods to be modified are uploaded to the code compiling software, a preset identification button in a code compiling main interface on the code compiling software is clicked, an obtaining instruction of the preset historical modification information list is triggered, wherein the obtaining instruction carries the identification information corresponding to the methods to be modified, the mapping relation is established based on the identification information and the list database and the code compiling software, the preset historical modification information list corresponding to the methods to be modified is obtained in the list database, and all information recorded in the preset historical modification information list is displayed in the code compiling main interface on the code compiling software in a flexible manner.
202. Performing word segmentation processing on the target modification demand information to obtain each first word segmentation corresponding to the target modification demand information, and performing word segmentation processing on each historical modification demand information to obtain each second word segmentation corresponding to each historical modification demand information.
For the embodiment of the present invention, after the target modification demand information corresponding to the method to be modified is obtained, in order to improve the matching accuracy between the target modification demand information and each piece of historical modification demand information, word segmentation processing needs to be performed on the target modification demand information and each piece of historical modification demand information, to obtain each first word segmentation corresponding to the target modification demand information and each second word segmentation corresponding to each piece of historical modification demand information, then stop words in each first word segmentation and each second word segmentation are removed, to obtain the simplified target modification demand information and each simplified historical modification demand information, and finally, similarity matching is performed on the simplified target modification demand information and each simplified historical modification demand information.
203. And detecting whether a first stop word exists in each first participle by using a preset stop word library, and if the first stop word exists, removing the first stop word in the target modification demand information to obtain the simplified target modification demand information.
Each stop word is stored in a preset stop word library, the stop word is a word which does not affect the similarity matching result, and the stop word is as follows: "and", "has", and all punctuation marks and the like.
For the embodiment of the invention, after determining each first participle corresponding to the target modification demand information, filtering each first participle by using a preset stop word bank, detecting whether the target modification demand information contains stop words in the preset stop word bank, if the target modification demand information contains stop words in the preset stop words, removing the stop words in the target modification demand information to obtain simplified target modification demand information, for example, under the condition that the target modification demand information is 'password error input for 3 times, a personal health file management program is not allowed to be logged in within 1 hour', performing participle processing on the target modification demand information, obtaining that each first participle corresponding to the target modification demand information is "password/input/error/3 times/situation/lower/,/1/hour/inner/not/permission/login/personal/health/archive/management/program/", then filtering each first participle corresponding to the target modification demand information by using a preset disabled thesaurus, finding "sum" and "in each first participle corresponding to the target modification demand information, and appearing in the disabled thesaurus, so that" sum "and" in each first participle corresponding to the target modification demand information are removed, and finally obtaining that each excluded first participle corresponding to the target modification demand information is "password/input/error/3 times/situation/lower/1/hour/inner/not/permission/login/personal/health/archive/management/program/", the corresponding simplified target modification requirement information is as follows: "no login of the personal health profile management program is allowed within 1 hour under the condition of 3 times of password error input".
204. And detecting whether a second stop word exists in each second participle by using the preset stop word library, and if the second stop word exists, removing the second stop word in each historical modification demand information to obtain each simplified historical modification demand information.
For the embodiment of the invention, after determining each second participle corresponding to each historical modification demand information, filtering each second participle by using a preset stop word bank, detecting whether each historical modification demand information contains stop words in the preset stop word bank, if each historical modification demand information contains stop words in the preset stop words, removing the stop words in each historical modification demand information to obtain each simplified historical modification demand information, wherein under the condition that one piece of historical modification demand information is ' a password is wrongly input for 5 times, a personal health file management program is not allowed to be logged in within 2 hours ', and performing participle processing on the historical modification demand information, obtaining the second participles corresponding to the historical modification demand information as ' password/input/error/5 times/condition/lower ',/2/hour/inner/not/allow/login/personal/health/file/management/program/', then filtering the second participles corresponding to the historical modification demand information by using a preset disabled thesaurus, finding the ' sum ' in the second participles corresponding to the historical modification demand information, and enabling the ' sum ' in the second participles corresponding to the historical modification demand information to be removed, and finally obtaining the excluded second participles corresponding to the historical modification demand information as ' password/input/error/5 times/condition/lower/2/hour/inner/not/allow/login/personal/health/file/management/program/', the corresponding simplified historical modification requirement information is as follows: similarly, another historical modification requirement information is that the function of full word search is changed into the function of fuzzy search, word segmentation processing and stop word removal processing are carried out on the historical modification requirement information, finally, each second word after the stop word removal is obtained is 'will/full/word/search/function/change/yes/fuzzy/search/function/', and the corresponding simplified historical modification requirement information is that: "change the full word search function to the fuzzy search function".
205. And performing similarity matching on the simplified target modification demand information and each simplified historical modification demand information to obtain target historical modification demand information matched with the target modification demand information.
For the embodiment of the present invention, after obtaining the simplified target modification requirement information and each simplified historical modification requirement information, in order to determine the target location information of the target code segment corresponding to the target modification requirement information in the method to be modified, similarity matching needs to be performed on the simplified target modification requirement information and each simplified historical modification requirement information, and based on this, step 205 specifically includes: determining a first semantic feature vector corresponding to the simplified target modification demand information, and determining a second semantic feature vector corresponding to each simplified historical modification demand information; calculating cosine similarity between the target modification demand information and each historical modification demand information based on the first semantic feature vector and each second semantic feature vector; and determining the maximum cosine similarity among the cosine similarities, and determining the historical modification requirement information corresponding to the maximum cosine similarity as the target historical modification requirement information matched with the target modification requirement information.
Specifically, in order to calculate the similarity between the target modification demand information and each piece of historical modification demand information, first, a first semantic feature vector corresponding to the reduced target modification demand information and a second semantic feature vector corresponding to each piece of reduced historical modification demand information need to be determined, and the method for specifically calculating the first semantic feature vector and the second semantic feature vector includes: inputting the simplified target modification demand information into a preset natural language model for extracting semantic features, and obtaining a first semantic feature vector corresponding to the simplified target modification demand information; and inputting each simplified historical modification demand information into the preset natural language model for semantic feature extraction, so as to obtain a second semantic feature vector corresponding to each simplified historical modification demand information.
The preset natural language model can be a preset Bert model, the preset Bert model comprises a plurality of encoders, each encoder is connected end to end, the output of the previous encoder can be used as the input of the next encoder, and the encoders specifically comprise an attention layer and a feedforward neural network layer. Specifically, first, determining each first character included in the simplified target modification requirement information and a first embedded vector corresponding to each first character, and determining each second character included in each simplified history modification requirement information and a second embedded vector corresponding to each second character; inputting the first embedded vector into a preset natural language model for language feature extraction to obtain a first semantic feature vector corresponding to the simplified target modification demand information, and inputting the second embedded vector into the preset natural language model for language feature extraction to obtain a second semantic feature vector corresponding to each simplified historical modification demand information. Specifically, the method for inputting the first embedded vector into a preset natural language model to perform language feature extraction to obtain the first semantic feature vector corresponding to the simplified target modification requirement information includes: inputting the first embedded vector to the attention layer for feature extraction to obtain a first feature vector corresponding to each first character; adding the first feature vector and the first embedded vector to obtain a second feature vector corresponding to each first character; and inputting the second feature vector to the feedforward neural network layer for feature extraction to obtain a first semantic feature vector corresponding to the simplified target modification demand information. Similarly, the method for inputting the second embedded vector into a preset natural language model for language feature extraction to obtain the second semantic feature vector corresponding to the simplified historical modification requirement information includes: inputting the second embedded vectors into the attention layer for feature extraction to obtain third feature vectors corresponding to the second characters; adding the third feature vector and the second embedded vector to obtain a fourth feature vector corresponding to each second character; and inputting the fourth feature vector to the feedforward neural network layer for feature extraction to obtain a second semantic feature vector corresponding to the simplified historical modification demand information, so that a second semantic feature vector corresponding to each simplified historical modification demand information can be obtained.
For example, the simplified target modification requirement information is "no login of the personal health profile management program is allowed within 1 hour under the condition that the password is input incorrectly for 3 times", the corresponding first characters are "secret/code/input/error/3/time/condition/down/1/small/time/in/not/allow/login/record/person/health/file/case/management/program/sequence/", the Word embedding method such as Word2Vec is used to convert each first character in the simplified target modification requirement information into a first embedded vector, and the first embedded vector corresponding to each first character is input into the attention layer of the first encoder in the preset Bert model for feature extraction, so as to obtain an output vector of the attention layer, namely, a first feature vector corresponding to each first character, wherein the specific process of feature extraction at the attention layer is as follows: determining a query vector, a key vector and a value vector corresponding to each first character according to the embedded vector corresponding to each first character; multiplying a query vector corresponding to a target character in each first character by a key vector corresponding to each first character to obtain an attention score of each first character for the target character; and multiplying and summing the attention scores corresponding to the first characters and the value vectors to obtain first feature vectors corresponding to the target characters.
For the embodiment of the present invention, in the process of obtaining the first feature vector corresponding to each first character, a first embedded vector corresponding to each first character in the reduced target modification requirement information may be multiplied by a weight matrix corresponding to an attention layer in a preset Bert model to obtain a query vector, a key vector, and a value vector corresponding to each first character, further, an attention score corresponding to each first character needs to be calculated, when an attention score corresponding to any one character (target character) in each first character is calculated, each first character in the reduced target modification requirement information needs to be used to score the target character, specifically, the query vector corresponding to the target character and the key vector corresponding to each first character are used to obtain a scoring value of the target character multiplied by each first character, that is, the attention score is obtained, then the attention scores and the value vectors corresponding to each first character are multiplied by each other, and summed, and an attention layer output vector corresponding to the target character, that is, the first feature vector corresponding to the target character is finally obtained, so that the first feature vector corresponding to each first character can be determined in the above manner, and the first feature vector corresponding to obtain the first characteristic vector corresponding to the reduced semantic information corresponding to each first character.
Further, in order to obtain a first semantic feature vector corresponding to the reduced target modification demand information, after a first embedded vector corresponding to each first character in the first semantic feature vector corresponding to the reduced target modification demand information is input to an attention layer of a first encoder, and a first feature vector corresponding to each first character is extracted, the first feature vector and the first embedded vector corresponding to each first character are added to obtain a second feature vector corresponding to each first character, and the second feature vector is input to a feedforward neural network layer of the first encoder to perform feature extraction, so that an output vector of the first encoder is obtained.
Further, after determining a first semantic feature vector corresponding to the simplified target modification requirement information and a second semantic feature vector corresponding to each simplified historical modification requirement information, calculating cosine similarity between the target modification requirement information and each historical modification requirement information based on the first semantic feature vector and the second semantic feature vector, where a specific calculation formula is as follows:
Figure BDA0003931998570000141
wherein cos (θ) represents a cosine similarity between the target modification requirement information and the history modification requirement information, x i Representing a first semantic feature vector, y, corresponding to the reduced target modification requirement information i And representing a second semantic feature vector corresponding to any one of the simplified historical modification demand information, calculating cosine similarity between each piece of historical modification demand information and the target modification demand information according to the formula, determining the maximum cosine similarity in each piece of cosine similarity, and determining the historical modification demand information corresponding to the maximum cosine similarity as the target historical modification demand information matched with the target modification demand information.
206. And determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified.
For the embodiment of the present invention, because the preset history modification information list records the position information of the code segment corresponding to each history modification requirement information in the method to be modified, based on each position information, the position information of the code segment corresponding to the target history modification requirement information is determined, and the position information is determined as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified.
207. And modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
For the embodiment of the present invention, after determining the target position information of the target code segment corresponding to the target modification requirement information in the to-be-modified method, the target code segment needs to be modified based on the target position information and the target modification requirement information, and based on this, step 207 specifically includes: and modifying the target code segment in the method to be modified based on the target position information, the target modification demand information and a target history modification mode corresponding to the target history modification demand information.
Specifically, since the preset history modification information list also records history modification modes corresponding to the history modification demand information, the target code segment is determined in the method to be modified based on the target position information, and the target code segment in the method to be modified is modified based on the target modification demand information and referring to the target modification mode. Further, after modifying the target code segment, the method further comprises: storing the target modification demand information and the target position information to the preset history modification information list to obtain an updated preset history modification information list; and storing the updated preset historical modification information list to the list database.
Specifically, in order to update the preset history modification information list in real time, after the target code segment is modified, a preset identification button in a code writing main interface on the code writing software is clicked, a popup window for displaying the preset history modification information is popped up, an information adding button exists in the popup window, the information adding button is clicked, an information adding text box is displayed, the target modification requirement information, the target position information and the target modification mode are filled in the text box, and after the completion of filling, a determination button is clicked, the information is added to the preset history modification information list according to the filling time sequence to obtain the updated preset history modification information list, namely, when the method is modified each time, the information such as the modification requirement information and the position information of the code segment corresponding to the modification requirement information needs to be added to the preset history modification information list.
According to another code modification method provided by the invention, compared with the mode of manually determining the code to be modified in the existing method, the target modification requirement information corresponding to the method to be modified is obtained, and the preset historical modification information list corresponding to the method to be modified is obtained, wherein the preset historical modification information list records each piece of historical modification requirement information corresponding to the method to be modified and the position information of the code segment corresponding to each piece of historical modification requirement information in the method to be modified; similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information; meanwhile, determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and finally, modifying the target code segment in the method to be modified based on the target position information and the target modification demand information, thereby determining the target historical modification demand information matched with the target modification demand information in each piece of historical modification demand information corresponding to the method to be modified, determining the position information of the code segment corresponding to the target modification demand information in the method to be modified as the target position information of the target code segment corresponding to the target modification demand information in the method to be modified, and finally modifying the target code segment in the method to be modified based on the target position information and the target modification demand information, so that the code modification efficiency is improved, and meanwhile, the condition that the technical level of workers is not uniform or the code is searched for wrongly due to the carelessness of the workers is avoided, so that the code modification accuracy is improved.
Further, as a specific implementation of fig. 1, an embodiment of the present invention provides a code modification apparatus, as shown in fig. 3, where the apparatus includes: an acquisition unit 31, a similarity matching unit 32, a determination unit 33, and a modification unit 34.
The obtaining unit 31 may be configured to obtain target modification requirement information corresponding to a method to be modified, and obtain a preset history modification information list corresponding to the method to be modified, where each history modification requirement information corresponding to the method to be modified and position information of a code segment corresponding to each history modification requirement information in the method to be modified are recorded in the preset history modification information list.
The similarity matching unit 32 may be configured to perform similarity matching between the target modification requirement information and each piece of historical modification requirement information, so as to obtain target historical modification requirement information matched with the target modification requirement information.
The determining unit 33 may be configured to determine, in the preset history modification information list, position information of a code segment corresponding to the target history modification requirement information, and determine the position information as target position information of a target code segment in the method to be modified, where the target code segment corresponds to the target modification requirement information.
The modifying unit 34 may be configured to modify the target code segment in the method to be modified based on the target location information and the target modification requirement information.
In a specific application scenario, in order to determine target history modification requirement information matched with the target modification requirement information, as shown in fig. 4, the similarity matching unit 32 includes a participle processing module 321, a stop word removing module 322, and a similarity matching module 323.
The word segmentation processing module 321 may be configured to perform word segmentation processing on the target modification demand information to obtain each first word segmentation corresponding to the target modification demand information, and perform word segmentation processing on each historical modification demand information to obtain each second word segmentation corresponding to each historical modification demand information.
The stop word removing module 322 may be configured to detect whether a first stop word exists in each first participle by using a preset stop word library, and if the first stop word exists, remove the first stop word in the target modification requirement information to obtain the simplified target modification requirement information.
The stop word removing module 322 may be further configured to detect whether a second stop word exists in each second segmented word by using the preset stop word library, and if the second stop word exists, remove the second stop word in each historical modification requirement information to obtain each simplified historical modification requirement information.
The similarity matching module 323 may be configured to perform similarity matching between the simplified target modification requirement information and each of the simplified historical modification requirement information, so as to obtain the simplified target historical modification requirement information that matches the simplified target modification requirement information.
In a specific application scenario, in order to determine the simplified target historical modification requirement information matched with the simplified target modification requirement information, the similarity matching module 323 includes a determining sub-module and a calculating sub-module.
The determining submodule may be configured to determine a first semantic feature vector corresponding to the reduced target modification requirement information, and determine a second semantic feature vector corresponding to each reduced historical modification requirement information.
The calculation sub-module may be configured to calculate a cosine similarity between the simplified target modification requirement information and each of the simplified historical modification requirement information based on the first semantic feature vector and each of the second semantic feature vectors.
The determining submodule may be specifically configured to determine a maximum cosine similarity among the cosine similarities, and determine the simplified history modification requirement information corresponding to the maximum cosine similarity as the simplified target history modification requirement information matched with the simplified target modification requirement information.
In a specific application scenario, in order to determine a first semantic feature vector corresponding to the simplified target modification demand information and determine a second semantic feature vector corresponding to each of the simplified historical modification demand information, the determining submodule may be specifically configured to input the simplified target modification demand information into a preset natural language model to extract semantic features, so as to obtain the first semantic feature vector corresponding to the simplified target modification demand information; and inputting each simplified historical modification demand information into the preset natural language model for semantic feature extraction, so as to obtain a second semantic feature vector corresponding to each simplified historical modification demand information.
In a specific application scenario, in order to obtain a preset historical modification information list corresponding to the method to be modified, the obtaining unit 31 includes a receiving module 311 and a determining module 312.
The receiving module 311 may be configured to receive an obtaining instruction of a preset historical modification information list corresponding to the method to be modified, where the obtaining instruction carries identification information corresponding to the method to be modified.
The determining module 312 may be configured to determine, based on the identification information, a preset historical modification information list corresponding to the method to be modified in a list database.
In a specific application scenario, in order to store the target modification demand information and the target location information in a preset history modification information list, the apparatus further includes: a storage unit 35.
The storage unit 35 may be configured to store the target modification demand information and the target location information in the preset history modification information list, so as to obtain an updated preset history modification information list.
The storage unit 35 may be specifically configured to store the updated preset history modification information list in the list database.
In a specific application scenario, in order to modify the target code segment in the method to be modified, the modifying unit 34 may be specifically configured to modify the target code segment in the method to be modified based on the target location information, the target modification requirement information, and a target history modification manner in the target history modification requirement information.
It should be noted that other corresponding descriptions of the functional modules related to the code modification apparatus provided in the embodiment of the present invention may refer to the corresponding description of the method shown in fig. 1, and are not described herein again.
Based on the method shown in fig. 1, correspondingly, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the following steps: acquiring target modification demand information corresponding to a method to be modified, and acquiring a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list; similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information; determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
Based on the above embodiments of the method shown in fig. 1 and the apparatus shown in fig. 3, an embodiment of the present invention further provides an entity structure diagram of a computer device, as shown in fig. 5, where the computer device includes: a processor 41, a memory 42, and a computer program stored on the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are both arranged on a bus 43 such that when the processor 41 executes the program, the following steps are performed: acquiring target modification demand information corresponding to a method to be modified, and acquiring a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list; similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information; determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
According to the technical scheme, the target modification demand information corresponding to the method to be modified is obtained, and the preset history modification information list corresponding to the method to be modified is obtained, wherein the preset history modification information list records each history modification demand information corresponding to the method to be modified and the position information of the code segment corresponding to each history modification demand information in the method to be modified; similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information; meanwhile, determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified; and finally, modifying the target code segment in the method to be modified based on the target position information and the target modification demand information, so that target historical modification demand information matched with the target modification demand information is determined in each piece of historical modification demand information corresponding to the method to be modified, the position information of the code segment corresponding to the target modification demand information in the method to be modified is determined as the target position information of the target code segment corresponding to the target modification demand information in the method to be modified, and finally, the target code segment in the method to be modified is modified based on the target position information and the target modification demand information, so that the code modification efficiency is improved, and meanwhile, the condition that the technical level of workers is uneven or the codes are searched for wrongly due to negligence of the workers is avoided, so that the code modification accuracy is improved.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made without departing from the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A code modification method, comprising:
acquiring target modification demand information corresponding to a method to be modified, and acquiring a preset historical modification information list corresponding to the method to be modified, wherein each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified are recorded in the preset historical modification information list;
similarity matching is carried out on the target modification demand information and the historical modification demand information to obtain target historical modification demand information matched with the target modification demand information;
determining the position information of the code segment corresponding to the target historical modification requirement information in the preset historical modification information list, and determining the position information as the target position information of the target code segment corresponding to the target modification requirement information in the method to be modified;
and modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
2. The method according to claim 1, wherein the similarity matching of the target modification requirement information and the respective historical modification requirement information to obtain target historical modification requirement information matched with the target modification requirement information comprises:
performing word segmentation processing on the target modification demand information to obtain each first word segmentation corresponding to the target modification demand information, and performing word segmentation processing on each historical modification demand information to obtain each second word segmentation corresponding to each historical modification demand information;
detecting whether a first stop word exists in each first participle by using a preset stop word library, and if the first stop word exists, removing the first stop word in the target modification demand information to obtain simplified target modification demand information;
detecting whether a second stop word exists in each second participle by using the preset stop word library, and if the second stop word exists, removing the second stop word in each historical modification demand information to obtain each simplified historical modification demand information;
and performing similarity matching on the simplified target modification demand information and each simplified historical modification demand information to obtain target historical modification demand information matched with the target modification demand information.
3. The method according to claim 2, wherein the similarity matching of the reduced target modification requirement information and the respective reduced historical modification requirement information to obtain target historical modification requirement information matched with the target modification requirement information comprises:
determining a first semantic feature vector corresponding to the simplified target modification demand information, and determining a second semantic feature vector corresponding to each simplified historical modification demand information;
calculating cosine similarity between the target modification demand information and each historical modification demand information based on the first semantic feature vector and each second semantic feature vector;
and determining the maximum cosine similarity among the cosine similarities, and determining the historical modification requirement information corresponding to the maximum cosine similarity as the target historical modification requirement information matched with the target modification requirement information.
4. The method according to claim 3, wherein the determining the first semantic feature vector corresponding to the reduced target modification requirement information includes:
inputting the simplified target modification demand information into a preset natural language model for extracting semantic features, and obtaining a first semantic feature vector corresponding to the simplified target modification demand information;
the determining the second semantic feature vector corresponding to each piece of reduced historical modification requirement information includes:
and inputting each simplified historical modification demand information into the preset natural language model for semantic feature extraction, so as to obtain a second semantic feature vector corresponding to each simplified historical modification demand information.
5. The method according to claim 1, wherein the obtaining of the preset historical modification information list corresponding to the method to be modified includes:
receiving an acquisition instruction of a preset historical modification information list corresponding to the method to be modified, wherein the acquisition instruction carries identification information corresponding to the method to be modified;
and determining a preset historical modification information list corresponding to the method to be modified in a list database based on the identification information.
6. The method according to claim 1, wherein after said modifying the target code segment in the method to be modified based on the target location information and the target modification requirement information, the method further comprises:
storing the target modification demand information and the target position information to the preset history modification information list to obtain an updated preset history modification information list;
and storing the updated preset historical modification information list to the list database.
7. The method according to claim 1, wherein said modifying the target code segment in the method to be modified based on the target location information and the target modification requirement information comprises:
and modifying the target code segment in the method to be modified based on the target position information, the target modification demand information and a target history modification mode corresponding to the target history modification demand information.
8. A code modification apparatus, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring target modification demand information corresponding to a method to be modified and acquiring a preset historical modification information list corresponding to the method to be modified, and the preset historical modification information list records each piece of historical modification demand information corresponding to the method to be modified and position information of a code segment corresponding to each piece of historical modification demand information in the method to be modified;
a similarity matching unit, configured to perform similarity matching between the target modification requirement information and each piece of historical modification requirement information to obtain target historical modification requirement information matched with the target modification requirement information;
a determining unit, configured to determine, in the preset history modification information list, location information of a code segment corresponding to the target history modification requirement information, and determine the location information as target location information of a target code segment corresponding to the target modification requirement information in the method to be modified;
and the modifying unit is used for modifying the target code segment in the method to be modified based on the target position information and the target modification demand information.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
10. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 7 when executed by the processor.
CN202211394970.5A 2022-11-08 2022-11-08 Code modification method and device, storage medium and computer equipment Pending CN115629745A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211394970.5A CN115629745A (en) 2022-11-08 2022-11-08 Code modification method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211394970.5A CN115629745A (en) 2022-11-08 2022-11-08 Code modification method and device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN115629745A true CN115629745A (en) 2023-01-20

Family

ID=84909123

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211394970.5A Pending CN115629745A (en) 2022-11-08 2022-11-08 Code modification method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN115629745A (en)

Similar Documents

Publication Publication Date Title
CN110309251B (en) Text data processing method, device and computer readable storage medium
AU2018354105B2 (en) Genealogical entity resolution system and method
CN110516210B (en) Text similarity calculation method and device
CN111785384A (en) Abnormal data identification method based on artificial intelligence and related equipment
US20200356627A1 (en) Using unsupervised machine learning for automatic entity resolution of natural language records
CN113656807A (en) Vulnerability management method, device, equipment and storage medium
CN112885478A (en) Medical document retrieval method, medical document retrieval device, electronic device, and storage medium
CN116721778B (en) Medical term standardization method, system, equipment and medium
CN113706322A (en) Service distribution method, device, equipment and storage medium based on data analysis
KR101852774B1 (en) Error correction method for prescription recognition, and error correction system for prescription recognition
CN110209929B (en) Resume recommendation method and device, computer equipment and storage medium
CN113344125B (en) Long text matching recognition method and device, electronic equipment and storage medium
US20210200994A1 (en) Processing method of learning face recognition by artificial intelligence module
CN113722507A (en) Hospital cost prediction method and device based on knowledge graph and computer equipment
WO2019085118A1 (en) Topic model-based associated word analysis method, and electronic apparatus and storage medium
CN111339778B (en) Text processing method, device, storage medium and processor
CN112836019A (en) Public health and public health named entity identification and entity linking method and device, electronic equipment and storage medium
CN115629745A (en) Code modification method and device, storage medium and computer equipment
CN112685389B (en) Data management method, data management device, electronic device, and storage medium
CN115906817A (en) Keyword matching method and device for cross-language environment and electronic equipment
US20110172991A1 (en) Sentence extracting method, sentence extracting apparatus, and non-transitory computer readable record medium storing sentence extracting program
CN111310442B (en) Method for mining shape-word error correction corpus, error correction method, device and storage medium
CN114446422A (en) Medical record marking method, system and corresponding equipment and storage medium
KR20210124033A (en) Method and apparatus for image processing, electronic device and computer readable storage medium
CN113434413A (en) Data testing method, device and equipment based on data difference and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination