Code verification method and device, storage medium and electronic equipment

Through the code development problem response system, the code is automatically extracted and compiled to solve the problem of low code efficiency in manual input in web front-end development, and the process of rapid verification and efficient problem solving is realized.

CN119322728APending Publication Date: 2025-01-17SUPCON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310774381.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-28
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

During the web front-end development process, developers need to manually find and enter solution code, which leads to inefficient and error-prone.

Method used

Provide a code verification method and device. Through the code development question answering system, users enter questions in the front-end question answering interface, and the intelligent question answering module generates answering data. The system automatically extracts and displays the solution code, and compiles and runs it after the user edits it to obtain verification. result.

Benefits of technology

No need for users to manually enter code, which shortens code verification time, improves work efficiency, and reduces manual participation and error rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322728A_ABST
    Figure CN119322728A_ABST
Patent Text Reader

Abstract

The invention provides a code verification method and device, a storage medium and electronic equipment, which are applied to a code development question response system, when a user inputs a code development question on a front-end question-answering interface, response data corresponding to the code development question fed back by an intelligent question-answering module is obtained, a question solving code is extracted from the response data, and the question solving code is sent to a server; the problem solving codes are displayed in a code editing area; in response to the code editing instruction, a problem solving code in a code editing area is edited, and a to-be-verified code is obtained; the to-be-verified code is compiled, the compiled code is operated on the operation interface, a verification result of the to-be-verified code is obtained, and the verification result comprises a verification conclusion about whether the to-be-verified code solves the code development problem or not. In the code verification process, a user does not need to manually input problem solving codes into a code editing area for editing, the verification time of the problem solving codes is shortened, and the working efficiency of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of front-end development technology, and in particular to a code verification method and device, a storage medium and an electronic device. Background Art

[0002] When developers encounter problems in function development during web front-end development, they usually search for solutions to the problem on search engines. After finding a solution, the developer needs to filter out the corresponding code from the solution, transfer the filtered code to the development project by manual input, and run the code in the development project to verify whether the code can solve the problem encountered by the developer. This process requires the full participation of the developer, and the entire process takes a lot of time, reducing the efficiency of the staff. Summary of the invention

[0003] In view of this, the present invention provides a code verification method and device, a storage medium and an electronic device. By applying the method provided by the present invention, in the process of verifying whether the code can solve the development problem, there is no need for the user to manually input the code, which can effectively shorten the time required for code verification and improve the work efficiency of the staff.

[0004] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0005] A code verification method, applied to a code development question answering system, comprises:

[0006] When a user inputs a code development question in a preset front-end question-and-answer interface, the preset intelligent question-and-answer module obtains answer data based on the code development question feedback;

[0007] Displaying the response data to the user on a preset display interface;

[0008] When receiving the code extraction instruction fed back by the user, extracting the problem solving code from the response data, and displaying the problem solving code in a preset code editing area;

[0009] When receiving the code editing instruction fed back by the user, editing the problem solving code displayed in the code editing area in response to the code editing instruction, to obtain the code to be verified for the code development problem;

[0010] When the code running instruction fed back by the user is received, the code to be verified is compiled, and the compiled code is run in a preset running interface to obtain a verification result of the code to be verified, and the verification result includes a verification conclusion on whether the code to be verified solves the code development problem.

[0011] A code verification device, applied to a code development question answering system, comprising:

[0012] An acquisition unit, configured to acquire, when a user inputs a code development question in a preset front-end question-and-answer interface, answer data fed back by a preset intelligent question-and-answer module based on the code development question;

[0013] A display unit, used to display the response data to the user on a preset display interface;

[0014] an extraction unit, configured to extract a problem-solving code from the response data when receiving a code extraction instruction fed back by the user, and display the problem-solving code in a preset code editing area;

[0015] An editing unit, configured to, when receiving a code editing instruction fed back by the user, edit the problem-solving code displayed in the code editing area in response to the code editing instruction to obtain a code to be verified for the code development problem;

[0016] The compiling unit is used to compile the code to be verified when receiving the code running instruction fed back by the user, and run the compiled code in a preset running interface to obtain the verification result of the code to be verified, and the verification result includes the verification conclusion of whether the code to be verified solves the code development problem.

[0017] A storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the code verification method as described above.

[0018] An electronic device includes a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the code verification method as described above.

[0019] Compared with the prior art, the present invention has the following advantages:

[0020] The present invention provides a code verification method and device, a storage medium and an electronic device, which are applied to a code development problem answering system. When a user inputs a code development problem in a front-end question and answer interface, the answer data corresponding to the code development problem fed back by the intelligent question and answer module is obtained, and then the problem-solving code is extracted from the answer data, and the problem-solving code is displayed in a code editing area. In response to a code editing instruction, the problem-solving code in the code editing area is edited to obtain a code to be verified, and then the code to be verified is compiled, and the compiled code is run in a running interface to obtain a verification result of the code to be verified, wherein the verification result includes a verification conclusion of whether the code to be verified solves the code development problem. When receiving a code development problem input by a user, the present invention obtains the answer data corresponding to the code development problem fed back by the intelligent question and answer module, extracts the problem-solving code in the application data, and then displays the problem-solving code to the user in the code editing area, and the user can directly edit it in the code editing area, thereby eliminating the need for the user to manually enter the problem-solving code into the code editing area for editing, thereby shortening the verification time of the code to solve the problem and effectively improving the user's work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0022] Figure 1 A method flow chart of a code verification method provided by an embodiment of the present invention;

[0023] Figure 2 A flow chart of a method for extracting a problem-solving code from response data provided by an embodiment of the present invention;

[0024] Figure 3 A schematic diagram of the architecture of a code development question answering system provided by an embodiment of the present invention;

[0025] Figure 4 A flow chart of a method for extracting codes by an online code extraction module provided in an embodiment of the present invention;

[0026] Figure 5 A flow chart of a method for editing code by an online code editing processing module provided in an embodiment of the present invention;

[0027] Figure 6 A flow chart of a method for compiling code by a code compiling execution module provided in an embodiment of the present invention;

[0028] Figure 7A flow chart of a method for running code provided by an embodiment of the present invention;

[0029] Figure 8 A flowchart of a code verification method executed by a code development question answering system provided by an embodiment of the present invention;

[0030] Fig. 9 A schematic diagram of the structure of a code verification device provided by an embodiment of the present invention;

[0031] Fig.10 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.

[0033] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0034] Terminology explanation:

[0035] chatGPT: is a natural language processing model based on the Transformer architecture, developed by OpenAI. It is a large-scale, unsupervised language model that can achieve excellent performance in multiple NLP tasks, such as text classification, machine translation, and dialogue generation. Currently, ChatGPT is widely used in intelligent customer service, chatbots and other fields due to its excellent performance in dialogue generation tasks.

[0036] npm: It is a package manager for Node.js that can be used to install, manage, and share JavaScript packages. Through npm, developers can easily download and install JavaScript packages, and can also publish their own JavaScript packages to npm for others to use.

[0037] markdown-it: An npm package, which is a Markdown parser written in JavaScript, which can convert Markdown formatted text into HTML. It supports standard Markdown syntax as well as some extended functions, and can be used on both the browser side and the server side.

[0038] AST: AST (Abstract Syntax Tree) is a tree data structure that represents the structure of code. In computer science, AST is often used in the implementation of compilers, interpreters and other programs.

[0039] Babel: is a tool for converting new versions of JavaScript code into backward-compatible JavaScript code. It can convert JavaScript code written with the latest syntax and features into code that can run in existing browsers and environments. The technologies involved in Babel include lexical analysis, syntax analysis, abstract syntax tree (AST) conversion, etc.

[0040] codeMirror: is a browser-based code editor library implemented in JavaScript.

[0041] As can be seen from the background technology, currently when developers encounter problems in web front-end development, they need to manually find solution codes and then manually input the solution codes into the development project. The whole process takes a lot of time, resulting in low efficiency in solving the problem.

[0042] When solving development problems, in addition to the solutions described in the background technology, with the emergence of chatGPT question-and-answer AI robots, technical problems in front-end development can now be directly thrown to chatGPT. The AI ​​robot will give specific code solutions based on previous learning experience and context, but it is still necessary to manually extract the code to the development environment for result verification. The process of manually copying or entering the code to the local development environment for verification is time-consuming, labor-intensive, and error-prone, which greatly affects the work efficiency of developers in the field of web front-end technology.

[0043] To solve the above problems, the present invention provides a code verification solution, which is applied to a code development problem answering system, thereby effectively shortening the time for solving development problems encountered by developers, improving problem solving efficiency and improving the work efficiency of developers.

[0044] The present invention can be used in many general or special computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, distributed computing environments including any of the above devices or devices, etc.

[0045] Reference Figure 1 , is a method flow chart of a code verification method provided by an embodiment of the present invention, the method can be applied to a code development question answering system, about Figure 1 The instructions are as follows:

[0046] S101. When a user inputs a code development question in a preset front-end question-and-answer interface, response data based on feedback of the code development question from a preset intelligent question-and-answer module is obtained.

[0047] The user of the present invention can be a developer, and the front-end question and answer interface is one of the interactive pages of the web front-end interactive interface module of the code development question answering system. The web front-end interactive interface module is arranged at the front end of the code development question answering system, and the web front-end interactive interface module is used to provide various interfaces for interacting with the user.

[0048] Developers can enter code development problems encountered during web front-end development in the front-end Q&A interface. After the user enters the code development problem in the front-end Q&A interface, the code development problem can be sent to the intelligent Q&A module, and then the intelligent Q&A module can obtain the response data based on the code development problem feedback.

[0049] It should be noted that the intelligent question and answer module can be an AI question and answer robot using chatGPT technology, or other modules with question and answer interactive functions.

[0050] Furthermore, the front end of the code development question answering system calls a pre-configured intelligent question and answer module interface to send the code development question to the intelligent question and answer module, triggering the intelligent question and answer module to search for solutions corresponding to the code development question; and obtains answer data generated by the intelligent question and answer module based on the solution content through the intelligent question and answer module interface.

[0051] The front end of the code development question answering system calls the intelligent question and answer module interface, sends the code development questions to the intelligent answer module, and then obtains the answer data fed back by the intelligent answer module through the intelligent question and answer module interface; it should be noted that the intelligent answer module interface is pre-configured in the interface module, and the interface is used to support data interaction between the front end and the intelligent answer module. Furthermore, when configuring the intelligent answer module interface in the interface module, it is necessary to apply for a service account for the intelligent question and answer module. For example, when the intelligent question and answer module is a chatGPT intelligent robot, it is necessary to apply for a chatGPT service account at this time; obtain the interface key corresponding to the service account, and use the interface key to configure the intelligent question and answer module interface, thereby improving the security when calling the interface.

[0052] S102: Display the response data to the user on a preset display interface.

[0053] It should be noted that the display interface is one of the interactive interfaces in the web front-end interactive interface module.

[0054] The code development question answering system displays the answering data to the user on the display interface.

[0055] It should be noted that the response data includes but is not limited to codes for solving code development problems.

[0056] S103: When receiving a code extraction instruction fed back by the user, extract the problem-solving code from the response data, and display the problem-solving code in a preset code editing area.

[0057] Preferably, a run button may be provided in the display page, and when the user clicks the run button, the code development question answering system receives the code extraction instruction.

[0058] It should be noted that when there is code in the display page, the run button is displayed to the user, and when there is no code in the display page, the run button can be hidden.

[0059] Reference Figure 2 , which is a flow chart of a method for extracting a problem-solving code from response data provided by an embodiment of the present invention, and is specifically described as follows:

[0060] S201. The lexical analysis module of the preset code online extraction module in the code development question answering system parses the answering data to obtain a data label list corresponding to the answering data.

[0061] It should be noted that the front end of the code development question answering system is provided with a code online extraction module, and the code development question answering system uses the code online extraction module to extract the problem solving code from the answering data.

[0062] Furthermore, a lexical analysis module is set in the code online extraction module, and the lexical analysis module parses the response data to obtain a data label list corresponding to the response data.

[0063] Preferably, the lexical analysis module can be a markdown-it module. Exemplarily, the markdown-it module first calls its external parse method, passes the return content as a parameter, and finally obtains a Token list including an AST structure. The Token list here is the data tag list above.

[0064] S202: The online code extraction module determines a tag corresponding to a preset data type in a data tag list as a target tag, and caches a data segment corresponding to the target tag.

[0065] Then the code online extraction module screens the data tag list to determine the target tag; preferably, the preset data type can be a tag with a type attribute of fence, and then the data fragment with a type attribute of fence is cached.

[0066] Furthermore, there is at least one data segment, and after the data segment is cached, the run button mentioned above can also be displayed.

[0067] S203: The online code extraction module extracts code fragments from the cached data fragments, and merges the extracted code fragments to obtain a problem-solving code.

[0068] The code online extraction module extracts code snippets from the data snippets. When there are multiple extracted code snippets, the code snippets are merged to obtain the problem-solving code. When there is only one extracted code snippet, the code snippet is determined as the problem-solving code.

[0069] It should be noted that after obtaining the problem-solving code, the problem-solving code can be displayed in the code editing area. In the method provided in the embodiment of the present invention, from extracting the problem-solving code to displaying the problem-solving code in the code editing area, there is no need for the user to manually enter the code, which reduces manual participation, thereby shortening the time required to extract the code and improving the user's work efficiency.

[0070] S104: When a code editing instruction fed back by the user is received, the problem solving code displayed in the code editing area is edited in response to the code editing instruction to obtain a code to be verified for the code development problem.

[0071] After the problem-solving code is displayed to the user in the code editing area, if the user needs to modify the code, the user can directly edit the problem-solving code in the code editing area. It should be noted that when the user edits the problem-solving code in the code editing area, the code development problem answering system will receive corresponding code editing instructions. Further code editing instructions include the specific operations edited by the user and the content of the operations, such as deleting code in the problem-solving code, adding code to the problem-solving code, modifying code in the problem-solving code, and other operations.

[0072] The code editor preset in the code development problem answering system parses the code editing instruction and obtains the code editing content in the code editing instruction; the code editor edits the problem solving code in the code editing area based on the code editing content, and determines the edited code as the code to be verified.

[0073] Preferably, the code editing content may include deleting code in the problem-solving code, adding code in the problem-solving code, modifying code in the problem-solving code, and the like.

[0074] Preferably, the code editor can be implemented using a codeMirror component. The code editor takes the code editing instruction as an input parameter, then calls a code hint interface to perform lexical analysis on the code editing instruction, and then edits the problem solving code.

[0075] Furthermore, a code editor can be set at the front end of the code development question answering system. When configuring the code editor, basic configuration settings, theme settings, syntax highlighting function settings, operation shortcut key support settings, etc. are required. The code editor can also highlight the code in the problem-solving code, and can also prompt the user with the code by calling the code prompt interface.

[0076] S105 . When receiving the code running instruction fed back by the user, compile the code to be verified, and run the compiled code in a preset running interface to obtain the verification result of the code to be verified.

[0077] It should be noted that before compiling the code to be verified, the code compilation execution module preset in the code development question answering system analyzes the modules referenced in the code to be verified and determines the modules referenced in the code to be verified as the target modules; the code compilation execution module determines whether the target module exists in the development project to which the code to be verified belongs. If the target module does not exist in the development module, the module package corresponding to the target module is obtained, and the module package is applied to install the target module. It should be noted that the module here is the basic code organization method.

[0078] You can use regular matching to extract the name of the module referenced by the code to be verified, and then determine whether there is a module with the same module name in the development project. If not, you need to obtain the module package corresponding to the module name. The module package here can be an npm module package. Install the module by executing the npm install command.

[0079] By analyzing the modules referenced in the code to be verified, when the module referenced by the code to be verified does not exist in the development project to which the code to be solved belongs, the module package of the module can be obtained first, and then the module should be installed according to the module package. In this way, it can be ensured that the modules referenced by the subsequent problem-solving code exist, avoiding exceptions caused by the failure to find the referenced modules when the code to be verified is compiled subsequently.

[0080] The process of compiling the code to be verified is as follows: the code compilation execution module preset in the code development question answering system applies the preset compilation method to compile the code to be verified to obtain the compiled code; the code compilation execution module saves the compiled code in the preset static file directory to obtain the resource path of the compiled code. It should be noted that the compilation method can be a transfrom method.

[0081] Preferably, the code compilation execution module is set in the front end of the code development problem application system. The code compilation execution module can be implemented using the babel module. Preferably, when setting the bable module, a series of plug-ins and presets required by the bable package can be installed through npm, npm install--save@babel / core@babel / cli@babel / preset-env@babel / preset-react, etc. The module can be referenced after the installation is completed.

[0082] It should be noted that the resource path is the storage path of the compiled code, and the compiled code can be saved in the backend. The storage path is the storage path of the compiled code in the backend, and the storage path can be the path address of the file that saves the compiled code.

[0083] The process of running the compiled code in the preset running interface is as follows: the front end of the code development question answering system obtains the resource path by calling the preset compilation interface; creates an inline frame in the preset running interface, and runs the code corresponding to the resource path in the inline frame.

[0084] It should be noted that the running interface is an interactive page of the front-end question-and-answer interface module. Creating an inline frame in the running interface can be to create an iframe element in the running interface, and the resource path finally obtained can be manually mounted under the iframe element in the form of a script tag, so as to run the code corresponding to the resource path.

[0085] By running the code in an inline frame, you can run the code in an isolated form, thus avoiding the impact of other factors when running the code.

[0086] After running the code, the corresponding verification result is obtained, and the verification result includes the verification conclusion of whether the problem-solving code solves the code development problem.

[0087] In the method provided by the embodiment of the present invention, when the user inputs a code development problem in the front-end question and answer interface, the answer data corresponding to the code development problem fed back by the intelligent question and answer module is obtained, and then the problem-solving code is extracted from the answer data, and the problem-solving code is displayed in the code editing area. In response to the code editing instruction, the problem-solving code in the code editing area is edited to obtain the code to be verified, and then the code to be verified is compiled, and the compiled code is run in the running interface to obtain the verification result of the code to be verified, wherein the verification result includes a verification conclusion of whether the code to be verified solves the code development problem. When the present invention receives the code development problem input by the user, the answer data corresponding to the code development problem fed back by the intelligent question and answer module is obtained, the problem-solving code in the application data is extracted, and then the problem-solving code is displayed to the user in the code editing area, and the user can directly edit it in the code editing area, thereby eliminating the need for the user to manually enter the problem-solving code into the code editing area for editing, thereby shortening the verification time of the code to solve the problem and effectively improving the user's work efficiency.

[0088] Reference Figure 3 , which is a schematic diagram of the architecture of the code development question answering system provided in an embodiment of the present invention. As shown in the figure, it can be divided into four parts: web front-end interface, code compilation, chatGPT, and back-end basic framework. Further, the code development question answering system can be divided into the front-end and the back-end, wherein the front-end includes the web front-end interface and the code compilation content, and the back-end includes chatGPT and the back-end basic framework content.

[0089] like Figure 3 As shown in the figure, the web front-end interface can provide functions such as question-and-answer interaction, code extraction, online code editing, compilation and running; code compilation can provide functions such as dynamic installation of dependency packages, babel compilation interface and generation of unique static resources; chatGPT can provide functions such as key verification, remote API call and exception handling; the back-end basic framework can provide development API interface, nodejs, npm and static resource storage.

[0090] Furthermore, the code development question answering system includes a web front-end interactive interface module, a code online extraction module, a code online editing and processing module, a code compilation and execution module, an intelligent question and answer module, and a back-end framework interface module.

[0091] It should be noted that the web front-end interactive interface module is used to provide users with various interactive pages, such as the front-end question and answer interface, the code editing area, and the running interface, etc. The web front-end interactive interface module can be implemented on the front end.

[0092] The backend framework module is mainly used to provide a basic user interface, including the compiled code of the hosted web frontend interface module, which is returned to the browser for display after the user visits the externally deployed address. In addition, it also includes the encapsulation of important API interfaces, such as the encapsulation of the intelligent question and answer module interface, and the code conversion and compilation function, which also returns the results to the frontend by calling the API interface.

[0093] The intelligent question-and-answer module can be understood as a chatGPT interface module. The chatGPT interface module is intended to provide an interface for the front-end to call. Here, you need to apply for a chatGPT account in advance and obtain the interface key corresponding to the service account to complete the configuration of the entire service. The API interface address is provided to the outside. When the user calls the interface, the module will forward the user's question information to the API developed by chatGPT. Similarly, when the chatGPT interface returns a message, it will forward the interface content to the front-end, thereby realizing the function of conversational questioning.

[0094] The web front-end interactive interface module provides a visual page for users to ask questions to chatGPT. It returns the results to users by calling the back-end chatGPT interface. Through the run operation provided on the interface, the code can be directly extracted from the returned results to the online editor of the page. After the user has made adjustments, he can execute the run operation to view the display effect.

[0095] The code online extraction module is mainly implemented in the web front-end interface module. For example, when a user asks a question to chatGPT, the returned content will include the code part. At this time, it is necessary to provide a function that can directly extract the code block in the content. The markdown-it module is used here, which can extract the code part in the returned content. After obtaining the code, it is directly replaced in the online editor on the page.

[0096] Reference Figure 4 , which is a flow chart of a method for extracting code by the code online extraction module provided in an embodiment of the present invention. The specific description is as follows: After obtaining the interactive return result of chatGPT, the markdown-it module is called to perform lexical analysis on the content. First, its external parse method is called, and the returned content is passed in as a parameter. Finally, a Token list including an AST structure is obtained, and then the list is filtered and processed. Only the fragments with the type attribute of fence are found and the results are cached. After the filtering operation, if no code fragment is found, the run button is hidden, otherwise the run operation is displayed. If there is a run operation, the user will take out the contents of all code fragments from the cache data and merge them after clicking. Finally, the set value method of the editor component is called, and the merged content is used as an input parameter to complete the code extraction operation.

[0097] The code online editing processing module is used to perform secondary editing on the extracted code blocks, so as to facilitate users to add more customized requirements, which is implemented by the codeMirror editor. It should be noted that the code online editing processing module can be understood as the code editor mentioned above.

[0098] Reference Figure 5 , which is a flow chart of a method for editing code in the code online editing processing module provided by an embodiment of the present invention. The specific description is as follows: the online editing processing module introduces the codeMirror component to implement code editing. After the component is introduced, the basic configuration settings are first performed, and the theme is additionally adjusted. For more user-friendly operation, js syntax highlighting support extensions are also introduced here, as well as support for operation shortcut keys and other functions. In addition, a code prompt function is provided, and the specific implementation steps are as follows: first, monitor the changes in the editor input content, use the user input content as an input parameter, call the code prompt API provided by the backend, the interface will perform lexical analysis on the input parameter content, compare all types definition files under the module, return the global method supported in the current operating environment or the method under the instance, and finally return the result to the editor for use. After the user finishes editing the code, the code to be verified can be obtained.

[0099] The core function of the code compilation and execution module is to compile and convert the online code. This part of the function is implemented in the backend, mainly by calling the code compilation function opened by the babel module. Finally, the compiled code is returned to the user in the form of an API. This part of the code is run separately in the front-end interface to display the result.

[0100] Reference Figure 6, a flow chart of the method for compiling code by the code compilation execution module provided by the embodiment of the present invention, as shown in the figure, the code to be compiled can be regarded as the source code, and the source code needs to be analyzed before compilation. First, analyze whether the module referenced in the source code exists in the development project, which can be understood as judging whether it is necessary to install new dependencies for the source code. When the module referenced by the source code exists in the development project, it is determined that it is not necessary to install new dependencies for the source code; when the module referenced by the source code does not exist in the development project, it is determined that it is necessary to install new dependencies for the source code. The dependency here refers to the module, thereby avoiding the problem of throwing an exception due to the module not being found during the compilation process. Here, the module name is extracted by using regular matching, and finally the modules that already exist in the current project are compared to find the missing npm module package, and finally the npminstall installation module command is executed, so that the corresponding module can be installed. Then the transfrom method provided by the babel module is called for compilation, the source code and the compilation configuration items are passed in, and the compiled code is set to the static file directory stored in the backend framework, and the file name is distinguished by a unique identifier. Finally, the file path address is returned to the front end as the interface content.

[0101] Furthermore, in order to use the babel module, you first need to install a series of plug-ins and presets required by the babel package through npm, npm install--save@babel / core@babel / cli@babel / preset-env@babel / preset-react, etc.

[0102] Reference Figure 7 , which is a flow chart of the method for running code provided by an embodiment of the present invention. When running the code, the front end of the code development question answering system can call the compilation interface provided by the code compilation execution module, and then obtain the file address of a js static resource obtained after the code compilation execution module is compiled. In order to be able to execute the code in an isolated form, a new iframe element is created on the page as a solution. Finally, the returned url address is manually mounted to the iframe element in the form of a script tag to achieve the purpose of running, and finally the verification result after the code is run is obtained. The url address here can be understood as the address returned by the compilation interface.

[0103] Reference Figure 8 , is a flow chart of a code verification method performed by a code development question answering system provided by an embodiment of the present invention, and the specific steps are as follows:

[0104] Step 1. The user accesses the chatGPT question-answering system interface.

[0105] Step 2. The user enters technical questions related to web front-end development in the question box.

[0106] Step 3. Click Send to initiate a request to the backend interface to obtain the returned result content.

[0107] Step 4. The web front-end interface parses the returned content and displays it synchronously on the system interface.

[0108] Step 5. After the Q&A is completed, the user can click the Run button on the right side of the result to extract the code block in the content. At this time, the code editing area of ​​the front-end interface will be replaced with the code block content mentioned above.

[0109] Step 6. The user adjusts the code being edited according to actual needs. After editing, execute the corresponding run button.

[0110] Step 7. At this time, the code compilation function of the backend will be called, and after the compilation is completed, the code will be returned to the front-end interface. The front-end interface will load the returned code and run it on the page to get the verification result of the code.

[0111] In the solution provided by the present invention, based on interactive questioning, code snippets in the returned content can be directly extracted, and the code can be compiled with the help of the babel module, and finally the code verification effect can be directly run on the interface to achieve the purpose of improving development efficiency.

[0112] The solution provided by the present invention can provide running operations directly on the page based on the question-and-answer style return results to extract the code part of the results, without the need for staff to manually input and copy the code in the extracted return content, and with the help of the online code editing function provided on the page, the code can be processed again, and finally the code can be directly run to verify the results. In this way, the intermediate manual operation links and the probability of errors are reduced, and the work efficiency of developers is greatly improved.

[0113] and Figure 1 Corresponding to the method shown in the figure, the present invention also provides a code verification device, which is applied to a code development question answering system, and is used to support Figure 1 Specific implementation of the method shown.

[0114] Reference Fig. 9 , is a schematic diagram of the structure of a code verification device provided by an embodiment of the present invention, and is specifically described as follows:

[0115] The acquisition unit 501 is used to acquire the answer data fed back by the preset intelligent question and answer module based on the code development question when the user inputs the code development question in the preset front-end question and answer interface;

[0116] A display unit 502, configured to display the response data to the user on a preset display interface;

[0117] An extraction unit 503 is configured to extract a problem-solving code from the response data when receiving a code extraction instruction fed back by the user, and display the problem-solving code in a preset code editing area;

[0118] An editing unit 504 is configured to, when receiving a code editing instruction fed back by the user, edit the problem-solving code displayed in the code editing area in response to the code editing instruction to obtain a code to be verified for the code development problem;

[0119] The compilation unit 505 is used to compile the code to be verified when receiving the code running instruction fed back by the user, and run the compiled code in a preset running interface to obtain the verification result of the code to be verified, and the verification result includes the verification conclusion of whether the code to be verified solves the code development problem.

[0120] In the device provided by the embodiment of the present invention, when the user inputs a code development problem in the front-end question and answer interface, the answer data corresponding to the code development problem fed back by the intelligent question and answer module is obtained, and then the problem-solving code is extracted from the answer data, and the problem-solving code is displayed in the code editing area. In response to the code editing instruction, the problem-solving code in the code editing area is edited to obtain the code to be verified, and then the code to be verified is compiled, and the compiled code is run in the running interface to obtain the verification result of the code to be verified, wherein the verification result includes a verification conclusion of whether the code to be verified solves the code development problem. When the present invention receives the code development problem input by the user, the answer data corresponding to the code development problem fed back by the intelligent question and answer module is obtained, the problem-solving code in the application data is extracted, and then the problem-solving code is displayed to the user in the code editing area, and the user can directly edit it in the code editing area, thereby eliminating the need for the user to manually enter the problem-solving code into the code editing area for editing, thereby shortening the verification time of the code to solve the problem and effectively improving the user's work efficiency.

[0121] In another embodiment provided by the present invention, the acquisition unit 501 of the device executes a process of acquiring the response data fed back by the preset intelligent question and answer module based on the code development question, including:

[0122] The front end of the code development question answering system calls a pre-configured intelligent question and answer module interface to send the code development question to the intelligent question and answer module, triggering the intelligent question and answer module to search for a solution corresponding to the code development question;

[0123] The answer data generated by the intelligent question and answer module based on the solution content is obtained through the intelligent question and answer module interface.

[0124] In another embodiment provided by the present invention, the extraction unit 503 of the device performs a process of extracting the problem-solving code from the response data, including:

[0125] The lexical analysis module of the code online extraction module preset in the code development question answering system parses the answer data to obtain a data label list corresponding to the answer data;

[0126] The online code extraction module determines the tag corresponding to the preset data type in the data tag list as a target tag, and caches the data segment corresponding to the target tag;

[0127] The online code extraction module extracts code fragments from the cached data fragments, and merges the extracted code fragments to obtain the problem-solving code.

[0128] In another embodiment of the present invention, the editing unit 504 of the device executes a process of editing the problem-solving code displayed in the code editing area in response to the code editing instruction to obtain the code to be verified for the code development problem, including:

[0129] The code editor preset in the code development question answering system parses the code editing instruction to obtain the code editing content in the code editing instruction;

[0130] The code editor edits the problem-solving code in the code editing area based on the code editing content, and determines the edited code as the code to be verified.

[0131] In another embodiment provided by the present invention, before the compiling unit 505 of the device compiles the code to be verified, the method further includes:

[0132] The code compiling and executing module preset in the code development question answering system analyzes the modules referenced in the code to be verified, and determines the modules referenced in the code to be verified as target modules;

[0133] The code compilation and execution module determines whether the target module exists in the development project to which the code to be verified belongs. If the target module does not exist in the development module, a module package corresponding to the target module is obtained, and the module package is used to install the target module.

[0134] In another embodiment provided by the present invention, the compiling unit 505 of the device performs a process of compiling the code to be verified, including:

[0135] The code compiling and executing module preset in the code development question answering system compiles the code to be verified by applying a preset compiling method to obtain a compiled code;

[0136] The code compiling and executing module saves the compiled code in a preset static file directory, and obtains the resource path of the compiled code.

[0137] In another embodiment provided by the present invention, the compiling unit 505 of the device executes a process of running the compiled code on a preset running interface, including:

[0138] Obtain the resource path by calling a preset compilation interface;

[0139] An inline frame is created in a preset running interface, and a code corresponding to the resource path is run in the inline frame.

[0140] An embodiment of the present invention further provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned code verification method.

[0141] The embodiment of the present invention further provides an electronic device, the structural diagram of which is shown in FIG. Fig.10 As shown, it specifically includes a memory 601 and one or more instructions 602, wherein the one or more instructions 602 are stored in the memory 601 and are configured to be executed by one or more processors 603 to execute the one or more instructions 602 to perform the above-mentioned code verification method.

[0142] The specific implementation processes and derivative methods of the above-mentioned embodiments are all within the protection scope of the present invention.

[0143] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0144] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0145] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A code verification method, characterized in that: Applied to code development question answering system, including: When a user inputs a code development question in a preset front-end question-and-answer interface, the preset intelligent question-and-answer module obtains answer data based on the code development question feedback; Displaying the response data to the user on a preset display interface; When receiving the code extraction instruction fed back by the user, extracting the problem solving code from the response data, and displaying the problem solving code in a preset code editing area; When receiving the code editing instruction fed back by the user, editing the problem solving code displayed in the code editing area in response to the code editing instruction, to obtain the code to be verified for the code development problem; When the code running instruction fed back by the user is received, the code to be verified is compiled, and the compiled code is run in a preset running interface to obtain a verification result of the code to be verified, and the verification result includes a verification conclusion on whether the code to be verified solves the code development problem.

2. The method according to claim 1, characterized in that The obtaining of the response data of the preset intelligent question-answering module based on the code development question feedback includes: The front end of the code development question answering system calls a pre-configured intelligent question and answer module interface to send the code development question to the intelligent question and answer module, triggering the intelligent question and answer module to search for a solution corresponding to the code development question; The answer data generated by the intelligent question and answer module based on the solution content is obtained through the intelligent question and answer module interface.

3. The method according to claim 1, characterized in that The extracting the problem-solving code from the response data comprises: The lexical analysis module of the code online extraction module preset in the code development question answering system parses the answer data to obtain a data label list corresponding to the answer data; The online code extraction module determines the tag corresponding to the preset data type in the data tag list as a target tag, and caches the data segment corresponding to the target tag; The online code extraction module extracts code fragments from the cached data fragments, and merges the extracted code fragments to obtain the problem-solving code.

4. The method according to claim 1, characterized in that: The step of editing the problem-solving code displayed in the code editing area in response to the code editing instruction to obtain the code to be verified for the code development problem includes: The code editor preset in the code development question answering system parses the code editing instruction to obtain the code editing content in the code editing instruction; The code editor edits the problem-solving code in the code editing area based on the code editing content, and determines the edited code as the code to be verified.

5. The method according to claim 1, characterized in that Before compiling the code to be verified, the method further includes: The code compiling and executing module preset in the code development question answering system analyzes the modules referenced in the code to be verified, and determines the modules referenced in the code to be verified as target modules; The code compilation and execution module determines whether the target module exists in the development project to which the code to be verified belongs. If the target module does not exist in the development module, a module package corresponding to the target module is obtained, and the module package is used to install the target module.

6. The method according to claim 1, characterized in that The compiling the code to be verified includes: The code compiling and executing module preset in the code development question answering system compiles the code to be verified by applying a preset compiling method to obtain a compiled code; The code compiling and executing module saves the compiled code in a preset static file directory, and obtains the resource path of the compiled code.

7. The method according to claim 6, characterized in that The step of running the compiled code in a preset running interface includes: Obtain the resource path by calling a preset compilation interface; An inline frame is created in a preset running interface, and a code corresponding to the resource path is run in the inline frame.

8. A code verification device, characterized in that: Applied to code development question answering system, including: An acquisition unit, configured to acquire, when a user inputs a code development question in a preset front-end question-and-answer interface, answer data fed back by a preset intelligent question-and-answer module based on the code development question; A display unit, used to display the response data to the user on a preset display interface; an extraction unit, configured to extract a problem-solving code from the response data when receiving a code extraction instruction fed back by the user, and display the problem-solving code in a preset code editing area; An editing unit, configured to, when receiving a code editing instruction fed back by the user, edit the problem-solving code displayed in the code editing area in response to the code editing instruction to obtain a code to be verified for the code development problem; The compiling unit is used to compile the code to be verified when receiving the code running instruction fed back by the user, and run the compiled code in a preset running interface to obtain the verification result of the code to be verified, and the verification result includes the verification conclusion of whether the code to be verified solves the code development problem.

9. A storage medium, characterized in that: The storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the code verification method according to any one of claims 1 to 7.

10. An electronic device, characterized in that: The device comprises a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the code verification method according to any one of claims 1 to 7.