Text code detection and evaluation method, device, equipment and storage medium

By verifying and analyzing text codes, and using hyperplane classification technology, the problem of inefficient code evaluation in the existing technology is solved, fast and accurate code quality evaluation is achieved, and resource waste is reduced.

CN114840438BActive Publication Date: 2025-01-10CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210574890.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2025-01-10
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

Existing text code detection and evaluation methods are tested after the code development is completed, resulting in inefficient code evaluation, inaccurate problem code, and the inability to quickly correct problem code, resulting in waste of resources.

Method used

By obtaining the text code to be evaluated, check whether it complies with the preset criteria, use abstract syntax tree to parse the feature data set, and build a hyperplane for classification. Check whether the code is qualified based on the results, and feedback the alarm signal to improve the code evaluation efficiency.

Benefits of technology

Improve the accuracy and efficiency of code evaluation, reduce resource waste, quickly correct problem code, and ensure that the code quality complies with specifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114840438B_ABST
    Figure CN114840438B_ABST
Patent Text Reader

Abstract

The present invention relates to artificial intelligence technology, and discloses a text code detection and evaluation method, including: obtaining a text code to be evaluated, and verifying whether the text code to be evaluated meets preset criteria; when it meets the preset criteria, parsing the text code to be evaluated using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, and standardizing the feature data set to obtain a standard specialized feature data set; constructing a hyperplane according to the standardized feature data set, classifying the feature data set using the hyperplane, and verifying whether the text code to be evaluated is qualified according to the classification result. In addition, the present invention also relates to blockchain technology, and the text code to be evaluated and the feature data set can be stored in the nodes of the blockchain. The present invention also proposes a text code detection and evaluation device, an electronic device, and a storage medium. The present invention can improve the accuracy of product recommendations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a text code detection and evaluation method, device, electronic device and computer-readable storage medium. Background Art

[0002] Text code is the logical expression of the business code process. The data results produced by the text code affect the business analysis and decision-making of the enterprise. Text code that does not conform to business logic and specifications is collectively referred to as problematic code. Problem code is often caused by developers not understanding the business process or non-standard development. At the same time, before deploying the text code in the production environment, the text code needs to be evaluated to ensure the quality of the code and data.

[0003] Existing text code detection and evaluation methods mainly test and debug the code in a test environment after code development is completed, but they cannot help developers quickly correct problematic code and avoid wasting resources by re-running the code. At the same time, text code needs to be reviewed and approved before it can be executed, which consumes a lot of time and leads to inefficient code evaluation. Summary of the invention

[0004] The present invention provides a text code detection and evaluation method, device and computer-readable storage medium, the main purpose of which is to solve the problem of low code evaluation efficiency.

[0005] To achieve the above object, the present invention provides a text code detection and evaluation method, comprising:

[0006] Obtaining a text code to be evaluated, and verifying whether the text code to be evaluated meets a preset criterion;

[0007] When the text code to be evaluated does not meet the preset criteria, feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal;

[0008] When the text code to be evaluated meets the preset criteria, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, and the feature data set is standard quantized to obtain a standardized feature data set;

[0009] Constructing a hyperplane according to the standardized feature data set, classifying the standardized feature data set using the hyperplane, and verifying whether the text code to be evaluated is qualified according to the classification result;

[0010] When the verification result is qualified, determining that the text code to be evaluated is qualified;

[0011] When the verification result is unqualified, the process returns to the step of feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal.

[0012] Optionally, the step of verifying whether the text code to be evaluated meets a preset criterion includes:

[0013] Calling a preset criteria verification script according to the text code to be evaluated;

[0014] Acquire a rule chain of preset criteria from the criterion verification script, wherein the rule chain includes a plurality of preset criteria;

[0015] Dividing the rule chain into a plurality of independently verifiable rule blocks according to the plurality of preset criteria;

[0016] Using the plurality of independently verifiable rule blocks to verify whether the text code to be evaluated meets a preset criterion;

[0017] If there are one or more rule block checks that do not meet the preset criteria, it is determined that the text code to be evaluated does not meet the preset criteria;

[0018] If the text code to be evaluated meets the preset criteria of each of the rule blocks, it is determined that the text code to be evaluated meets the preset criteria.

[0019] The method of parsing the text code to be evaluated by using an abstract syntax tree to obtain a feature data set of the text code to be evaluated includes:

[0020] Generate a corresponding abstract syntax tree based on each function in the text code to be evaluated;

[0021] Retrieving a label code in the abstract syntax tree using a preset code evaluation label;

[0022] A feature data set of the text code to be evaluated is determined according to the label code.

[0023] Optionally, the performing standard quantization on the feature data set to obtain a standardized feature data set includes:

[0024] dividing the feature data set into character string feature data and numerical feature data according to the type of the feature data;

[0025] Performing one-hot encoding on the character string feature data, and normalizing the numerical feature data;

[0026] The character string feature data after the one-hot encoding and the numerical feature data after the normalization processing are collected to obtain a standardized feature data set.

[0027] Optionally, constructing a hyperplane according to the standardized feature data set, and using the hyperplane to classify the standardized feature data set includes:

[0028] Performing vector transformation on the standardized feature data set using a pre-built vector transformation model to obtain a feature vector set;

[0029] Mapping the vector feature set to a coordinate set to obtain a feature vector coordinate set;

[0030] Calculate the Euclidean distance between any two coordinates in the feature vector coordinate set, and select the feature coordinate with the smallest Euclidean distance as the target feature coordinate;

[0031] Constructing a hyperplane function according to the target feature coordinates, and calculating a distance value from the target feature coordinates to the hyperplane function;

[0032] According to the distance value, a minimum distance value is selected and a constraint condition is constructed, and the minimum distance based on the constraint condition is solved by the Lagrange multiplier method to obtain a hyperplane;

[0033] The standardized feature data set is classified using the hyperplane to obtain a classification result.

[0034] Optionally, the calculating the distance value from the target feature coordinates to the hyperplane function includes:

[0035] The distance value from the target feature coordinates to the hyperplane function is calculated using the following formula:

[0036]

[0037] Among them, γ i is the distance from the target feature coordinates to the hyperplane, x i is the i-th target feature coordinate, y i Yes, x i The category label belongs to the category above or below the hyperplane function, wherein the category label is +1 or -1, and w and b are preset fixed parameters.

[0038] Optionally, verifying whether the text code to be evaluated is qualified according to the classification result includes:

[0039] When each of the standardized feature data classification results is qualified, determining that the text code to be evaluated is qualified;

[0040] If there is greater than or equal to one standardized feature data classification result that is unqualified, it is determined that the text code to be evaluated is unqualified.

[0041] In order to solve the above problems, the present invention also provides a text code detection and evaluation device, the device comprising:

[0042] A code criteria verification module is used to obtain the text code to be evaluated and verify whether the text code to be evaluated meets the preset criteria;

[0043] A feedback module, used for feeding back the text code to be evaluated and a preset alarm signal to a corresponding terminal when the text code to be evaluated does not meet the preset criteria;

[0044] A standardized feature data acquisition module is used to parse the text code to be evaluated by using an abstract syntax tree to obtain a feature data set of the text code to be evaluated when the text code to be evaluated meets the preset criteria, and to perform standard quantization on the feature data set to obtain a standardized feature data set;

[0045] A classification module, used to construct a hyperplane according to the standardized feature data set, and classify the standardized feature data set using the hyperplane;

[0046] A qualification verification module is used to verify whether the text code to be evaluated is qualified according to the classification result;

[0047] The qualified evaluation module is used to determine that the text code to be evaluated is qualified when the verification result is qualified.

[0048] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:

[0049] at least one processor; and,

[0050] a memory communicatively connected to the at least one processor; wherein,

[0051] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the text code detection and evaluation method described above.

[0052] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned text code detection and evaluation method.

[0053] The embodiment of the present invention further improves the accuracy of the code and thus improves the quality of the code by verifying whether the text code to be evaluated meets the preset criteria; when the text code to be evaluated meets the preset criteria, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated; a hyperplane is constructed according to the feature data set, the feature data set is classified using the hyperplane, and whether the text code to be evaluated is qualified is verified according to the classification result, thereby achieving a comprehensive verification of the text code to be evaluated and thus improving the efficiency of the evaluation of the text code to be evaluated. Therefore, the text code detection and evaluation method, device, electronic device and computer-readable storage medium proposed in the present invention can solve the problem of low efficiency in code evaluation. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 A flowchart of a text code detection and evaluation method provided by an embodiment of the present invention;

[0055] Figure 2 A schematic diagram of a flow chart of a verification code criterion provided by an embodiment of the present invention;

[0056] Figure 3 A schematic diagram of a code parsing process provided by an embodiment of the present invention;

[0057] Figure 4 A functional module diagram of a text code detection and evaluation device provided by an embodiment of the present invention;

[0058] Figure 5 A schematic diagram of the structure of an electronic device for implementing the text code detection and evaluation method provided by one embodiment of the present invention.

[0059] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0060] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0061] The embodiment of the present application provides a text code detection and evaluation method. The execution subject of the text code detection and evaluation method includes but is not limited to at least one of the electronic devices such as the server, the terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the text code detection and evaluation method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0062] Reference Figure 1 FIG. 1 is a flow chart of a text code detection and evaluation method provided by an embodiment of the present invention. In this embodiment, the text code detection and evaluation method includes:

[0063] S1. Obtain the text code to be evaluated, and verify whether the text code to be evaluated meets the preset criteria;

[0064] In an embodiment of the present invention, the text code to be evaluated can be obtained from the terminals of developers of different text codes to be evaluated, and the preset criteria are preset development rules and preset code development specifications, for example, usage rules, data accuracy, not allowing the use of "select *" in SQL code, requiring association conditions when associating two tables, and other criteria for code development.

[0065] For details, see Figure 2 As shown, the checking whether the text code to be evaluated meets the preset criteria includes:

[0066] S11, calling a preset criterion verification script according to the text code to be evaluated;

[0067] S12, obtaining a rule chain of preset criteria from the criterion verification script, wherein the rule chain includes a plurality of preset criteria;

[0068] S13, dividing the rule chain into a plurality of independently verifiable rule blocks according to the plurality of preset criteria;

[0069] S14, using the multiple independently verifiable rule blocks to verify whether the text code to be evaluated meets the preset criteria;

[0070] S15. If one or more rule block checks do not meet the preset criteria, it is determined that the text code to be evaluated does not meet the preset criteria;

[0071] S16: If the text code to be evaluated meets the preset criteria of each rule block, determine that the text code to be evaluated meets the preset criteria.

[0072] In one optional embodiment of the present invention, the criterion verification script can be a JavaScript script, and the operating environment in which the script is loaded includes but is not limited to a Nashorn script engine or a Rhino script engine. The criterion verification script is used to verify whether the text code to be evaluated meets the preset criteria, thereby improving the criterion verification efficiency of the text code to be evaluated and avoiding vulnerabilities in the text code to be evaluated during the human development process.

[0073] When the text code to be evaluated does not meet the preset criteria, executing S2, feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal;

[0074] In the embodiment of the present invention, when the text code to be evaluated does not meet the preset specifications, it means that the text code to be evaluated does not meet the business logic or the development specifications, and a problem code is generated. The problem code not only affects the accuracy of the data, but also wastes manpower and computing resources.

[0075] In an embodiment of the present invention, the corresponding terminal may be a corresponding terminal that obtains the text code to be evaluated. Feedback of the text code to be evaluated to the corresponding terminal can quickly help developers find problematic codes and correct them in a timely manner, thereby avoiding code re-running due to problematic codes, reducing resource waste and improving the quality of the text code to be evaluated.

[0076] When the text code to be evaluated meets the preset criteria, executing S3, parsing the text code to be evaluated using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, and performing standard quantization on the feature data set to obtain a standardized feature data set;

[0077] In the embodiment of the present invention, when the text code to be evaluated meets the preset criteria, it means that the text code to be evaluated has preliminarily eliminated loopholes in the code development process, and further code quality evaluation can be performed to ensure the quality of the text code to be evaluated.

[0078] For details, see Figure 3 As shown, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, including:

[0079] S31, generating a corresponding abstract syntax tree based on each function in the text code to be evaluated;

[0080] S32, using a preset code evaluation tag to retrieve a tag code in the abstract syntax tree;

[0081] S33. Determine a feature data set of the text code to be evaluated according to the label code.

[0082] Specifically, in an embodiment of the present invention, the preset code evaluation labels include but are not limited to the naming of tasks, tables, indicators and dimensions, the blood relationship between data, the code length, the reuse of tables, etc., and the characteristic data of the text code to be evaluated is determined according to the labels, for example: the naming of tasks, tables, indicators and dimensions, the length data of the code, the reuse data of the table, etc.

[0083] Furthermore, in an embodiment of the present invention, the step of performing standard quantization on the feature data set to obtain a standardized feature data set includes:

[0084] dividing the feature data set into character string feature data and numerical feature data according to the type of the feature data;

[0085] Performing one-hot encoding on the character string feature data, and normalizing the numerical feature data;

[0086] The character string feature data after the one-hot encoding and the numerical feature data after the normalization processing are collected to obtain a standardized feature data set.

[0087] In the embodiment of the present invention, the one-hot encoding is to encode N states using an N-bit state register, each state has its own independent register bit, and at any time, only one bit is valid, which solves the problem that string type data is difficult to process and plays a role in expanding data features.

[0088] S4, constructing a hyperplane according to the standardized feature data set, and using the hyperplane to classify the standardized feature data set; and verifying whether the text code to be evaluated is qualified according to the classification result;

[0089] In the embodiment of the present invention, the hyperplane is a classification plane in a support vector machine, and different categories are separated by the hyperplane to obtain a classification result, which is qualified or unqualified.

[0090] In detail, constructing a hyperplane according to the standardized feature data set, and using the hyperplane to classify the standardized feature data set includes:

[0091] Performing vector transformation on the standardized feature data set using a pre-built vector transformation model to obtain a feature vector set;

[0092] Mapping the vector feature set to a coordinate set to obtain a feature vector coordinate set;

[0093] Calculate the Euclidean distance between any two coordinates in the feature vector coordinate set, and select the feature coordinate with the smallest Euclidean distance as the target feature coordinate;

[0094] Constructing a hyperplane function according to the target feature coordinates, and calculating a distance value from the target feature coordinates to the hyperplane function;

[0095]

[0096] Among them, γ i is the distance from the target feature coordinates to the hyperplane, x i is the i-th target feature coordinate, y i Yes, x i The category label belongs to the category above or below the hyperplane function, wherein the category label is +1 or -1, and w and b are preset fixed parameters.

[0097] According to the distance value, a minimum distance value is selected and a constraint condition is constructed, and the minimum distance based on the constraint condition is solved by the Lagrange multiplier method to obtain a hyperplane;

[0098] In the embodiment of the present invention, the constraint condition is:

[0099]

[0100] Wherein, γ is the minimum distance, and the constraint condition is that the distance from each target feature coordinate to the hyperplane is greater than or equal to the minimum distance.

[0101] The standardized feature data set is classified using the hyperplane to obtain a classification result.

[0102] Furthermore, in an embodiment of the present invention, the minimum distance based on the constraint condition is solved by using Lagrange multiplier method to obtain a hyperplane, including:

[0103] The constraint condition and the minimum distance function are constructed into a Lagrangian objective function according to a Lagrangian function;

[0104] The partial derivative of the Lagrangian function is obtained to obtain the hyperplane.

[0105] In the embodiment of the present invention, the hyperplane may be

[0106] f(x)=(w t x+b)

[0107] S5. Check whether the text code to be evaluated is qualified according to the classification result;

[0108] In the embodiment of the present invention, the result of the classification is to determine whether the feature data is qualified. When all feature data sets are qualified, the text code to be evaluated is qualified, thereby comprehensively verifying the text code to be evaluated and improving the efficiency of code evaluation.

[0109] In detail, the checking whether the text code to be evaluated is qualified according to the classification result includes:

[0110] When each of the standardized feature data classification results is qualified, determining that the text code to be evaluated is qualified;

[0111] If there is greater than or equal to one standardized feature data classification result that is unqualified, it is determined that the text code to be evaluated is unqualified.

[0112] By classifying the text code to be evaluated according to the hyperplane, it is possible to determine whether the text code to be evaluated is qualified, thereby ensuring the quality of the text code to be evaluated.

[0113] When the verification result is qualified, executing S6, determining that the text code to be evaluated is qualified;

[0114] In the embodiment of the present invention, when the verification result is qualified, all features of the text code to be evaluated are evaluated as qualified, indicating that the quality of the text code to be evaluated meets the requirements of code production deployment, and the next step of production deployment can be carried out. The text code to be evaluated is classified by a hyperplane, which reduces the waste of computing resources, improves the efficiency of code evaluation, and eliminates the influence of human subjective factors.

[0115] Furthermore, in an embodiment of the present invention, when the verification result is unqualified, the process returns to the above step S2.

[0116] In an embodiment of the present invention, when the verification result is unqualified, it means that there are unqualified items in the feature data of the text code to be evaluated, that is, a problem code has occurred. The text code to be evaluated needs to be fed back to the corresponding terminal and an alarm signal is issued to prompt the corresponding developer to deal with the unqualified items in time and quickly correct the problem code.

[0117] The embodiment of the present invention further improves the accuracy of the code and thus improves the quality of the code by verifying whether the text code to be evaluated meets the preset criteria; when the text code to be evaluated meets the preset criteria, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated; a hyperplane is constructed according to the feature data set, the feature data set is classified using the hyperplane, and whether the text code to be evaluated is qualified is verified according to the classification result, thereby achieving a comprehensive verification of the text code to be evaluated and thus improving the efficiency of the evaluation of the text code to be evaluated. Therefore, the text code detection and evaluation method proposed by the present invention can solve the problem of low efficiency in code evaluation.

[0118] like Figure 4 , is a functional module diagram of a text code detection and evaluation device provided in one embodiment of the present invention.

[0119] The text code detection and evaluation device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the text code detection and evaluation device 100 can include a code criteria verification module 101, a feedback module 102, a standardized feature data set acquisition module 103, a classification module 104, a qualified verification module 105 and an evaluation qualified module 106. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.

[0120] In this embodiment, the functions of each module / unit are as follows:

[0121] The code criteria verification module 101 is used to obtain the text code to be evaluated and verify whether the text code to be evaluated meets the preset criteria;

[0122] The feedback module 102 is used to feed back the text code to be evaluated and a preset alarm signal to the corresponding terminal when the text code to be evaluated does not meet the preset criteria;

[0123] The standardized feature data acquisition module 103 is used to parse the text code to be evaluated by using an abstract syntax tree to obtain a feature data set of the text code to be evaluated when the text code to be evaluated meets the preset criteria, and to perform standard quantization on the feature data set to obtain a standardized feature data set;

[0124] The classification module 104 is used to construct a hyperplane according to the standardized feature data set, and classify the standardized feature data set using the hyperplane;

[0125] A qualification verification module 105 is used to verify whether the text code to be evaluated is qualified according to the classification result;

[0126] The qualified evaluation module 106 is used to determine that the text code to be evaluated is qualified when the verification result is qualified.

[0127] In detail, each module described in the text code detection and evaluation device 100 in the embodiment of the present invention is used in the same manner as described above. Figures 1 to 3 The text code detection and evaluation method described in the text code detection and evaluation method is the same technical means and can produce the same technical effects, so it will not be repeated here.

[0128] like Figure 5 , is a schematic diagram of the structure of an electronic device for implementing a text code detection and evaluation method provided by an embodiment of the present invention.

[0129] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a text code detection and evaluation program.

[0130] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing text code detection and evaluation programs, etc.), and calls data stored in the memory 11 to execute various functions of the electronic device and process data.

[0131] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device, such as the code of the text code detection and evaluation program, but also be used to temporarily store data that has been output or is to be output.

[0132] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.

[0133] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.

[0134] The figure only shows an electronic device with components. Those skilled in the art will understand that the structure shown in the figure does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0135] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0136] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0137] The text code detection and evaluation program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:

[0138] Obtaining a text code to be evaluated, and verifying whether the text code to be evaluated meets a preset criterion;

[0139] When the text code to be evaluated does not meet the preset criteria, feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal;

[0140] When the text code to be evaluated meets the preset criteria, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, and the feature data set is standard quantized to obtain a standardized feature data set;

[0141] Constructing a hyperplane according to the standardized feature data set, and classifying the standardized feature data set using the hyperplane;

[0142] Verify whether the text code to be evaluated is qualified according to the classification result;

[0143] When the verification result is qualified, determining that the text code to be evaluated is qualified;

[0144] When the verification result is unqualified, the process returns to the step of feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal.

[0145] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.

[0146] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0147] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:

[0148] Obtaining a text code to be evaluated, and verifying whether the text code to be evaluated meets a preset criterion;

[0149] When the text code to be evaluated does not meet the preset criteria, feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal;

[0150] When the text code to be evaluated meets the preset criteria, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, and the feature data set is standard quantized to obtain a standardized feature data set;

[0151] Constructing a hyperplane according to the standardized feature data set, and classifying the standardized feature data set using the hyperplane;

[0152] Verify whether the text code to be evaluated is qualified according to the classification result;

[0153] When the verification result is qualified, determining that the text code to be evaluated is qualified;

[0154] When the verification result is unqualified, the process returns to the step of feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal.

[0155] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

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

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

[0158] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0159] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0160] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

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

[0162] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A text code detection and evaluation method, characterized in that: The method comprises: Obtaining a text code to be evaluated, and verifying whether the text code to be evaluated meets a preset criterion; When the text code to be evaluated does not meet the preset criteria, feeding back the text code to be evaluated and a preset alarm signal to the corresponding terminal; When the text code to be evaluated meets the preset criteria, the text code to be evaluated is parsed using an abstract syntax tree to obtain a feature data set of the text code to be evaluated, and the feature data set is standard quantized to obtain a standardized feature data set; Constructing a hyperplane according to the standardized feature data set, and classifying the standardized feature data set using the hyperplane; Verify whether the text code to be evaluated is qualified according to the classification result; When the verification result is qualified, determining that the text code to be evaluated is qualified; Wherein, the verification of whether the text code to be evaluated meets the preset criteria includes: calling a preset criteria verification script according to the text code to be evaluated; obtaining a rule chain of preset criteria from the criteria verification script, wherein the rule chain includes multiple preset criteria; dividing the rule chain into multiple independently verifiable rule blocks according to the multiple preset criteria; using the multiple independently verifiable rule blocks to verify whether the text code to be evaluated meets the preset criteria; if there is one or more rule blocks that do not meet the preset criteria, it is determined that the text code to be evaluated does not meet the preset criteria; if the text code to be evaluated meets the preset criteria of each of the rule blocks, it is determined that the text code to be evaluated meets the preset criteria.

2. The text code detection and evaluation method according to claim 1, characterized in that: The method of parsing the text code to be evaluated by using an abstract syntax tree to obtain a feature data set of the text code to be evaluated includes: Generate a corresponding abstract syntax tree based on each function in the text code to be evaluated; Retrieving a label code in the abstract syntax tree using a preset code evaluation label; A feature data set of the text code to be evaluated is determined according to the label code.

3. The text code detection and evaluation method according to claim 1, characterized in that: The step of performing standard quantization on the feature data set to obtain a standardized feature data set includes: dividing the feature data set into character string feature data and numerical feature data according to the type of the feature data; Performing one-hot encoding on the character string feature data, and normalizing the numerical feature data; The character string feature data after the one-hot encoding and the numerical feature data after the normalization processing are collected to obtain a standardized feature data set.

4. The text code detection and evaluation method according to claim 1, characterized in that: The step of constructing a hyperplane according to the standardized feature data set and classifying the standardized feature data set using the hyperplane includes: Performing vector transformation on the standardized feature data set using a pre-built vector transformation model to obtain a feature vector set; Mapping the feature vector set to a coordinate set to obtain a feature vector coordinate set; Calculate the Euclidean distance between any two coordinates in the feature vector coordinate set, and select the feature coordinate with the smallest Euclidean distance as the target feature coordinate; Constructing a hyperplane function according to the target feature coordinates, and calculating a distance value from the target feature coordinates to the hyperplane function; According to the distance value, a minimum distance value is selected and a constraint condition is constructed, and the minimum distance based on the constraint condition is solved by the Lagrange multiplier method to obtain a hyperplane; The standardized feature data set is classified using the hyperplane to obtain a classification result.

5. The text code detection and evaluation method according to claim 4, characterized in that: The calculating the distance value from the target feature coordinates to the hyperplane function includes: The distance value from the target feature coordinates to the hyperplane function is calculated using the following formula: in, is the distance from the target feature coordinates to the hyperplane, It is The target feature coordinates, yes The class labels belonging to the hyperplane function above or below, where the class labels are +1 or -1, and These are preset fixed parameters.

6. The text code detection and evaluation method according to claim 1, characterized in that: The step of checking whether the text code to be evaluated is qualified according to the classification result includes: When each of the standardized feature data classification results is qualified, determining that the text code to be evaluated is qualified; If there is greater than or equal to one standardized feature data classification result that is unqualified, it is determined that the text code to be evaluated is unqualified.

7. A text code detection and evaluation device, used to implement the text code detection and evaluation method as claimed in any one of claims 1 to 6, characterized in that: The device comprises: A code criteria verification module is used to obtain the text code to be evaluated and verify whether the text code to be evaluated meets the preset criteria; A feedback module, used for feeding back the text code to be evaluated and a preset alarm signal to a corresponding terminal when the text code to be evaluated does not meet the preset criteria; A standardized feature data acquisition module is used to parse the text code to be evaluated by using an abstract syntax tree to obtain a feature data set of the text code to be evaluated when the text code to be evaluated meets the preset criteria, and to perform standard quantization on the feature data set to obtain a standardized feature data set; A classification module, used to construct a hyperplane according to the standardized feature data set, and classify the standardized feature data set using the hyperplane; A qualification verification module is used to verify whether the text code to be evaluated is qualified according to the classification result; The qualified evaluation module is used to determine whether the text code to be evaluated is qualified when the verification result is qualified.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the text code detection and evaluation method as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text code detection and evaluation method as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Junk file monitoring method and device, equipment and storage medium

    CN113868093A

  • Method and device for determining code generation quality and efficiency evaluation value based on multiple indexes

    CN114064046A