Code detection method and device based on artificial intelligence, equipment and storage medium

Through the artificial intelligence-based code detection method, the code semantic features are extracted using generative pre-trained models and abstract syntax trees, the code error detection is automated and intelligent, and the problems of high professionalism and low efficiency in the existing technology are solved, and the detection efficiency and accuracy are improved.

CN119512900APending Publication Date: 2025-02-25PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411411814.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, code error detection requires manual configuration of rules and error modes, which have high professional requirements and low efficiency, which affects the normal operation of the code development process.

Method used

Using artificial intelligence-based code detection method, the original code is detected by a generative pre-trained model and detection target information, and the code is converted into an abstract syntax tree to extract code semantic features and merge detection information to achieve automated and intelligent error detection.

Benefits of technology

It reduces the professional requirements for code error detection, improves detection efficiency and accuracy, reduces manpower investment, and ensures the normal operation of the code development process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512900A_ABST
    Figure CN119512900A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a code detection method and device based on artificial intelligence, equipment and a storage medium, and belongs to the technical field of financial science and technology. The method comprises the following steps: acquiring an original code and detection target information of the original code; performing error detection on the original code through a generative pre-training model and the detection target information to obtain first error detection information; converting the original code into an abstract syntax tree; performing feature extraction on the original code according to the abstract syntax tree to obtain a code semantic feature; performing error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information; and merging the first error detection information and the second error detection information to obtain target error detection information of the original code. According to the embodiment of the invention, the professional requirement of code error detection can be reduced, and the code error detection efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of financial technology, and in particular to an artificial intelligence-based code detection method and apparatus, device and storage medium. Background Art

[0002] Code error detection is an essential step in the code development process, which affects the normal operation of the system platform. For example, in the code development process of the financial service platform, if the code does not detect the error code during the development process, it will affect the normal operation of the financial service platform. In the related technology, code error detection is mainly completed by developers based on manually configured rules and error patterns. It not only requires developers to have professional code programming knowledge, but also takes a lot of time to complete code error detection, affecting the efficiency of code detection. Therefore, how to reduce the professional requirements of code error detection and improve detection efficiency has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to propose a code detection method and apparatus, device and storage medium based on artificial intelligence, aiming to reduce the professional requirements of code error detection and improve the efficiency of code error detection.

[0004] To achieve the above objectives, a first aspect of an embodiment of the present application proposes a code detection method based on artificial intelligence, the method comprising:

[0005] Acquire original code and detection target information of the original code;

[0006] Performing error detection on the original code using a generative pre-trained model and the detection target information to obtain first error detection information;

[0007] Convert the original code into an abstract syntax tree;

[0008] Perform feature extraction on the original code according to the abstract syntax tree to obtain code semantic features;

[0009] Performing error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information;

[0010] The first error detection information and the second error detection information are combined to obtain target error detection information of the original code.

[0011] In some embodiments, converting the original code into an abstract syntax tree includes:

[0012] Performing syntax parsing on the original code to obtain code syntax parsing information; wherein the code syntax parsing information includes: syntax elements and element dependency parameters between the syntax elements, the element dependency parameters representing the hierarchy and dependency relationship between the syntax elements;

[0013] The syntax elements are converted into syntax nodes, and the syntax nodes are connected according to the element dependency parameters to obtain an abstract syntax tree.

[0014] In some embodiments, the process of performing syntax parsing on the target original code to obtain code syntax parsing information includes:

[0015] Decomposing the original code to obtain code elements;

[0016] Obtaining the lexical category of each of the code elements;

[0017] Converting the code element into a code token according to a preset lexical rule and the lexical category; wherein the lexical rule includes a mapping relationship between the lexical category and the code token;

[0018] Converting the code mark into the grammatical element according to a preset grammatical rule; wherein the grammatical rule includes a mapping relationship between the code mark and the grammatical element;

[0019] Obtaining logic information of the code element;

[0020] Dependency relationships of the syntax elements are identified according to the logic information to obtain the element dependency parameters of the syntax elements.

[0021] In some embodiments, the code semantic features include: code semantic information, key variables and function dependency information;

[0022] The extracting features of the original code according to the abstract syntax tree to obtain code semantic features includes:

[0023] Traversing the abstract syntax tree to obtain node information; wherein the node information includes: node category, node structure information, node usage count and node dependency information;

[0024] Extracting the code semantic information from the original code according to the node category and the node structure information;

[0025] Extracting the key variable from the original code according to the number of times the node is used;

[0026] The function dependency information is extracted from the original code according to the node dependency information.

[0027] In some embodiments, performing error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information includes:

[0028] Performing basic syntax error detection on the original code according to the code semantic features and the detection target information to obtain basic syntax error detection information;

[0029] Performing rule detection on the original code according to a preset detection rule, the code semantic feature and the detection target information to obtain rule detection information;

[0030] Performing error detection on the original code by using a preset error detection model, the code semantic features and the detection target information to obtain intelligent error detection information;

[0031] The basic grammatical error detection information, the rule detection information and the intelligent error detection information are concatenated to obtain the second error detection information.

[0032] In some embodiments, after merging the first error detection information and the second error detection information to obtain the target error detection information of the original code, the method further includes:

[0033] Filtering selected code repair information from preset candidate code repair information according to the target error detection information;

[0034] A repair solution is generated according to the target error detection information and the selected code repair information to obtain a code repair solution.

[0035] In some embodiments, the selecting the selected code repair information from preset candidate code repair information according to the target error detection information includes:

[0036] Performing category recognition on the target error detection information to obtain an error category;

[0037] Selected code repair information is screened out from the candidate code repair information according to the error category and the target error detection information.

[0038] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a code detection device based on artificial intelligence, the device comprising:

[0039] An acquisition module, used to acquire original code and detection target information of the original code;

[0040] A model error detection module, used to perform error detection on the original code by using a generative pre-trained model and the detection target information to obtain first error detection information;

[0041] A syntax tree building module, used for converting the original code into an abstract syntax tree;

[0042] A feature extraction module, used to extract features from the original code according to the abstract syntax tree to obtain code semantic features;

[0043] An error detection module, used to perform error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information;

[0044] The merging module is used to merge the first error detection information and the second error detection information to obtain the target error detection information of the original code.

[0045] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes a computer device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the method described in the first aspect when executing the computer program.

[0046] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0047] The code-based error detection method and device, computer equipment and storage medium proposed in the present application obtain the first error detection information by using a generative pre-training model and detection target information to perform error detection on the original code, and at the same time, the original code is captured into an abstract syntax tree, so that the grammatical structure of the original code is represented by the abstract syntax tree, and the code semantic features of the original code can be extracted from the original code according to the abstract syntax tree, so that the original code is error-detected according to the code semantic features and the detection target information to obtain the second error detection information. Finally, the first error detection information and the second error detection information are merged into the target error detection information of the original code. Therefore, not only the automatic detection of the original code is realized, but also the combination of intelligent and semantic features is used in the detection process to realize the error detection of the original code, which not only reduces the professional requirements for the detection of the original code, reduces the manpower of the detection of the original code, but also can improve the accuracy of the error detection of the original code. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 This is a system architecture diagram of the artificial intelligence-based code detection method provided in an embodiment of the present application;

[0049] Figure 2 is a flow chart of a code detection method based on artificial intelligence provided by an embodiment of the present application;

[0050] Figure 3 yes Figure 2 Flow chart of step S203 in FIG.

[0051] Figure 4 yes Figure 3 Flow chart of step S301 in FIG.

[0052] Figure 5 yes Figure 2 Flow chart of step S204 in FIG.

[0053] Figure 6 yes Figure 2 Flow chart of step S205 in FIG.

[0054] Figure 7 is a flowchart of an artificial intelligence-based code detection method provided by another embodiment of the present application;

[0055] Figure 8 yes Figure 7 Flow chart of step S701 in FIG.

[0056] Fig. 9 is a schematic diagram of a user interface in an artificial intelligence-based code detection method provided in an embodiment of the present application;

[0057] Fig.10 is a schematic diagram of the structure of a code detection device based on artificial intelligence provided in an embodiment of the present application;

[0058] Fig.11 It is a schematic diagram of the hardware structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0060] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0062] First, some nouns involved in this application are analyzed:

[0063] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0064] Natural Language Processing (NLP): It is an important direction in the field of artificial intelligence, dedicated to enabling computers to understand, generate and process human language. With the development of technology, NLP has been widely used in many fields such as machine translation, text summarization, chatbots, speech recognition, sentiment analysis, etc.

[0065] Abstract Syntax Tree (AST): It is a tree representation of the abstract syntax structure of the original code. Each node in the tree represents a structure in the original code. It is abstract because the AST does not represent every detail of the real syntax. The AST is usually constructed in the syntax analysis phase of the compiler for subsequent semantic analysis, code optimization, and code generation.

[0066] The Generative Pre-trained Transformer (GPT) is a large language model developed by OpenAI. It is based on the Transformer architecture and uses deep learning methods to pre-train on massive text data to learn language patterns and structures. The core of the GPT model is that it can generate coherent and logically reasonable text content, and can predict the next text content based on a given text prompt.

[0067] Low Code Platform: A software development method that allows developers to create applications with little or no code. Low Code Platforms usually provide a graphical interface to build application logic by dragging and dropping components, pre-set templates, and configuration options.

[0068] Engine: It is the core component of developing programs or systems on electronic platforms. Using the engine, developers can quickly build and lay out the functions required by the program, or use it to assist the operation of the program. Generally speaking, the engine is the supporting part of a program or a system.

[0069] During the software development process, code errors are one of the common problems. In order to reduce code errors, the generated code needs to be checked in advance to prevent the system platform from downtime due to code errors. For example, during the development of a financial platform, if there is an error in the code, it will affect the normal operation of the financial platform and cause financial transactions to fail to proceed normally. In the related art, in order to check for code errors, error detection tools are mainly used, but the error detection tools need to be manually configured with rules or predefined error modes, which not only consumes the manpower of developers, but also requires developers to have professional code programming knowledge. Therefore, how to reduce the professional requirements of the code detection process and improve detection efficiency has become a technical problem that needs to be solved urgently.

[0070] Based on this, the embodiments of the present application provide a code detection method and apparatus, a device and a storage medium based on artificial intelligence, which aims to obtain the first error detection information by performing error detection on the original code using a generative pre-trained model, and then converting the original code into an abstract syntax tree by means of a code detection platform, and extracting the code semantic features in the original code according to the abstract syntax tree, so as to perform error detection on the original code again according to the code semantic features to obtain the second error detection information. Finally, the first error detection information and the second error detection information are combined as the target error detection information of the original code. Therefore, by combining the two code error detection methods of the model and the code detection platform to realize the error detection of the original code, not only the manpower of the error detection of the original code is saved, but also the accuracy of the error detection of the original code can be improved.

[0071] The artificial intelligence-based code detection method, apparatus, device, and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the artificial intelligence-based code detection method in the embodiments of the present application is described.

[0072] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0073] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0074] The artificial intelligence-based code detection method provided in the embodiment of the present application relates to the field of financial technology. The artificial intelligence-based code detection method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements an artificial intelligence-based code detection method, etc., but is not limited to the above forms.

[0075] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer computer devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0076] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0077] like Figure 1 As shown, Figure 1 It is a system architecture diagram of the artificial intelligence-based code detection method provided in an embodiment of the present application, which includes a terminal 130, a server 110, a gateway 120, etc.

[0078] The terminal 130 is used to upload the original code, and the terminal 130 includes various forms such as a desktop computer, a laptop computer, a PDA (personal digital assistant), a mobile phone, a vehicle terminal, a home theater terminal, a dedicated terminal, etc. In addition, the terminal 130 can be a single device or a collection of multiple devices. The terminal 130 can communicate with the server 110 in a wired or wireless manner to exchange data.

[0079] The server 110 refers to a code detection system that detects the original code uploaded by the terminal 130, and uses artificial intelligence methods to complete the detection of the original code. Compared with ordinary terminals 130, the server 110 has higher requirements in terms of stability, security, performance, etc. The server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), etc.

[0080] It should be noted that a model platform, a low-code platform and an error detection engine are set in the server 110, and the error detection engine sends the original code and detection target information to the model platform and the low-code platform respectively, and uses the generative pre-trained model on the model platform to perform error detection on the original code, and then uses the low-code platform to perform error detection on the original code. Finally, the error detection engine combines the error detection information output by the model platform and the low-code platform respectively as the final error detection information of the original code, and realizes the combination of the generative pre-trained model and the low-code platform to complete code detection. It combines the language understanding ability of the generative pre-trained model and the code parsing ability of the low-code platform, making code detection more intelligent and accurate, and improving the efficiency of code detection.

[0081] The gateway 120 is also called an internetwork connector or a protocol converter. The gateway 120 realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway 120 is a translator between two systems that use different communication protocols, data formats or languages, or even have completely different architectures. At the same time, the gateway 120 can also provide filtering and security functions. The message (such as the original code) sent by the terminal 130 to the server 110 needs to be sent to the corresponding server 110 through the gateway 120. The message (such as the target error detection information) sent by the server 110 to the terminal 130 also needs to be sent to the corresponding terminal 130 through the gateway 120.

[0082] Figure 2 is an optional flowchart of the code detection method based on artificial intelligence provided in an embodiment of the present application. Figure 2 The method may include but is not limited to steps S201 to S206.

[0083] Step S201, obtaining the original code and the detection target information of the original code;

[0084] Step S202, performing error detection on the original code using the generative pre-training model and detection target information to obtain first error detection information;

[0085] Step S203, converting the original code into an abstract syntax tree;

[0086] Step S204, extracting features from the original code according to the abstract syntax tree to obtain code semantic features;

[0087] Step S205, performing error detection on the original code according to the code semantic features and the detection target information to obtain second error detection information;

[0088] Step S206: The first error detection information and the second error detection information are combined to obtain target error detection information of the original code.

[0089] Steps S201 to S206 shown in the embodiment of the present application are to first perform error detection on the original code using a generative pre-trained model and detection target information to obtain first error detection information, then convert the original code into an abstract syntax tree, and extract the code semantic features of the original code based on the abstract syntax tree, so as to perform error detection on the original code based on the code semantic features and detection target information to obtain second error detection information. Finally, the first error detection information and the second error detection information are combined as the target error detection information of the original code. Therefore, the combination of the model and the code semantic features to perform error detection on the original code can realize intelligent code detection, which not only saves manpower in the original code detection process, reduces the professional requirements of code detection, improves the efficiency of code detection, but also can improve the accuracy of code error detection.

[0090] In step S201 of some embodiments, the original code and detection target information are sent from the terminal to the server, and the original code is the code written by the terminal. The detection target information is used to indicate which error problems are detected in the original code. The detection target information can be used to determine the error problems or performance problems in the original code.

[0091] In step S202 of some embodiments, the generative pre-trained model is referred to as the GPT model, and the GPT model is used to understand and analyze the original code to detect the error information of the original code and generate high-quality first error detection information. It should be noted that the GPT model is a pre-trained and fine-tuned language model. The training code and the error verification information of the training code are first obtained, and the error prediction information is obtained by inputting the training code into the GPT model for error detection. The parameters of the GPT model are adjusted according to the error prediction information and the error verification information to obtain a GPT model that can accurately detect code errors. In this embodiment, the GPT model uses a common deep learning framework in the pre-training and fine-tuning process, which can be any one of Tensorflow, Pytorch, Keras and Caffe. This embodiment does not specifically limit the deep learning framework of the GPT model. Specifically, Tensorflow has a leading position in the deep learning framework; Pytorch can use powerful GPU-accelerated Tensor calculations and can build deep neural networks with autograd; Keras provides a consistent and concise API, which can greatly reduce the workload of users in general applications. Therefore, according to the needs of GPT model for code detection, you can choose a suitable deep learning framework to improve the training effect of the GPT model and make code error detection more accurate.

[0092] Specifically, the original code is detected for errors through the GPT model and the detection target information. Specifically, the original code is semantically understood through the GPT model and the detection target information to obtain code semantic information, and then the original code is detected for errors through the GPT model and the code semantic information to obtain the first error detection information. Among them, the first error detection information specifically includes the error category, error location and error nature of the original code. The error category includes the basic error category and the potential error category. The basic error category characterizes some common code error categories that appear in the original code, such as code missing, code syntax error, code duplication, etc.; the potential error category characterizes the potential errors in the original code. The error nature characterizes the error attributes in the original code. It should be noted that the first error detection information is displayed in the form of a report, and the report lists all the problems found by the GPT model in the original code, including the error category, error location and error nature, to achieve error detection of the original code.

[0093] It should be noted that after setting up the GPT model to implement error detection of the original code, in order to further improve the accuracy of the original code detection, the low-code platform is set up to perform error detection on the original code again. It should be noted that the low-code platform is used to parse and detect errors in the original code. It can automatically parse the original code and obtain the structure and semantic information of the original code to perform error detection on the original code based on the structure and semantic information of the original code. Specifically, the low-code platform converts the original code into an abstract syntax tree, extracts the code semantic information of the original code based on the abstract syntax tree, and performs error detection on the original code based on the code semantic information and detection target information to obtain second error detection information.

[0094] As disclosed above, the low-code platform needs to complete parsing, semantic feature extraction and error detection, and the low-code platform includes: a code parser, a semantic analyzer and an error detection module. The code parser is used to convert the original code into an abstract syntax tree, the semantic analyzer is used to extract the code semantic features of the original code based on the abstract syntax tree, and the error detection module is used to detect errors in the original code based on the code semantic features.

[0095] See also Figure 3 In some embodiments, step S203 may include but is not limited to steps S301 to S302:

[0096] Step S301, parse the original code to obtain code grammar parsing information; wherein the code grammar parsing information includes: grammar elements and element dependency parameters between grammar elements, and the element dependency parameters represent the hierarchy and dependency relationship between grammar elements;

[0097] Step S302: convert the syntax elements into syntax nodes, and connect the syntax nodes according to the element dependency parameters to obtain an abstract syntax tree.

[0098] In step S301 of some embodiments, as disclosed above, the original code is parsed by a code parser to obtain code grammar parsing information. The code grammar parsing information includes: grammar elements and element dependency parameters between grammar elements. The grammar elements may include any of the following: variables, functions, classes, objects, conditional statements, loop statements, etc. The element dependency parameters represent the hierarchy of the grammar elements and the dependency relationship between the grammar elements. The grammar elements are combined together according to the element dependency parameters to form a complete program to achieve specific functions.

[0099] Specifically, the original code is decomposed into language elements by the code parser, and the language elements are the basic components of the language, such as keywords, identifiers, operators, constants and separators, etc. The code parser includes a lexical analyzer and a syntax analyzer, which convert the original code into syntax elements according to the lexical rules and syntax rules of the language, and the syntax analyzer also verifies the structure of the original code according to the syntax rules.

[0100] In step S302 of some embodiments, the syntax analyzer not only verifies the syntax structure of the original code, but also organizes the syntax elements into a tree structure according to the syntax rules to obtain an abstract syntax tree. It should be noted that the abstract syntax tree is a simplified representation of the structure of the original code, which is different from the specific syntax format and pays more attention to the semantics of the original code. Specifically, when constructing the abstract syntax tree, the syntax analyzer creates syntax nodes according to the syntax elements, and the syntax nodes are tree nodes of the abstract syntax tree. Each syntax node represents a specific part of the original code structure, and then the syntax nodes are connected into an abstract syntax tree according to the element dependency parameters, so as to represent the syntax structure of the original code through the abstract syntax tree, which can improve the syntax understanding ability of the original code.

[0101] It should be noted that the parser can construct the syntax elements and element dependency parameters into an abstract syntax tree, or construct the syntax elements and element dependency parameters into other processable data structures. This embodiment does not specifically limit the data structure constructed by the syntax elements and element dependency parameters. Further, after the abstract syntax tree is constructed, semantic information is added to the abstract syntax tree, and the semantic information includes: data category and scope, etc., to assist in feature extraction and error detection of the original code.

[0102] In steps S301 to S302 shown in this embodiment, the original code is parsed into syntax elements and element dependency parameters of the syntax elements, and the syntax elements are converted into syntax nodes. The syntax nodes are then connected into an abstract syntax tree according to the element dependency parameters, so that the syntax structure of the original code is represented by the abstract syntax tree. This can assist in subsequent feature extraction and error detection of the original code and improve the accuracy of error detection.

[0103] See also Figure 4 In some embodiments, step S301 may include but is not limited to steps S401 to S406:

[0104] Step S401, decomposing the original code to obtain code elements;

[0105] Step S402, obtaining the lexical category of each code element;

[0106] Step S403, converting the code element into a code token according to preset lexical rules and lexical categories; wherein the lexical rules include a mapping relationship between lexical categories and code tokens;

[0107] Step S404, converting the code token into a grammatical element according to a preset grammatical rule; wherein the grammatical rule includes a mapping relationship between the code token and the grammatical element;

[0108] Step S405, obtaining logic information of the code element;

[0109] Step S406: Identify the dependency relationship of the syntax element according to the logic information to obtain the element dependency parameter of the syntax element.

[0110] In steps S401 to S403 of some embodiments, the code element is an element that constructs the original code, which can be one of a variable, a function, a class, an object, a conditional statement, and a loop statement. The lexical category represents the category of the code element, and the lexical rule records the mapping relationship between each lexical category and the candidate tag. According to the lexical category of each code element, the corresponding candidate tag is found in the lexical rule as the code tag of the code element, and multiple code tags are spliced ​​into a code tag sequence to represent the lexical structure of the original code through the code tag sequence.

[0111] In step S404 of some embodiments, the grammar rules are set in the grammar analyzer, and the grammar rules record the mapping relationship between code tags and grammar elements. The grammar elements corresponding to each code tag are found in the grammar rules by the grammar analyzer, so that the grammar element determination operation is fast and accurate.

[0112] In steps S405 to S406 of some embodiments, as disclosed above, element dependency parameters characterize the hierarchy of grammatical elements and the dependency relationship between grammatical elements, so the logical information between the code elements is first determined to determine the hierarchy and dependency relationship of the code elements, and the dependency relationship of the grammatical elements is identified based on the logical information to obtain the element dependency parameters, so that the element dependency parameters are easy to find and can accurately characterize the dependency relationship between the code elements.

[0113] It should be noted that when the code parser generates syntax elements and element-dependent parameters of syntax elements, if it directly finds that there are syntax errors in the original code, it will directly generate syntax error information, and the syntax error information indicates the location and nature of the syntax error in the original code, so that the user can correct the original code according to the syntax error information.

[0114] In step S401 to step S406 shown in this embodiment, by decomposing the original code into code elements, converting the code elements into code tags, and finally determining the syntax elements according to the code tags and syntax rules, the syntax information of the code elements can be accurately represented. At the same time, the element dependency parameters of the syntax elements are determined according to the logical information between the code elements, so that the generation operation of the syntax elements and the element dependency parameters is simple, and the semantic structure of the original code can be accurately represented.

[0115] In step S204 of some embodiments, code semantic features are extracted from the original code through a semantic analyzer and an abstract syntax structure, and the code semantic features are used to analyze the features of errors in the original code. Among them, the code semantic features include: code semantic information, key variables and function dependency information. It should be noted that the code semantic information is the meaning expressed by the original code, that is, the intrinsic meaning of the original code in the programming language and the operations it performs, the key variables are the key variables in the original code, and the function dependency information represents the logical relationship of the functions in the original code and the dependency relationship between the functions.

[0116] See also Figure 5 In some embodiments, step S204 may include but is not limited to steps S501 to S504:

[0117] Step S501, traverse the abstract syntax tree to obtain node information; wherein the node information includes: node category, node structure information, node usage count and node dependency information;

[0118] Step S502, extracting code semantic information from the original code according to the node category and node structure information;

[0119] Step S503, extracting key variables from the original code according to the number of node usages;

[0120] Step S504: extracting function dependency information from the original code according to the node dependency information.

[0121] In step S501 of some embodiments, the abstract syntax tree is traversed by a semantic analyzer, and the traversal method can be depth-first or breadth-first. This embodiment does not specifically limit the traversal method of the abstract syntax tree. Specifically, each element node of the abstract syntax tree and the dependency relationship between element nodes are traversed by a syntax analyzer, and the semantic analyzer will create or update a symbol table, which is used to store information such as the name, category, and scope of variables and functions. If an element node of a variable declaration or function definition is encountered during the traversal process, the semantic analyzer will add the relevant information of the element node to the symbol table to maintain the node information through the symbol table. Among them, the node information includes node category, node structure information, node usage count and node dependency information. The node structure information is the structure of the element node, the node usage count is the number of times the element node is used, and the node dependency information is the dependency relationship between the element nodes.

[0122] In step S502 of some embodiments, the semantic analyzer extracts code semantic information in the original code based on the node category and node structure information to determine the meaning represented by the original code.

[0123] In step S503 of some embodiments, the key variable is an important code element in the original code, and the number of node usages also represents the number of element usages of the code element. The higher the number of element usages, the more important the code element is. Therefore, the nodes are sorted from large to small according to the number of node usages, and the code elements corresponding to a preset number of element nodes are selected as key variables.

[0124] In step S504 of some embodiments, the function dependency relationship represents the calling relationship between functions, for example, function A depends on the return value of function B. Specifically, the element nodes can be directly determined as the dependency relationship between functions through the node dependency relationship to determine the function dependency information.

[0125] It should be noted that the code semantic features may also include unused variables and unused functions. Code elements whose node usage count is zero and whose element nodes are variables are determined as unused variables, and code elements whose node usage count is zero and whose element nodes are functions are determined as unused functions.

[0126] In steps S501 to S504 shown in this embodiment, the semantic analyzer traverses the abstract syntax tree to determine the node category, node structure information, node usage count, and node dependency information, and extracts code semantic information from the original code based on the node category and node structure information, extracts key variables from the original code based on the node usage count, and extracts function dependency information from the original code based on the node dependency information. Therefore, it is easy to collect the code semantic information, key variables, and function dependency information of the original code through the semantic analyzer, and it is convenient to make error detection of the original code more accurate based on the code semantic information, key variables, and function dependency information.

[0127] In step S205 of some embodiments, error detection is performed on the original code through the error detection module, code semantic features and detection target information, and the error detection module of this embodiment uses three error detection technologies to detect errors in the original code. Among them, the three error detection technologies include: static analysis technology, rule engine technology and machine learning technology. The static analysis technology mainly detects basic errors in the original code, the rule engine technology detects errors in the original code that do not comply with the rules according to the rules it carries, and the machine learning technology intelligently detects errors in the original code.

[0128] See also Figure 6 In some embodiments, step S205 may include but is not limited to steps S601 to S604:

[0129] Step S601, performing basic syntax error detection on the original code according to the code semantic features and detection target information to obtain basic syntax error detection information;

[0130] Step S602, performing rule detection on the original code according to preset detection rules, code semantic features and detection target information to obtain rule detection information;

[0131] Step S603, performing error detection on the original code by using a preset error detection model, code semantic features and detection target information to obtain intelligent error detection information;

[0132] Step S604, concatenating the basic syntax error detection information, the rule detection information and the intelligent error detection information to obtain second error detection information.

[0133] In step S601 of some embodiments, basic syntax error detection is performed on the original code, mainly including data flow analysis, category checking and pattern matching. It should be noted that data flow analysis is to analyze whether the variables in the original code are undefined or exceed their scope, specifically by obtaining the data flow formula in the original code, and the data flow formula represents the use flow direction of the variables in the context in the original code, and the data flow formula can be a definition-use chain. Then, the variables in the original code are checked according to the data flow formula to determine the use status and scope information of the variables, and the data flow analysis information is determined according to the use status and scope information of the variables. Category detection is to detect the consistency of the data categories between the function parameters, return values ​​and variables in the original code to obtain category detection information. Pattern matching is to find out common errors in the original code according to the preset pattern, such as dead loops, resource leaks, etc., to obtain pattern matching information. Finally, the data flow analysis information, category detection information and pattern matching information are spliced ​​to obtain basic syntax error detection information.

[0134] In step S602 of some embodiments, rule detection is implemented by a rule engine, and the rule engine predefines detection rules, and the detection rules are rules written in advance to detect errors in the original code. For example, the preset detection rules may be "uninitialized variables are prohibited to be used" or "the categories of function parameters need to be consistent". Specifically, before the rule engine performs rule detection on the original code, the original code is first parsed into a structure understood by the rule engine to obtain the target code, the detection rules are loaded through the rule engine, and each code segment in the target code is evaluated to evaluate whether each code segment complies with the detection rules to obtain rule detection information. It should be noted that the rule detection information includes: error code segments that violate the detection rules and error information of the error code segments.

[0135] In step S603 of some embodiments, the error detection model is a machine learning model that is trained in advance and used for code error detection. It should be noted that before the error detection model performs error detection on the original code, a large amount of sample code and error reference information of the sample code are first collected, and the sample code includes normal code and abnormal code of known errors. Error detection is performed by inputting the sample code into the machine learning model, and the machine learning model is adjusted according to the output information and error reference information of the machine learning model to obtain an error detection model that can perform code error detection. In addition, after completing the training of the error detection model, it is also necessary to evaluate the error detection model in real time to evaluate the accuracy of the error detection model in error detection. Specifically, the error detection model is evaluated by the test code and the error reference information of the test code, and the error detection model is optimized according to the evaluation information to obtain an error detection model with more accurate error detection. Therefore, the error detection of the original code is completed by the error detection model that is trained and optimized in real time, and the detection process is completed in combination with the code semantic features and the detection target information to obtain accurate intelligent error detection information.

[0136] In step S604 of some embodiments, the basic grammatical error detection information, the rule detection information, and the intelligent error detection information may be concatenated in a manner such as summation, weighted summation, and average value. This embodiment does not specifically limit the concatenation of the basic grammatical error detection information, the rule detection information, and the intelligent error detection information. If the weighted summation concatenation is adopted, the weights of the basic grammatical error detection information, the rule detection information, and the intelligent error detection information are first determined respectively, and the basic grammatical error detection information, the rule detection information, and the intelligent error detection information are summed according to the weights to obtain the second error detection information.

[0137] In steps S601 to S604 shown in this embodiment, the original code is firstly subjected to basic syntax error detection by using static analysis technology, and then the original code is subjected to rule detection by loading preset detection rules through the rule engine, and finally the machine learning model is introduced to perform deep learning and error detection on the original code. Therefore, the error detection of the original code is completed by combining the three error detection technologies, and the comprehensiveness of the error detection of the original code is improved to obtain more accurate second error detection information.

[0138] In step S206 of some embodiments, in order to improve the accuracy of original code detection, the first error detection information output by the GPT model and the second error detection information output by the low-code platform are merged to obtain the target error detection information of the original code. Specifically, the first error detection information includes multiple first error detection contents, and the second error detection information includes multiple second error detection contents. The contents that are the same as the first error detection contents and the second error detection contents are first used as selected error detection contents, and the contents that are different from the first error detection contents and the second error detection contents are used as candidate error detection contents. The selected error detection contents are filtered out from the candidate error detection contents according to the preset error detection rules, and finally the selected error detection contents and the selected error detection contents are spliced ​​into the target error detection information. It should be noted that the error detection rules represent the reference error categories that may exist in the original code. If the error category of the candidate error detection content meets the reference error category, the corresponding candidate error detection content is selected as the selected error detection content.

[0139] For example, if the detection target information is to detect the problem of uninitialized variables in the original code, the original code is converted into an abstract syntax tree through a code parser, and then the semantic analyzer extracts the first variable usage information from the original code according to the abstract syntax tree, and the first variable usage information includes: first variable declaration information and first variable usage status. At the same time, the GPT model also performs semantic understanding of the original code and detects the second variable usage information in the original code, and the second variable usage information includes: second variable declaration information and second variable usage status. Then, the matching of the first variable declaration information and the second variable declaration information, as well as the matching of the first variable usage status and the second variable usage status are used to determine the variables that were not initialized when used in the original code to obtain the target error detection information.

[0140] It should be noted that the error detection engine outputs target error detection information of the original code and provides repair suggestions for the original code based on the target error detection information. The repair suggestions include the specific location of the code error, the cause of the error and the recommended repair solution.

[0141] See also Figure 7 In some embodiments, after step S106, the code detection method based on artificial intelligence further includes but is not limited to steps S701 to S702:

[0142] Step S701, selecting selected code repair information from preset candidate code repair information according to target error detection information;

[0143] Step S702: Generate a repair solution according to the target error detection information and the selected code repair information to obtain a code repair solution.

[0144] In step S701 of some embodiments, the candidate code repair information is also a repair suggestion for the original code, and the repair suggestion includes the error location of the original code and the repair measures. Specifically, candidate repair tag information is set on each candidate code repair information, and the candidate repair tag information records the applicable error information, so the selected repair tag information is filtered out from the candidate repair tag information according to the target error detection information, and then the selected code repair information is filtered out from the candidate code repair information according to the selected repair tag information.

[0145] In step S702 of some embodiments, there are multiple selected code repair information, and each target error detection information is matched with the corresponding selected code repair information to obtain a code repair sub-scheme, and then the multiple code repair sub-schemes are merged to obtain a code repair scheme. It should be noted that the code repair scheme records the code error problems that occur in the original code and the repair suggestions corresponding to each code error problem, so the code repair scheme can assist developers in repairing the errors in the original code, so as to output updated code with fewer errors and improve the stability of the financial system.

[0146] In steps S701 to S702 shown in this embodiment, selected code repair information is selected from candidate code repair information based on target error detection information, and the target error detection information and the selected code repair information of each target error detection information are combined into a code repair scheme to assist developers in repairing the original code through the code repair scheme and reduce error problems in the original code.

[0147] See also Figure 8 In some embodiments, step S701 may include but is not limited to steps S801 to S802:

[0148] Step S801, classifying the target error detection information to obtain the error class;

[0149] Step S802: Selected code repair information is screened out from candidate code repair information according to the error category and target error detection information.

[0150] In steps S801 to S802 of some embodiments, during the screening of candidate code repair information, it is necessary to first determine the error category of the target error detection information, so as to screen out selected repair information with category matching according to different error categories. Specifically, the error category of the target error detection information is first identified, and the selected code repair information is screened out from the candidate code repair information according to the error category, and then the selected code repair information is screened out from the selected code repair information according to the target error detection information, so as to realize the rapid screening of the selected code repair information.

[0151] Specifically, the error categories include: syntax error category, logic error category, performance error category and vulnerability error category. For example, the syntax error category indicates that the original code has missing semicolons, mismatched brackets, etc., the logic error category can indicate that the original code has improper conditional judgments, loops that do not terminate, etc., the performance error category indicates that the original code has highly complex loops, frequent function calls, etc., and the vulnerability error category indicates that the original code has uninitialized variables, resource leaks, etc. It should be noted that the selected code repair information selected includes error locations and error repair suggestions. For example, if the error category is a syntax error category, and the target error detection information is a missing semicolon, the error repair suggestion is determined to be "add a semicolon at the syntax error location". If the error category is a logic error category, and the target error detection information is a conditional judgment using an incorrect operator, the error repair suggestion is determined to be "please change '==' to '!=' to correct this logic error". Therefore, according to different error categories and target error detection information, the corresponding selected code repair information is selected, and repair suggestions can be provided to developers, making the repair of the original code more efficient and simple.

[0152] In step S801 to step S802 shown in this embodiment, the selected code repair information is screened out from the candidate code repair information by combining the error category of the target error detection information and the target error detection information, so that the screening of the selected code repair information is more efficient.

[0153] A user interface is set on the terminal, and the developer inputs the original code and the detection target information of the original code through the user interface, and interacts with the server through the user interface, and displays the target error detection information and code repair plan of the original code through the user interface. It should be noted that multiple code repair plans can be generated, and the developer can select a target repair plan from multiple code repair plans through the user node, and modify the original code according to the target repair plan to obtain the updated code. For example, Fig. 9 The user interface is shown in the figure, and the code input area, code detection result area and repair suggestion area are set on the user interface. Developers can click the code import button in the code input area to input the original code and input the target detection information at the same time. After waiting for a while, the code detection result area will display the target error detection information, and the target error detection information includes the error category, error cause and error location, and the repair suggestion area will display the code repair plan corresponding to the target error detection information.

[0154] The embodiment of the present application combines the GPT model and the low-code platform to complete the error detection of the original code. Specifically, the error detection engine receives the original code and the detection target information of the original code, and sends the original code and the detection target information to the GPT model and the low-code platform respectively. The original code is semantically understood by the GPT model and the detection target information to obtain a semantic representation, and the original code is error-detected according to the semantic representation of the original code to obtain the first error detection information. Among them, the low-code platform includes: a code parser, a semantic analyzer, and an error detection module, and the code parser is composed of a lexical analyzer and a syntax analyzer. The lexical analyzer first parses the original code into code elements, and obtains the lexical category of each code element, and converts the code elements into code tags according to the lexical rules and lexical categories. Then, the code tags are converted into grammatical elements by the syntax analyzer and the syntax rules, and the logical information of the code elements is obtained at the same time, and the element dependency parameters between the syntax elements are determined according to the logical information. The syntax analyzer first converts the syntax elements into syntax nodes according to the syntax rules, and connects the syntax nodes into an abstract syntax tree according to the element dependency parameters. Therefore, by constructing an abstract syntax tree to represent the grammatical structure of the original code, the error detection of the original code can be assisted according to the abstract syntax tree.

[0155] After constructing the abstract syntax tree, the abstract syntax tree is traversed by the semantic analyzer to obtain the node category, node structure information, node usage times and node dependency information, and the code semantic information is extracted from the original code according to the node category and node structure information, and the key variables are extracted from the original code according to the node usage times, and then the function dependency information is extracted from the original code according to the node dependency information. The error detection module combines the code semantic information, key variables, code semantic information and detection target information to perform error detection on the original code. Specifically, in the error detection process of the error detection module, the basic syntax errors of the original code are first detected by static analysis technology to obtain basic syntax error information, and then the detection rules are loaded by the rule engine. According to the detection rules, code semantic information, key variables, code semantic information and detection target information, the original code is subjected to rule detection to obtain rule detection information, and the machine learning model, code semantic information, key variables, code semantic information and detection target information are introduced to perform intelligent error detection on the original code to obtain intelligent error detection information. Finally, the basic syntax error detection information, rule detection information and intelligent error detection information are spliced ​​into the second error detection information. Then, the target error detection information of the original code is merged based on the first error detection information and the second error detection information. Therefore, by combining the language understanding ability of the GPT model and the code parsing ability of the low-code platform, intelligent code detection can be achieved, which not only reduces the professional requirements for code detection, improves the efficiency of code detection, but also improves the accuracy of error detection in the original code. At the same time, when completing the error detection of the original code through the low-code platform, a combination of three error detection technologies is used to make error detection more comprehensive.

[0156] In order to improve the efficiency of repairing the original code, the target error detection information will first be categorized to obtain the error category, and the selected code repair information will be screened out from the candidate code repair information based on the error category and the target error detection information. Then, the target error detection information and the selected code repair information will be spliced ​​into a code repair plan to assist developers in quickly repairing problems in the original code and improve system development efficiency.

[0157] See also Fig.10 The embodiment of the present application also provides an artificial intelligence-based code detection device, which can implement the above-mentioned artificial intelligence-based code detection method, and the device includes:

[0158] An acquisition module 1001 is used to acquire the original code and the detection target information of the original code;

[0159] A model error detection module 1002 is used to perform error detection on the original code by using a generative pre-trained model and detection target information to obtain first error detection information;

[0160] A syntax tree construction module 1003, used to convert the original code into an abstract syntax tree;

[0161] A feature extraction module 1004 is used to extract features from the original code according to the abstract syntax tree to obtain code semantic features;

[0162] The error detection module 1005 is used to perform error detection on the original code according to the code semantic features and the detection target information to obtain second error detection information;

[0163] The merging module 1006 is used to merge the first error detection information and the second error detection information to obtain target error detection information of the original code.

[0164] The specific implementation of the artificial intelligence-based code detection device is basically the same as the specific implementation of the above-mentioned artificial intelligence-based code detection method, and will not be repeated here.

[0165] The embodiment of the present application also provides a computer device, the computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned code detection method based on artificial intelligence when executing the computer program. The computer device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0166] See also Fig.11 , Fig.11 The hardware structure of a computer device according to another embodiment is shown, and the computer device includes:

[0167] The processor 1101 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0168] The memory 1102 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1102 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1102, and the processor 1101 calls and executes the artificial intelligence-based code detection method of the embodiment of this application;

[0169] Input / output interface 1103, used to implement information input and output;

[0170] The communication interface 1104 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);

[0171] A bus 1105 that transmits information between various components of the device (e.g., the processor 1101, the memory 1102, the input / output interface 1103, and the communication interface 1104);

[0172] The processor 1101 , the memory 1102 , the input / output interface 1103 and the communication interface 1104 are connected to each other in communication within the device via the bus 1105 .

[0173] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned artificial intelligence-based code detection method is implemented.

[0174] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0175] The artificial intelligence-based code detection method, device, equipment and storage medium provided in the embodiments of the present application perform error detection on the original code through a generative pre-trained model and detection target information to obtain first error detection information, and then convert the original code into an abstract syntax tree to represent the grammatical structure of the original code through the abstract syntax tree, so as to extract code semantic features that assist error detection from the original code according to the abstract syntax tree, so as to complete the error detection of the original code according to the code semantic features and the detection target information to obtain accurate second error detection information. Finally, the first error detection information and the second error detection information are combined into target error detection information to realize the combination of the two error detection modes to complete the error detection of the original code, which not only reduces the professional requirements of code detection, improves the efficiency of code detection, but also improves the accuracy of error detection of the original code.

[0176] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0177] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0178] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0179] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0180] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0181] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0182] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0183] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0184] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0185] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0186] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A code detection method based on artificial intelligence, characterized in that: The method comprises: Acquire original code and detection target information of the original code; Performing error detection on the original code using a generative pre-trained model and the detection target information to obtain first error detection information; Convert the original code into an abstract syntax tree; Perform feature extraction on the original code according to the abstract syntax tree to obtain code semantic features; Performing error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information; The first error detection information and the second error detection information are combined to obtain target error detection information of the original code.

2. The method according to claim 1, characterized in that The converting the original code into an abstract syntax tree comprises: Performing syntax parsing on the original code to obtain code syntax parsing information; wherein the code syntax parsing information includes: syntax elements and element dependency parameters between the syntax elements, the element dependency parameters representing the hierarchy and dependency relationship between the syntax elements; The syntax elements are converted into syntax nodes, and the syntax nodes are connected according to the element dependency parameters to obtain an abstract syntax tree.

3. The method according to claim 2, characterized in that The process of performing syntax analysis on the target original code to obtain code syntax analysis information includes: Decomposing the original code to obtain code elements; Obtaining the lexical category of each of the code elements; Converting the code element into a code token according to a preset lexical rule and the lexical category; wherein the lexical rule includes a mapping relationship between the lexical category and the code token; Converting the code mark into the grammatical element according to a preset grammatical rule; wherein the grammatical rule includes a mapping relationship between the code mark and the grammatical element; Obtaining logic information of the code element; Dependency relationships of the syntax elements are identified according to the logic information to obtain the element dependency parameters of the syntax elements.

4. The method according to claim 1, characterized in that: The code semantic features include: code semantic information, key variables and function dependency information; The extracting features of the original code according to the abstract syntax tree to obtain code semantic features includes: Traversing the abstract syntax tree to obtain node information; wherein the node information includes: node category, node structure information, node usage count and node dependency information; Extracting the code semantic information from the original code according to the node category and the node structure information; Extracting the key variable from the original code according to the number of times the node is used; The function dependency information is extracted from the original code according to the node dependency information.

5. The method according to claim 1, characterized in that The performing error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information includes: Performing basic syntax error detection on the original code according to the code semantic features and the detection target information to obtain basic syntax error detection information; Performing rule detection on the original code according to a preset detection rule, the code semantic feature and the detection target information to obtain rule detection information; Performing error detection on the original code by using a preset error detection model, the code semantic features and the detection target information to obtain intelligent error detection information; The basic grammatical error detection information, the rule detection information and the intelligent error detection information are concatenated to obtain the second error detection information.

6. The method according to any one of claims 1 to 4, characterized in that: After the first error detection information and the second error detection information are combined to obtain the target error detection information of the original code, the method further includes: Filtering selected code repair information from preset candidate code repair information according to the target error detection information; A repair solution is generated according to the target error detection information and the selected code repair information to obtain a code repair solution.

7. The method according to claim 6, characterized in that The selecting the selected code repair information from the preset candidate code repair information according to the target error detection information includes: Performing category recognition on the target error detection information to obtain an error category; Selected code repair information is screened out from the candidate code repair information according to the error category and the target error detection information.

8. A code detection device based on artificial intelligence, characterized in that: The device comprises: An acquisition module, used to acquire original code and detection target information of the original code; A model error detection module, used to perform error detection on the original code by using a generative pre-trained model and the detection target information to obtain first error detection information; A syntax tree building module, used for converting the original code into an abstract syntax tree; A feature extraction module, used to extract features from the original code according to the abstract syntax tree to obtain code semantic features; An error detection module, used to perform error detection on the original code according to the code semantic feature and the detection target information to obtain second error detection information; The merging module is used to merge the first error detection information and the second error detection information to obtain the target error detection information of the original code.

9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the artificial intelligence-based code detection method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the artificial intelligence-based code detection method according to any one of claims 1 to 7 is implemented.