Code data filling method and device, processor and readable storage medium
By using AI big models and natural language processing technology in software development, automatically analyzing the context of code data and generating fill code data, the problem of inefficient filling of code data is solved, the program performance is improved and the workload of manual management dependencies is reduced.
Patent Information
- Application Number
- CN202411930978.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-18
AI Technical Summary
During the software development process, the inefficient code data filling efficiency leads to a decrease in program operation efficiency, and manual management of dependencies is complicated and easy to make mistakes, which can easily lead to version mismatch and dependency conflicts.
By obtaining the initial code data to be filled, determining its code context data, generating fill code data based on the code context data, and filling it with the initial code data, obtaining the target code data. This method uses AI big model and natural language processing technology to automatically analyze the context of code data and intelligently identify required libraries and dependencies.
Improves the efficiency of code data filling, reduces program execution time, improves program performance, reduces the workload of manual management of dependencies, and avoids version mismatch and dependency conflicts.
Smart Images

Figure CN119847484A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a method, device, processor and readable storage medium for filling code data. Background Art
[0002] At present, in the process of software development, managing project dependencies is one of the key links to ensure the smooth progress of the project. Data filling is a common operation in managing the program in the project. If the efficiency of filling data is low, the overall operation efficiency of the program will decrease. Efficient data filling can reduce the execution time of the program and improve the performance of the program.
[0003] Under normal circumstances, developers need to manually find, select, and import the required code library dependencies, which is not only cumbersome but also error-prone. As the scale of projects increases and dependencies become more complicated, the workload of manually managing dependencies increases dramatically, placing a heavy burden on developers. At the same time, manually importing dependencies may also lead to problems such as version mismatches and dependency conflicts, further affecting the stability and maintainability of the project. In order to solve this problem, some automated tools have appeared on the market, trying to help developers manage project dependencies more efficiently. However, most of these tools rely on fixed templates or rules and cannot be intelligently identified and adjusted according to the actual needs of the project. Therefore, when using these tools, developers still need to spend a lot of time and energy on manual configuration and optimization. Therefore, there is a technical problem of low efficiency in code data filling.
[0004] Currently, no effective solution has been proposed to the above-mentioned technical problem of low efficiency in filling in code data. Summary of the invention
[0005] Embodiments of the present invention provide a method, device, processor, and readable storage medium for filling code data, so as to at least solve the technical problem of low efficiency in filling code data.
[0006] According to one aspect of an embodiment of the present invention, a method for filling code data is provided. The method may include: obtaining initial code data to be filled; determining code context data of the initial code data, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; generating filling code data based on the code context data; and filling the filling code data into the initial code data to obtain target code data.
[0007] Optionally, determining the code context data of the initial code data includes: extracting code background and code semantics from the initial code data, wherein the code background includes at least one of the following: context information, grammatical structure and semantic relationship of the code data, and the code semantics is used to indicate information of multiple elements in the initial code data, as well as dependency relationship and / or calling order between the multiple elements; integrating the code background and code semantics to determine the code context data.
[0008] Optionally, based on the code context data, generating fill-in code data includes: obtaining a code completion model, wherein the code completion model is trained using code data samples corresponding to the initial code data; based on the code completion model and the code context data, generating fill-in code data.
[0009] Optionally, based on the code completion model and the code context data, filling code data is generated, including: inputting the code context data into the code completion model to determine missing code data, wherein the missing code data is used to indicate data missing from the initial code data; based on the missing code data, generating filling code data.
[0010] Optionally, before filling the filling code data into the initial code data to obtain the target code data, the code data filling method further includes: verifying the filling code data.
[0011] Optionally, the code data filling method further includes: storing the target code data and the initial code data in a database.
[0012] According to another aspect of an embodiment of the present invention, a device for filling code data is also provided. The device may include: an acquisition unit, used to acquire initial code data to be filled; a determination unit, used to determine code context data of the initial code data, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; a generation unit, used to generate filling code data based on the code context data; and a filling unit, used to fill the filling code data into the initial code data to obtain target code data.
[0013] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein when the program is executed by a processor, the device where the storage medium is located is controlled to execute the code data filling method in the embodiment of the present invention.
[0014] According to another aspect of an embodiment of the present invention, a processor is further provided, wherein the processor is used to run a program, wherein the method for filling code data in an embodiment of the present invention is executed when the program is run.
[0015] According to another aspect of an embodiment of the present invention, a computer program product is provided, which includes computer instructions, and when the computer instructions are executed by a processor, the method for filling code data in an embodiment of the present invention is implemented.
[0016] In an embodiment of the present invention, the initial code data to be filled is obtained; the code context data of the initial code data is determined, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; based on the code context data, the filling code data is generated; and the filling code data is filled into the initial code data to obtain the target code data. That is to say, the present invention generates the filling code data according to the code context data of the initial code data, and thus fills the initial code data according to the filling code data. Since the present invention can automatically analyze the context of the code data, intelligently identify the required filling code such as libraries and dependencies, and automatically generate the filling, the technical problem of low efficiency of code data filling is solved, and the technical effect of improving code data filling is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0018] Figure 1 is a flow chart of a method for filling code data according to an embodiment of the present invention;
[0019] Figure 2 is a flowchart of a method for automatically importing code based on an AI big model and natural language processing technology according to an embodiment of the present invention;
[0020] Figure 3 is a schematic diagram of an automatic import platform according to an embodiment of the present invention;
[0021] Figure 4 is a schematic diagram of a Kafka Broker and Zookeeper cluster deployment according to an embodiment of the present invention;
[0022] Figure 5 is a schematic diagram of an algorithm end architecture according to an embodiment of the present invention;
[0023] Figure 6 A schematic diagram of a database cluster according to an embodiment of the present invention;
[0024] Figure 7 is a schematic diagram of a device for filling code data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, functional component or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, functional components or devices.
[0027] According to an embodiment of the present invention, an embodiment of a method for filling code data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] Figure 1 is a flow chart of a method for filling code data according to an embodiment of the present invention. Figure 1 As shown, the method may include the following steps:
[0029] Step S101, obtaining the initial code data to be filled.
[0030] In the technical solution provided in the above step S101 of the present invention, the initial code data may also be referred to as code data to be completed.
[0031] In this embodiment, the initial code data to be filled is obtained, for example, through a user application, which is only an illustrative example and does not limit the specific method of obtaining the initial code data to be filled.
[0032] For example, a user application (such as the World Wide Web (Web) or an application (App)) sends the code data to be completed to a server when the user performs a corresponding operation, and the server stores the received code data to be completed in a disk.
[0033] Step S102, determining the code context data of the initial code data.
[0034] In the technical solution provided in the above step S102 of the present invention, the code context data is used to indicate the function, operation and semantic structure of the initial code data during the running process.
[0035] In this embodiment, after the initial code data to be filled is obtained in step S101, the code context data of the initial code data is determined. For example, the code context data of the initial code data is determined by an algorithm module, which is only an illustrative example and does not limit the specific method of determining the code context data of the initial code data.
[0036] For example, the algorithm module uses natural language processing (NLP) technology to deeply understand and analyze the context information, grammatical structure and semantic relationship of the initial code data, so as to determine the code context data of the initial code data.
[0037] Step S103, generating filling code data based on the code context data.
[0038] In the technical solution provided in the above step S103 of the present invention, the filling code data may also be referred to as a completion code.
[0039] In this embodiment, after the code context data of the initial code data is determined in step S102, the filling code data is generated by analyzing the code context data. For example, the key elements in the initial code data are determined by the code context data, so as to generate the filling code data. This is only an illustrative example, and the specific method of generating the filling code data is not limited.
[0040] For example, the key elements in the initial code data, such as variable names, function names, class names, etc., as well as their dependencies and calling order, are identified. Based on this, the algorithm module infers the missing code parts and generates matching completion codes.
[0041] Step S104, filling the filling code data into the initial code data to obtain the target code data.
[0042] In the technical solution provided in the above step S104 of the present invention, after the filling code data is generated in step S103, the filling code data is filled into the initial code data to obtain the target code data.
[0043] In this embodiment, the filling code data is integrated with the initial code data, that is, the filling code data is added to the initial code data to obtain the target code data.
[0044] Optionally, the target code data containing the fill code data can more comprehensively display the code functions and logic. Such target code data can help developers better understand the overall structure and execution flow of the code, making it easier to debug and optimize.
[0045] It should be noted that the above embodiment can be executed by a code data filling device.
[0046] In the above steps S101 to S104 of the present invention, the initial code data to be filled is obtained; the code context data of the initial code data is determined, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; based on the code context data, the filling code data is generated; and the filling code data is filled into the initial code data to obtain the target code data. That is to say, the present invention generates the filling code data according to the code context data of the initial code data, and thus fills the initial code data according to the filling code data. Since the present invention can automatically analyze the context of the code data, intelligently identify the required filling code such as libraries and dependencies, and automatically generate filling, the technical problem of low efficiency of code data filling is solved, and the technical effect of improving code data filling is achieved.
[0047] The above method of this embodiment is further introduced below.
[0048] As an optional implementation method, determining code context data of initial code data includes: extracting code background and code semantics from the initial code data, wherein the code background includes at least one of the following: context information, grammatical structure and semantic relationship of the code data, and the code semantics is used to indicate information of multiple elements in the initial code data, as well as dependency relationships and / or calling order between the multiple elements; integrating the code background and code semantics to determine the code context data.
[0049] In this embodiment, code background and code semantics are extracted from the initial code data, wherein the code background at least includes the context information, grammatical structure and semantic relationship of the initial code data, and the code semantics at least includes the key elements in the initial code data, such as variable names, function names, class names, etc., as well as the dependency relationship and calling sequence between them. Thus, the code background and code semantics are integrated to determine the code context data.
[0050] For example, the algorithm module uses natural language processing (NLP) technology to deeply understand and analyze the context information, grammatical structure and semantic relationship of the initial code data. At the same time, NLP technology enables the algorithm module to identify key elements in the initial code data, such as variable names, function names, class names, etc., as well as the dependencies and calling order between them, thereby determining the code context data.
[0051] As an optional implementation method, based on the code context data, fill-in code data is generated, including: obtaining a code completion model, wherein the code completion model is trained using code data samples corresponding to the initial code data; based on the code completion model and the code context data, the fill-in code data is generated.
[0052] In this embodiment, a code completion model is obtained, wherein the code completion model may also be a dual-channel code completion model. The code completion model is used to analyze the code context data to generate fill-in code data.
[0053] For example, a dual-channel code completion model is designed by integrating a pre-trained language model (Enhanced Representation throughkNowledge Integration, ERNIE for short), a bidirectional long short-term memory network (Bidirectional Long Short-Term Memory Network, BiLSTM for short), a text convolutional neural network (Text Convolutional Neural Network, TextCNN for short), a self-attention mechanism, and a feature fusion module.
[0054] As an optional implementation method, filling code data is generated based on a code completion model and code context data, including: inputting the code context data into the code completion model to determine missing code data, wherein the missing code data is used to indicate data missing from the initial code data; and generating filling code data based on the missing code data.
[0055] In this embodiment, the code context data is input into the code completion model for analysis to determine missing code data, wherein the missing code data may also be referred to as completion code.
[0056] Optionally, by inputting missing code data into the model, it can help the model better understand the context of the entire code, thereby improving the model's code completion accuracy.
[0057] As an optional implementation manner, before filling the filling code data into the initial code data to obtain the target code data, the code data filling method further includes: verifying the filling code data.
[0058] In this embodiment, the padding code data is verified, for example, the format of the padding code data is verified.
[0059] Optionally, format verification of the filled data can help ensure the accuracy of the data and avoid inaccurate or invalid data due to incorrect or irregular filling.
[0060] As an optional implementation manner, the method for filling code data further includes: storing the target code data and the initial code data in a database.
[0061] In this embodiment, the target code data and the initial code data are stored in a database. For example, a database cluster with a master-slave structure is used to store the processed code data and user feedback data.
[0062] For example, the target code data and the initial code data are stored in a data table using a database cluster, and user feedback data is also stored.
[0063] It should be noted that the above embodiment can be executed by a code data filling device.
[0064] In this embodiment, the initial code data to be filled is obtained; the code context data of the initial code data is determined, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; based on the code context data, the filling code data is generated; the filling code data is filled into the initial code data to obtain the target code data. That is to say, the present invention generates the filling code data according to the code context data of the initial code data, and thus fills the initial code data according to the filling code data. Since the present invention can automatically analyze the context of the code data, intelligently identify the required filling code such as libraries and dependencies, and automatically generate the filling, the technical problem of low efficiency of code data filling is solved, and the technical effect of improving code data filling is achieved.
[0065] The technical solution of the embodiment of the present invention is illustrated below in conjunction with preferred implementation modes.
[0066] At present, in the process of software development, managing project dependencies is one of the key links to ensure the smooth progress of the project. Data filling is a common operation in managing the program in the project. If the efficiency of filling data is low, the overall operation efficiency of the program will decrease. Efficient data filling can reduce the execution time of the program and improve the performance of the program.
[0067] Under normal circumstances, developers need to manually find, select and import the required code library dependencies, which is not only cumbersome but also error-prone. With the expansion of project scale and the complexity of dependency relationships, the workload of manually managing dependencies has increased dramatically, which has brought a heavy burden to developers. At the same time, manual import of dependencies may also lead to problems such as version mismatch and dependency conflicts, further affecting the stability and maintainability of the project. In order to solve this problem, some automated tools have appeared on the market to try to help developers manage project dependencies more efficiently. However, most of these tools rely on fixed templates or rules and cannot be intelligently identified and adjusted according to the actual needs of the project. Therefore, when using these tools, developers still need to spend a lot of time and energy on manual configuration and optimization. Therefore, there is a technical problem of low efficiency in code data filling. For the above-mentioned technical problem of low efficiency in code data filling, no effective solution has been proposed yet.
[0068] However, an embodiment of the present invention proposes an automatic code import method based on an AI big model and natural language processing technology, which collects the code to be completed, analyzes the code to be completed, determines the completion code, and then completes the code to be completed according to the completion code, thereby solving the technical problem of low efficiency of code data filling and achieving the technical effect of improving the efficiency of code data filling.
[0069] The embodiments of the present invention are further described below.
[0070] Figure 2 1 is a flowchart of a method for automatically importing code based on an AI big model and natural language processing technology according to an embodiment of the present invention. The method for automatically importing code based on an AI big model and natural language processing technology comprises the following steps:
[0071] Step S201, collecting and reporting code data to be completed.
[0072] In this embodiment, the user application (eg, Web, App) pushes the code data to be completed to the Kafka Broker using the Kafka Producer when the user performs a corresponding operation.
[0073] Step S202, receiving code data to be completed.
[0074] In this embodiment, the Kafka Broker accepts messages sent by producers and stores them on disk, while serving requests from consumers to pull partition messages and returning currently committed messages.
[0075] Step S203, consuming the code data to be completed.
[0076] In this embodiment, the consumer pulls the subscribed code data to be completed from the Kafka Broker cluster. Multiple consumers can asynchronously and in parallel read data from different topic partitions of Kafka to improve processing efficiency.
[0077] Optionally, the consumer consumes the pulled data. Specifically, it calls the method of the algorithm module to complete the original code data and convert it into a normal format code.
[0078] Optionally, message consumption refers to the process of receiving and processing messages or notifications sent to a specific target object. In computer science and communications, message consumption usually involves receiving messages from other systems or components and processing them, such as reading data, performing specific operations, or triggering corresponding events. Message consumption is an important communication method, especially common in distributed systems and microservices architectures, which can achieve decoupling and asynchronous communication between systems.
[0079] Step S204, completing the code data to be completed.
[0080] In this embodiment, the algorithm module is called to complete the original code data and convert it into normal format code. The algorithm module uses natural language processing technology (NLP) to deeply understand and analyze the context information, grammatical structure and semantic relationship of the original code data.
[0081] Optionally, NLP technology can enable the algorithm module to identify key elements in the code, such as variable names, function names, class names, etc., as well as their dependencies and calling order. On this basis, the algorithm module can intelligently infer the missing code parts and generate matching completion codes.
[0082] Step S205, storing the code and feedback data.
[0083] In this embodiment, the processed code data and user feedback data are stored efficiently and reliably. The code data is format-verified and stored in a data table using a database cluster, and the user feedback data is also stored, supporting efficient data analysis and product optimization.
[0084] Optionally, a database cluster with a master-slave structure is used to store processed code data and user feedback data. The master database is responsible for handling read and write operations, while the slave database serves as a backup to ensure high data availability. This structure also achieves load balancing, improves system performance, and has scalability to meet future growth needs.
[0085] Figure 3 Schematic diagram of an automatic import platform according to an embodiment of the present invention. Figure 3As shown, the automatic import platform 300 may include: a production end 301 , a Kafka cluster 302 , a consumer end 303 , an algorithm end 304 and a database cluster 305 .
[0086] The production end 301 is usually composed of various user applications, which use Kafka Producer to push the user's to-be-completed code to the Kafka Broker cluster 302 in real time. The Kafka cluster can also be called a Kafka Broker cluster.
[0087] The Kafka Broker cluster 302 mainly receives and processes messages from the production end 301 and transmits messages to the consumer end 303 .
[0088] The consumer end 303 is responsible for pulling data from the Kafka Broker cluster 302 and consuming the data.
[0089] The algorithm end 304 provides a code completion interface, and the code is completed by calling the interface through the consumer end 303.
[0090] The database cluster 305 is composed of multiple relational databases, and mainly stores the completion record table and the user record table.
[0091] Optionally, a Kafka Broker cluster refers to a cluster consisting of multiple Kafka Broker nodes, which is used to store and process data in the Kafka message queue. A Kafka Broker cluster usually contains multiple Broker nodes, each of which is responsible for storing and processing a portion of the data. By horizontally scaling Broker nodes, the throughput and reliability of the Kafka cluster can be improved.
[0092] Optionally, in a Kafka Broker cluster, each Broker node has its own independent storage and computing resources, which can handle requests from multiple producers and consumers at the same time. By distributing data copies among multiple Broker nodes, high availability and fault tolerance of data can be ensured. When a Broker node fails, other nodes in the cluster can take over its work to ensure the normal operation of the message queue.
[0093] Optionally, the scale and architecture of the Kafka Broker cluster can be flexibly adjusted according to business needs. By increasing or decreasing the number of Broker nodes, the performance and capacity of the cluster can be adjusted according to changes in data volume and access volume. At the same time, the performance and reliability of the cluster can be optimized by configuring appropriate replica replication strategies and data partitioning schemes.
[0094] Alternatively, the existing automatic import functions on the market may not fully meet the needs of all users and lack flexibility, resulting in inconvenience or inefficiency in use. By collecting user feedback and continuously optimizing functions, we can improve user experience and satisfaction. At the same time, we provide customizable options, enhance the flexibility and adaptability of functions, meet the personalized needs of different users, and thus increase user stickiness and frequency of use.
[0095] Optionally, the present invention designs an automatic code import platform based on AI big model and natural language processing technology, which solves the problem of cumbersome, error-prone and inefficient manual import of code library dependencies, realizes automatic identification of project requirements and intelligent import of required libraries and dependencies, ensuring the efficiency, accuracy and scalability of the system.
[0096] Optionally, the present invention has consistency and efficiency: by designing a standardized completion protocol, the problem of data differentiation in different application scenarios and business types in a distributed system is solved, ensuring the consistency and efficiency of data collection and processing.
[0097] Optionally, the present invention has system scalability and maintainability: when adding a new code completion task on the production side, there is no need to add a Kafka Topic and a completion protocol, which simplifies the complexity of system expansion and maintenance.
[0098] Optionally, the present invention has a code completion accuracy rate: a dual-channel code completion model designed by integrating ERNIE, BiLSTM, TextCNN, self-attention mechanism, and feature fusion module. Taking advantage of its ability to handle long texts, the user code is completed. Multiple comparative experimental results show that this model has achieved excellent results for the code to be completed provided by the user.
[0099] Optionally, the present invention has high availability: Kafka and the database in the system are deployed in a distributed cluster, and Kafka uses a partition copy mechanism, so even if a single node goes down, it will not affect the overall function, thereby ensuring the high availability of the system.
[0100] The following is a specific example of an automatic code import method based on an AI big model and natural language processing technology of the present invention to further illustrate.
[0101] Data collection and reporting of code to be completed. After the automatic import platform service is started, it is ready to accept requests and code completion tasks from front-end users. When the user clicks the publish task button on the web page, the data will be pushed to the Kafka Broker through the Kafka Producer in the format of the completion protocol.
[0102] Optionally, for completing the protocol data, the basic information includes the following fields: type, msg Id, channelCode, attr1, attr2, etc.
[0103] Optionally, type indicates project dependency completion, 0 indicates code reference completion, and 1 indicates code logic completion; msgId indicates a unique message ID, which consists of a 64-bit string.
[0104] Optionally, channel Code indicates a channel code, and its possible values are Web and App; attr1 and attr2 are extension fields for facilitating data expansion.
[0105] Optionally, the fields of the completion protocol are separated by |, and the format is as follows: "type|msgId|channelCode|attr1|attr2".
[0106] Optionally, the automatic import platform service client pushes data of this form to Topic A of Kafka Broker through Kafka Producer 0. Topic A indicates the topic of the completion code message.
[0107] The code data to be completed is received. Figure 4 is a schematic diagram of a Kafka Broker and Zookeeper cluster deployment according to an embodiment of the present invention, such as Figure 4 As shown, the Kafka cluster consists of Kafka Broker 0, Kafka Broker 1, and Kafka Broker 2.
[0108] Optionally, the Zookeeper cluster consists of zk1, zk2, and zk3. The Zookeeper server stores key information of the Kafka cluster, including recording information of all Kafka Broker servers, indicating which are Leaders, and recording available Broker instances.
[0109] Optionally, in the Kafka cluster, the code completion topic Topic A is divided into three partitions, each partition is distributed on a different Kafka Broker, and each partition has a replica.
[0110] For example, on Kafka Broker 0, the leader of the first partition of Topic A is Topic A-partition0-leader, and the replica is Topic A-partition0-follower. The leader of each partition is responsible for processing all read and write requests within the partition.
[0111] To consume the completed code data, the consumer side pulls the subscribed completed code topic data from the Kafka Broker cluster and reads data from different topic partitions of Kafka in parallel in the form of consumer groups to improve data consumption efficiency. Figure 4 As shown, Kafka Consumer Group represents a consumer group, including three consumers Kafka Consumer0, Kafka Consumer1, and Kafka Consumer2.
[0112] Optionally, Kafka Consumer N reads data from Topic A-partition N-leader, where N is 0, 1, or 2. After the consumer obtains the data, it first parses the completion protocol data and filters out the data that does not meet the completion protocol field conditions; then it converts the filtered code data to be completed into a structured data format of the code record table.
[0113] The code data to be completed is completed. Figure 5 is a schematic diagram of an algorithm end architecture according to an embodiment of the present invention. Figure 5 As shown in the figure, the core of the algorithm is a pre-trained ERNIE model, which is responsible for converting code snippets into vector representations containing rich context and semantic information.
[0114] Optionally, these vectors are then fed into a BiLSTM and a feature fusion module. The BiLSTM is able to capture long-term dependencies in the code and understand the context of the code from both directions.
[0115] Optionally, to reduce information loss, the algorithm introduces an attention mechanism, which helps the algorithm focus on the most important and relevant parts of the code.
[0116] Optionally, the code vector processed by the attention mechanism is merged with the original code vector in a feature fusion module to obtain a more comprehensive code feature representation.
[0117] Optionally, the algorithm also uses TextCNN to extract local features of the code and merge these features with the previous features.
[0118] Optionally, the synthesized code vector is fed into a fully connected layer and the probability distribution of possible completion options is calculated through a Softmax layer, thereby intelligently recommending the most likely completion result.
[0119] Optionally, the Softmax layer is a commonly used output layer in neural networks, which is used to convert the output of the last layer of the neural network into a probability distribution. The Softmax function converts the original output value into a probability value between 0 and 1, so that the sum of the probabilities of all outputs is 1, which can be used for multi-classification problems.
[0120] Optionally, the Softmax function is characterized by being able to amplify larger values and keep smaller values from being compressed too much, which can better distinguish the probability differences between different categories. The Softmax layer is often used in the output layer of a neural network, especially in multi-classification problems.
[0121] Code, feedback data storage, Figure 6 A schematic diagram of a database cluster according to an embodiment of the present invention. Figure 6 As shown in the figure, the MySQL database is used as an example. The Master is the MySQL master database, and Slave1 and Slave2 are MySQL slave databases. The MySQL cluster uses master-slave replication, where the master database is responsible for writing and the slave database is responsible for reading, improving the database read and write performance and the system throughput.
[0122] Optionally, code completion: a feature provided in a programming environment that aims to speed up the coding process by predicting code snippets that the programmer may want to type. This feature predicts and recommends possible completion options by analyzing the current context (such as variable names, function names, class names, grammatical structures, etc.) and the parts of the code that the programmer has already typed.
[0123] Optionally, publish and subscribe: a messaging paradigm in which the sender of a message (called a publisher) does not send the message directly to a specific receiver (called a subscriber), but broadcasts it through a message channel for subscribers who subscribe to the message topic to consume it.
[0124] Optionally, master-slave replication: data can be replicated from a database server master node to one or more slave nodes.
[0125] In this embodiment, by collecting the code to be completed, analyzing the code to be completed, and determining the completion code, the code to be completed is completed according to the completion code, thereby solving the technical problem of low efficiency of code data filling and achieving the technical effect of improving the efficiency of code data filling.
[0126] According to an embodiment of the present invention, a device for filling code data is also provided. It should be noted that the device for filling code data can be used to execute the method for filling code data in the method embodiment.
[0127] Figure 7 Schematic diagram of a device for filling code data according to an embodiment of the present invention. Figure 7 As shown, the code data filling device 700 may include: an acquisition unit 701, a determination unit 702, a generation unit 703 and a filling unit 704.
[0128] The acquisition unit 701 is used to acquire the initial code data to be filled.
[0129] The determination unit 702 is used to determine the code context data of the initial code data, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during the running process.
[0130] The generating unit 703 is used to generate filling code data based on the code context data.
[0131] The filling unit 704 is used to fill the filling code data into the initial code data to obtain the target code data.
[0132] Optionally, the determination unit 402 may include: an extraction module, used to extract code background and code semantics from the initial code data, wherein the code background includes at least one of the following: context information, grammatical structure and semantic relationship of the code data, and the code semantics is used to indicate information of multiple elements in the initial code data, as well as the dependency relationship and / or calling order between the multiple elements; an integration module, used to integrate the code background and code semantics to determine the code context data.
[0133] Optionally, the generation unit 703 may include: an acquisition module for acquiring a code completion model, wherein the code completion model is trained using a code data sample corresponding to the initial code data; and a generation module for generating fill-in code data based on the code completion model and code context data.
[0134] Optionally, the generation module may include: an input submodule, used to input code context data into the code completion model to determine missing code data, wherein the missing code data is used to indicate missing data in the initial code data; and a generation submodule, used to generate filling code data based on the missing code data.
[0135] Optionally, the device 700 for filling code data may further include: a verification unit, configured to verify the filled code data.
[0136] Optionally, the code data filling device 700 may further include: a storage unit, used to store the target code data and the initial code data in a database.
[0137] In this embodiment, the initial code data to be filled is obtained; the code context data of the initial code data is determined, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; based on the code context data, the filling code data is generated; the filling code data is filled into the initial code data to obtain the target code data. That is to say, the present invention generates the filling code data according to the code context data of the initial code data, and thus fills the initial code data according to the filling code data. Since the present invention can automatically analyze the context of the code data, intelligently identify the required filling code such as libraries and dependencies, and automatically generate the filling, the technical problem of low efficiency of code data filling is solved, and the technical effect of improving code data filling is achieved.
[0138] According to an embodiment of the present invention, a computer-readable storage medium is further provided. The storage medium includes a stored program, wherein the program executes the code data filling method in the method embodiment.
[0139] According to an embodiment of the present invention, a processor is further provided. The processor is used to run a program, wherein the method for filling code data in the method embodiment is executed when the program is running.
[0140] According to an embodiment of the present invention, a computer program product is further provided. The computer program product includes computer instructions. When the computer instructions are executed by a processor, the code data filling method in the method embodiment is implemented.
[0141] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0142] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0143] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, 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 units or modules, which can be electrical or other forms.
[0144] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0145] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0146] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent functional component, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software functional component, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc., which can store program codes.
[0147] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for filling code data, characterized in that: include: Get the initial code data to be filled; Determining code context data of the initial code data, wherein the code context data is used to indicate the function, operation and semantic structure of the initial code data during operation; Based on the code context data, generating fill code data; The filling code data is filled into the initial code data to obtain the target code data.
2. The method according to claim 1, characterized in that: Determining the code context data of the initial code data includes: Extracting code context and code semantics from the initial code data, wherein the code context includes at least one of the following: context information, grammatical structure and semantic relationship of the code data, and the code semantics is used to indicate information of multiple elements in the initial code data, and dependency relationship and / or calling order between the multiple elements; The code background and the code semantics are integrated to determine the code context data.
3. The method according to claim 1, characterized in that Based on the code context data, generating filling code data includes: Acquire a code completion model, wherein the code completion model is trained using a code data sample corresponding to the initial code data; The fill-in code data is generated based on the code completion model and the code context data.
4. The method according to claim 3, characterized in that Generating the filling code data based on the code completion model and the code context data includes: Inputting the code context data into the code completion model to determine missing code data, wherein the missing code data is used to indicate data missing from the initial code data; Based on the missing code data, filler code data is generated.
5. The method according to claim 1, characterized in that Before filling the filling code data into the initial code data to obtain the target code data, the method further includes: The padding code data is verified.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: The target code data and the initial code data are stored in a database.
7. A device for filling code data, characterized in that: include: An acquisition unit, used for acquiring initial code data to be filled; a determining unit, configured to determine code context data of the initial code data, wherein the code context data is used to indicate a function, an operation, and a semantic structure of the initial code data during operation; A generating unit, configured to generate filling code data based on the code context data; A filling unit is used to fill the filling code data into the initial code data to obtain a target code data filling unit, which is used for.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed by a processor, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
9. A processor, characterized in that: The processor is used to run a program, wherein the program executes the method according to any one of claims 1 to 6 when running.
10. A computer program product, characterized in that The computer program product comprises computer instructions, which implement the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Code completion method and system, electronic equipment and storage medium
CN115048105A