Code analysis method and device, equipment and storage medium
By using position markers in JSON parsing to determine the processing status of code files and adopting incremental or full parsing methods, the problem of high resource consumption in existing technologies is solved, achieving faster parsing speed and higher efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2026-03-27
AI Technical Summary
Existing JSON parsing methods consume a lot of computer resources, resulting in slower parsing speeds.
By using position markers in the code file to determine whether it is the first value, incremental or full parsing is adopted to avoid repeated processing of already parsed code, thus saving CPU, memory and I/O resources.
It improves the parsing speed of code files, saves computer resources, and enhances parsing efficiency.
Smart Images

Figure CN119883275B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a code parsing method and device, equipment and storage medium. BACKGROUND
[0002] JSON (JavaScript Object Notation) parsing is the process of converting a JSON-formatted string into a corresponding data structure (such as a dictionary in Python or an object in JavaScript), and the basic structure of JSON includes objects (composed of key-value pairs) and arrays (an ordered collection of values).
[0003] In related technologies, a manual parsing method is usually used to parse a JSON file. First, JSON data needs to be read into memory, and JSON data can be obtained using file read / write operations or network requests, etc., 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 is composed of key-value pairs, and each key corresponds to a value, which can be parsed step by step using string processing operations (such as substring extraction) and regular expressions. After completing the parsing, the corresponding value can be obtained through the key, and 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.) using string processing operations and type conversion. The advantage of manual parsing is high flexibility, which is suitable for simple JSON structure and small JSON files.
[0004] However, the above parsing method consumes a large amount of computer resources, resulting in slow parsing speed. SUMMARY
[0005] The embodiments of the present application provide a code parsing method, device, equipment and storage medium. The technical solutions provided by the embodiments of the present application are as follows:
[0006] According to an aspect of the embodiments of the present application, a code parsing method is provided, which comprises:
[0007] obtaining 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 which has been processed by code parsing;
[0008] in the case that the position marker is not a first numerical 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 the incremental code in the code file, the incremental code refers to the code located after the position marker, and the position marker not being the first numerical value is used to represent that there is code in the code file which has been processed by code parsing.
[0009] In a case where the position marker is the first value, performing full-amount parsing processing on the code file to obtain a full-amount parsing result, the full-amount parsing processing being used for performing code parsing processing on full-amount code in the code file, and the position marker being the first value being used for indicating that there is no code that has been subjected to code parsing processing in the code file.
[0010] According to an aspect of an embodiment of the present application, a code parsing device is provided, and the device comprises:
[0011] a code obtaining module configured to obtain a code file, the code file comprising a position marker, the position marker being used for indicating a position of code in the code file that has been subjected to code parsing processing;
[0012] an incremental parsing module configured to, in a case where 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 being used for performing code parsing processing on incremental code in the code file, the incremental code being code located after the position marker, and the position marker not being the first value being used for indicating that there is code that has been subjected to code parsing processing in the code file;
[0013] a full-amount parsing module configured to, in a case where the position marker is the first value, perform full-amount parsing processing on the code file to obtain a full-amount parsing result, the full-amount parsing processing being used for performing code parsing processing on full-amount code in the code file, and the position marker being the first value being used for indicating that there is no code that has been subjected to code parsing processing in the code file.
[0014] According to an 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 code parsing method described above.
[0015] According to an aspect of an embodiment of the present application, a computer readable storage medium is provided, the computer readable storage medium storing a computer program, the computer program being loaded and executed by a processor to implement the code parsing method described above.
[0016] According to an aspect of an embodiment of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being loaded and executed by a processor to implement the code parsing method described above.
[0017] The technical solution provided by 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 manners can be adopted according to whether the position mark is the first value. In the case that the position mark is not the first value, only the incremental code in the code file is subjected to code parsing processing to obtain an incremental parsing result. For the code that has been subjected to code parsing processing, the corresponding code parsing result can be directly obtained from the server. Therefore, according to the incremental parsing result and the code parsing result of the code that has been subjected to code parsing processing, the code parsing result of the full-amount code in the code file is obtained, and the code parsing processing of the code that has been subjected to code parsing processing is avoided, thereby saving the computer resources such as CPU (Central Processing Unit) resources, memory resources, I / O (Input / Output) resources, and the like, and effectively improving the code parsing speed of the code file. BRIEF DESCRIPTION OF DRAWINGS
[0019] Figure 1 is a schematic diagram of a scheme implementation environment 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 is a classification schematic diagram of type information of a code file provided by an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of an acquisition process of an incremental parsing result provided by an embodiment of the present application;
[0023] Figure 5 is a schematic diagram of an acquisition process of a full-amount parsing result provided by an embodiment of the present application;
[0024] Figure 6 is a schematic diagram of a complete process of a code parsing method provided by an embodiment of the present application;
[0025] Figure 7 is a block diagram of a code parsing apparatus provided by an embodiment of the present application;
[0026] Figure 8 is a structural block diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION
[0027] To make the objectives, technical solutions and advantages of the present application clearer, the following will further describe the embodiments of the present application in combination with the drawings.
[0028] Reference should be made to Figure 1Fig. 1 shows a schematic diagram of a scheme implementation environment according to an embodiment of the present application. The scheme implementation environment can be implemented as a code analysis system. The scheme implementation environment can include a terminal device 10 and a server 20.
[0029] There can be one or more terminal devices 10. The terminal device 10 can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, a game console, an e-book reader, a multimedia player, a wearable device, a smart voice interactive device, a smart home appliance, a vehicle-mounted terminal, an aircraft, etc.
[0030] The terminal device 10 can be installed with a client of a target application program, which has a function of editing code and generating a code file. The target application program can be a code editing program, for example. Alternatively, the target application program can be an application program that needs to be downloaded and installed, or an application program that can be used immediately after being clicked, which is not limited in the present application.
[0031] The server 20 is configured to provide background services for the client of the target application program installed and running in the terminal device 10. For example, the server 20 can be a background server of the target application program. The server 20 can be a physical server, a server cluster composed of multiple servers, or a cloud computing service center. Alternatively, the server 20 can provide background services for multiple target application programs in multiple terminal devices 10. The terminal device 10 and the server 20 can communicate with each other through a network.
[0032] The server 20 stores code analysis results of full-amount code in a code file that has been processed by the analysis. Alternatively, the user edits code in the target application program, which can be to add new code on the basis of the code file that has been processed by the analysis, thereby generating an updated code file. There is a part of code in the updated code file that has a corresponding code analysis result stored in the server 20. Therefore, the server 20 only needs to perform code analysis on the incremental code to obtain an incremental analysis result. For the code in the updated code file that has been processed by the code analysis, the corresponding code analysis result can be directly obtained from the server 20.
[0033] Alternatively, the user edits code in the target application program, which can be to create a brand-new code file. The code in the brand-new code file is all code that has not been processed by the code analysis. Therefore, the server 20 needs to perform code analysis on the full-amount code in the brand-new code file to obtain a full-amount analysis result.
[0034] In the 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 marker, which is used to indicate the position of the code in the code file that has been processed by the code parsing. First, it is determined whether the server stores the code parsing result of the full amount of code in the code file. If the server stores the code parsing result of the full amount of code in the code file, the code parsing result of the full amount of code in the code file is obtained from the server. If the server does not store the code parsing result of the full amount of code in the code file, it is determined whether the position marker in the code file is a first value. If the position marker is not the first value, that is, if there is code in the code file that has been processed by the code parsing, incremental parsing processing is performed on the code file to obtain an incremental parsing result. If the position marker is the first value, that is, if there is no code in the code file that has been processed by the code parsing, full amount parsing processing is performed on the code file to obtain a full amount parsing result.
[0035] Please refer to Figure 2 which shows a flowchart of a code parsing method provided by an embodiment of the present application. The execution subject of each step of the method can be a server. The method can include at least one of the following steps 210-230:
[0036] Step 210, obtaining a code file, the code file including a position marker, the position marker being used to indicate the position of the code in the code file that has been processed by the code parsing.
[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] The code file is a file for the storage property of the object data. For example, in general, an object can only exist during the running of a program, and when the program ends, the object also disappears. Therefore, there is a demand for the user to convert the object into data with persistent properties that can be transmitted and stored. Therefore, the user creates a file in the target application and inputs the object data into the file in the code format to generate a code file, which is convenient for transmission and storage. The terminal device sends the code file to the server, and the server performs code parsing processing 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 the JSON format.
[0039] The code file includes at least one line of object data, and each line of object data is used to describe a specific case 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, and skill. The object data includes an object name and object content, and 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 represented 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 can be a code file generated for the first time. That is, the user creates a new file in the target application program, edits and inputs object data in the new file, and generates the code file. The generated code file does not include code that has been processed by the code parsing process, that is, all the code in the generated code file is code that has not been processed by the code parsing process. The position marker in the code file is a numerical value, which is used to indicate that there is no code in the code file that has been processed by the code parsing process, and in the case that there is no code in the code file that has been processed by the code parsing process, that is, in the case that the code file is a code file generated for the first time, the position marker in the code file is a first numerical value. Exemplarily, the first numerical value is 0.
[0051] Optionally, the code file can also be based on the last generated code file and further edited to generate the code file. That is, the user edits the existing code file to add new code to generate the code file, and the code file is updated based on the last generated code file. Since the server has performed code parsing processing on the last generated code file, the code in the code file has been processed, and the server has the code parsing result corresponding to the last generated code file, that is, the server has the code parsing result of the code in the code file that has been processed. The position marker in the code file is used to indicate that the code in the code file has been processed. When the code file is further edited based on the last generated code file, the position marker in the code file is not the first value. For example, the position marker 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 at the last edit, that is, the position marker is used to represent the total number of lines of code in the last edited code. Since the last edited code has been processed, the position marker is used to indicate the position of the code in the code file that has been processed. For example, if the code file is a newly generated code file, there is no last edited code in the code file, and the position marker is 0. For example, if the code file is further edited based on the last generated code file, there is last edited code in the code file, and the position marker is not 0. For example, if the last generated code file contains 5 lines of code, the position marker is 5, which can be used to represent that there are 5 lines of code in the last edited code, or the end position of the code in the last edited code is the 5th line.
[0053] In some embodiments, the code parsing result of the code in the code file that has been processed is 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 last generated code file is already 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] In the case where the position marker is not the first value, the incremental parsing processing is performed on the code file to obtain an incremental parsing result. 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 marker. The position marker not being the first value indicates that there is code in the code file that has been subjected to code parsing processing.
[0056] For example, in the case where the position marker is not 0, the incremental parsing processing is performed on the code file to obtain an incremental parsing result.
[0057] In the case where the position marker is not the first value, the code file is further edited based on the last generated code file, and thus there is code in the code file that has been subjected to code parsing processing. The server also stores code parsing results of the code that has been subjected to code parsing processing. Therefore, in the case where the code parsing result of the entire code in the code file is required, the code parsing result of the code that has been subjected to code parsing processing can be directly obtained from the server, and the incremental parsing processing is performed on the code file by the server to obtain the code parsing result of the incremental code in the code file, i.e., the incremental parsing result. Thus, the code parsing result corresponding to the code file is obtained based on the code parsing result of the code that has been subjected to code parsing processing and the incremental parsing result.
[0058] The code file includes code that has been subjected to code parsing processing and incremental code. The incremental code is newly added code when the last generated code file is edited this time, and refers to code located after the position marker, specifically, other code in the code file located after the code that has been subjected to code parsing processing. The incremental parsing processing refers to code parsing processing performed 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 marker is 5, the incremental code includes {"zipcode":"10001","isEmployed":true}, and the incremental parsing processing is performed on the incremental code to obtain an incremental parsing result. The server stores the code parsing result 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 result of the first 5 lines of code stored in the server and the incremental parsing result obtained by the incremental parsing processing this time.
[0060] In the case where the position marker is the first value, the full parsing processing is performed on the code file to obtain a full parsing result. The full parsing processing is used to perform code parsing processing on the entire code in the code file. The position marker being the first value indicates that there is no code in the code file that has been subjected to code parsing processing.
[0061] Exemplarily, in the case that the position marker is 0, full parsing processing is performed on the code file to obtain a full parsing result.
[0062] In the case that the position marker 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 subjected to code parsing processing, and there is also no code parsing result of any code in the code file in the server. Therefore, in the case that the code parsing result of the full code in the code file is required, no available code parsing result can be obtained from the server, and full parsing processing needs to be performed on the code file by 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 full code in the code file is code that has not been subjected to code parsing processing, that is, all the full code in the code file is code located after the position marker. Performing full parsing processing on the code file means performing code parsing processing on the full code 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 marker is 0, code parsing processing needs to be performed on each line of code in the code file to obtain the code parsing result corresponding to the code file.
[0065] The technical scheme provided by the embodiments of the present application enables different code parsing manners to be used according to whether the position marker is the first value, in the case that the position marker is not the first value, only the incremental code in the code file is subjected to code parsing processing to obtain an incremental parsing result, and for the code that has been subjected to code parsing processing, 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 subjected to code parsing processing, and the code parsing processing of the code that has been subjected to code parsing processing is avoided, thereby saving computer resources such as CPU resources, memory resources, I / O resources, and effectively improving the code parsing speed of the code file.
[0066] In some embodiments, in the case that the code parsing result of the full code in the code file exists in the server, the code parsing result of the full code in the code file is obtained from the server; and in the case that the code parsing result of the full code in the code file does not exist in the server, it is determined whether the position marker in the code file is the 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 the code parsing result of the full code in the code file exists 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 then it needs to be determined whether the position marker in the code file is the first value, that is, whether there is code that has been processed by code parsing in the code file. Then in the case where the position marker is not the first value, that is, 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 executed to obtain the incremental parsing result. In the case where the position marker is the first value, that is, there is no code that has been processed by code parsing in the code file, the full code in the code file is executed to obtain the full parsing result.
[0068] By determining whether the code parsing result of the full code in the code file exists in the server after obtaining the code file, unnecessary code parsing steps are avoided in the case where the code parsing result of the full code in the code file exists in the server, computer resources are wasted, and code acquisition efficiency is affected.
[0069] The process of incremental parsing will be introduced below.
[0070] In some embodiments, step 220 includes at least one of sub-steps 221-223.
[0071] Sub-step 221, according to the code file and the position marker, the incremental code in the code file is obtained.
[0072] The incremental code in the code file refers to the code in the code file after the position marker.
[0073] Illustratively, for the code file shown above, if the position marker is 5, the code in the code file after the position marker is obtained, and the incremental code obtained is {"zipcode":"10001","isEmployed":true}. If the position marker is 3, the code in the code file after the position marker is obtained, and the incremental code obtained is {"address":{"city":"New York","zipcode":"10001"},"isEmployed":true}.
[0074] In sub-step 222, according to the delta code, field information of the delta code and type information of the delta code are determined, the field information of the delta code including at least one key-value pair in the delta code, and the type information of the delta code including type information of a key in the at least one key-value pair in the delta code.
[0075] The field information of the delta code is used to indicate code content of the delta code, and the field information of the delta code includes at least one key-value pair in the delta code, each key-value pair consisting of a unique key and a corresponding value, the key being used to identify the uniqueness of data, and the value being data associated with the key, and such a 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] For example, if the delta code is {"zipcode":"10001","isEmployed":true}, the at least one key-value pair included in the field information of the delta 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 delta code is used to indicate type information of the at least one key-value pair in the delta code, specifically type information of the key in the at least one key-value pair in the delta code. The definition of the type information of the key is set by a technician in advance, and is not limited in the present application. For example, for the code file shown above, the type information of the key includes an Address class and a 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, and thus the type information of the full code in the code file shown above can refer to Figure 3 .
[0078] For example, if the delta code is {"zipcode":"10001","isEmployed":true}, the type information of the delta 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] In sub-step 223, the value in the at least one key-value pair of the delta code is assigned to the type information of the key in the at least one key-value pair in the delta code to obtain a delta parsing result, the delta parsing result including object information corresponding to each type information in the delta code respectively, the object information corresponding to the type information including the value in the at least one key-value pair corresponding to the type information.
[0080] Exemplarily, the type information in the delta code shown above includes the Address class and the Person class, and the delta 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 including the value in the at least one key-value pair corresponding to the Address class, and the object information corresponding to the Person class including the value in the at least one key-value pair corresponding to the Person class.
[0081] Exemplarily, if the delta code is {"zipcode":"10001","isEmployed":true}, the at least one key-value pair included in the field information of the delta code is {"zipcode":"10001"} and {"isEmployed":true}, the type information of the delta 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 the at least one key-value pair of the delta code is assigned to the type information of the key in the at least one key-value pair in the delta code, that is, the value "10001" in the key-value pair {"zipcode":"10001"} is assigned to the type information of the key "zipcode" to obtain that 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" to obtain that the object information corresponding to the Person class includes "true".
[0082] For example, if the incremental code is {"address":{"city":"New York","zipcode":"10001"},"isEmployed":true}, 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}, the type information of the incremental code includes the type information of "address", the type information of "city", the type information of "zipcode" and the type information of "isEmployed", the type information of "city" and "zipcode" is Address, and the type information of "address" and "isEmployed" is Person. The value in the at least one key-value pair of the incremental code is assigned to the type information of the key in the at least one key-value pair of the incremental code, so that the object information corresponding to the Address includes "New York" and "10001", and the object information corresponding to the Person includes {"city":"New York","zipcode":"10001"} and "true".
[0083] Through the above steps, the incremental code in the code file is subjected to code parsing processing, and an incremental parsing result is obtained, so that the code parsing result corresponding to the code file can be obtained according to the incremental parsing result and the code parsing result of the code stored in the server and subjected to code parsing processing, the computing resources are saved, and the code parsing efficiency is improved.
[0084] In some embodiments, the sub-step 222 includes at least one of sub-steps 2221-2222.
[0085] The sub-step 2221 performs line-by-line reading on the incremental code to obtain the field information of the incremental code.
[0086] The code is written according to the code format when written, so that the string corresponding to each line of code can represent an object data. After the incremental code in the code file is obtained, line-by-line reading is performed on the incremental code to sequentially obtain the string corresponding to each line of code in the incremental code, and 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, and the field information of the incremental code is obtained.
[0087] For example, for the code file shown above, if the position marker is 5, the incremental code can be represented as:
[0088] "zipcode":"10001"
[0089] },
[0090] "isEmployed":true
[0091] }
[0092] The line-by-line reading is performed on the incremental code to obtain the corresponding string of each line of code, which are {"zipcode":"10001"}、{"},"}、{"isEmployed":true}、{"}"} in turn. Among them, the strings corresponding to {"zipcode":"10001"} and {"isEmployed":true} can be accessed in the form of key-value pairs, while the strings corresponding to {"},"} and {"}"} cannot be accessed in the form of key-value pairs. Therefore, according to the strings {"zipcode":"10001"} and {"isEmployed":true}, the field information of the incremental code can be obtained.
[0093] In sub-step 2222, the type information of the incremental code is generated by the type generation model according to the incremental code and the first prompt information. The first prompt information is used to prompt the type generation model to generate the 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 can 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 training a large language model according to 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 trained on a large amount of data, and the amount of data can reach a sample level of hundreds of millions or more. The present 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 parameters of the large language model, and obtains the type generation model.
[0097] By using the type generation model to obtain the type information of the incremental code, the type information of the code can be automatically generated. Compared with the manual parsing method used in the related art, automatically generating the type information can simplify the generation step, can be applied to a code with a large size, reduces the probability of errors when manually generating the type information, and improves the accuracy of the generated type information.
[0098] In some embodiments, the type generation model generates the type information of the incremental code according to the incremental code, the first prompt information, and the first configuration information. 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 a 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 by using a java code.
[0100] The type generation model is a model obtained by fine-tuning training of the large language model according to the second training sample. The training process of the type generation model is as follows: at least one second training sample of the type generation model is obtained, 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 type information of the second sample code. The large language model generates predicted type information of the second sample code according to the second sample code, the second sample prompt, and the second sample configuration, calculates a second loss function value according to the difference between the predicted type information and the sample type information, takes reducing the second loss function value as a training target, adjusts parameters of the large language model, and obtains the type generation model.
[0101] By adding the configuration information when generating the type information of the incremental code, the generation method of the type information is limited, so that the generated type information of the incremental code can meet the customization needs of the user, and the type information is more convenient for interfacing and intercommunication with other data in the server, which is helpful for data sharing and utilization.
[0102] A schematic diagram of the process of obtaining the incremental analysis result can refer to FIG. 1. Figure 4 As shown, first, according to the code file and the position mark, an incremental code located after the position mark in the code file is obtained, line-by-line reading of the incremental code is performed to obtain field information of the incremental code, and 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. Here, the field information of the incremental code includes at least one key-value pair in the incremental code, the type information of the incremental code includes type information of a key in the at least one key-value pair in the incremental code, a value in the at least one key-value pair in the incremental code is assigned to the type information of the key in the at least one key-value pair in the incremental code to obtain an incremental analysis result, and the incremental analysis result includes object information corresponding to each type information in the incremental code.
[0103] In some embodiments, after the substep 223, at least one of substeps 224-226 is further included.
[0104] In the substep 224, a processing time of the incremental analysis processing is obtained.
[0105] The processing time of the incremental analysis processing is the time when the incremental analysis processing is completed minus the time when the incremental analysis processing is started. The time when the code file is obtained can be taken as the time when the incremental analysis processing is started, and the time when the incremental analysis result is obtained can be taken as the time when the incremental analysis processing is completed.
[0106] In the substep 225, in a case where the processing time of the incremental analysis processing is greater than or equal to a first duration, second prompt information is determined, and the second prompt information is used to adjust classification of the type information of the incremental code.
[0107] The processing time of the incremental analysis processing is related to the complexity of the type information. The more the number of classes contained in the type information, the more complex the type information, and correspondingly, the longer the processing time of the incremental analysis processing. The fewer the number of classes contained in the type information, the shorter the processing time of the incremental analysis processing.
[0108] In a case where the processing time of the incremental analysis processing is greater than or equal to the first duration, it is determined that the performance and efficiency of the incremental analysis processing 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, to optimize and reduce the classification of the type information of the incremental code, so as to shorten the processing time of the incremental analysis processing.
[0109] The specific value of the first duration is set by the technician according to the incremental analysis requirement, and is not limited in the present application.
[0110] Exemplarily, the second prompt information can be: the definition of the current type information is complex, resulting in too long time consumption of the analysis, please optimize the definition of the class.
[0111] In the sub-step 226, the full code file is parsed according to the second prompt information to obtain the updated incremental parsing result, and the updated incremental parsing result is used to update the code parsing result of the code in the code file stored in the server.
[0112] Since the classification of the type information has been adjusted, if only the incremental code is parsed, the classification of the type information of the incremental code will be different from the classification of the type information of the code that has been parsed, and 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 fused, and the code parsing is not complete. Therefore, the full code file needs to be parsed according to the second prompt information to obtain the updated incremental parsing result, and the updated incremental parsing result includes the object information corresponding to each type information of the full code file.
[0113] In the case where the processing time of the incremental parsing is less than the first time length, the incremental parsing result is stored in the server. In the case where the processing time of the incremental parsing is greater than or equal to the first time length, the updated incremental parsing result is used to replace the code parsing result of the code in the code file stored in the server, so that the code parsing result corresponding to the code file is stored in the server, that is, the updated incremental parsing result.
[0114] The process of performing the full code parsing on the code file according to the second prompt information is as follows: 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 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 the at least one key-value pair in the code file to obtain the updated incremental parsing result.
[0115] By judging whether the processing time of the incremental parsing is greater than or equal to the first time length, whether the performance and efficiency of the incremental parsing meet the requirements can be determined, so that the second prompt information can be determined in time, the classification of the type information of the incremental code can be adjusted, the processing time of the incremental parsing can be shortened, and the generated updated incremental parsing result can meet the performance and efficiency requirements of the parsing, and the quality of the code parsing can be improved.
[0116] The process of the full code parsing will be introduced below.
[0117] In some embodiments, the step 230 includes at least one of the sub-steps 231-233.
[0118] Sub-step 231, performing line-by-line reading on the code file to obtain field information of the code file, the field information of the code file including at least one key-value pair in the code file.
[0119] Performing line-by-line reading on the code file, sequentially obtaining the string corresponding to each line of code in the code file, accessing the string corresponding to each line of code in the form of a key-value pair, for the string that cannot be accessed in the form of a key-value pair, removing the string corresponding to the line of code, and thus obtaining the field information of the code file.
[0120] Illustratively, for the above-mentioned code file, the at least one key-value pair included in the field information of the code file is {"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, generating type information of the code file according to the code file and third prompt information through a type generation model, the type information of the code file including type information of a key in the at least one key-value pair in the code file, the third prompt information being used to prompt the type generation model to generate the type information of the code file.
[0122] Inputting the code file and the third prompt information into the type generation model to output the type information of the code file, the training process of the type generation model can refer to the process of fine-tuning training the large language model according to the first training sample in the above-mentioned 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] Exemplarily, for the code file shown above, the type information of the code file includes the 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. The type information of the code file can refer to the following table. Figure 3
[0124] In some embodiments, the type generation model is used to generate the type information of the code file 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 manner 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 manner of the type information of the code file, for example, the second configuration information can be: please convert the input code into type information, and implement it in java code. The training process of the type generation model can refer to the process of fine-tuning the large language model according to the second training sample in the above embodiments.
[0126] By adding configuration information when generating the type information of the code file, the generation manner of the type information is limited, so that the generated type information of the code file can meet the customization needs of the user, and the type information is more convenient for interfacing and intercommunication with other data in the server, which is helpful for data sharing and utilization.
[0127] In substep 233, the value in at least one key-value pair in the code file is assigned to the type information of the key in the at least one key-value pair in the code file, and a full-amount analysis result is obtained, wherein the full-amount analysis 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, and the full-amount analysis result includes object information corresponding to the Address class and object information corresponding to the Person class, wherein the object information corresponding to the Address class includes the value in at least one key-value pair corresponding to the Address class, and the object information corresponding to the Person class includes the value in 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 the 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 of the key "name" in the key-value pair, which is the Person class, the value "30" in the key-value pair {"age":30} is assigned to the type information of the key "age" in the key-value pair, which is the Person class, the value "["Java","Python","JSON"]" in the key-value pair {"skills":["Java","Python","JSON"]} is assigned to the type information of the key "skills" in the key-value pair, which is the Person class, the value {"city":"New York","zipcode":"10001"}" in the key-value pair {"address":{"city":"New York","zipcode":"10001"} is assigned to the type information of the key "address" in the key-value pair, which is the Person class, the value "New York" in the key-value pair {"city":"New York"} is assigned to the type information of the key "city" in the key-value pair, which is the Address class, 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, which is the Address class, and 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, which is 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 using the type generation model to obtain the type information of the incremental code, the type information of the code can be automatically generated, the accuracy of generating the type information can be improved, and the code parsing efficiency can be improved by performing the code parsing processing on the full code in the code file.
[0131] The schematic diagram of the obtaining process of the full parsing result can refer to Figure 5As shown, the code file is read by line to obtain field information of the code file, and the type generation model generates type information of the code file according to the code file, the third prompt information and the second configuration information. Here, the field information of the code file includes at least one key-value pair in the code file, the type information of the code file includes type information of a key in the at least one key-value pair in the code file, the value in the at least one key-value pair in the code file is assigned to the type information of the key in the at least one key-value pair in the code file, and a full parsing result is obtained. The full parsing result includes object information corresponding to each type information in the code file.
[0132] In some embodiments, after the sub-step 233, at least one of sub-steps 234-236 is further included.
[0133] In the sub-step 234, a processing time of the full parsing processing is obtained.
[0134] The processing time of the full parsing processing is the time when the full parsing processing is completed minus the time when the full parsing processing is started. The time when the code file is obtained can be taken as the time when the full parsing processing is started, and the time when the full parsing result is obtained can be taken as the time when the full parsing processing is completed.
[0135] In the sub-step 235, in a case where the processing time of the full parsing processing is greater than or equal to a second time length, fourth prompt information is determined. The fourth prompt information is used to optimize the classification of the type information of the code file.
[0136] The processing time of the full parsing processing is related to the complexity of the type information. The more the number of classes contained in the type information, the more complex the type information, and correspondingly, the longer the processing time of the full parsing processing. The fewer the number of classes contained in the type information, the shorter the processing time of the full parsing processing.
[0137] In a case where the processing time of the full parsing processing is greater than or equal to the second time length, the performance and efficiency of the full parsing processing performed 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, so as to shorten the processing time of the incremental parsing processing.
[0138] The specific value of the second time length is set by the technician according to the incremental parsing requirement, and the present application does not make any limitation. Optionally, the second time length can be the same as the first time length, or can be different from the first time length, and the present application does not make any limitation. In some embodiments, the second time length is equal to the first time length.
[0139] For example, the fourth prompt information can be: the definition of the current type information is complex, which leads to too long parsing time, please optimize the definition of the class.
[0140] In the case that the processing time of the full parsing processing is greater than or equal to the second time length, the updated full parsing result is stored in the server. In the case that the processing time of the full parsing processing is less than the second time length, the full parsing result is stored in the server.
[0141] In the case that the processing time of the full parsing processing is greater than or equal to the second time length, the updated full parsing result is stored in the server. In the case that the processing time of the full parsing processing is less than the second time length, the full parsing result is stored in the server.
[0142] By judging whether the processing time of the full parsing processing is greater than or equal to the second time length, whether the performance and efficiency of the full parsing processing meet the requirements can be determined, so that the type information of the code file can be adjusted in time according to the fourth prompt information to shorten the processing time of the full parsing processing, and the generated updated full parsing result meets the performance and efficiency requirements of the parsing processing, and the quality of code parsing is improved.
[0143] The schematic diagram of the complete process of the code parsing method provided in the application can be referred to Figure 6 As shown in the figure, after the server obtains the code file, the server first identifies the code file to determine whether the code parsing result of the full code in the code file exists in the server. In the case that the code parsing result of the full code in the code file exists in the server, the cached code parsing result 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 marker in the code file is 0. In the case that the position marker is not 0, the code parsing processing is performed on the incremental code in the code file to obtain an incremental parsing result. In the case that the position marker is 0, the code parsing processing is performed on the full code in the code file to obtain a full parsing result. Then, it is determined whether the time of the code parsing processing is less than a 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, a 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 an updated parsing result.
[0144] The following is an apparatus embodiment of the application, which can be used to execute the method embodiments of the application. For details not disclosed in the apparatus embodiments of the application, please refer to the method embodiments of the application.
[0145] Please refer to Figure 7FIG. 7 shows a block diagram of a code parsing apparatus according to an embodiment of the present application. The apparatus has the functions of the code parsing method described above, which can be implemented by hardware or by execution of corresponding software by hardware. The apparatus can be the server described above or can be arranged in the server. As shown in FIG. 7, the apparatus 700 can include a code obtaining module 710, an incremental parsing module 720, and a full parsing module 730. Figure 7
[0146] The code obtaining module 710 is configured to obtain a code file, wherein the code file includes a position marker, and the position marker is used to indicate the position of code in the code file that has been processed by code parsing.
[0147] The incremental parsing module 720 is configured to, when the position marker 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 on incremental code in the code file, the incremental code refers to code after the position marker, and the position marker not being the first value is used to indicate that there is code in the code file that has been processed by code parsing.
[0148] The full parsing module 730 is configured to, when the position marker is the first value, perform full parsing processing on the code file to obtain a full parsing result, wherein the full parsing processing is used to perform code parsing on full code in the code file, and the position marker being the first value is used to indicate that there is no code in the code file that has been processed by code parsing.
[0149] In some embodiments, the incremental parsing module 720 is configured to:
[0150] obtain incremental code in the code file according to the code file and the position marker;
[0151] determine field information of the incremental code and 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 type information of a key in the at least one key-value pair in the incremental code;
[0152] assign a value in the at least one key-value pair in the incremental code to the type information of the key in the 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 respectively, and the object information corresponding to the type information includes the value in the at least one key-value pair corresponding to the type information.
[0153] In some embodiments, the incremental parsing module 720 is configured to:
[0154] perform line-by-line reading on the incremental code to obtain field information of the incremental code;
[0155] generate, by a type generation model, type information of the incremental code according to the incremental code and first prompt information, the first prompt information being 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 configured to:
[0157] generate, by the type generation model, type information of the incremental code according to the incremental code, the first prompt information, and first configuration information, the first configuration information being used to indicate a generation manner 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 undergone code parsing processing is stored in a server, and the incremental parsing module 720 is configured to:
[0159] obtain a processing time of the incremental parsing processing;
[0160] in a case where the processing time of the incremental parsing processing is greater than or equal to a first time length, determine second prompt information, the second prompt information being used to adjust classification of the type information of the incremental code;
[0161] perform, according to the second prompt information, full parsing processing on the code file to obtain an updated incremental parsing result, the updated incremental parsing result being used to update the code parsing result of the code in the code file that has undergone code parsing processing and stored in the server.
[0162] In some embodiments, the full parsing module 730 is configured to:
[0163] perform line-by-line reading on the code file to obtain field information of the code file, the field information of the code file including at least one key-value pair in the code file;
[0164] generate, by a type generation model, type information of the code file according to the code file and third prompt information, the type information of the code file including type information of a key in the at least one key-value pair in the code file, the third prompt information being used to prompt the type generation model to generate the type information of the code file;
[0165] assign a value in at least one key-value pair in the code file to type information of a key in the at least one key-value pair in the code file to obtain the full-amount analysis result, the full-amount analysis result including object information corresponding to each type information in the code file respectively, the object information corresponding to the type information including the value in at least one key-value pair corresponding to the type information.
[0166] In some embodiments, the full-amount analysis module 730 is configured to:
[0167] generate, by the type generation model, type information of the code file according to the code file, the third prompt information, and second configuration information, the second configuration information being used to indicate a generation manner of the type information of the code file.
[0168] In some embodiments, the full-amount analysis module 730 is configured to:
[0169] obtain a processing time of the full-amount analysis processing;
[0170] in a case where the processing time of the full-amount analysis processing is greater than or equal to a second time length, determine fourth prompt information, the fourth prompt information being used to optimize classification of the type information of the code file;
[0171] re-execute the step of performing the full-amount analysis processing on the code file according to the fourth prompt information to obtain an updated full-amount analysis result, the updated full-amount analysis result being stored in a server.
[0172] In some embodiments, a code analysis result of code in the code file that has undergone code analysis processing is stored in a server; the apparatus further includes a result reuse module, the result reuse module being configured to:
[0173] in a case where the code analysis result of the full-amount code in the code file exists in the server, obtain the code analysis result of the full-amount code in the code file from the server;
[0174] in a case where the code analysis result of the full-amount code in the code file does not exist in the server, determine whether the position marker in the code file is the first numerical value.
[0175] It should be noted that the apparatus provided by the above embodiments, in realizing its functions, is only exemplified by the above division of functional modules, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the content structure of the device is divided into different functional modules to complete all or part of the above-described functions. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0176] Please refer to Figure 8 which shows the structural block diagram of the server 800 provided by an embodiment of the present application. The server 800 can be any electronic device with data computing, processing and storage functions. The server 800 can be used to implement the code analysis method provided in the above embodiments.
[0177] Generally, the server 800 includes a processor 801 and a memory 802.
[0178] The processor 801 can include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 801 can be implemented in at least one of the hardware forms of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). The processor 801 can 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 can be integrated with a GPU (Graphics Processing Unit) that is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 801 can also include an AI (Artificial Intelligence) processor for processing machine learning-related computing operations.
[0179] The memory 802 can include one or more computer-readable storage media. The computer-readable storage media can be non-transitory. The memory 802 can also include high-speed random access memory and can include non-volatile memory, such as one or more magnetic disk storage devices, optical disk storage devices, flash memory devices, or other non-volatile storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 802 is used for storing the computer programs configured to be executed by one or more processors to implement the above-mentioned code parsing method.
[0180] Those skilled in the art can understand that Figure 8 The structure shown in the figure does not constitute a limitation on the server 800, and can include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0181] In the illustrative embodiment, a computer-readable storage medium is also provided, and the computer-readable storage medium stores a computer program. When the computer program is executed by the processor of the server, the computer program implements the above-mentioned code parsing method. Optionally, the computer-readable storage medium can be a ROM (Read-Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0182] In the exemplary embodiment, a computer program product is also provided, and the computer program product includes a computer program stored in a computer-readable storage medium. The processor of the 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 "multiple" mentioned herein refers to two or more. The "and / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents that the associated objects before and after it are in an "or" relationship. In addition, the step numbers described herein only exemplarily show a possible execution order between steps. In some other embodiments, the above steps can also be executed in a different order from the numbering order, such as simultaneously executing two steps with different numbers, or executing two steps with different numbers in an order opposite to the illustration, and the embodiments of the present application do not limit this.
[0184] The above merely provides exemplary embodiments of the present application, but is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A code parsing method characterized by, The method comprises: obtaining a code file, the code file comprising a position mark, the position mark being used to indicate a position of code in the code file that has been processed by code parsing, the code file being a JSON file; in a case where the position mark is not a first numerical value, obtaining, according to the code file and the position mark, incremental code in the code file, the incremental code being code located after the position mark, the position mark not being the first numerical value being used to indicate that there is code in the code file that has been processed by code parsing; performing line-by-line reading on the incremental code to obtain field information of the incremental code, the field information of the incremental code comprising at least one key-value pair in the incremental code; generating, by a type generation model, type information of the incremental code according to the incremental code and first prompt information, the first prompt information being used to prompt the type generation model to generate the type information of the incremental code, the type information of the incremental code comprising type information of a key in at least one key-value pair in the incremental code; assigning values in the at least one key-value pair in the incremental code to the type information of the key in the at least one key-value pair in the incremental code to obtain an incremental parsing result, the incremental parsing result comprising object information corresponding to each type information in the incremental code, the object information corresponding to the type information comprising values in at least one key-value pair corresponding to the type information; in a case where the position mark is the first numerical value, performing full-amount parsing processing on the code file to obtain a full-amount parsing result, the full-amount parsing processing being used to perform code parsing processing on full-amount code in the code file, the position mark being the first numerical value being used to indicate that there is no code in the code file that has been processed by code parsing.
2. The method of claim 1, wherein, The generating, by the type generation model, of the type information of the incremental code according to the incremental code and the first prompt information comprises: generating, by the type generation model, the type information of the incremental code according to the incremental code, the first prompt information and first configuration information, the first configuration information being used to indicate a generation mode of the type information of the incremental code.
3. The method of claim 1, wherein, The code parsing result of the code in the code file that has been processed by code parsing is stored in a server; after the assigning of the values in the at least one key-value pair in the incremental code to the type information of the key in the at least one key-value pair in the incremental code to obtain the incremental parsing result, the method further comprises: obtaining a processing time of the incremental parsing processing; in a case where the processing time of the incremental parsing processing is greater than or equal to a first time length, determining second prompt information, the second prompt information being used to adjust classification of the type information of the incremental code; performing, according to the second prompt information, full-amount parsing processing on the code file to obtain an updated incremental parsing result, the updated incremental parsing result being used to update the code parsing result of the code in the code file that has been processed by code parsing and stored in the server.
4. The method of claim 1, wherein, The full parsing processing is performed on the code file to obtain a full parsing result, including: The code file is read line by line to obtain field information of the code file, the field information of the code file including at least one key-value pair in the code file; Type information of the code file is generated by a type generation model according to the code file and third prompt information, the type information of the code file including type information of a key in at least one key-value pair in the code file, the third prompt information being used to prompt the type generation model to generate the type information of the code file; Values in at least one key-value pair in the code file are assigned to type information of a key in at least one key-value pair in the code file to obtain the full parsing result, the full parsing result including object information corresponding to each type information in the code file, the object information corresponding to the type information including values in at least one key-value pair corresponding to the type information.
5. The method of claim 4, wherein, The type information of the code file is generated by the type generation model according to the code file and third prompt information, including: The type information of the code file is generated by the type generation model according to the code file, the third prompt information and second configuration information, the second configuration information being used to indicate a generation mode of the type information of the code file.
6. The method of claim 4, wherein, After the full parsing processing of the code file is performed to obtain the full parsing result, the method further includes: A processing time of the full parsing processing is obtained; In a case where the processing time of the full parsing processing is greater than or equal to a second time length, fourth prompt information is determined, the fourth prompt information being used to optimize classification of the type information of the code file; According to the fourth prompt information, the step of performing the full parsing processing on the code file is re-executed to obtain an updated full parsing result, the updated full parsing result being stored in a server.
7. The method of claim 1, wherein, The code parsing result of the code in the code file that has undergone code parsing processing is stored in a server; the method further includes: In a case where the code parsing result of the full code in the code file exists in the server, the code parsing result of the full code in the code file is obtained from the server; In a case where the code parsing result of the full code in the code file does not exist in the server, it is judged whether the position marker in the code file is the first numerical value.
8. A code parsing apparatus characterized by comprising: The apparatus includes: A code obtaining module is configured to obtain a code file, the code file including a position marker, the position marker being used to indicate a position of code in the code file that has undergone code parsing processing, and the code file being a JSON file; The incremental analysis module is configured to, when the position mark is not the first value, obtain, according to the code file and the position mark, an incremental code in the code file, the incremental code being code located after the position mark, and the position mark not being the first value indicating that there is code in the code file that has been processed by code analysis; perform line-by-line reading on the incremental code to obtain field information of the incremental code, the field information of the incremental code including at least one key-value pair in the incremental code; generate, by a type generation model, type information of the incremental code according to the incremental code and first prompt information, the first prompt information being used to prompt the type generation model to generate the type information of the incremental code, the type information of the incremental code including type information of a key in the at least one key-value pair in the incremental code; and assign a value in the at least one key-value pair in the incremental code to the type information of the key in the at least one key-value pair in the incremental code to obtain an incremental analysis result, the incremental analysis result including object information corresponding to each type information in the incremental code, the object information corresponding to the type information including the value in the at least one key-value pair corresponding to the type information. The total analysis module is configured to, when the position mark is the first value, perform total analysis processing on the code file to obtain a total analysis result, the total analysis processing being used to perform code analysis processing on total code in the code file, and the position mark being the first value indicating that there is no code in the code file that has been processed by code analysis.
9. A server, characterized by The server includes a processor and a memory, and the memory stores a computer program, which is loaded and executed by the processor to implement the code analysis method according to any one of claims 1 to 7.
10. 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 analysis method according to any one of claims 1 to 7.
11. A computer program product, characterised in that, The computer program product includes a computer program, which is loaded and executed by a processor to implement the code analysis method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Java class analysis method and device, storage medium and electronic equipment
CN110990019A
JSON file analysis method, electronic equipment, storage medium and program product
CN117973365A