Method and device for assisting in compiling codes, medium and product
By analyzing code snippets and using knowledge graphs or deep learning modules to obtain technical information, assisting development objects in writing code, solving the problem of time-consuming searching documents and searching the network in the existing technology, improving code writing efficiency and development efficiency.
Patent Information
- Application Number
- CN202411332129.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-02-07
AI Technical Summary
During the existing software development process, development objects need to consult a large number of documents or search the network to obtain technical information when writing code, which results in long time and low efficiency, which increases the cost and time of software development and increases the difficulty of development.
By analyzing the code snippets of the development object, obtaining technical information related to the code snippets, using knowledge graphs or pre-trained deep learning modules to obtain technical solutions and technical hierarchical information, and displaying this information to the development object to assist in code writing.
This method helps development objects quickly obtain technical information required for code writing, improves code writing efficiency, reduces the cost and time of software development, reduces development difficulty, and improves development efficiency.
Smart Images

Figure CN119396377A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular, to a method, device, medium and product for assisting in writing code. Background Art
[0002] Software development is the process of building a software system or the software part of a system according to user requirements. Software development is a system engineering that includes demand capture, demand analysis, design, implementation and testing. In software development, software-related code writing is a crucial part of the entire software development process.
[0003] However, in the existing software development process, when developers write code, in order to improve the efficiency and accuracy of code writing, they often need to consult a large number of documents or search the Internet to obtain the required technical information. This process is time-consuming and inefficient, especially when developing software for complex technology stacks and frameworks. It takes more time to search for technical information, which greatly increases the cost and time of software development. This increases the difficulty of software development and reduces development efficiency. Summary of the invention
[0004] The embodiments of the present application provide a method, device, medium and product for assisting in writing code, which can solve the problem that the existing writing code requires a lot of time to search for technical information related to the code, which is time-consuming and inefficient, increases the cost and time of software development, increases the difficulty of software development, and reduces development efficiency. In order to achieve this purpose, the embodiments of the present application provide the following solutions.
[0005] According to one aspect of an embodiment of the present application, a method for assisting in writing code is provided, the method comprising:
[0006] Parse code snippets of development objects;
[0007] Acquire technical information related to the code snippet according to the parsing result of the code snippet, wherein the technical information is acquired based on a knowledge graph or a pre-trained deep learning module, and the technical information includes at least one of a technical solution and technical level information;
[0008] The technical information is displayed to the development object to assist the development object in writing codes.
[0009] In a possible implementation, the construction of the knowledge graph includes:
[0010] Performing structured processing on the acquired code data to generate structured data of the code data, wherein the code data includes at least one of API documents, open source project code comments, and technical forum posts, blog articles, and academic papers related to code writing;
[0011] Acquire entity information in the structured data and perform semantic analysis on the structured data, wherein the entity information includes entities and relationships between entities;
[0012] A knowledge graph is constructed based on the entity information and semantic parsing results.
[0013] In a possible implementation, the code snippet of parsing the development object includes:
[0014] Segmenting the code snippet into vocabulary units, and constructing a syntax tree based on the vocabulary units;
[0015] The code snippet is semantically analyzed based on the syntax tree, wherein the semantic analysis includes checking the logic correctness of the code snippet.
[0016] In a possible implementation, the acquiring technical information related to the code snippet according to the parsing result of the code snippet includes:
[0017] If it is determined that the semantic analysis is completed, a query request is sent to the knowledge graph based on the parsing results and features of the code snippet, the query results fed back by the knowledge graph are obtained, and the technical information related to the code snippet is determined based on the query results. The query results include the target knowledge graph nodes and edges that match the code snippet.
[0018] In a possible implementation, sending a query request to the knowledge graph according to the parsing result and features of the code snippet includes:
[0019] Acquire the features of the code snippet, and acquire scope limitation information of the code snippet according to the parsing result, wherein the scope limitation information includes meaning and context information;
[0020] The query request is generated according to the scope limitation information and the feature, and a query is initiated to the knowledge graph based on the query request.
[0021] In a possible implementation, the acquiring technical information related to the code snippet according to the query result includes:
[0022] Obtain the technical solution corresponding to the target knowledge graph node, and determine the technical level information according to the hierarchical relationship of the technical solution in the knowledge graph;
[0023] Obtain an alternative solution corresponding to the technical solution, and determine the technical information based on the technical solution, the technical level information and the alternative solution.
[0024] In a possible implementation, presenting the technical information to the development object includes:
[0025] Obtain ranking information of each technical solution in the technical information, and display the technical information on an interactive interface corresponding to the code snippet based on the ranking information, wherein the ranking information is determined based on at least one of the relevance, practicality, context adaptability, personalized adjustment information, balance, and preset display strategy of the technical solution.
[0026] According to one aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described above.
[0027] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described above are implemented.
[0028] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described above are implemented.
[0029] The beneficial effects of the technical solution provided by the embodiment of the present application are:
[0030] The method for assisting code writing provided by the present application includes: parsing the code snippet of the development object; obtaining technical information related to the code snippet based on the parsing result of the code snippet, the technical information including at least one of a technical solution and technical level information; displaying the technical information to the development object to assist the development object in writing code. When the development object writes code, the embodiment of the present application obtains relevant technical information based on the code snippet of the development object, and displays the technical information to the development object, which can help the development object quickly obtain the technical information required for code writing and improve code writing efficiency, thereby effectively reducing the cost and time of software development, reducing the difficulty of software development, and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following is a brief introduction to the drawings required for use in describing the embodiments of the present application.
[0032] Figure 1 A flowchart of a method for assisting in writing code provided in an embodiment of the present application;
[0033] Figure 2 This is a structural diagram of the electronic device of this application. DETAILED DESCRIPTION
[0034] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.
[0035] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation of other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the present technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" indicates that it is implemented as "A", or is implemented as "A", or is implemented as "A and B".
[0036] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0037] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.
[0038] The method, device, medium and product for assisting code writing provided in this application are intended to solve at least one technical problem existing in the prior art.
[0039] In an embodiment of the present application, a method for assisting in code writing is provided. The device for executing the method for assisting in code writing can be a mobile phone, a computer, a server, a cloud platform, or other terminal that can obtain code snippets written by the development object and use the code snippets to obtain technical information.
[0040] Optionally, the terminal can execute the method of the present application through a plug-in integrated into a code editing environment (such as Visual Studio Code, IntelliJIDEA), or can implement the method through cloud services or local deployment. In order to ensure the stable operation of the method, CI / CD pipeline automation testing and deployment can be used.
[0041] Alternatively, if Figure 1 As shown, the methods for assisting in writing code include:
[0042] S101: Parse the code snippet of the development object.
[0043] Optionally, the code snippet may be a code snippet written by the development object in an editor, or may be a code snippet stored in another external storage device or downloaded through the Internet by the development object.
[0044] Optionally, the operation of parsing the code snippet may be performed after receiving a parsing instruction from the development object, or after detecting that the length of the code snippet meets a preset length or receiving a technical information search instruction input by the development object.
[0045] Optionally, the semantic information of the code snippet is obtained by parsing the code snippet. The semantic information of the code snippet can be represented by obtaining an encoder in a deep learning model to convert the code snippet into a vector representation of a fixed length, or a syntax tree of the code snippet can be obtained and the semantic information of the code snippet can be obtained by using the syntax tree.
[0046] In one embodiment, when semantic information is obtained through a deep learning model, the deep learning model uses an encoder-decoder architecture, and the deep learning model can be used to connect code snippets and obtain technical information corresponding to the code snippets. Among them, the encoder is used to convert the input code snippet into a vector representation of a fixed length, and this vector can be used to represent the semantic information of the code snippet. The encoder in the deep learning model is composed of a multi-layer neural network, such as a long short-term memory network (LSTM), a gated recurrent unit (GRU) or a Transformer. During the encoding process, the encoder reads each element in the code snippet one by one (such as words, identifiers, operators, etc.), and gradually generates a vector representation related to the code snippet based on the read elements. This vector contains the global information of the code snippet, and the technical information related to the code snippet is obtained using this vector.
[0047] Optionally, when parsing using the syntax tree of the code snippet, parsing the code snippet of the development object includes: dividing the code snippet into vocabulary units, building a syntax tree based on the vocabulary units; and performing semantic analysis on the code snippet based on the syntax tree, wherein the semantic analysis includes checking the logical correctness of the code snippet. The syntax tree can be built by a syntax analyzer.
[0048] Optionally, the vocabulary units include basic constituent units of the code such as keywords, identifiers, numbers, character strings, operators, etc., and a lexical analyzer can be used to identify the basic constituent units of the code snippet and segment the basic constituent units to obtain a series of vocabulary units.
[0049] Optionally, semantic analysis includes type checking, symbol table construction, scope analysis, etc., and the meaning of the code snippet is obtained and the logical correctness of the code is ensured by semantic analysis. The specific operation of the semantic analysis may include checking whether the variable has been declared, whether the function call is correct, whether the data type matches, and other features related to the logic of the code. When it is determined that the logic of the code is incorrect, the incorrect part of the code snippet can be displayed to facilitate the modification of the development object. After the development object is modified, the semantic information is obtained based on the modified code snippet.
[0050] In one embodiment, a code snippet input by a development object is obtained through a development object editor, and when the development object inputs the code snippet, the plug-in embedded in the development object editor is used to monitor and parse the code snippet in real time. Wherein, the code snippet can be a code parsing engine. During code parsing, the code parsing engine in the plug-in performs lexical analysis on the input code through a lexical analyzer, and divides the code into a series of vocabulary units, such as keywords, identifiers, numbers, strings, operators and other basic constituent units of the code snippet. After the code snippet is divided into vocabulary units, the code parsing engine performs grammatical analysis on these vocabulary units through a grammatical analyzer, and constructs a grammatical tree for code judgment according to preset grammatical rules, so as to facilitate the logical structure of the code. After obtaining the grammatical tree, a semantic analysis is performed based on the grammatical tree to obtain the meaning of the code. The content of the semantic analysis includes type checking, symbol table construction, scope analysis, etc., to ensure the logical correctness of the code. For example, the relevant inspection content includes checking whether the variable has been declared, whether the function call is correct, whether the data type matches, etc. Wherein, the code parsing engine can be a parser generation tool such as ANTLR and Esprima, and can also include a custom grammatical parser.
[0051] Optionally, the structure of the code snippet is understood by splitting the code snippet into lexical units, obtaining a syntax tree, and performing semantic analysis, such as function calls, variable declarations, loops, conditional judgments, etc., which constitute the basic skeleton of the code. Semantic understanding further interprets the actual meaning of the code, understands the intent and function of the code snippet, and the role it plays in the larger context. This enables the system to identify the purpose and potential problems of the code and provide context-sensitive suggestions for development objects. By understanding the syntax and semantics of the code snippet, the code snippet can be mapped to the relevant nodes in the knowledge graph, so that the matching technical solutions, best practices, related documents, and alternatives can be retrieved. This is crucial for providing instant code assistance and solutions.
[0052] Optionally, during the code snippet parsing process, common syntax errors and logic loopholes can be identified based on the parsing results, and developers can be reminded in time to help them correct errors at an early stage and avoid potential bugs and maintenance costs. Based on the understanding of the code snippet, code refactoring suggestions, performance optimization techniques, and more efficient or concise code implementation methods can be provided to help improve code quality and development efficiency. In addition, by parsing the code snippet, key information (such as features) of the code snippet can be obtained. Based on this key information, the coding habits and preferences of the development object can be learned to provide more personalized code completion, code generation, and resource recommendations.
[0053] S102: Acquire technical information related to the code snippet according to the parsing result of the code snippet.
[0054] Optionally, the technical information includes at least one of a technical solution and technical level information.
[0055] Optionally, the technical solution includes at least one of technical principles, application scenarios, implementation details, performance indicators, compatibility and dependencies, best practices, alternative solutions, documentation and resource links, update history and version control, community support and ecosystem. Specifically, the technical principle explains the theoretical basis behind the technical solution, how it works, and what problems it solves. The application scenario describes the use scenario of the technical solution in actual development, including the type of problems it is suitable for solving and under what circumstances it performs best. The implementation details provide code examples, configuration parameters, interface descriptions and other specific steps required to implement the technical solution. The performance indicators describe the performance characteristics of the technical solution, including execution efficiency, resource consumption, scalability, etc. Compatibility and dependencies: List other technologies or libraries required by the technical solution, and its compatibility with the existing technology stack. Best practices: Give best practices when applying the technical solution, including design patterns, coding standards and potential pitfalls or precautions. Alternative solutions: Provide other solutions similar to the technical solution, including their respective advantages and disadvantages, to help developers make choices about the information. Document and resource links: Provide links to official documents, tutorials, case studies and community discussions to facilitate in-depth understanding and learning by development objects. Update history and version control: Describe the evolution of the technical solution, including important version updates and improvements. Community support and ecosystem: Describe the community activity, available tool chains, plug-ins, and third-party services of the technical solution. The information of the technical solution can help developers fully understand the characteristics and limitations of the technical solution, so as to make more appropriate choices and applications in the projects corresponding to the code snippets.
[0056] Optionally, the technology level information includes at least one of the composition of the technology stack, technology maturity and applicability, technology evolution path, relationship between technologies, best practices and patterns, alternatives, hierarchical structure of technology, and depth and breadth of technology. Among them, the composition of the technology stack: lists all technologies and tools used in a project or environment, such as programming languages, frameworks, libraries, middleware, etc., and the dependencies between them. Technology maturity and applicability: describes the maturity, stability and applicable scenarios of each technology, helping developers understand when and where these technologies are best used. Technology evolution path: provides the development history and future direction of the technology, which is very useful for long-term planning and maintenance of projects. Relationship between technologies: describes how different technologies interact and integrate with each other, including interface specifications, communication protocols, etc. Best practices and patterns: lists the best practices for using a certain technology in a specific context, including design patterns, coding standards, and solutions to common problems. Alternatives: provides a choice of different technologies with similar functions, including a comparison of their respective advantages and disadvantages, so that developers can make the best decision based on project requirements. Hierarchical structure of technology: Technology may be organized into layers, for example, low-level technology may provide basic functions, while high-level technology is built on top of it to provide higher levels of abstraction and functions. Depth and breadth of technology: Depth refers to the level of detail of the technology, while breadth refers to the scope of the technology. This helps developers understand the comprehensiveness and depth of the technology.
[0057] The above technical information can help developers better understand the technologies they are using or considering, so that they can make more informed decisions and improve development efficiency and code quality. For example, when encountering a problem, developers can quickly locate the technical level of the problem based on the technical level information and find appropriate solutions or alternative technologies.
[0058] Optionally, the technical information is obtained based on a knowledge graph or a pre-trained deep learning module. The construction of the knowledge graph includes: structuring the obtained code data to generate structured data of the code data, the code data includes API documents, open source project code comments, and at least one of technical forum posts, blog articles, and academic papers related to code writing; obtaining entity information in the structured data and performing semantic analysis on the structured data, the entity information includes entities and the relationship between entities; and constructing a knowledge graph based on the entity information and the semantic analysis results.
[0059] Optionally, before the code data is structured, the code data may be cleaned, which includes removing irrelevant or erroneous data, such as deleting duplicates, correcting format errors, filling missing values, removing noise, duplicate content, meaningless tags and HTML tags, and retaining plain text.
[0060] Optionally, the structured processing includes converting unstructured or semi-structured text in the code data into structured data, such as extracting information such as function signatures, parameters, return values, etc. in the API document.
[0061] Optionally, after obtaining the structured data, obtaining entity information in the structured data includes: using natural language processing technology to identify entities in the text, such as programming language names, framework names, library names, function names, class names, variable names, etc. Pre-trained named entity recognition models can be used to identify entities, such as BiLSTM+CRF, BERT. After identifying the entities in the structured data, the relationship between the entities is obtained based on the structured data, such as function calls, class inheritance, module dependencies, etc. Among them, the relationship between entities can be obtained through dependency syntax analysis, semantic role labeling, etc.
[0062] Optionally, to facilitate the construction of the knowledge graph, the natural language description in the structured data can be converted into a machine-understandable form through semantic parsing, such as parsing a text describing the function of a function into the input, output and behavior of the function. Specifically, a semantic parser, such as an AMR (Abstract Meaning Representation) parser, can be used to convert sentences in structured data into semantic graphs.
[0063] Optionally, when constructing a knowledge graph based on entity information and semantic parsing results, first obtain the structure of the knowledge graph, such as the types of nodes and edges, where nodes represent entities and edges represent semantic relationships between entities. Map the preprocessed and analyzed data to the knowledge graph to create nodes and edges of the knowledge graph. The knowledge graph also stores the semantic parsing results and code data corresponding to the nodes and edges. The created knowledge graph can use graph database technologies, such as Neo4j, RDF4J, etc., to store and manage the knowledge graph.
[0064] Optionally, after creating the knowledge graph, the knowledge graph is deduplicated, missing information is supplemented, and erroneous information is corrected. In addition, rule reasoning and / or a preset machine learning model can be used to infer the implicit relationship between nodes in the knowledge graph to enrich the knowledge graph.
[0065] Optionally, after the knowledge graph is created, it can be updated regularly to incorporate new technical documents, codes, and discussions to keep the knowledge current. The knowledge graph can also be optimized based on user feedback and usage to improve the accuracy of recommendations and searches.
[0066] In this way, a knowledge graph containing multiple programming languages, technical frameworks, and solutions can be built, thereby providing real-time, context-related code snippets and technical documentation recommendations when developers write code.
[0067] Optionally, when obtaining technical information through the knowledge graph, technical information related to the code snippet is obtained based on the parsing results of the code snippet, including: if it is determined that the semantic analysis is completed, a query request is sent to the knowledge graph based on the parsing results and features of the code snippet, and the query results fed back by the knowledge graph are obtained, and the technical information related to the code snippet is determined based on the query results, and the query results include the target knowledge graph node that matches the code snippet.
[0068] Optionally, a query request is sent to the knowledge graph based on the parsing results and features of the code snippet, including: obtaining the features of the code snippet, obtaining scope limitation information of the code snippet based on the parsing results, the scope limitation information including meaning and context information; generating a query request based on the scope limitation information and the features, and initiating a query to the knowledge graph based on the query request.
[0069] Optionally, obtaining the features of the code snippet may include obtaining the grammatical structure of the code (such as a syntax tree) according to the parsing result of the code snippet and obtaining feature data of the code snippet. The feature data includes function calls, variable types, API usage, etc.
[0070] In one embodiment, the meaning and context information of the code snippet can be obtained according to the parsing result of the code snippet in the parsing result, and the meaning and context information include the context environment of the code snippet, the framework or library used, the project location and dependency, the code scope (such as local variables or global variables) and environment (such as server-side or client-side), the code style mode (the design pattern or programming paradigm followed, such as object-oriented, functional programming or event-driven programming), historical code and version control. Specifically, the context environment includes the programming language, framework, library corresponding to the context of the code and the location of the code in the project.
[0071] In one embodiment, the query request can be generated based on the query language of the graph database, such as Cypher (the query language of Neo4j) or SPARQL (the query language of the RDF database), and the object receiving the query request generates a query request according to the query language of the graph database corresponding to the knowledge graph.
[0072] Optionally, the nodes and edges in the knowledge graph that are most relevant to the code snippet can be obtained based on similarity calculation. The similarity between the code snippet and the nodes in the knowledge graph can be calculated based on content similarity and semantic similarity. The knowledge graph nodes and edges with similarity greater than a predetermined threshold are determined as query results.
[0073] Optionally, after obtaining the query results by indicating the graph, technical information related to the code snippet is obtained according to the query results, including: obtaining the technical solution corresponding to the target knowledge graph node, and determining the technical hierarchy information according to the hierarchical relationship of the technical solution in the knowledge graph; obtaining alternative solutions corresponding to the technical solution, and determining the technical information based on the technical solution, technical hierarchy information and alternative solutions.
[0074] Optionally, when obtaining alternative solutions, the technical problem solved by the technical solution can be obtained, and collaborative filtering technology and the technical problem can be used to obtain similar technical solutions that solve the same or similar technical problems, and the similar technical solutions can be determined as alternative solutions.
[0075] Optionally, when multiple technical solutions are obtained, the similarity and practicality between each technical solution and the code snippet may be obtained, and the obtained technical information may be sorted according to the similarity and practicality.
[0076] Optionally, when obtaining technical information through a deep learning model, the code snippet is first converted into a vector of fixed length using the encoder in the deep learning model, and the vector is transmitted to the decoder. The decoder outputs a technical solution related to the code snippet based on the vector representation generated by the encoder. The decoder is the same as the encoder and can also be an LSTM, GRU or Transformer structure. It will gradually generate a description of the technical solution based on the output of the encoder. The description of the technical solution can be a text description, a label of the technical solution, or a pointer to a specific node in the knowledge graph. The technical solution related to the code snippet is obtained based on the description.
[0077] Optionally, to improve the predictive power of the deep learning model, an attention mechanism can be added between the encoder and the decoder. This attention mechanism allows the decoder to generate outputs not only relying on the fixed vector representation generated by the encoder, but also weighting the sequence of vectors generated by the encoder to focus on the most valuable parts for the current prediction.
[0078] Optionally, the training of the deep learning module can be based on a large amount of code snippets and technical solution pairing data. The pairing data can be generated based on the acquired code data. The goal of the training is to minimize the difference between the predicted technical solution and the actual technical solution. Specifically, the cross entropy loss function or other appropriate loss functions can be used to reduce this difference. During the training process, the weights of the encoder and decoder are adjusted through the back propagation algorithm to optimize the prediction performance of the model.
[0079] The prediction result of the model may be a probability distribution, indicating the possibility of different technical solutions matching the code snippet, or a direct label, which indicates the most likely technical solution and displays the technical level information related to the technical solution when the developer views the technical solution. Through this encoder-decoder structure, it is possible to predict the relevant technical solutions based on the input code snippet, thereby providing targeted guidance and suggestions for the developer. In this way, even when processing long sequences, the model can better capture the key information in the input sequence.
[0080] S103: Displaying technical information to the development object to assist the development object in writing codes.
[0081] Optionally, after obtaining the technical information related to the code snippet, the technical information can be displayed on the editing interface corresponding to the code snippet or on one side of the editing interface. An icon for jumping to the technical information display interface can also be displayed on the editing interface, and the development object jumps to the technical information display interface by clicking the icon.
[0082] Optionally, when displaying technical information, information of code input or code snippet modification by the development object may also be obtained, a new code snippet may be obtained based on the information, and recommended information may be obtained based on the new code snippet.
[0083] Optionally, when displaying technical information, a brief description of the technical solution can be displayed, and detailed content, including code examples, document links, etc., can be expanded based on click operations on the development object.
[0084] Optionally, when displaying technical information, a search instruction of the development object may be received, specific keywords or technical points in the technical information may be searched according to the search instruction, and the technical information may be displayed based on the search results.
[0085] Optionally, displaying technical information to the development object includes: obtaining sorting information of each technical solution in the technical information, and displaying the technical information in an interactive interface corresponding to the code snippet based on the sorting information, wherein the sorting information is determined based on at least one of the relevance, practicality, context adaptability, personalized adjustment information, balance, and preset display strategy of the technical solution.
[0086] In one embodiment, when sorting according to relevance, the relevance score of each matching result can be given based on the similarity calculation between the code snippet and the node in the knowledge graph. This score is based on multiple factors, including the matching degree of code features, the consistency of semantic understanding, and the applicability of the technical solution. When sorting according to practicality, the practicality of each technical information is evaluated. It can be determined based on factors such as the novelty, detailedness, ease of understanding and difficulty of implementation of the information. Among them, it can be based on the feedback of the development object on similar technical information and the popularity and maturity of the technical solution in the technical information. When sorting based on context adaptability, the ranking of technical information can be adjusted according to the context of the code (such as the programming language, framework, library, etc. used) to ensure that the recommended technical solution matches the specific needs of the development object. When sorting information based on personalization, the recommendation list can be adjusted based on the historical behavior, personal settings and preferences of the development object to provide personalized sorting. When sorting based on balance, the technical solution is sorted according to the novelty of the technical solution. Among the multiple technical solutions of the technical information, if the angle or solution of the technical solution is different from that of other technical solutions, it can be ranked first or in a higher position. When displaying technical information, you can filter out duplicate or obviously irrelevant information to improve the refinement of the displayed technical information and ensure that each recommended technical information is unique and valuable.
[0087] Optionally, after the technical information is sorted, it can be displayed according to a preset display strategy. The sorted technical information will be displayed to the user in a certain strategy, including paging display, classification by category, or highlighting the most popular suggestions. It can also provide filtering options for technical information, so that users can further filter the results according to their needs, such as sorting by time, popularity, or relevance. The rules for technology sorting and filtering can be dynamically adjusted according to the feedback of the development object or the set performance indicators to continuously optimize the experience and recommendation effect.
[0088] Optionally, if multiple development objects use the same technology stack or solve similar problems, recommendation preferences can be learned from their behavior patterns, and technical information matching the code snippet can be determined based on the recommendation preferences and the technical information can be displayed. Among them, the technology stack corresponding to the code snippet or the code snippet that solves similar technical problems can be obtained based on at least one of the parsing results of the code snippet, the usage of editor plug-ins, the project file structure and dependency management files, the collaboration and contribution mode, and the behavior data. Specifically, the code snippets submitted by multiple development objects can be obtained to identify the programming languages, frameworks, libraries, API calls, etc. used. If multiple code snippets show similar technical elements, it can be inferred that these development objects are using the same technology stack. The plug-ins installed and used by the development objects in the code editor can also be obtained to determine whether they use the same technology or framework. For example, if multiple development objects have installed the React code completion plug-in, this indicates that they may all be developing applications based on React. The project file structure and dependency management files (such as package.json, pom.xml, etc.) can also be analyzed, and common dependency libraries and project configurations can be identified based on the analysis results, which is a sign of using the same technology stack. In an open source project or team development environment, by analyzing Git commit records, code review requests, and merge conflicts, you can identify whether developers are working together to solve the same or related problems. You can also collect and analyze developer interaction data, such as search history, technical documents viewed, and recommended solutions adopted, and determine developer preferences and commonly used technology stacks based on this interaction data.
[0089] This method can be used to identify groups of developers who use the same technology stack or solve similar problems, which helps provide more personalized and relevant recommendations. For example, if it is found that a group of developers are all using the Angular framework, it can prioritize Angular-related technical information, thereby improving the accuracy and practicality of the recommendations.
[0090] Optionally, after displaying the technical information, feedback information from the development object can be obtained, and the knowledge graph can be updated according to the feedback information. Specifically, the update of the knowledge graph includes:
[0091] Collect feedback data: Obtain user evaluation of recommended technical information, including: likes, marking irrelevant, requesting more information, etc., to express satisfaction or specific needs for recommended content in different ways. The collected feedback data is analyzed regularly to identify technical information that is considered useful and situations that do not meet needs. Determine whether the knowledge graph needs to be corrected based on the feedback data, and determine the correction method based on the feedback data. The correction method deletes inaccurate or outdated information, supplements missing details, or adds new technical solutions and alternative solutions. Feedback data can also be used to discover blank areas in the knowledge graph and guide the expansion of the knowledge graph. The relationship and weight between nodes in the knowledge graph can also be adjusted based on feedback data. For example, if it is determined based on feedback data that the development object is often recommended another irrelevant solution when searching for a certain technical solution, the relationship weight between the knowledge graph nodes corresponding to the two technical solutions is adjusted to reduce mismatches.
[0092] Optionally, as technology evolves and new frameworks emerge, the knowledge graph needs to be updated regularly to include new technical documentation, code examples, and discussions to keep the knowledge graph current and comprehensive.
[0093] Optionally, the deep learning model can also be adjusted based on the feedback data. The adjustment includes at least one of algorithm parameter adjustment, model iteration, and introduction of new algorithms. Specifically, algorithm parameter adjustment: adjust the parameters of the recommendation algorithm in the model according to the feedback, such as the threshold of similarity calculation, feature weight, etc., to improve the accuracy of the recommendation. Model iteration: use the feedback data as part of the training set to retrain or fine-tune the recommendation algorithm, such as the deep learning model or collaborative filtering model. Introduce a new algorithm: introduce new recommendation algorithms or technologies based on feedback data, such as content-based recommendations, user-based recommendations, or hybrid recommendation methods to improve the diversity or personalization level of recommendations. After each algorithm optimization, rigorous testing and evaluation are carried out to ensure that the modifications have indeed improved the quality of the recommendations. The performance of the algorithm before and after optimization can be compared using A / B testing to obtain test and evaluation results, and the model can be adjusted based on the results (such as confirming that the optimization is complete and no further adjustments are made or the optimization is wrong, and the unoptimized algorithm is still used).
[0094] Optionally, you can also obtain interaction data of the development object, such as click-through rate, dwell time, etc., and build a user behavior model based on the interaction data to more accurately predict user needs and preferences, thereby optimizing the recommendation strategy.
[0095] In an optional embodiment, an electronic device is provided, such as Figure 2 As shown, Figure 2The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.
[0096] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0097] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0098] Memory 4003 can be ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or it can be EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disc, optical disk, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage medium, other magnetic storage devices or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation here.
[0099] The memory 4003 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.
[0100] Among them, the electronic device can be any electronic product that can interact with an object, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0101] The electronic device may also include a network device and / or an object device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers for cloud computing.
[0102] The network where the electronic device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), etc.
[0103] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0104] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0105] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of this application 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 numbers used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that shown or described in the drawings.
[0106] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.
[0107] The above is only an optional implementation method for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.
Claims
1. A method for assisting code writing, characterized in that: The method comprises: Parse code snippets of development objects; Acquire technical information related to the code snippet according to the parsing result of the code snippet, wherein the technical information is acquired based on a knowledge graph or a pre-trained deep learning module, and the technical information includes at least one of a technical solution and technical level information; The technical information is displayed to the development object to assist the development object in writing codes.
2. The method for assisting in writing code according to claim 1, characterized in that: The construction of the knowledge graph includes: Performing structured processing on the acquired code data to generate structured data of the code data, wherein the code data includes at least one of API documents, open source project code comments, and technical forum posts, blog articles, and academic papers related to code writing; Acquire entity information in the structured data and perform semantic analysis on the structured data, wherein the entity information includes entities and relationships between entities; A knowledge graph is constructed based on the entity information and semantic parsing results.
3. The method for assisting in writing code according to claim 1, characterized in that: The code snippet for parsing the development object includes: Segmenting the code snippet into vocabulary units, and constructing a syntax tree based on the vocabulary units; The code snippet is semantically analyzed based on the syntax tree, wherein the semantic analysis includes checking the logic correctness of the code snippet.
4. The method for assisting in writing code according to claim 3, characterized in that: The obtaining of technical information related to the code snippet according to the parsing result of the code snippet includes: If it is determined that the semantic analysis is completed, a query request is sent to the knowledge graph based on the parsing results and features of the code snippet, the query results fed back by the knowledge graph are obtained, and the technical information related to the code snippet is determined based on the query results. The query results include the target knowledge graph nodes and edges that match the code snippet.
5. The method for assisting in writing code according to claim 4, characterized in that: The sending a query request to the knowledge graph according to the parsing result and features of the code snippet includes: Acquire the features of the code snippet, and acquire scope limitation information of the code snippet according to the parsing result, wherein the scope limitation information includes meaning and context information; The query request is generated according to the scope limitation information and the feature, and a query is initiated to the knowledge graph based on the query request.
6. The method for assisting in writing code according to claim 4, characterized in that: The obtaining of technical information related to the code snippet according to the query result includes: Obtain the technical solution corresponding to the target knowledge graph node, and determine the technical level information according to the hierarchical relationship of the technical solution in the knowledge graph; Obtain an alternative solution corresponding to the technical solution, and determine the technical information based on the technical solution, the technical level information and the alternative solution.
7. The method for assisting in writing code according to claim 1, characterized in that: The presenting the technical information to the development object includes: Obtain ranking information of each technical solution in the technical information, and display the technical information on an interactive interface corresponding to the code snippet based on the ranking information, wherein the ranking information is determined based on at least one of the relevance, practicality, context adaptability, personalized adjustment information, balance, and preset display strategy of the technical solution.
8. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Code management system and method based on software demand design
CN120162034A
Multi-agent code production method and system and electronic equipment
CN120994180A