Code analysis method and device, equipment and storage medium
By using position markers in JSON files to determine the parsing method, and using incremental or full parsing processing, the problem of slow parsing speed of JSON files in the prior art is solved, improving the analysis efficiency and saving computing resources.
Patent Information
- Application Number
- CN202411945660.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-27
AI Technical Summary
In the prior art, JSON file parsing speed is slow and consumes a lot of computer resources, especially when processing large JSON files.
By adding a position mark in the code file, it is determined whether it is the first numerical value. If it is not the first numerical value, incremental analysis processing is performed; if it is the first numerical value, full analysis processing is performed to avoid repeated analysis of the already parsed code.
It effectively improves the parsing speed of code files, saves CPU, memory and I/O resources, and avoids repeated parsing.
Smart Images

Figure CN119883275A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a code parsing method, device, equipment and storage medium. Background Art
[0002] JSON (JavaScript Object Notation) parsing is the process of converting a string in JSON format into a corresponding data structure (such as a dictionary in Python or an object in JavaScript). The basic structure of JSON includes objects (consisting of key-value pairs) and arrays (an ordered collection of values).
[0003] In the related art, manual parsing methods are usually used to parse JSON files. First, the JSON data needs to be read into the memory. The JSON data can be obtained by using file read and write operations or network requests, and then the data is stored in a string variable. Then, each field of the JSON data needs to be parsed one by one. JSON data consists of key-value pairs, each key corresponds to a value, and the JSON data can be gradually parsed using string processing operations (such as intercepting substrings) and regular expressions. After the parsing is completed, the corresponding value can be obtained by key. According to the structure of the JSON data, the obtained value can be converted into the required data type, such as string, integer, floating point number, etc., by using string processing operations and type conversion. The advantage of manual parsing is high flexibility, which is suitable for simple JSON structures and small JSON files.
[0004] However, the above analysis method consumes a lot of computer resources, resulting in a slow analysis speed. Summary of the invention
[0005] The embodiment of the present application provides a code parsing method, device, equipment and storage medium. The technical solution provided by the embodiment of the present application is as follows:
[0006] According to one aspect of an embodiment of the present application, a code parsing method is provided, the method comprising:
[0007] Acquire a code file, wherein the code file includes a position mark, and the position mark is used to indicate the position of the code in the code file that has been subjected to code parsing processing;
[0008] In the case where the position mark is not the first value, performing incremental parsing processing on the code file to obtain an incremental parsing result, wherein the incremental parsing processing is used to perform code parsing processing on incremental code in the code file, the incremental code refers to code located after the position mark, and the position mark not being the first value is used to indicate that there is code in the code file that has been subjected to code parsing processing;
[0009] When the position mark is the first value, a full parsing process is performed on the code file to obtain a full parsing result, wherein the full parsing process is used to perform code parsing process on the full code in the code file, and the position mark is the first value to indicate that there is no code in the code file that has undergone code parsing process.
[0010] According to one aspect of an embodiment of the present application, a code parsing device is provided, the device comprising:
[0011] A code acquisition module, used to acquire a code file, wherein the code file includes a position mark, and the position mark is used to indicate the position of the code in the code file that has been processed by code parsing;
[0012] an incremental parsing module, configured to, when the position mark is not a first value, perform incremental parsing processing on the code file to obtain an incremental parsing result, wherein the incremental parsing processing is used to perform code parsing processing on incremental code in the code file, wherein the incremental code refers to code located after the position mark, and the position mark not being the first value is used to indicate that there is code in the code file that has been subjected to code parsing processing;
[0013] A full parsing module is used to perform full parsing processing on the code file when the position mark is the first value to obtain a full parsing result. The full parsing processing is used to perform code parsing processing on the full code in the code file. The position mark is the first value used to indicate that there is no code in the code file that has undergone code parsing processing.
[0014] According to one aspect of an embodiment of the present application, a server is provided, the server comprising a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-mentioned code parsing method.
[0015] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned code parsing method.
[0016] According to one aspect of an embodiment of the present application, a computer program product is provided, wherein the computer program product includes a computer program, and the computer program is loaded and executed by a processor to implement the above-mentioned code parsing method.
[0017] The technical solution provided in the embodiments of the present application can bring the following beneficial effects:
[0018] By judging whether the position mark in the code file is the first value, different code parsing methods can be adopted according to whether the position mark is the first value. When the position mark is not the first value, code parsing is only performed on the incremental code in the code file to obtain the incremental parsing result. For the code that has been parsed, the corresponding code parsing result can be directly obtained from the server, so that the code parsing result of the full code in the code file is obtained according to the incremental parsing result and the code parsing result of the code that has been parsed, avoiding re-executing the code parsing for the code that has been parsed, saving computer resources such as CPU (Central Processing Unit) resources, memory resources, and I / O (Input / Output) resources, and effectively improving the code parsing speed of the code file. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application;
[0020] Figure 2 is a flowchart of a code parsing method provided by an embodiment of the present application;
[0021] Figure 3 This is a schematic diagram of the classification of type information of code files provided by an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of a process for obtaining incremental parsing results provided by an embodiment of the present application;
[0023] Figure 5 It is a schematic diagram of a process of obtaining a full parsing result provided by an embodiment of the present application;
[0024] Figure 6 It is a schematic diagram of the complete process of the code parsing method provided by an embodiment of the present application;
[0025] Figure 7 is a block diagram of a code parsing device provided by an embodiment of the present application;
[0026] Figure 8 This is a structural block diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0028] Please refer to Figure 1, which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment can be implemented as a code parsing system. The solution implementation environment may include: a terminal device 10 and a server 20.
[0029] The number of terminal devices 10 can be one or more. The terminal device 10 can be an electronic device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a game console, an e-book reader, a multimedia player, a wearable device, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc.
[0030] The terminal device 10 may be installed with a client of a target application, and the target application has the function of editing code and generating a code file. Exemplarily, the target application may be a code editing program. Optionally, the target application may be an application that needs to be downloaded and installed, or may be a click-to-use application, which is not limited in this application.
[0031] The server 20 is used to provide background services for the client of the target application installed and running in the terminal device 10. For example, the server 20 can be the background server of the above-mentioned target application. The server 20 can be an independent physical server, or a server cluster composed of multiple servers, or a cloud computing service center. Optionally, the server 20 provides background services for the target applications in multiple terminal devices 10 at the same time. The terminal device 10 and the server 20 can communicate with each other through the network.
[0032] The server 20 stores the code parsing results of the full amount of code in the parsed code file. Optionally, when a user edits code in the target application, he may add new code to the parsed code file to generate an updated code file. Then, there is a portion of code in the updated code file and the corresponding code parsing results are stored in the server 20. Therefore, the server 20 only needs to perform code parsing on the incremental code to obtain the incremental parsing results. For the code in the updated code file that has been parsed, the corresponding code parsing results can be directly obtained from the server 20.
[0033] Optionally, the user edits the code in the target application, or creates a new code file, in which the codes are all codes that have not been parsed. Therefore, the server 20 needs to perform code parsing on the full amount of code in the new code file to obtain a full parsing result.
[0034] In an embodiment of the present application, after the user edits the code in the target application and generates a code file, the client of the target application on the terminal device sends the code file to the server, and the server receives the code file. The code file includes a position mark, which is used to indicate the position of the code in the code file that has been processed by code parsing, that is, to indicate the end position of the code in the code file that the user edited last time. First, it is determined whether the code parsing result of the full amount of code in the code file is stored in the server. In the case that the code parsing result of the full amount of code in the code file exists in the server, the code parsing result of the full amount of code in the code file is obtained from the server. In the case that the code parsing result of the full amount of code in the code file does not exist in the server, it is determined whether the position mark in the code file is a first value. In the case that the position mark is not the first value, that is, in the case that there is code that has been processed by code parsing in the code file, the code file is subjected to incremental parsing processing to obtain an incremental parsing result. In the case that the position mark is the first value, that is, in the case that there is no code that has been processed by code parsing in the code file, the code file is subjected to full parsing processing to obtain a full parsing result.
[0035] Please refer to Figure 2 , which shows a flow chart of a code parsing method provided by an embodiment of the present application. The execution subject of each step of the method may be a server. The method may include at least one of the following steps 210 to 230:
[0036] Step 210: Obtain a code file, wherein the code file includes a position marker, and the position marker is used to indicate the position of the code in the code file that has been subjected to code parsing processing.
[0037] The code file is a code file edited and generated by the user in the target application of the terminal device. After the code file is edited and generated, the terminal device sends the code file to the server.
[0038] A code file is a file that stores object data. For example, normally an object can only exist when a program is running. When the program ends, the object disappears. Therefore, there is a need for users to convert objects into data with persistent properties that can be transmitted and stored. Therefore, users create a file in the target application and input the object data into the file in code format to generate a code file. The code file is easy to transmit and store. The terminal device sends the code file to the server, and the server performs code parsing on the code file to obtain the object data in the code file, so that the server can freely use the object data in the code file. Exemplarily, the code file can be a JSON file, and the code file is stored in JSON format.
[0039] The code file includes at least one line of object data, and each line of object data is used to describe the specific situation of an object. The objects in the code file include but are not limited to any object such as name, age, height, address, city, zip code, skills, etc. Object data includes object name and object content. The object content is used to explain the object name. For example, if the object name is name, the object content can be "XXX", if the object name is age, the object content can be "20", and so on. Exemplarily, the code file can be expressed as:
[0040] {
[0041] "name":"John Doe",
[0042] "age":30,
[0043] "skills":["Java","Python","JSON"],
[0044] "address":{
[0045] "city":"New York",
[0046] "zipcode":"10001"
[0047] },
[0048] "isEmployed":true
[0049] }
[0050] Optionally, the code file may be a code file generated for the first time. That is, the user creates a new file in the target application, and edits the input object data in the new file to generate a code file. The generated code file does not contain any code that has been processed by code parsing, that is, the code in the generated code file is all code that has not been processed by code parsing. The position mark in the code file is a numerical value, which is used to indicate that there is no code that has been processed by code parsing in the code file, and when there is no code that has been processed by code parsing in the code file, that is, when the code file is a code file generated for the first time, the position mark in the code file is a first numerical value. Exemplarily, the first numerical value is 0.
[0051] Optionally, the code file may also be a code file generated by further editing based on the code file generated last time. That is, the user edits and adds new code to the existing code file to obtain the code file generated this time, and the code file generated this time is a code file obtained by updating the code file generated last time. Since the server has performed code parsing processing on the code file generated last time when the code file was generated last time, there are codes that have been processed by code parsing in the code file generated this time, and the server has the code parsing results corresponding to the code file generated last time, that is, the server has the code parsing results of the codes that have been processed by code parsing in the code file generated this time. The position mark in the code file is used to indicate that there are codes that have been processed by code parsing in the code file. In the case where there are codes that have been processed by code parsing in the code file, that is, in the case where the code file is a code file generated by further editing based on the code file generated last time, the position mark in the code file is not the first value. Exemplarily, the position mark in the code file is not 0.
[0052] The position marker in the code file is used to indicate the end position of the code in the code file when it was last edited, that is, the position marker is used to indicate the total number of lines of code in the code that was last edited. Since the code that was last edited has been processed by code parsing, the position marker is used to indicate the position of the code that has been processed by code parsing in the code file. For example, if the code file is a code file generated for the first time, the code that was last edited does not exist in the code file, and the position marker is 0. For example, if the code file is a code file generated by further editing based on the code file that was last generated, the code that was last edited exists in the code file, and the position marker is not 0. For example, if the code file that was last generated contains 5 lines of code, the position marker 5 can be used to indicate that there are 5 lines of code in the code that was last edited, and it can also be used to indicate that the end position of the code in the code that was last edited is the 5th line.
[0053] In some embodiments, the code parsing results of the codes in the code file that have been subjected to the code parsing process are stored in the server.
[0054] The code parsing result corresponding to each generated code file is stored in the server, so the code parsing result corresponding to the code file generated last time has been stored in the server. Here, the code parsing result corresponding to the code file refers to the code parsing result of each line of code in the code file.
[0055] Step 220, when the position marker is not the first value, perform incremental parsing processing on the code file to obtain an incremental parsing result. The incremental parsing processing is used to perform code parsing processing on the incremental code in the code file. The incremental code refers to the code located after the position marker. The position marker is not the first value, which is used to indicate that there is code in the code file that has undergone code parsing processing.
[0056] Exemplarily, when the position mark is not 0, incremental parsing is performed on the code file to obtain an incremental parsing result.
[0057] When the position mark is not the first value, the code file is a code file generated by further editing based on the last generated code file, and there will be code in the code file that has been processed by code parsing, and there will also be code parsing results of the code that has been processed by code parsing in the server. Therefore, when it is necessary to obtain the code parsing results of the full code in the code file, the code parsing results of the code that has been processed by code parsing can be directly obtained from the server, and the code parsing results of the incremental code in the code file can be obtained by performing incremental parsing on the code file through the server, that is, the incremental parsing results, so as to obtain the code parsing results corresponding to the code file according to the code parsing results of the code that has been processed by code parsing and the incremental parsing results.
[0058] The code file includes the code that has been parsed and the incremental code. The incremental code is the code that was added when the code file was last generated. It refers to the code located after the position mark, specifically, the other code in the code file that is located after the code that has been parsed. Performing incremental parsing on the code file means performing code parsing on the incremental code in the code file. The incremental parsing result refers to the code parsing result of the incremental code.
[0059] For example, for the code file shown above, if the position mark is 5, the incremental code includes {"zipcode":"10001","isEmployed":true}, and the incremental code is parsed to obtain the incremental parsing result. The server stores the code parsing results of the first 5 lines of code in the code file. Therefore, the code parsing result corresponding to the code file is obtained based on the code parsing results of the first 5 lines of code stored in the server and the incremental parsing result obtained by this incremental parsing process.
[0060] Step 230, when the position mark is a first value, perform full parsing processing on the code file to obtain a full parsing result. The full parsing processing is used to perform code parsing processing on all codes in the code file. The position mark is a first value used to indicate that there is no code in the code file that has been parsed.
[0061] Exemplarily, when the position mark is 0, a full parsing process is performed on the code file to obtain a full parsing result.
[0062] When the position mark is the first value, the code file is a code file generated for the first time, and there is no code in the code file that has been parsed, and there is no code parsing result of any code in the code file in the server. Therefore, when it is necessary to obtain the code parsing result of the full code in the code file, no available code parsing result can be obtained from the server, and it is necessary to perform full parsing processing on the code file through the server to obtain the code parsing result of the full code in the code file, that is, the full parsing result.
[0063] All the codes in the code file are codes that have not been parsed, that is, all the codes in the code file are codes located after the position marker. Performing full parsing on the code file means performing code parsing on all the codes in the code file, and the full parsing result means the code parsing result of the full code.
[0064] Exemplarily, for the code file shown above, if the position mark is 0, it is necessary to perform code parsing processing on each line of code in the code file to obtain a code parsing result corresponding to the code file.
[0065] The technical solution provided by the embodiment of the present application determines whether the position mark in the code file is a first value, so that different code parsing methods can be adopted according to whether the position mark is the first value. When the position mark is not the first value, code parsing is only performed on the incremental code in the code file to obtain an incremental parsing result. For the code that has been parsed, the corresponding code parsing result can be directly obtained from the server, so that the code parsing result of the full code in the code file is obtained based on the incremental parsing result and the code parsing result of the code that has been parsed, thereby avoiding re-executing the code parsing process on the code that has been parsed, saving computer resources such as CPU resources, memory resources, and I / O resources, and effectively improving the code parsing speed of the code file.
[0066] In some embodiments, when the code parsing results of the full code in the code file exist in the server, the code parsing results of the full code in the code file are obtained from the server; when the code parsing results of the full code in the code file do not exist in the server, it is determined whether the position mark in the code file is a first value.
[0067] After step 210, the code file can also be identified first to determine whether the code file is a code file that has been processed by code parsing, that is, to determine whether there is a code parsing result of the full code in the code file in the server. In the case where the code file has been processed by code parsing, the code parsing result of the full code in the code file exists in the server, and for the code parsing result corresponding to the code file that needs to be obtained this time, the code parsing result of the full code in the code file can be directly obtained from the server. In the case where the code file has not been processed by code parsing, the code parsing result of the full code in the code file does not exist in the server, and it is necessary to determine whether the position mark in the code file is the first value, that is, to determine whether there is code that has been processed by code parsing in the code file. Then, when the position mark is not the first value, that is, when there is code that has been processed by code parsing in the code file, the incremental code (code that has not been processed by code parsing) in the code file is subjected to code parsing processing to obtain the incremental parsing result. In the case where the position mark is the first value, that is, when there is no code that has been processed by code parsing in the code file, the code parsing process is performed on the full code in the code file to obtain the full parsing result.
[0068] After obtaining the code file, by first judging whether the code parsing result of the full code in the code file exists in the server, it is avoided that when the code parsing result of the full code in the code file exists in the server, unnecessary code parsing steps are performed on the code file, which wastes computer resources and affects the code acquisition efficiency.
[0069] The following is an introduction to the incremental parsing process.
[0070] In some embodiments, step 220 includes at least one of sub-steps 221 - 223 .
[0071] Sub-step 221, obtaining the incremental code in the code file according to the code file and the position mark.
[0072] The incremental code in a code file refers to the code after the position marker in the code file.
[0073] For example, for the code file shown above, if the position marker is 5, the code after the position marker in the code file is obtained, and the incremental code obtained is {"zipcode":"10001","isEmployed":true}. If the position marker is 3, the code after the position marker in the code file is obtained, and the incremental code obtained is {"address":{"city":"New York","zipcode":"10001"},"isEmployed":true}.
[0074] Sub-step 222, determines the field information of the incremental code and the type information of the incremental code according to the incremental code, wherein the field information of the incremental code includes at least one key-value pair in the incremental code, and the type information of the incremental code includes the type information of the key in at least one key-value pair in the incremental code.
[0075] The field information of the incremental code is used to indicate the code content of the incremental code. The field information of the incremental code includes at least one key-value pair in the incremental code. Each key-value pair consists of a unique key (key) and a corresponding value (value). The key is used to identify the uniqueness of the data, and the value is the data associated with the key. This structure allows the corresponding value to be quickly found and accessed through the key. Each key-value pair in the code is used to represent an object data.
[0076] Exemplarily, if the incremental code is {"zipcode":"10001","isEmployed":true}, then the at least one key-value pair included in the field information of the incremental code is {"zipcode":"10001"} and {"isEmployed":true}, wherein, for the key-value pair {"zipcode":"10001"}, "zipcode" is the key in the key-value pair, and "10001" is the value in the key-value pair, and for the key-value pair {"isEmployed":true}, "isEmployed" is the key in the key-value pair, and "true" is the value in the key-value pair.
[0077] The type information of the incremental code is used to indicate the type information of at least one key-value pair in the incremental code, specifically refers to the type information of the key in at least one key-value pair in the incremental code. The definition of the key type information is preset by the technical staff and is not limited in this application. Exemplarily, for the code file shown above, the type information of the key includes the Address class and the Person class, wherein the type information of "city" and "zipcode" is the Address class, and the type information of "name", "age", "skills", "address" and "isEmployed" is the Person class. Therefore, the type information of the full code in the code file shown above can be referred to. Figure 3 shown.
[0078] For example, if the incremental code is {"zipcode":"10001","isEmployed":true}, the type information of the incremental code includes type information of "zipcode" and type information of "isEmployed", the type information of "zipcode" is the Address class, and the type information of "isEmployed" is the Person class.
[0079] Sub-step 223, assigns the value in at least one key-value pair of the incremental code to the type information of the key in at least one key-value pair in the incremental code, and obtains an incremental parsing result, wherein the incremental parsing result includes object information corresponding to each type information in the incremental code, and the object information corresponding to the type information includes the value in at least one key-value pair corresponding to the type information.
[0080] Exemplarily, the type information in the incremental code shown above includes the Address class and the Person class, then the incremental parsing result includes object information corresponding to the Address class and object information corresponding to the Person class, the object information corresponding to the Address class includes the value of at least one key-value pair corresponding to the Address class, and the object information corresponding to the Person class includes the value of at least one key-value pair corresponding to the Person class.
[0081] Exemplarily, if the incremental code is {"zipcode":"10001","isEmployed":true}, then at least one key-value pair included in the field information of the incremental code is {"zipcode":"10001"} and {"isEmployed":true}, and the type information of the incremental code includes the type information of "zipcode" and the type information of "isEmployed", the type information of "zipcode" is the Address class, and the type information of "isEmployed" is the Person class. Then the value in at least one key-value pair of the incremental code is assigned to the type information of the key in at least one key-value pair in the incremental code, that is, the value "10001" in the key-value pair {"zipcode":"10001"} is assigned to the type information of the key "zipcode" in the key-value pair, and the object information corresponding to the Address class includes "10001". The value "true" in the key-value pair {"isEmployed":true} is assigned to the type information of the key "isEmployed" in the key-value pair, and the object information corresponding to the Person class includes "true".
[0082] Exemplarily, if the incremental code is {"address":{"city":"New York","zipcode":"10001"},"isEmployed":true}, then the at least one key-value pair included in the field information of the incremental code is {"address":{"city":"New York","zipcode":"10001"}}, {"city":"New York"}, {"zipcode":"10001"}, and {"isEmployed":true}, and the type information of the incremental code includes type information of "address", type information of "city", type information of "zipcode", and type information of "isEmployed", the type information of "city" and "zipcode" is the Address class, and the type information of "address" and "isEmployed" is the Person class. The value in at least one key-value pair of the incremental code is assigned to the type information of the key in at least one key-value pair in the incremental code, and the object information corresponding to the Address class includes "New York" and "10001", and the object information corresponding to the Person class includes {"city":"New York","zipcode":"10001"} and "true".
[0083] Through the above steps, code parsing is performed on the incremental code in the code file to obtain an incremental parsing result. Therefore, based on the incremental parsing result and the code parsing result of the code that has been code parsed and stored in the server, the code parsing result corresponding to the code file can be obtained, which saves computing resources and improves code parsing efficiency.
[0084] In some embodiments, sub-step 222 includes at least one of sub-steps 2221 - 2222 .
[0085] Sub-step 2221, read the incremental code line by line to obtain the field information of the incremental code.
[0086] The code is written according to the code format, so the string corresponding to each line of code can represent an object data. After obtaining the incremental code in the code file, the incremental code is read line by line, and the string corresponding to each line of code in the incremental code is obtained in turn. The string corresponding to each line of code is accessed in the form of a key-value pair. For the string that cannot be accessed in the form of a key-value pair, the string corresponding to the line of code is removed to obtain the field information of the incremental code.
[0087] For example, for the code file shown above, if the position mark is 5, the incremental code can be expressed as:
[0088] "zipcode":"10001"
[0089] },
[0090] "isEmployed":true
[0091] }
[0092] The incremental code is read line by line to obtain the strings corresponding to each line of code, which are {"zipcode":"10001"}, {"},"}, {"isEmployed":true}, {"}"}, in order. The strings corresponding to {"zipcode":"10001"} and {"isEmployed":true} can be accessed as key-value pairs, while the strings corresponding to {"},"} and {"}"} cannot be accessed as key-value pairs. Therefore, according to the strings {"zipcode":"10001"} and {"isEmployed":true}, the field information of the incremental code can be obtained.
[0093] Sub-step 2222: Generate type information of the incremental code according to the incremental code and the first prompt information through the type generation model, where the first prompt information is used to prompt the type generation model to generate type information of the incremental code.
[0094] The incremental code and the first prompt information are input into the type generation model, and the type information of the incremental code is output. The first prompt information is used to prompt the type generation model to generate the type information of the incremental code. For example, the first prompt information may be: please convert the input code into type information, and the input code is {"zipcode":"10001","isEmployed":true}.
[0095] The type generation model is a model obtained by fine-tuning a large language model based on the first training sample. The large language model here can be any publicly available large language model, such as a natural language model based on a transformer structure obtained by training with a large amount of data. The large amount of data can reach a sample level of more than 100 million, and this application does not limit this.
[0096] The training process of the type generation model is as follows: at least one first training sample of the type generation model is obtained, each first training sample includes a first sample code, a first sample prompt and sample type information, and the sample type information is type information of the first sample code. The large language model generates predicted type information of the first sample code according to the first sample code and the first sample prompt, calculates a first loss function value according to the difference between the predicted type information and the sample type information, takes reducing the first loss function value as a training target, adjusts the parameters of the large language model, and obtains the type generation model.
[0097] By adopting a type generation model to obtain type information of incremental code, type information of the code can be automatically generated. Compared with the manual parsing method used in related technologies, automatic generation of type information can simplify the generation steps and can also be applied to larger codes, reducing the probability of errors when manually generating type information and improving the accuracy of type information generation.
[0098] In some embodiments, type information of the incremental code is generated according to the incremental code, the first prompt information and the first configuration information through a type generation model, and the first configuration information is used to indicate a generation method of the type information of the incremental code.
[0099] The incremental code, the first prompt information and the first configuration information are input into the type generation model, and the type information of the incremental code is output. The first configuration information is used to indicate the generation method of the type information of the incremental code. For example, the first configuration information can be: please convert the input code into type information and implement it with Java code.
[0100] The type generation model is a model obtained by fine-tuning the large language model according to the second training sample. The training process of the type generation model is as follows: obtain at least one second training sample of the type generation model, each second training sample includes a second sample code, a second sample prompt, a second sample configuration and sample type information, and the sample type information is the type information of the second sample code. The large language model generates the predicted type information of the second sample code according to the second sample code, the second sample prompt and the second sample configuration, and calculates the second loss function value according to the difference between the predicted type information and the sample type information, and takes reducing the second loss function value as the training goal, adjusts the parameters of the large language model, and obtains the type generation model.
[0101] By adding configuration information when generating the type information of the incremental code, the generation method of the type information is limited so that the type information of the generated incremental code can meet the user's customization requirements, making it easier for the type information to be connected and interoperable with other data in the server, thereby facilitating data sharing and utilization.
[0102] The schematic diagram of the incremental analysis result acquisition process can be found in Figure 4 As shown, first, according to the code file and the position mark, the incremental code located after the position mark in the code file is obtained, the incremental code is read line by line, and the field information of the incremental code is obtained. The type information of the incremental code is generated according to the incremental code, the first prompt information and the first configuration information through the type generation model. Here, the field information of the incremental code includes at least one key-value pair in the incremental code, and the type information of the incremental code includes the type information of the key in at least one key-value pair in the incremental code. The value in at least one key-value pair of the incremental code is assigned to the type information of the key in at least one key-value pair in the incremental code to obtain the incremental parsing result, and the incremental parsing result includes the object information corresponding to each type information in the incremental code.
[0103] In some embodiments, sub-step 223 further includes at least one of sub-steps 224 to 226.
[0104] Sub-step 224, obtaining the processing time of the incremental parsing process.
[0105] The processing time of the incremental parsing process = the time when the incremental parsing process is completed - the time when the incremental parsing process starts. The time when the code file is obtained can be regarded as the time when the incremental parsing process starts, and the time when the incremental parsing result is obtained can be regarded as the time when the incremental parsing process is completed.
[0106] Sub-step 225, when the processing time of the incremental parsing process is greater than or equal to the first duration, determining second prompt information, the second prompt information being used to adjust the classification of the type information of the incremental code.
[0107] The processing time of incremental parsing is related to the complexity of type information. The more classes included in the type information and the more complex the type information is, the longer the processing time of incremental parsing will be. The fewer classes included in the type information, the shorter the processing time of incremental parsing will be.
[0108] When the processing time of the incremental parsing is greater than or equal to the first duration, it is determined that the performance and efficiency of the incremental parsing performed this time do not meet the requirements, and it is necessary to adjust the classification of the type information of the incremental code by determining the second prompt information, optimize and reduce the classification of the type information of the incremental code, thereby shortening the processing time of the incremental parsing.
[0109] The specific value of the first duration is set by the technical personnel according to the incremental analysis requirements, and this application does not limit it.
[0110] Exemplarily, the second prompt information may be: the current definition of type information is complex, resulting in a long parsing time, please optimize the class definition.
[0111] Sub-step 226, according to the second prompt information, performs full parsing processing on the code file to obtain an updated incremental parsing result, and the updated incremental parsing result is used to update the code parsing result of the code that has been parsed in the code file stored in the server.
[0112] Since the classification of type information has been adjusted, if only incremental parsing is performed on the incremental code, the classification of the incremental code's type information will be different from the classification of the type information of the code that has been parsed, so that the object information corresponding to each type information in the incremental code and the object information corresponding to each type information in the code that has been parsed cannot be merged, and the code parsing is incomplete. Therefore, it is necessary to perform code parsing on the full amount of code in the code file according to the second prompt information to obtain an updated incremental parsing result, which includes the object information corresponding to each type information of the full amount of code in the code file.
[0113] When the processing time of the incremental parsing process is less than the first duration, the incremental parsing result is stored in the server. When the processing time of the incremental parsing process is greater than or equal to the first duration, the updated incremental parsing result is used to replace the code parsing result of the code in the code file stored in the server that has undergone code parsing processing, so that the code parsing result corresponding to the code file, i.e., the updated incremental parsing result, is stored in the server.
[0114] The process of performing full parsing processing on the code file according to the second prompt information is as follows: the code file is read line by line to obtain field information of the code file, and the type information of the code file is generated according to the code file, the first prompt information, the second prompt information and the first configuration information through the type generation model. The value in at least one key-value pair in the code file is assigned to the type information of the key in at least one key-value pair in the code file to obtain an updated incremental parsing result.
[0115] By judging whether the processing time of the incremental parsing is greater than or equal to the first duration, it is judged whether the performance and efficiency of the incremental parsing meet the requirements, so that the second prompt information can be determined in time, and the classification of the type information of the incremental code can be adjusted to shorten the processing time of the incremental parsing, so that the generated updated incremental parsing results meet the performance and efficiency requirements of the parsing processing, thereby improving the quality of code parsing.
[0116] The following is an introduction to the process of full-scale parsing.
[0117] In some embodiments, step 230 includes at least one of sub-steps 231 - 233 .
[0118] Sub-step 231, read the code file line by line to obtain field information of the code file, where the field information of the code file includes at least one key-value pair in the code file.
[0119] Read the code file line by line, get the string corresponding to each line of code in the code file in turn, access the string corresponding to each line of code in the form of a key-value pair, and for the string that cannot be accessed in the form of a key-value pair, remove the string corresponding to the line of code to get the field information of the code file.
[0120] Exemplarily, for the code file shown above, the field information of the code file includes at least one key-value pair of {"name":"John Doe"}, {"age":30}, {"skills":["Java","Python","JSON"]}, {"address":{"city":"New York","zipcode":"10001"}}, {"city":"New York"}, {"zipcode":"10001"}, and {"isEmployed":true}.
[0121] Sub-step 232, generates type information of the code file according to the code file and the third prompt information through the type generation model, the type information of the code file includes type information of the key in at least one key-value pair in the code file, and the third prompt information is used to prompt the type generation model to generate type information of the code file.
[0122] The code file and the third prompt information are input into the type generation model, and the type information of the code file is output. The training process of the type generation model can refer to the process of fine-tuning the large language model according to the first training sample in the above embodiment. The third prompt information is used to prompt the type generation model to generate the type information of the code file. For example, the third prompt information can be: Please convert the input code into type information. The input code is {"name":"John Doe","age":30,"skills":["Java","Python","JSON"],"address":{"city":"New York","zipcode":"10001"},"isEmployed":true}.
[0123] For example, for the code file shown above, the type information of the code file includes type information of "name", "age", "skills", "address", "city", "zipcode" and "isEmployed", wherein the type information of "city" and "zipcode" is the Address class, and the type information of "name", "age", "skills", "address" and "isEmployed" is the Person class. For the type information of the code file, please refer to Figure 3 shown.
[0124] In some embodiments, type information of the code file is generated by a type generation model according to the code file, the third prompt information and the second configuration information, and the second configuration information is used to indicate the generation method of the type information of the code file.
[0125] The code file, the third prompt information and the second configuration information are input into the type generation model, and the type information of the code file is output. The second configuration information is used to indicate the generation method of the type information of the code file. For example, the second configuration information may be: please convert the input code into type information, and implement it with Java code. The training process of the type generation model here can refer to the process of fine-tuning the large language model according to the second training sample in the above embodiment.
[0126] By adding configuration information when generating the type information of the code file, the generation method of the type information is limited so that the type information of the generated code file can meet the user's customization requirements, making it easier for the type information to be connected and communicated with other data in the server, which is conducive to data sharing and utilization.
[0127] Sub-step 233, assigns the value in at least one key-value pair in the code file to the type information of the key in at least one key-value pair in the code file, and obtains a full parsing result, wherein the full parsing result includes object information corresponding to each type information in the code file, and the object information corresponding to the type information includes the value in at least one key-value pair corresponding to the type information.
[0128] Exemplarily, the type information in the code file shown above includes the Address class and the Person class, then the full parsing result includes object information corresponding to the Address class and object information corresponding to the Person class, the object information corresponding to the Address class includes the value of at least one key-value pair corresponding to the Address class, and the object information corresponding to the Person class includes the value of at least one key-value pair corresponding to the Person class.
[0129] Exemplarily, the value in at least one key-value pair in the code file is assigned to the type information of the key in at least one key-value pair in the code file, that is, the value "John Doe" in the key-value pair {"name":"John Doe"} is assigned to the type information Person class of the key "name" in the key-value pair, the value "30" in the key-value pair {"age":30} is assigned to the type information Person class of the key "age" in the key-value pair, the value "["Java","Python","JSON"]" in the key-value pair {"skills":["Java","Python","JSON"]} is assigned to the type information Person class of the key "skills" in the key-value pair, the value "address":{"city":"New York","zipcode":"10001"}} in the key-value pair {"city":"New York","zipcode":"10001"}" is assigned to the type information Person class of the key "address" in the key-value pair, and the value "New New York", assign the type information of the key "city" in the key-value pair to the Address class, assign the value "10001" in the key-value pair {"zipcode":"10001"} to the type information of the key "zipcode" in the key-value pair to the Address class, and assign the value "true" in the key-value pair {"isEmployed":true} to the type information of the key "isEmployed" in the key-value pair to the Person class. The object information corresponding to the Address class includes "New York" and "10001", and the object information corresponding to the Person class includes "John Doe", "30", ["Java","Python","JSON"], {"city":"New York","zipcode":"10001"}, and "true".
[0130] By adopting a type generation model to obtain type information of incremental code, type information of the code can be automatically generated. By performing code parsing processing on the entire code in the code file, the accuracy of type information generation can be improved, as well as the efficiency of code parsing.
[0131] The schematic diagram of the process of obtaining the full analysis results can be referred to Figure 5As shown, the code file is read line by line to obtain the field information of the code file, and the type information of the code file is generated according to the code file, the third prompt information and the second configuration information through the type generation model. Here, the field information of the code file includes at least one key-value pair in the code file, and the type information of the code file includes the type information of the key in at least one key-value pair in the code file. The value in at least one key-value pair in the code file is assigned to the type information of the key in at least one key-value pair in the code file to obtain a full parsing result, which includes the object information corresponding to each type information in the code file.
[0132] In some embodiments, sub-step 233 further includes at least one of sub-steps 234 to 236 .
[0133] Sub-step 234, obtaining the processing time of the full parsing process.
[0134] The processing time of the full parsing process = the time when the full parsing process is completed - the time when the full parsing process starts. The time when the code file is obtained can be regarded as the time when the full parsing process starts, and the time when the full parsing result is obtained can be regarded as the time when the full parsing process is completed.
[0135] Sub-step 235, when the processing time of the full parsing process is greater than or equal to the second duration, determining fourth prompt information, the fourth prompt information being used to optimize the classification of the type information of the code file.
[0136] The processing time of full parsing is related to the complexity of type information. The more classes included in the type information and the more complex the type information is, the longer the processing time of full parsing will be. The fewer classes included in the type information, the shorter the processing time of full parsing will be.
[0137] When the processing time of the full parsing is greater than or equal to the second time duration, it is determined that the performance and efficiency of the full parsing executed this time do not meet the requirements, and it is necessary to adjust the classification of the type information of the full code by determining the fourth prompt information, optimize and reduce the classification of the type information of the incremental code, thereby shortening the processing time of the incremental parsing.
[0138] The specific value of the second duration is set by the technician according to the incremental analysis requirements, and this application does not limit it. Optionally, the second duration can be the same as the first duration, or different from the first duration, and this application does not limit it. In some embodiments, the second duration is equal to the first duration.
[0139] Exemplarily, the fourth prompt information may be: the current definition of type information is complex, resulting in a long parsing time, please optimize the class definition.
[0140] Sub-step 236, according to the fourth prompt information, re-execute the step of performing full parsing processing on the code file to obtain an updated full parsing result, and the updated full parsing result is used to store in the server.
[0141] If the processing time of the full parsing process is greater than or equal to the second duration, the updated full parsing result is stored in the server. If the processing time of the full parsing process is less than the second duration, the full parsing result is stored in the server.
[0142] By judging whether the processing time of the full parsing is greater than or equal to the second time duration, it is judged whether the performance and efficiency of the full parsing meet the requirements, so that the fourth prompt information can be determined in time, and the classification of the type information of the incremental code file can be adjusted to shorten the processing time of the full parsing, so that the generated updated full parsing result meets the performance and efficiency requirements of the parsing, thereby improving the quality of code parsing.
[0143] The schematic diagram of the complete process of the code parsing method provided in this application can be referred to Figure 6 As shown, after obtaining the code file, the server first identifies the code file to determine whether there is a code parsing result of the full code in the code file in the server. In the case that the code parsing result of the full code in the code file exists in the server, the code parsing result cached in the server is reused, that is, the code parsing result of the full code in the code file is directly obtained from the server. In the case that the code parsing result of the full code in the code file does not exist in the server, it is necessary to determine whether the position mark in the code file is 0. In the case that the position mark is not 0, the incremental code in the code file is subjected to code parsing processing to obtain the incremental parsing result. In the case that the position mark is 0, the code parsing processing is performed on the full code in the code file to obtain the full parsing result. Then, it is determined whether the time of the code parsing processing is less than the threshold. In the case that the time of the code parsing processing is less than the threshold, the incremental parsing result or the full parsing result is stored in the server. In the case that the time of the code parsing processing is greater than or equal to the threshold, the prompt information is determined to optimize the classification of the type information, and the full parsing processing is performed on the code file according to the prompt information to obtain the updated parsing result.
[0144] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0145] Please refer to Figure 7, which shows a block diagram of a code parsing device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned code parsing method, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be the server introduced above, or it can be set in the server. Figure 7 As shown, the device 700 may include: a code acquisition module 710, an incremental parsing module 720 and a full parsing module 730.
[0146] The code acquisition module 710 is used to acquire a code file, wherein the code file includes a position mark, and the position mark is used to indicate the position of the code in the code file that has been subjected to code parsing processing.
[0147] The incremental parsing module 720 is used to perform incremental parsing processing on the code file to obtain an incremental parsing result when the position mark is not a first value. The incremental parsing processing is used to perform code parsing processing on the incremental code in the code file, and the incremental code refers to the code located after the position mark. The position mark not being the first value is used to indicate that there is code in the code file that has undergone code parsing processing.
[0148] The full parsing module 730 is used to perform a full parsing process on the code file when the position mark is the first value to obtain a full parsing result. The full parsing process is used to perform code parsing process on the full code in the code file. The position mark is the first value to indicate that there is no code in the code file that has undergone code parsing process.
[0149] In some embodiments, the incremental parsing module 720 is used to:
[0150] According to the code file and the position mark, obtaining the incremental code in the code file;
[0151] Determine, according to the incremental code, field information of the incremental code and type information of the incremental code, wherein the field information of the incremental code includes at least one key-value pair in the incremental code, and the type information of the incremental code includes type information of a key in at least one key-value pair in the incremental code;
[0152] The value in at least one key-value pair of the incremental code is assigned to the type information of the key in at least one key-value pair in the incremental code to obtain the incremental parsing result, wherein the incremental parsing result includes object information corresponding to each type information in the incremental code, and the object information corresponding to the type information includes the value in at least one key-value pair corresponding to the type information.
[0153] In some embodiments, the incremental parsing module 720 is used to:
[0154] Read the incremental code line by line to obtain field information of the incremental code;
[0155] The type information of the incremental code is generated according to the incremental code and the first prompt information by a type generation model, wherein the first prompt information is used to prompt the type generation model to generate the type information of the incremental code.
[0156] In some embodiments, the incremental parsing module 720 is used to:
[0157] The type information of the incremental code is generated by the type generation model according to the incremental code, the first prompt information and the first configuration information, wherein the first configuration information is used to indicate a generation method of the type information of the incremental code.
[0158] In some embodiments, the code parsing result of the code in the code file that has been subjected to code parsing processing is stored in the server; the incremental parsing module 720 is used to:
[0159] Obtaining the processing time of the incremental parsing process;
[0160] In a case where the processing time of the incremental parsing process is greater than or equal to the first duration, determining second prompt information, wherein the second prompt information is used to adjust the classification of the type information of the incremental code;
[0161] According to the second prompt information, a full parsing process is performed on the code file to obtain an updated incremental parsing result, and the updated incremental parsing result is used to update the code parsing result of the code that has been subjected to code parsing process in the code file stored in the server.
[0162] In some embodiments, the full-data parsing module 730 is used to:
[0163] Read the code file line by line to obtain field information of the code file, where the field information of the code file includes at least one key-value pair in the code file;
[0164] Generate type information of the code file according to the code file and third prompt information through a type generation model, wherein the type information of the code file includes type information of a key in at least one key-value pair in the code file, and the third prompt information is used to prompt the type generation model to generate the type information of the code file;
[0165] The value in at least one key-value pair in the code file is assigned to the type information of the key in at least one key-value pair in the code file to obtain the full parsing result, wherein the full parsing result includes object information corresponding to each type information in the code file, and the object information corresponding to the type information includes the value in at least one key-value pair corresponding to the type information.
[0166] In some embodiments, the full-data parsing module 730 is used to:
[0167] The type information of the code file is generated by the type generation model according to the code file, the third prompt information and the second configuration information, wherein the second configuration information is used to indicate a generation method of the type information of the code file.
[0168] In some embodiments, the full-data parsing module 730 is used to:
[0169] Obtaining the processing time of the full parsing process;
[0170] When the processing time of the full parsing process is greater than or equal to the second duration, determining fourth prompt information, wherein the fourth prompt information is used to optimize the classification of the type information of the code file;
[0171] According to the fourth prompt information, the step of performing full parsing processing on the code file is re-executed to obtain an updated full parsing result, and the updated full parsing result is used to be stored in the server.
[0172] In some embodiments, the code parsing result of the code in the code file that has been subjected to code parsing processing is stored in the server; the device further includes a result reuse module, the result reuse module being used to:
[0173] If the code parsing result of the full amount of code in the code file exists in the server, obtaining the code parsing result of the full amount of code in the code file from the server;
[0174] When the code parsing result of the full code in the code file does not exist in the server, it is determined whether the position mark in the code file is the first value.
[0175] It should be noted that the device provided in the above embodiment, when implementing its functions, 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 content structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0176] Please refer to Figure 8 , which shows a structural block diagram of a server 800 provided in one embodiment of the present application. The server 800 can be any electronic device with data calculation, processing and storage functions. The server 800 can be used to implement the code parsing method provided in the above embodiment.
[0177] Typically, the server 800 includes a processor 801 and a memory 802 .
[0178] The processor 801 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 801 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). The processor 801 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 801 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 801 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0179] The memory 802 may include one or more computer-readable storage media, which may be non-transitory. The memory 802 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 802 is used to store a computer program, which is configured to be executed by one or more processors to implement the above-mentioned code parsing method.
[0180] Those skilled in the art will understand that Figure 8 The structure shown in the figure does not constitute a limitation on the server 800, and the server 800 may include more or less components than those shown in the figure, or combine some components, or adopt a different arrangement of components.
[0181] In an illustrative embodiment, a computer-readable storage medium is also provided, in which a computer program is stored, and when the computer program is executed by a processor of a server, the above-mentioned code parsing method is implemented. Optionally, the above-mentioned computer-readable storage medium can be ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage device, etc.
[0182] In an exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a server reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the server executes the above-mentioned code parsing method.
[0183] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.
[0184] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A code analysis method, characterized in that: The method comprises: Acquire a code file, wherein the code file includes a position mark, and the position mark is used to indicate the position of the code in the code file that has been subjected to code parsing processing; In the case where the position mark is not the first value, performing incremental parsing processing on the code file to obtain an incremental parsing result, wherein the incremental parsing processing is used to perform code parsing processing on incremental code in the code file, the incremental code refers to code located after the position mark, and the position mark not being the first value is used to indicate that there is code in the code file that has been subjected to code parsing processing; When the position mark is the first value, a full parsing process is performed on the code file to obtain a full parsing result, wherein the full parsing process is used to perform code parsing process on the full code in the code file, and the position mark is the first value to indicate that there is no code in the code file that has undergone code parsing process.
2. The method according to claim 1, characterized in that The performing incremental parsing processing on the code file to obtain an incremental parsing result includes: According to the code file and the position mark, obtaining the incremental code in the code file; Determine, according to the incremental code, field information of the incremental code and type information of the incremental code, wherein the field information of the incremental code includes at least one key-value pair in the incremental code, and the type information of the incremental code includes type information of a key in at least one key-value pair in the incremental code; The value in at least one key-value pair of the incremental code is assigned to the type information of the key in at least one key-value pair in the incremental code to obtain the incremental parsing result, wherein the incremental parsing result includes object information corresponding to each type information in the incremental code, and the object information corresponding to the type information includes the value in at least one key-value pair corresponding to the type information.
3. The method according to claim 2, characterized in that The step of determining, according to the incremental code, field information of the incremental code and type information of the incremental code includes: Read the incremental code line by line to obtain field information of the incremental code; The type information of the incremental code is generated according to the incremental code and the first prompt information by a type generation model, wherein the first prompt information is used to prompt the type generation model to generate the type information of the incremental code.
4. The method according to claim 3, characterized in that The step of generating type information of the incremental code according to the incremental code and the first prompt information by using a type generation model includes: The type information of the incremental code is generated by the type generation model according to the incremental code, the first prompt information and the first configuration information, wherein the first configuration information is used to indicate a generation method of the type information of the incremental code.
5. The method according to claim 3, characterized in that: The code parsing result of the code in the code file that has been subjected to code parsing processing is stored in the server; After performing incremental parsing on the code file to obtain the incremental parsing result, the method further includes: Obtaining the processing time of the incremental parsing process; In a case where the processing time of the incremental parsing process is greater than or equal to the first duration, determining second prompt information, wherein the second prompt information is used to adjust the classification of the type information of the incremental code; According to the second prompt information, a full parsing process is performed on the code file to obtain an updated incremental parsing result, and the updated incremental parsing result is used to update the code parsing result of the code that has been subjected to code parsing process in the code file stored in the server.
6. The method according to claim 1, characterized in that The performing of full parsing processing on the code file to obtain a full parsing result includes: Read the code file line by line to obtain field information of the code file, where the field information of the code file includes at least one key-value pair in the code file; Generate type information of the code file according to the code file and third prompt information through a type generation model, wherein the type information of the code file includes type information of a key in at least one key-value pair in the code file, and the third prompt information is used to prompt the type generation model to generate the type information of the code file; The value in at least one key-value pair in the code file is assigned to the type information of the key in at least one key-value pair in the code file to obtain the full parsing result, wherein the full parsing result includes object information corresponding to each type information in the code file, and the object information corresponding to the type information includes the value in at least one key-value pair corresponding to the type information.
7. The method according to claim 6, characterized in that The step of generating type information of the code file according to the code file and the third prompt information by using a type generation model includes: The type information of the code file is generated by the type generation model according to the code file, the third prompt information and the second configuration information, wherein the second configuration information is used to indicate a generation method of the type information of the code file.
8. The method according to claim 6, characterized in that After performing full parsing processing on the code file and obtaining a full parsing result, the method further includes: Obtaining the processing time of the full parsing process; When the processing time of the full parsing process is greater than or equal to the second duration, determining fourth prompt information, wherein the fourth prompt information is used to optimize the classification of the type information of the code file; According to the fourth prompt information, the step of performing full parsing processing on the code file is re-executed to obtain an updated full parsing result, and the updated full parsing result is used to be stored in the server.
9. The method according to claim 1, characterized in that: The code parsing result of the code in the code file that has been subjected to code parsing processing is stored in the server; the method further comprises: If the code parsing result of the full amount of code in the code file exists in the server, obtaining the code parsing result of the full amount of code in the code file from the server; When the code parsing result of the full code in the code file does not exist in the server, it is determined whether the position mark in the code file is the first value.
10. A code analysis device, characterized in that: The device comprises: A code acquisition module, used to acquire a code file, wherein the code file includes a position mark, and the position mark is used to indicate the position of the code in the code file that has been processed by code parsing; an incremental parsing module, configured to, when the position mark is not a first value, perform incremental parsing processing on the code file to obtain an incremental parsing result, wherein the incremental parsing processing is used to perform code parsing processing on incremental code in the code file, wherein the incremental code refers to code located after the position mark, and the position mark not being the first value is used to indicate that there is code in the code file that has been subjected to code parsing processing; A full parsing module is used to perform full parsing processing on the code file when the position mark is the first value to obtain a full parsing result. The full parsing processing is used to perform code parsing processing on the full code in the code file. The position mark is the first value used to indicate that there is no code in the code file that has undergone code parsing processing.
11. A server, characterized in that: The server includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the code parsing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the code parsing method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises a computer program, which is loaded and executed by a processor to implement the code parsing method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Java class analysis method and device, storage medium and electronic equipment
CN110990019A
Incremental code analysis method and device, equipment and medium
CN116149726A
JSON file analysis method, electronic equipment, storage medium and program product
CN117973365A
Code checking method and device
CN118057330A
Markup language file processing device, system and method and medium
CN118133781A