Code detection method and platform based on artificial intelligence
By adopting artificial intelligence-based code detection methods in programming education, combining regular detection and AI detection, the time-consuming and labor-consuming problem of code detection in the existing technology is solved, and efficient and accurate automatic code correction and personalized feedback are achieved.
Patent Information
- Application Number
- CN202411685074.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-04-04
AI Technical Summary
In existing programming education, code detection is time-consuming and labor-intensive, and lacks timely task detection and feedback, which affects students' learning results and increases the pressure of teachers to correct homework.
Using artificial intelligence-based code detection methods, by obtaining pre-configured course code templates and program detection configuration information, the code to be detected is automatically detected, and combining regular detection and AI detection to achieve intelligent and standardized automatic code correction.
It improves the efficiency and consistency of code reviews, reduces the work burden of teachers, provides personalized feedback and modification suggestions, and helps students improve their programming skills.
Smart Images

Figure CN119759733A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to an artificial intelligence-based code detection method and platform. Background Art
[0002] With the rapid development of artificial intelligence (AI) and data science, the importance of programming education has gradually been widely recognized. More and more parents are aware of the importance of programming skills to their children's future development, actively looking for relevant learning opportunities, and encouraging their children to participate in programming courses and activities. At the same time, many schools have included programming in formal courses, allowing young people to be exposed to programming during the learning process. However, the current programming education has many shortcomings in the submission and feedback of homework. Students lack timely task detection and feedback during the creation process, and cannot accurately judge the completion of their tasks. This not only affects the learning effect of students, but also brings additional pressure to teachers in grading homework.
[0003] Existing technologies mainly rely on teachers or teaching assistants to manually review the code submitted by students, check its logic, structure, style and comments, and provide specific feedback. This process is not friendly to beginners, because novices often need to get feedback prompts before submitting their code to avoid confusion or frustration. In addition, manual review is not only time-consuming and labor-intensive, but especially in the case of large class sizes, it is difficult for teachers to conduct a detailed review of each student's code, resulting in limited feedback coverage. Since different reviewers may have different standards and preferences, the subjectivity of feedback also makes it difficult for students to obtain consistent evaluation results. These problems urgently need to be solved through automation technology to improve the efficiency and consistency of code review.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a code detection method and platform based on artificial intelligence, so as to at least solve the technical problem that code detection in the prior art is time-consuming and labor-intensive.
[0006] According to one aspect of an embodiment of the present invention, there is provided an artificial intelligence-based code detection method, comprising: obtaining a pre-configured course code template and program detection configuration information used as a standard answer; obtaining a code to be detected, and performing code detection on the code to be detected based on the course code template and program detection configuration information.
[0007] According to another aspect of an embodiment of the present invention, there is also provided an artificial intelligence-based code detection platform, including: an acquisition module, configured to acquire a pre-configured course code template and program detection configuration information; a detection module, configured to acquire a code to be detected, and perform code detection on the code to be detected based on the course code template and program detection configuration information.
[0008] In the embodiment of the present invention, a pre-configured course code template and program detection configuration information used as a standard answer are obtained; the code to be detected is obtained, and code detection is performed on the code to be detected based on the course code template and program detection configuration information. Through the above scheme, the technical problem of time-consuming and labor-intensive code detection in the prior art is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0010] Figure 1 is a flow chart of a code detection method based on artificial intelligence according to an embodiment of the present invention;
[0011] Figure 2 is a flow chart of a code detection method based on artificial intelligence according to an embodiment of the present invention;
[0012] Figure 3 is a flow chart of a code regularity detection method according to an embodiment of the present invention;
[0013] Figure 4 is a flow chart of an output regularity detection method according to an embodiment of the present invention;
[0014] Figure 5 is a flow chart of an AI detection method according to an embodiment of the present invention;
[0015] Figure 6 is an architecture diagram of an artificial intelligence-based code detection platform according to an embodiment of the present invention;
[0016] Figure 7 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0018] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0019] According to an embodiment of the present invention, a method embodiment of a code detection method based on artificial intelligence is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0020] Figure 1 According to an embodiment of the present invention, the code detection method based on artificial intelligence is as follows: Figure 1 As shown, the method comprises the following steps:
[0021] Step S102, obtaining a pre-configured course code template and program detection configuration information used as a standard answer.
[0022] Before obtaining the pre-configured course code template and program detection configuration information, first create the course content based on the pre-planned course chapters; based on the course content, configure the course code template and the program detection configuration information. For example, configure the detection type, wherein the detection type includes at least one of the following: regular detection and AI detection, wherein the regular detection includes code detection for detecting whether the code is correct and / or output detection for detecting whether the output result is correct; in the case where the configured detection type is the code detection or the output detection, configure at least one of the following: a purpose field for indicating the detection purpose, a prompt field for indicating the prompt text, and a regular field for indicating a regular expression; in the case where the configured detection type is the AI detection, configure a rule field for indicating the rule text.
[0023] Step S104, obtaining the code to be detected, and performing code detection on the code to be detected based on the course code template and program detection configuration information.
[0024] In the case where the program detection configuration information is the regular detection, refer to the course code template and perform at least one of the following detections on the code to be detected based on the program detection configuration information: missing part of the code, parameter syntax error, parameter content error, code sequence error, code output error;
[0025] In the case where the program detection configuration information is the AI detection, refer to the course code template and call the AI big model based on the rule field to perform corresponding detection on the code to be detected, wherein the rule field is used to indicate at least one of the following: text description of task instructions, detection requirements, and example code.
[0026] In some embodiments, after obtaining the code to be detected, the code to be detected is cleaned to remove comments in the code to be detected. The code to be detected can also be run; the console is automatically expanded to display the running result of the code to be detected through the console, and / or prompt information related to the result of running the code to be detected is displayed in the code area for inputting the code to be detected.
[0027] Existing code detection methods usually rely on regular expression detection, but this method has the defects of high design cost and high misjudgment rate. Since the configuration process of judgment rules is complicated and time-consuming, existing regular expression detection often fails to accurately identify the diversity of students' answers, resulting in limited detection effect and unable to meet the needs of efficient and accurate judgment in the education process.
[0028] In order to solve the problems of high configuration cost and high misjudgment rate of judgment rules in the prior art, the embodiment of the present invention provides a code detection method based on artificial intelligence, which can realize intelligent and standardized automatic code correction in the field of course teaching and programming, especially C++ programming, by introducing a combination of AI detection and regular detection, improve teaching efficiency, reduce detection configuration costs, and provide students with personalized feedback and modification suggestions. Through this method, teachers can quickly detect the logical correctness of students' codes and the accuracy of output formats, and can promptly identify syntax errors, runtime errors and other problems in the code, helping students improve their programming skills.
[0029] Specifically, Figure 2 As shown, the following steps are included:
[0030] Step S202, obtaining a course code template.
[0031] First, the course code template and program detection configuration information are generated through the pre-configured teaching content and code template. According to the course plan or chapter outline, the course content applicable to each knowledge point is first established. Each course content corresponds to one or more code templates, which are used as standard answers, namely course code templates. These code templates are pre-designed by teachers and can effectively cover common programming requirements in course teaching, such as basic operations, conditional statements, loop structures, etc.
[0032] Step S204, obtaining program detection configuration information.
[0033] The program detection configuration information includes the configuration of regular expression detection and the configuration of AI detection. Specifically, the detection type can be set to one of the following two categories, or both detections can be used at the same time: regular expression detection and AI detection, where regular expression detection includes code regular expression and output regular expression. Regular expression detection is suitable for accurately judging whether the code structure meets the standards, including code area detection and output area detection. Detection types include code detection (judging the format and logic of the code content) and output detection (judging the correctness of the program output). The advantage of regular expression detection is that the detection standard can be flexibly configured to adapt to different programming languages and output formats. AI detection is connected to the AI big model, and through the semantic understanding ability of artificial intelligence, it conducts in-depth analysis of the code logic and structure, and can judge whether the code meets expectations and provide modification suggestions. Compared with regular expression detection, AI detection can handle more complex code logic and programming patterns, and provide students with more detailed feedback.
[0034] Specifically, the system performs specific configurations of regular expression detection and AI detection according to the preset rule fields, including the purpose field, prompt field and regular field of the detection. Among them, the purpose field is used to indicate the main goal of the detection, such as whether the logical structure of the code, syntax specifications, and variable naming meet the requirements. The prompt field is used to provide prompt information to help users understand the specific requirements of code detection, such as "the output format should be an integer type." The regular field is used to define the standards for code or output detection through regular expressions. For example, check whether the code contains the "cout<<68 / 15;" statement to ensure that the student code meets the expected format.
[0035] In AI detection, the system presets rule fields to provide the AI model with task instructions, detection requirements, and sample code so that the model can accurately determine whether the logic and format of the code meet the standards. The specific contents of these fields include: task description, which is used to describe the specific tasks of code detection, such as "detecting whether the code correctly implements the addition operation"; detection requirements, which are used to list the technical requirements of the detection in detail, including output results, variable naming, etc. For example, "the output result should be 'pass' or 'fail'"; sample code, which is used to provide multiple positive and negative examples to help the AI model understand the detection rules of the code and ensure that the judgment results of the AI model meet the course standards.
[0036] Step S206, executing code detection.
[0037] After the system completes the configuration of course content and detection rules, it enters the code detection process. This process performs regular detection and AI detection on the code to be detected to determine the correctness of the code and output the detection results. First, obtain the code to be detected. The user submits the code to be detected, and the system first obtains the content of the code. After the code is submitted, the system immediately starts the detection process.
[0038] When only a single detection rule is configured, detection can be performed only according to the configured single detection rule. When multiple detection rules are configured, detection can be performed in the configuration order.
[0039] The following describes the regular expression detection process. When the system detects that the program detection configuration information of the code to be detected is regular expression detection, the system can detect the code content (code area) or output result (output area) based on the regular expression. The specific detection process is as follows:
[0040] 1) Code content detection.
[0041] like Figure 3As shown, first delete the code comment information, then determine whether the code is empty. If it is not empty, perform code regularization detection. Specifically, the format and logic of the code area are matched through regular expressions. For example, the teacher stipulates that the format of the detection code must be output using "cout<<68 / 15;". The system will match the code content to determine whether it meets the standard output format requirements to ensure that the student code meets the course code template requirements.
[0042] 2) Output result detection.
[0043] like Figure 4 As shown, first delete the code comment information, then determine whether the code is empty, and if it is not empty, run the code and output the result.
[0044] Specifically, first run the code to be tested and display the execution result in the console. If the code encounters an error during execution, the system will detect the specific error type and provide corresponding prompts. The error types include: 1) Compile error (CE): If the code cannot be compiled, the system will expand the console and prompt the user to check for syntax errors. The system prompts "There is a problem with the code, please check the syntax" in the interface. 2) Runtime error (RE): If an error occurs during code execution, the system prompts the user to check for errors such as variable names and function calls. 3) Run timeout (TLE): If the code running time exceeds 60 seconds, the system automatically terminates execution and prompts "The code running time is too long, please optimize the code." 4) Memory overflow (MLE): If the memory usage exceeds 50MB during operation, the system will prompt "Memory overflow, please optimize the code and try again"; 5) Output is too long (OLE): If the output content exceeds 1MB during code execution, the system will terminate the output and prompt "Too much output content, please check the loop conditions"
[0045] Then, the content of the output area is matched by regular expressions. For example, the system can determine whether the code output is an integer of the calculation result of "68 / 15", and at the same time allow the addition of unit words such as "pieces" or "boxes" after the calculation result to meet the diverse needs of actual business scenarios.
[0046] After the test is completed, the system returns the test results directly in the console and user interface, and provides personalized feedback to the user. The test results are divided into two categories: pass or fail: "pass" means that the code meets the test requirements, and the "correction result: pass" is returned. "Fail" means that the code does not meet the test requirements, and the "correction result: fail" is returned, with modification suggestions. In the case of failure, the system will provide specific modification suggestions for the code content and prompt the user where to make corrections. For example, the prompt "need to output the result of 68 divided by 15".
[0047] When the system detects that the program detection configuration information of the code to be detected is AI detection, such as Figure 5 As shown, first delete the code comment information, then determine whether the code is empty, and if it is not empty, perform code regularization detection.
[0048] Next, call the AI big model to perform intelligent detection on the code content. The specific detection process is as follows:
[0049] 1) Clean code comments.
[0050] In order to reduce misjudgments during detection, the system will remove comments in the code before detection, including single-line comments and multi-line comments. Single-line comments start with double slashes ( / / ), and the system will remove all code comment lines starting with / / before detection. Multi-line comments are surrounded by / and / symbols, and the system will clear all code comments that match this pattern to improve detection accuracy. In C++, if a backslash (\) is added after a single-line comment, the next line will also be commented out. The system will process such comments to ensure that the detection process is not disturbed by comments.
[0051] 2) Conduct testing.
[0052] After cleaning the code comments, the system matches the code with the preset detection rules and task requirements based on the task description field. The system calls the AI model, inputs the detection rules and the code to be detected into the model together, and the AI model judges the correctness of the code based on the sample code and the detection requirements, and returns the detection results. The judgment of the AI model includes whether the detection is passed and specific modification suggestions. For example, the first eigenvector of the context code of the code to be detected and the second eigenvector of the current code to be detected are extracted respectively, and the first eigenvector and the second eigenvector are respectively upgraded according to the extended rank criterion, and the multi-channel convolution kernel is used to perform feature coupling and fusion processing of the first eigenvector and the second eigenvector to obtain the coupled main embedded feature matrix and auxiliary embedded feature matrix. The above matrix is expanded along the direction of the extended dimension to form multiple sub-matrices. Each sub-matrix is subjected to singular value decomposition to extract the core subspace representation and factor matrix. The principal component difference between the main feature matrix and the auxiliary feature matrix is calculated based on the core subspace representation and the factor matrix to extract the core features, thereby effectively identifying logical errors and reference problems.
[0053] Specifically, after cleaning the code comments, the system will match the code to be tested with the preset detection rules and task requirements based on the task description field. The system will extract the relevant features of the code to be tested and compare them with the configured detection rules to more comprehensively evaluate the correctness and compliance of the code. The system calls the AI model and inputs the detection rules and the code to be tested into the model. The AI model determines the correctness of the code based on the sample code and detection requirements, and returns the detection results and specific modification suggestions.
[0054] The AI model generates a first feature vector by extracting the contextual information of the code to be tested, which represents the semantic and structural features of the code in a specific context. At the same time, the current code to be tested will also generate a second feature vector, which reflects the logical structure and execution flow of the code itself. Then, based on the extended rank criterion, the system upgrades the first feature vector and the second feature vector respectively to enhance the expressive power of the feature vector, so that it can better capture the complex logic and potential errors of the code.
[0055] After the up-order processing is completed, the system uses a multi-channel convolution kernel to couple and fuse the first eigenvector and the second eigenvector. In this way, the system can generate a coupled main embedding feature matrix and an auxiliary embedding feature matrix, which respectively carry the feature representation of the code in different dimensions. The use of this multi-channel convolution can effectively improve the depth and breadth of feature fusion, making the model more sensitive and accurate in capturing code features.
[0056] Subsequently, the system expands the main embedding feature matrix and the auxiliary embedding feature matrix along the direction of the expansion dimension to form multiple sub-matrices. The generation of these sub-matrices not only makes the feature expression more detailed, but also provides a richer data basis for subsequent analysis. Each sub-matrix can be extracted into a core subspace representation and a factor matrix after singular value decomposition (SVD). The singular value decomposition process can effectively reduce the dimension, extract features with significant information, and help the model identify the most important structure in the data.
[0057] Based on the core subspace representation and factor matrix, the system will calculate the principal component differences between the main feature matrix and the auxiliary feature matrix. This difference analysis provides an important basis for the identification of logical errors and reference problems. When the AI model detects significant differences between feature matrices, it can infer errors or inconsistencies in the code logic. This core feature recognition method based on feature matrix difference extraction enables the system to quickly locate problems when processing complex codes, greatly improving the efficiency and accuracy of code detection.
[0058] In short, by extracting and analyzing the multi-dimensional features of the code to be tested, the AI model can understand the structure and logic of the code at a deeper level, quickly identify potential errors, and provide corresponding modification suggestions. This process not only improves the intelligence level of code detection, but also provides timely and accurate feedback to students and teachers, which helps to promote the further development of programming education.
[0059] 3) Generate feedback.
[0060] The system intercepts and processes the information returned by the AI model according to the preset format, and feeds back the results to the user in a standard format. The test feedback includes the following parts: 1) Correction results: The system intercepts the content of the "Correction results" field in the test results, and the results are divided into "pass" or "fail" for users to quickly understand whether the code meets the requirements. 2) Modification suggestions: The system intercepts the modification suggestions returned by the AI model, and only feeds back modification suggestions when the test fails, such as "The variable name is used incorrectly, and should be corrected to "result" as the variable name."
[0061] Throughout the code detection process, an exception handling mechanism is also provided to ensure that users can get proper guidance and help when they encounter problems. When the system encounters a connection problem or a timeout error, feedback will be automatically provided to the user to avoid confusion and inconvenience to the user. Specifically, when an AI service connection exception occurs during the detection process, the system will immediately display a prompt "Connection exception, please try again later". After the user submits the code, if no feedback is received for a long time, the system will prompt a loading message "Processing, please wait..." to ensure that the user knows that the detection is still in progress.
[0062] In addition, the system also has an automatic retry function. When a temporary network problem occurs, the system will try to automatically reconnect to the AI service to avoid service interruptions caused by network fluctuations. If multiple attempts fail in succession, the system will prompt the user to check the network connection and suggest that the user try again later. Through such a design, the system can significantly improve the user experience and reduce the usage barriers caused by technical problems.
[0063] The code detection method of the present invention not only focuses on the accuracy of detection, but also emphasizes the importance of teaching feedback. When using the system, teachers can obtain students' code submission records and their detection results to provide data support for subsequent teaching. This feedback loop mechanism can help teachers analyze the common types of errors students make in programming learning, and then adjust teaching strategies to improve classroom teaching effectiveness. In addition, teachers can find common errors in students' specific knowledge points based on the reports generated by the system, adjust teaching plans in time, and conduct targeted tutoring and explanations. For example, if the system frequently prompts students to use the wrong format in the "cout" output statement, teachers can reiterate this knowledge point in class to ensure that students understand and master it. In addition, the system also allows teachers to make personalized teaching adjustments based on students' feedback, provide additional practice materials and guidance, and help students better master programming skills.
[0064] In addition, the system can continuously improve the judgment logic of the AI model based on user feedback. The modification suggestions and feedback information submitted by users when using the system will be recorded and used as samples for subsequent model training. This not only improves the accuracy of the model, but also effectively reduces users' repeated problems and improves overall user satisfaction.
[0065] The embodiment of the present invention provides an efficient and accurate automatic judgment solution by introducing a code detection method based on artificial intelligence. The method sets standard course codes and detailed program detection configuration information, so that teachers can quickly and accurately identify errors in student codes when performing code detection, and provide students with personalized modification suggestions. By combining regular detection with AI detection, the system can handle diverse detection needs and improve the flexibility and adaptability of code detection.
[0066] During the implementation process, the system's functions such as code comment cleaning, dynamic application of detection rules, and classification feedback of error types not only simplify the teacher's work of judging questions, but also greatly improve students' learning efficiency. By real-time monitoring of the code running status and feedback of corresponding error information, students can correct problems in the code in a timely manner, thereby improving their programming and problem-solving abilities.
[0067] In summary, the AI-based code detection method of this embodiment not only has flexible detection rules and powerful detection capabilities, but also brings new ideas and directions to programming education. It is hoped that this method can help more learners master programming skills and improve their problem-solving abilities in practical applications.
[0068] This application also provides a code detection platform based on artificial intelligence, such as Figure 6 As shown, it includes: an acquisition module 62, which is configured to acquire a pre-configured course code template and program detection configuration information; a detection module 64, which is configured to acquire the code to be detected, and perform code detection on the code to be detected based on the course code template and program detection configuration information.
[0069] It should be noted that the AI-based code detection platform provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the AI-based code detection platform provided in the above embodiment and the AI-based code detection method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0070] The present invention also provides an artificial intelligence-based code detection system, which can effectively detect missing parts, parameter syntax errors, parameter content errors, code sequence errors, and output errors in the code by configuring regular detection and prompt text, and display the corresponding detection results and suggestions. At the same time, the present invention also provides an optional AI detection function, which simplifies the configuration difficulty and enables educators to implement courses more efficiently.
[0071] The system mainly consists of two modules: the teaching and research platform module and the course application module. The teaching and research platform module provides an intuitive user interface that allows teaching and research personnel to easily create new courses and supports chapter management of course content. Teachers can divide the course content according to the teaching plan, and add or edit the course's code templates, program detection, and multimedia content (such as videos, PDF documents, etc.) to organize them into the course structure. This module is only open to teachers and R&D teams who produce courses to ensure the security and confidentiality of the content. In addition, the teaching and research platform also provides a variety of program detection options, including code detection, output detection, and AI detection, and supports quick import and export of course content. Testers can enter the modified code and view the program detection results to determine whether it meets expectations.
[0072] The course application module aims to provide students with rich course functions to help them learn programming from scratch and cultivate computational thinking and innovation capabilities. Courses are divided into difficulty levels, from entry-level to advanced. Students can choose appropriate courses according to their own level and gradually advance their learning. Multimedia resources such as videos, animations, and audio are integrated into the course to help students understand programming concepts more intuitively. At the same time, the system records students' learning progress, including completed courses, achievements achieved, and the amount of code written, so that teachers can track and evaluate. When students submit programming code, the system will review the code through the regular expression detection and AI detection configured by the course, and provide instant feedback prompts. Error lines and code will be highlighted to help students quickly identify problems.
[0073] The workflow of the system provided by the present invention can be divided into the following steps. First, the teaching and research staff plans the course chapters on the teaching and research platform and creates corresponding course content, including code templates and multimedia materials. Next, the teaching and research staff configures program detection according to the course requirements, including code detection, output detection and AI detection. After entering the teaching and learning link, the rich functions provided by the course application module support students to participate in learning, complete programming tasks and submit code. The system then performs regular detection and output detection on the submitted code, and gives detection results and emotional prompts to help students understand errors. If AI detection is configured, the system will submit the code and related task instructions, detection requirements to the server, perform intelligent detection through AI, and return detection results and suggestions.
[0074] The teaching and research platform of the present invention detects the course code and output by configuring regular expressions to ensure that the code meets the predetermined standards. In terms of AI detection, the system configures task instructions, detection requirements and sample codes, and performs intelligent detection through a large language model, which enhances the intelligence and accuracy of the detection.
[0075] Compared with the existing technology, the present invention can quickly analyze a large amount of code and maintain consistent review standards, thus saving time and human resources. In addition, students can view potential errors through instant feedback when writing code, which facilitates timely correction and improves learning efficiency. Finally, the system has high customizability. Educators can configure regular expressions or AI detection requirements according to the course code template to flexibly adapt to the needs of different projects.
[0076] In summary, the embodiments of the present invention realize an intelligent course detection and feedback mechanism through reasonable module design and clear workflow, providing strong support for the future development of programming education.
[0077] Figure 7 FIG. 1 shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present disclosure. It should be noted that: Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0078] As shown in the figure, the electronic device includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0079] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0080] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A code detection method based on artificial intelligence, characterized in that: include: Obtain pre-configured course code templates and program detection configuration information for use as standard answers; The code to be detected is obtained, and code detection is performed on the code to be detected based on the course code template and program detection configuration information.
2. The method according to claim 1, characterized in that Before obtaining the pre-configured course code template and program detection configuration information, the method further includes: Create course content based on pre-planned course sections; Based on the course content, the course code template and the program detection configuration information are configured.
3. The method according to claim 2, characterized in that Configuring the program to detect configuration information includes: Configure a detection type, wherein the detection type includes at least one of the following: regular detection and AI detection, wherein the regular detection includes a code detection for detecting whether the code is correct and / or an output detection for detecting whether the output result is correct; In the case where the configured detection type is the code detection or the output detection, configuring at least one of the following: a purpose field for indicating a detection purpose, a prompt field for indicating a prompt text, and a regular field for indicating a regular expression; In the case where the configured detection type is the AI detection, a rule field for indicating a rule text is configured.
4. The method according to claim 3, characterized in that Based on the course code template and program detection configuration information, code detection is performed on the code to be detected, including: In the case where the program detection configuration information is the regular detection, refer to the course code template and perform at least one of the following detections on the code to be detected based on the program detection configuration information: missing part of the code, parameter syntax error, parameter content error, code sequence error, code output error; In the case where the program detection configuration information is the AI detection, refer to the course code template and call the AI big model based on the rule field to perform corresponding detection on the code to be detected, wherein the rule field is used to indicate at least one of the following: text description of task instructions, detection requirements, and sample code.
5. According to the method according to any one of claims 1 to 4, after obtaining the code to be detected, the method further comprises: Run the code to be tested; The console is automatically expanded, and the running result of the code to be detected is displayed through the console, and / or prompt information related to the result of running the code to be detected is displayed in the code area for inputting the code to be detected.
6. The method according to any one of claims 1 to 4, after obtaining the code to be detected, the method further comprises: The code to be detected is cleaned to remove comments in the code to be detected.
7. A code detection platform based on artificial intelligence, characterized in that: include: An acquisition module, configured to acquire pre-configured course code templates and program detection configuration information; The detection module is configured to obtain the code to be detected and perform code detection on the code to be detected based on the course code template and program detection configuration information.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
9. A computer device, characterized in that: include: Memory and processor, The memory stores a computer program; The processor is used to execute the computer program stored in the memory, and when the computer program is run, the processor is enabled to execute the method according to any one of claims 1 to 6.
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 6 are implemented.
Citation Information
Cited By
Abnormal code detection method and device based on artificial intelligence
CN120011245A
An Abnormal Code Detection Method and Device Based on Artificial Intelligence
CN120011245B