A cross-language SDK generation method based on offline compilation and feature derivation

Generating SDKs that are adapted to different programming languages ​​through feature derivation mechanisms solves the problems of inefficient SDK generation and insufficient multilingual support in the prior art, and realizes efficient and targeted SDK code generation and cross-language development support.

CN119045814BActive Publication Date: 2025-02-18SHENZHEN MAGIC NUMBER INTELLIGENT ARTIFICIAL INTELLIGENCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411547805.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-18
Estimated Expiration
2044-11-01

AI Technical Summary

Technical Problem

The existing SDK generation tools require manual writing and maintenance of SDK code in each language version, which is inefficient and error-prone, and the support for different target programming languages ​​is not comprehensive enough, making it difficult to adapt to the characteristics of different languages, resulting in the efficiency and quality of SDK generation. Restricted.

Method used

Through the feature derivation mechanism, derivative features adapted to different programming languages ​​are generated from the input initial feature logic, offline SDKs for multiple target programming languages ​​are generated, more targeted SDK code generation is realized, more extensive development needs are supported, and support Offline compilation and cross-language development.

Benefits of technology

It realizes more targeted SDK code generation, supports a wider development requirement, and supports offline compilation and cross-language development, improving the efficiency and quality of SDK generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119045814B_ABST
    Figure CN119045814B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of software development, and specifically discloses a method for generating an offline compilation cross-language SDK based on feature derivation, comprising: acquiring source data of each target programming language in an offline compilation request based on a data source adapter component; performing feature derivation on the source data of each target programming language to obtain feature derivation information of each target programming language; generating a sub-code package of each function of each target programming language based on the feature derivation information of each target programming language; encapsulating the sub-code packages of all functions of each target programming language to obtain an SDK offline code package of each target programming language; and generating offline SDKs of multiple target programming languages ​​to support offline compilation and cross-language development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software development, and in particular to an offline compiled cross-language SDK generation method based on feature derivation. Background Art

[0002] At present, with the diversification and complexity of software development requirements, interoperability between different target programming languages ​​is becoming more and more important. SDK (Software Development Kit) is an important bridge between developers and applications. It is usually necessary to generate different versions for different target programming languages ​​to adapt to various application environments.

[0003] However, existing SDK generation tools usually require manual writing and maintenance of SDK codes for various language versions, which is inefficient and prone to errors. Figure 1 , the existing SDK generation tools do not fully support different target programming languages, resulting in limitations in cross-language development. In addition, many existing tools rely on online environments for compilation and generation, which are not suitable for scenarios that require offline development or deployment. In multi-language support, feature calculation logic is often difficult to directly adapt to the characteristics of different languages, resulting in limited efficiency and quality of SDK generation.

[0004] Therefore, the present invention proposes an offline compiled cross-language SDK generation method based on feature derivation. Summary of the invention

[0005] The present invention provides an offline compiled cross-language SDK generation method based on feature derivation, which is used to generate derived features adapted to different programming languages ​​from the input initial feature logic through a feature derivation mechanism, generate offline SDKs for multiple target programming languages, and achieve more targeted SDK code generation, thereby supporting a wider range of development needs, and supporting offline compilation and cross-language development.

[0006] The present invention provides a method for generating a cross-language SDK by offline compilation based on feature derivation, comprising:

[0007] S1: Obtain source data of each target programming language in the offline compilation request based on the data source adapter component;

[0008] S2: deriving features from source data of each target programming language to obtain feature derivative information of each target programming language;

[0009] S3: generating a sub-code package for each function of each target programming language based on feature derivative information of each target programming language;

[0010] S4: Encapsulate the sub-code packages of all functions of each target programming language to obtain the SDK offline code package of each target programming language.

[0011] Preferably, the feature-derived offline compilation cross-language SDK generation method, S1: obtaining source data of each target programming language in the offline compilation request based on the data source adapter component, including:

[0012] Receive an offline compilation request and determine all target programming language types in the offline compilation request;

[0013] Get the source language code;

[0014] Based on the source language code and the data source adapter component of all target programming languages ​​in the offline compilation request, the source data of each target programming language in the offline compilation request is obtained.

[0015] Preferably, the offline compilation cross-language SDK generation method based on feature derivation, S2: deriving features from source data of each target programming language to obtain feature derivation information of each target programming language, including:

[0016] Parse the source language code to obtain the code structure and semantic information of the source language code;

[0017] Based on the code structure tree and semantic information of the source language code, feature derivation is performed on the source data of each target programming language to obtain feature derivation information of each target programming language.

[0018] Preferably, the feature-derived offline compilation cross-language SDK generation method parses the source language code to obtain the code structure tree and semantic information of the source language code, including:

[0019] Determine the overall implementation function of the source language code;

[0020] Determine the meaning of each code statement in the source language code;

[0021] Based on the overall implementation function of the source language code and the meaning of each code statement, all code statements in the source language code are divided into functional modules to obtain multiple code blocks;

[0022] Generate a sub-execution logic flow of each code block based on the statement meanings of all code statements in each code block in the source language code;

[0023] Based on the overall implementation function of the source language code and the sub-implementation functions of all code blocks in the source language code, the sub-implementation functions of all code blocks in the source language code are logically connected to obtain the macro execution logic flow of all code blocks in the source language code;

[0024] Based on the macro execution logic flow of all code blocks in the source language code, the sub execution logic flow of all code blocks is filled and partially concatenated to obtain the code structure tree of the source language code;

[0025] All code statements in the source language code are associated with all minimum unit execution steps in the code structure tree to obtain semantic information of the source language code.

[0026] Preferably, the offline compilation cross-language SDK generation method based on feature derivation performs feature derivation on source data of each target programming language based on the code structure tree and semantic information of the source language code to obtain feature derivation information of each target programming language, including:

[0027] Based on the code structure tree and semantic information of the source language code, all key features of the source language code are extracted;

[0028] Determine the feature type of each key feature in the source language code, and determine the feature derivation method corresponding to each target programming language based on the feature type of each key feature and the source language type and each target programming language type;

[0029] Based on the feature derivation method corresponding to each target programming language, feature derivation is performed on the source data of each target programming language to obtain all derived features of each target programming language;

[0030] All derived features of each target programming language are regarded as feature derivative information of each target programming language.

[0031] Preferably, the offline compilation cross-language SDK generation method extracts all key features in the source language code based on the code structure tree and semantic information of the source language code, including:

[0032] Input the code structure tree and semantic information of the source language code into the feature extraction model to obtain all extracted features of the source language code;

[0033] Get all extracted features in a preset amount of sample code;

[0034] Based on all extracted features in a preset amount of sample code, calculate an internally measured typical rate for each extracted feature in the source language code;

[0035] All extracted features in the source language code whose internal typicality rate is not less than the typicality rate threshold are regarded as all key features in the source language code.

[0036] Preferably, the feature-derived offline compiled cross-language SDK generation method calculates the internal measurement typicality of each extracted feature in the source language code based on all extracted features in a preset amount of sample code, including:

[0037] The ratio of the frequency of occurrence of each extracted feature in the source language code in the preset amount of sample codes to the preset amount is regarded as the relative frequency of occurrence of each extracted feature;

[0038] Based on the maximum and minimum values ​​of the relative occurrence frequencies of all extracted features in the source language code and the relative occurrence frequency of each extracted feature, the relative occurrence frequency of each extracted feature in the source language code is normalized to obtain the internal standard occurrence frequency of each extracted feature;

[0039] Sort all extracted features according to the principle of descending frequency of internal criteria to obtain a feature sequence;

[0040] The ratio of the ranking value of each extracted feature in the feature sequence in the language code to the total number of all extracted features is taken as the internal measure typicality of each extracted feature in the source language code.

[0041] Preferably, the feature-derivative-based offline compilation cross-language SDK generation method, S3: generating a sub-code package for each function of each target programming language based on the feature-derivative information of each target programming language, including:

[0042] Get the sub-implementation function of each code block in the source language code;

[0043] generating a sub-code package for each function of each target programming language based on a language specification of a sub-implementation function of each code block in the source language code and feature derivative information of each target programming language;

[0044] Among them, all functional types of the target programming language correspond one-to-one to the sub-implementation functions of all code blocks in the source language code.

[0045] Preferably, the feature-derivation-based offline compilation cross-language SDK generation method generates a sub-code package for each function of each target programming language based on the language specification of the sub-implementation function of each code block in the source language code and the feature derivation information of each target programming language, including:

[0046] Based on the language specification of each target programming language for the sub-implementation function of each code block in the source language code, assembling the feature derivative information of each target programming language according to the template to generate an initial code package for each function of each target programming language;

[0047] The initial code package of each function of each target programming language is verified to obtain a sub-code package of each function of each target programming language.

[0048] Preferably, the feature-derived offline compilation cross-language SDK generation method verifies the initial code package of each function of each target programming language to obtain a sub-code package of each function of each target programming language, including:

[0049] Testing the initial code package of each function of each target programming language to obtain a test result of the initial code package of each function;

[0050] Based on the test results of the initial code package of each function, the initial code package is optimized and adjusted to obtain a sub-code package of each function of each target programming language.

[0051] The beneficial effects of the present invention compared to the prior art are as follows: through the feature derivation mechanism, derived features adapted to different programming languages ​​are generated from the input initial feature logic, and offline SDKs for multiple target programming languages ​​are generated, thereby achieving more targeted SDK code generation, thereby supporting a wider range of development needs, and supporting offline compilation and cross-language development.

[0052] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures specifically pointed out in this application document.

[0053] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0055] Figure 1 This is a flow chart of a traditional compilation cross-language SDK generation method in an embodiment of the present invention;

[0056] Figure 2 This is a flow chart of a method for generating a cross-language SDK by offline compilation based on feature derivation in an embodiment of the present invention;

[0057] Figure 3 This is a logical flow diagram of a feature-derived offline compiled cross-language SDK generation method in an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0059] Example 1

[0060] The present invention provides a method for generating a cross-language SDK by offline compilation based on feature derivation, referring to Figure 2 and 3 ,include:

[0061] S1: Obtain source data of each target programming language in the offline compilation request based on the data source adapter component;

[0062] S2: deriving features from source data of each target programming language to obtain feature derivative information of each target programming language;

[0063] S3: generating a sub-code package for each function of each target programming language based on feature derivative information of each target programming language;

[0064] S4: Encapsulate the sub-code packages of all functions of each target programming language to obtain the SDK offline code package of each target programming language.

[0065] In this embodiment, it is an important part of the microservice architecture, mainly responsible for receiving and processing data from external data sources and converting it into a format and structure that can be used by microservices. For example: JDBC adapter: used to connect to a relational database, providing Java code as an external interface to facilitate other microservice calls;

[0066] There are many different data source adapters available for a variety of programming languages ​​and databases such as Java, Python, and SQL. Here are some common adapters:

[0067] 1.MySQLConnector / J: JDBC adapter for connecting to MySQL database, supporting Java development.

[0068] 2.JDBCDriverManager: A built-in data source adapter in Java that can be used to connect to a variety of relational databases, including MySQL, Oracle, SqlServer, etc.

[0069] 3.SQLAlchemy: Python ORM (object-relational mapping) library for interacting with relational databases.

[0070] 4.PyMySQL: MySQL adapter in Python, similar to JDBCConnector / J, but written in Python.

[0071] 5.DjangoORM: Django is a popular Python web framework with a built-in ORM system that simplifies database operations.

[0072] 6.SQLite3: The built-in SQL database module in Python can be used to create and manage SQLite databases.

[0073] 7.PostgreSQLadapter: PostgreSQL adapter in Python, similar to JDBCConnector / J, but written in Python.

[0074] 8.SQLServerdriver: Adapter used to connect to MicrosoftSQLServer database, supporting multiple programming languages, such as C#, VB.NET, Python, etc.

[0075] In this embodiment, the offline compilation request is a request initiated by an external user to compile SDK codes in an offline state.

[0076] In this embodiment, the target programming language is at least one programming language included in the offline compilation request that the user wants to perform cross-language compilation.

[0077] In this embodiment, the source data is code data obtained by directly translating the source language code into the target programming language.

[0078] In this embodiment, the sub-code package of each function of each target programming language is a code package of the target programming language type that can implement the sub-implementation function of each code block in the source language code.

[0079] In this embodiment, the SDK offline code package is finally compiled in an offline state to obtain a cross-language SDK code package.

[0080] In this embodiment, reference Figure 3 , the system obtains data source data through the data source adapter component according to the configured data source information;

[0081] Developers configure data source relationships and application feature derivation templates in the system. After configuration is complete, the system automatically derives features based on the application's feature templates.

[0082] When the system is performing the feature derivation process, it abstracts the calculation logic of the feature derivation operator and records the entire feature derivation relationship, including data source, derivation process, derivation results, and the relationship in derivation;

[0083] Get the configured data source information and data details, replace the generation template of the data source of the corresponding language, and get the specific data acquisition code;

[0084] Obtain the abstract information of feature derivative operators and convert the detailed information of feature derivative operators in the corresponding language;

[0085] Generate data cleaning code in the corresponding language based on the feature derivative operator details;

[0086] Generate feature derivation code in the corresponding language based on feature derivation operator details;

[0087] Get the required feature derivative name, convert the result to the corresponding language, and filter the code;

[0088] Get the date column derived from the feature and convert it into the date formatting code of the corresponding language;

[0089] Perform system built-in code syntax verification, data field verification, and data verification;

[0090] Encapsulate the final SDK offline code package.

[0091] The beneficial effects of the above technology are: through the feature derivation mechanism, derived features suitable for different programming languages ​​are generated from the input initial feature logic, and offline SDKs for multiple target programming languages ​​are generated to achieve more targeted SDK code generation, thereby supporting a wider range of development needs, and supporting offline compilation and cross-language development.

[0092] Example 2

[0093] Based on Example 1, a method for generating a cross-language SDK for offline compilation based on feature derivation is provided. S1: acquiring source data of each target programming language in an offline compilation request based on a data source adapter component, including:

[0094] Receive an offline compilation request and determine all target programming language types in the offline compilation request;

[0095] Get the source language code;

[0096] Based on the source language code and the data source adapter component of all target programming languages ​​in the offline compilation request, the source data of each target programming language in the offline compilation request is obtained.

[0097] In this embodiment, the source language code is an input object of the compiler and is a high-level language code data.

[0098] In this embodiment, the target programming language type is the code language type that the user wants to obtain by cross-language compilation in the offline compilation request, for example: Java, Python, SQL.

[0099] In this embodiment, the source language type is the language type of the input initial code, which is then used to generate code packages in other languages ​​using the feature-derived offline compilation cross-language SDK generation method in this embodiment.

[0100] In this embodiment, based on the source language code and the data source adapter components of all target programming languages ​​in the offline compilation request, the source data of each target programming language in the offline compilation request is obtained, namely:

[0101] The source language code is adapted and converted using data source adaptation components of all target programming language types in the offline compilation request to obtain source data of each target programming language in the offline compilation request.

[0102] The beneficial effect of the above technology is: based on the offline compilation request and the data source adapter components of various target programming languages, the source data of each target programming language in the offline compilation request is obtained.

[0103] Example 3

[0104] Based on Example 1, an offline compilation cross-language SDK generation method based on feature derivation, S2: performing feature derivation on source data of each target programming language to obtain feature derivation information of each target programming language, including:

[0105] Parse the source language code to obtain the code structure and semantic information of the source language code;

[0106] Based on the code structure tree and semantic information of the source language code, feature derivation is performed on the source data of each target programming language to obtain feature derivation information of each target programming language.

[0107] The beneficial effect of the above technology is: based on the code structure and semantic information of the source language code, feature derivation of the source data of each target programming language is achieved.

[0108] Example 4

[0109] On the basis of Example 3, the feature-derived offline compilation cross-language SDK generation method parses the source language code to obtain the code structure tree and semantic information of the source language code, including:

[0110] Determine the overall implementation function of the source language code;

[0111] Determine the meaning of each code statement in the source language code;

[0112] Based on the overall implementation function of the source language code and the meaning of each code statement, all code statements in the source language code are divided into functional modules to obtain multiple code blocks;

[0113] Generate a sub-execution logic flow of each code block based on the statement meanings of all code statements in each code block in the source language code;

[0114] Based on the overall implementation function of the source language code and the sub-implementation functions of all code blocks in the source language code, the sub-implementation functions of all code blocks in the source language code are logically connected to obtain the macro execution logic flow of all code blocks in the source language code;

[0115] Based on the macro execution logic flow of all code blocks in the source language code, the sub execution logic flow of all code blocks is filled and partially concatenated to obtain the code structure tree of the source language code;

[0116] All code statements in the source language code are associated with all minimum unit execution steps in the code structure tree to obtain semantic information of the source language code.

[0117] In this embodiment, the overall implementation function of the source language code is the program function that can be implemented by the complete source language code.

[0118] In this embodiment, the meaning of a code statement represents the instruction content that can be completed.

[0119] In this embodiment, based on the overall implementation function of the source language code and the meaning of each code statement, all code statements in the source language code are divided into functional modules to obtain multiple code blocks, namely:

[0120] In this case, the functional modules are usually divided according to the logical structure of the code, functional relevance, and dependencies between statements. Through in-depth analysis and understanding of the code, code statements with similar functions or close associations are combined into a code block.

[0121] In this embodiment, based on the statement meanings of all code statements in each code block in the source language code, generating the sub-execution logic flow of each code block specifically usually requires a detailed analysis of the code statements in each code block, understanding their execution order and dependencies, and thus generating the corresponding sub-execution logic flow.

[0122] In this embodiment, based on the overall implementation function of the source language code and the sub-implementation functions of all code blocks in the source language code, the sub-implementation functions of all code blocks in the source language code are logically connected to obtain the macro execution logic flow of all code blocks in the source language code. This process requires comprehensive consideration of the overall function of the source language code and the sub-implementation functions of each code block. By analyzing the association and dependency relationship between them, the sub-implementation functions are connected in series in a certain logical order, thereby forming a macro execution logic flow.

[0123] In this embodiment, the macro execution logic flow of the code block is a combination of the overall source language code and each code block sub-function, which is connected in series based on associations and dependencies, and can clearly display the overall execution logic.

[0124] In this embodiment, the sub-execution logic flow of the code block is generated by detailed analysis of the code statements in the code block according to their execution order and dependency relationships, which helps to clearly understand the execution process and logic of the code.

[0125] In this embodiment, the sub-implementation function of the code block is an instruction function that can be implemented by all code statements in the code block as a whole.

[0126] In this embodiment, based on the macro execution logic flow of all code blocks in the source language code, the sub execution logic flows of all code blocks are filled and partially concatenated to obtain a code structure tree of the source language code, including:

[0127] The sub-execution logic flows of all code blocks are used to replace the corresponding nodes in the macro-execution logic flow of all code blocks in the source language code, and based on the execution order and dependency relationship between the end statements and the start statements of different code blocks, the sub-execution logic flows of the code blocks of adjacent nodes in the macro-execution logic flow of all code blocks in the source language code are partially concatenated, so as to obtain a code structure tree that can represent the code hierarchy and relationship in the source language code.

[0128] In this embodiment, all code statements in the source language code are associated with all minimum unit execution steps in the code structure tree to obtain semantic information of the source language code, namely:

[0129] All code statements in the source language code are associated with the minimum unit execution instructions in each code block in the code structure tree to obtain the semantic information of the source language code.

[0130] The beneficial effects of the above technology are as follows: first, by gradually determining the overall implementation function of the source language code and the meaning of each code statement, developers or analysts can have an in-depth and accurate understanding of the code. This helps to more clearly grasp the core purpose and specific role of the code in the subsequent development, maintenance and optimization process. Functional module division of code statements and obtaining multiple code blocks help improve the readability and maintainability of the code. Decomposing complex code into relatively independent modules makes the function of each module clearer and convenient for modification, testing and debugging separately. Generating a sub-execution logic flow for each code block can show the execution process inside each functional module in detail, which helps to find potential logical errors and optimization points. Logically concatenating the sub-implementation functions of all code blocks to obtain a macro-execution logic flow can grasp the running process of the code as a whole and better understand the collaborative relationship and data transfer between each module. Filling and partially concatenating the sub-execution logic flow based on the macro-execution logic flow to obtain a code structure tree can present the structure and logical relationship of the code in an intuitive and hierarchical manner, which is convenient for developers to conduct systematic analysis and design. Finally, the code statements are associated with the smallest unit execution steps in the code structure tree to obtain semantic information, which provides a solid foundation for automated code analysis, document generation, code refactoring, and other tasks, improving the efficiency and quality of software development. This solution can fully and deeply understand the source language code, improve the maintainability, scalability, and comprehensibility of the code, and thus effectively improve the overall level of software development.

[0131] Example 5

[0132] On the basis of Example 3, the offline compilation cross-language SDK generation method based on feature derivation performs feature derivation on the source data of each target programming language based on the code structure tree and semantic information of the source language code to obtain feature derivation information of each target programming language, including:

[0133] Based on the code structure tree and semantic information of the source language code, all key features of the source language code are extracted;

[0134] Determine the feature type of each key feature in the source language code, and determine the feature derivation method corresponding to each target programming language based on the feature type of each key feature and the source language type and each target programming language type;

[0135] Based on the feature derivation method corresponding to each target programming language, feature derivation is performed on the source data of each target programming language to obtain all derived features of each target programming language;

[0136] All derived features of each target programming language are regarded as feature derivative information of each target programming language.

[0137] In this embodiment, the feature types of key features include, for example: data source information, data detail information, data type, function call, function signature, variable type, class structure, control structure, etc.

[0138] In this embodiment, based on the feature type of each key feature, the source language type, and each target programming language type, a feature derivation method corresponding to each target programming language is determined, including:

[0139] The following is an explanation of how the above steps are implemented:

[0140] First, it is necessary to clarify the feature type of each key feature, which may include data types (such as integers, strings, Boolean values, etc.), function types (such as calculation, judgment, storage, etc.), etc.; then understand the type of source language, such as Python, Java or other languages; then, for each type of target programming language, such as C++, GoLang, etc. According to the type and function of the key features in the source language, combined with the syntax and characteristics of the target programming language, determine the corresponding feature derivation method. For example, if a key feature in the source language is an integer type variable, in the target programming language C++, it may be necessary to consider the differences in its memory allocation method, scope, etc., so as to determine how to implement this feature in C++. For another example, a specific calculation logic in the source language may need to use different functions or grammatical structures to achieve the same function in the target programming language GoLang.

[0141] The beneficial effects of the above technologies are as follows: clarifying the types of key features helps to accurately grasp the nature and purpose of code elements, laying the foundation for subsequent conversion and reuse. Understanding the type of source language can be targeted and processed according to its characteristics to improve the accuracy of conversion. Considering the type of target programming language makes the conversion work more targeted and adaptable. Determining the feature derivation method based on the characteristics of the source language and the target language can achieve smooth conversion and reuse of code between different languages, avoid repeated development, and improve development efficiency. By deeply understanding the source language and the target language, efficient conversion and reuse of code is achieved, saving development time and resources.

[0142] Example 6

[0143] Based on Example 5, the feature-derived offline compilation cross-language SDK generation method extracts all key features in the source language code based on the code structure tree and semantic information of the source language code, including:

[0144] Input the code structure tree and semantic information of the source language code into the feature extraction model to obtain all extracted features of the source language code;

[0145] Get all extracted features in a preset amount of sample code;

[0146] Based on all extracted features in a preset amount of sample code, calculate an internally measured typical rate for each extracted feature in the source language code;

[0147] All extracted features in the source language code whose internal typicality rate is not less than the typicality rate threshold are regarded as all key features in the source language code.

[0148] In this embodiment, the feature extraction model is a model obtained by pre-training with a large number of sample codes and all the extracted features contained therein marked by artificial or other existing single feature extraction feature extraction models as samples.

[0149] In this embodiment, the preset amount is, for example, 1000.

[0150] In this embodiment, the example code is a pre-prepared code package that may contain one or more extracted features, and a single example code is composed of multiple code statements.

[0151] In this embodiment, all extracted features in the example code may include data types (such as integers, strings, Boolean values, etc.), function types (such as calculation, judgment, storage, etc.), etc.

[0152] In this embodiment, the internal measurement typicality of the extracted features represents the degree of typicality among all the extracted features in a large amount of code, which is obtained by taking the frequency of occurrence of a single extracted feature in a preset amount of sample code as a reference and relatively calibrating it with the frequency of occurrence of all the extracted features contained in the source language code in a preset amount of sample code.

[0153] In this embodiment, the typicality threshold is a preset value that the internal typicality of the key feature in the source language code cannot be less than.

[0154] The beneficial effects of the above technology are: by inputting the code structure tree and semantic information into the feature extraction model, the extracted features of the source language code can be obtained comprehensively and accurately, providing a rich data basis for subsequent analysis. Obtaining the extracted features in a preset amount of sample code helps to establish a reference standard, making the measurement of source language code features more objective. Calculating the internal measurement typicality rate of each extracted feature can quantify the importance and representativeness of the feature, allowing developers to more clearly understand the key parts of the code. Screening out extracted features with an internal measurement typicality rate not less than the typicality rate threshold as key features helps to focus on key points and improve the efficiency of code analysis and optimization. That is, effectively extracting and screening key features of the source language code, improving the pertinence and efficiency of code analysis and processing, and providing strong support for code optimization and improvement.

[0155] Example 7

[0156] On the basis of Example 6, the feature-derived offline compiled cross-language SDK generation method calculates the internal measurement typicality of each extracted feature in the source language code based on all extracted features in the preset amount of sample code, including:

[0157] The ratio of the frequency of occurrence of each extracted feature in the source language code in the preset amount of sample codes to the preset amount is regarded as the relative frequency of occurrence of each extracted feature;

[0158] Based on the maximum and minimum values ​​of the relative occurrence frequencies of all extracted features in the source language code and the relative occurrence frequency of each extracted feature, the relative occurrence frequency of each extracted feature in the source language code is normalized to obtain the internal standard occurrence frequency of each extracted feature;

[0159] Sort all extracted features according to the principle of descending frequency of internal criteria to obtain a feature sequence;

[0160] The ratio of the ranking value of each extracted feature in the feature sequence in the language code to the total number of all extracted features is taken as the internal measure typicality of each extracted feature in the source language code.

[0161] In this embodiment, based on the maximum and minimum values ​​of the relative occurrence frequencies of all extracted features in the source language code and the relative occurrence frequency of each extracted feature, the relative occurrence frequency of each extracted feature in the source language code is normalized to obtain the internal standard occurrence frequency of each extracted feature, including:

[0162] The difference between the relative occurrence frequency of each extracted feature and the minimum relative occurrence frequency of all extracted features in the source language code is divided by the difference between the maximum and minimum relative occurrence frequencies of all extracted features in the source language code to obtain the internal standard occurrence frequency of each extracted feature.

[0163] The beneficial effects of the above technology are as follows: calculating the relative frequency of occurrence of each extracted feature can intuitively reflect its commonness in the sample code, which helps to initially understand the importance of the feature. Normalizing the relative frequency of occurrence to obtain the internal standard frequency of occurrence makes the frequencies of different features comparable, which is convenient for subsequent analysis and processing. Sorting the feature sequence according to the internal standard frequency of occurrence can clearly show the order of importance of the features. Calculating the internal measurement typicality of each extracted feature provides a quantitative basis for further evaluation and screening of features, which helps to improve the accuracy and efficiency of code analysis and processing. Through a series of calculations and processing, the extracted features in the source language code can be effectively quantitatively analyzed and sorted, providing valuable information for related code research and applications.

[0164] Example 8

[0165] Based on Example 1, the offline compilation cross-language SDK generation method based on feature derivation, S3: generating a sub-code package for each function of each target programming language based on feature derivation information of each target programming language, including:

[0166] Get the sub-implementation function of each code block in the source language code;

[0167] generating a sub-code package for each function of each target programming language based on a language specification of a sub-implementation function of each code block in the source language code and feature derivative information of each target programming language;

[0168] Among them, all functional types of the target programming language correspond one-to-one to the sub-implementation functions of all code blocks in the source language code.

[0169] In this embodiment, the language specification of the sub-implementation function of the code block refers to the programming rules and conventions that should be followed by each relatively independent code block divided out from a larger source language code.

[0170] For example, in Python, a function can be regarded as a code block. The definition of a function needs to follow a specific syntax, such as the naming rules of the function name and the way of passing parameters. This is the language specification of the function code block.

[0171] For example, in Java, a method in a class is also a code block. The method's access modifiers (public, private, etc.), return value type, parameter type, etc. are the language specifications of this method code block.

[0172] The language specification ensures that the functionality of a code block can be implemented correctly, clearly, and efficiently, and is easy for other developers to understand and use.

[0173] The beneficial effects of the above technology are: it can obtain the sub-implementation functions of each code block in the source language code, so that developers can have a more detailed understanding of the code functions, which is convenient for subsequent processing and optimization. Sub-code packages are generated based on the specifications and feature-derived information of the target programming language, making the conversion and application of codes in different language environments more convenient. Since the functions of the target programming language correspond one-to-one with the sub-implementation functions of the source language code blocks, the accuracy and completeness of the code conversion are guaranteed, and the portability and reusability of the code are improved. It helps to improve the adaptability and usability of the code in different language environments, bringing convenience and efficiency to software development.

[0174] Example 9

[0175] On the basis of Example 8, the offline compilation cross-language SDK generation method based on feature derivation generates a sub-code package for each function of each target programming language based on the language specification of the sub-implementation function of each code block in the source language code of each target programming language and the feature derivation information of each target programming language, including:

[0176] Based on the language specification of each target programming language for the sub-implementation function of each code block in the source language code, assembling the feature derivative information of each target programming language according to the template to generate an initial code package for each function of each target programming language;

[0177] The initial code package of each function of each target programming language is verified to obtain a sub-code package of each function of each target programming language.

[0178] The beneficial effects of the above technology are as follows: assembling and generating the initial code package based on the language specification can make the code conform to the specifications of the target programming language and improve the standardization and compatibility of the code. Verifying the initial code package to obtain the sub-code package helps to ensure the accuracy and reliability of the code and reduce errors and vulnerabilities. The entire process can improve the efficiency of code development and avoid unnecessary problems in subsequent use. It makes the functional implementation of the code in different target programming languages ​​more accurate and effective. It helps to improve the quality and development efficiency of the code and ensure the accuracy and reliability of the code.

[0179] Embodiment 10:

[0180] On the basis of Example 9, based on the feature-derived offline compilation cross-language SDK generation method, the initial code package of each function of each target programming language is verified to obtain a sub-code package of each function of each target programming language, including:

[0181] Testing the initial code package of each function of each target programming language to obtain a test result of the initial code package of each function;

[0182] Based on the test results of the initial code package of each function, the initial code package is optimized and adjusted to obtain a sub-code package of each function of each target programming language, including:

[0183] First, the test results of the initial code package for each function must be clarified. This includes identifying the problems found in the test, such as performance bottlenecks, error output, missing functions, etc.

[0184] Then, analyze the test results. For example, if a performance bottleneck is found, you may need to check the complexity of the algorithm to see if you can improve performance by optimizing the algorithm; if there is an error output, you need to locate the location and cause of the error, which may be a logical error, unhandled boundary conditions, etc.

[0185] Next, we will make optimization adjustments. For example, for performance optimization, we can use a more efficient data structure (such as changing an array to a linked list in some cases); for bug fixes, we can modify the corresponding code logic.

[0186] Take a simple function that calculates the sum of two numbers as an example.

[0187] The test results show that when the input number is very large, the calculation time is too long. After analysis, it is found that it is because the direct use of the "+" operator is not efficient;

[0188] The optimized subcode package can introduce conditional statements, compare two numbers with 0 respectively, and perform calculations according to different situations, thereby improving the performance when processing the addition of large numbers.

[0189] In short, optimization adjustments based on test results require careful analysis of the problem and targeted modifications to obtain a better sub-code package.

[0190] The beneficial effects of the above technology are: testing can clarify the actual performance of the initial code package of each function, providing a basis for subsequent optimization. Optimization and adjustment based on test results can help improve the quality and performance of the code package. Each target programming language and each function are processed separately, making the optimization more targeted and accurate. The obtained sub-code package is expected to be more complete and efficient in function implementation. The quality and performance of various function code packages in the target programming language can be improved through testing and optimization.

[0191] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for generating cross-language SDK by offline compilation based on feature derivation, characterized in that: include: S1: Obtain source data of each target programming language in the offline compilation request based on the data source adapter component; S2: deriving features from source data of each target programming language to obtain feature derivative information of each target programming language; S3: generating a sub-code package for each function of each target programming language based on feature derivative information of each target programming language; S4: Encapsulate the sub-code packages of all functions of each target programming language to obtain the SDK offline code package of each target programming language; Wherein, step S2: deriving features from source data of each target programming language to obtain feature derivative information of each target programming language includes: Parse the source language code to obtain the code structure and semantic information of the source language code; Based on the code structure tree and semantic information of the source language code, feature derivation is performed on the source data of each target programming language to obtain feature derivation information of each target programming language; Among them, based on the code structure tree and semantic information of the source language code, feature derivation is performed on the source data of each target programming language to obtain feature derivation information of each target programming language, including: Based on the code structure tree and semantic information of the source language code, all key features of the source language code are extracted; Determine the feature type of each key feature in the source language code, and determine the feature derivation method corresponding to each target programming language based on the feature type of each key feature and the source language type and each target programming language type; Based on the feature derivation method corresponding to each target programming language, feature derivation is performed on the source data of each target programming language to obtain all derived features of each target programming language; All derived features of each target programming language are regarded as feature derivative information of each target programming language.

2. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 1, characterized in that: S1: Obtain source data of each target programming language in the offline compilation request based on the data source adapter component, including: Receive an offline compilation request and determine all target programming language types in the offline compilation request; Get the source language code; Based on the source language code and the data source adapter component of all target programming languages ​​in the offline compilation request, the source data of each target programming language in the offline compilation request is obtained.

3. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 1, characterized in that: Parse the source language code to obtain the code structure tree and semantic information of the source language code, including: Determine the overall implementation function of the source language code; Determine the meaning of each code statement in the source language code; Based on the overall implementation function of the source language code and the meaning of each code statement, all code statements in the source language code are divided into functional modules to obtain multiple code blocks; Generate a sub-execution logic flow of each code block based on the statement meanings of all code statements in each code block in the source language code; Based on the overall implementation function of the source language code and the sub-implementation functions of all code blocks in the source language code, the sub-implementation functions of all code blocks in the source language code are logically connected to obtain the macro execution logic flow of all code blocks in the source language code; Based on the macro execution logic flow of all code blocks in the source language code, the sub execution logic flow of all code blocks is filled and partially concatenated to obtain the code structure tree of the source language code; All code statements in the source language code are associated with all minimum unit execution steps in the code structure tree to obtain semantic information of the source language code.

4. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 1, characterized in that: Based on the code structure tree and semantic information of the source language code, all key features of the source language code are extracted, including: Input the code structure tree and semantic information of the source language code into the feature extraction model to obtain all extracted features of the source language code; Get all extracted features in a preset amount of sample code; Based on all extracted features in a preset amount of sample code, calculate an internally measured typical rate for each extracted feature in the source language code; All extracted features in the source language code whose internal typicality rate is not less than the typicality rate threshold are regarded as all key features in the source language code.

5. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 4, characterized in that: Based on all extracted features in a preset amount of sample code, calculate the internal measure representative rate of each extracted feature in the source language code, including: The ratio of the frequency of occurrence of each extracted feature in the source language code in the preset amount of sample codes to the preset amount is regarded as the relative frequency of occurrence of each extracted feature; Based on the maximum and minimum values ​​of the relative occurrence frequencies of all extracted features in the source language code and the relative occurrence frequency of each extracted feature, the relative occurrence frequency of each extracted feature in the source language code is normalized to obtain the internal standard occurrence frequency of each extracted feature; Sort all extracted features according to the principle of descending frequency of internal criteria to obtain a feature sequence; The ratio of the ranking value of each extracted feature in the feature sequence in the language code to the total number of all extracted features is taken as the internal measure typicality of each extracted feature in the source language code.

6. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 1, characterized in that: S3: Generate a sub-code package for each function of each target programming language based on feature derivative information of each target programming language, including: Get the sub-implementation function of each code block in the source language code; generating a sub-code package for each function of each target programming language based on a language specification of a sub-implementation function of each code block in the source language code and feature derivative information of each target programming language; Among them, all functional types of the target programming language correspond one-to-one to the sub-implementation functions of all code blocks in the source language code.

7. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 6, characterized in that: Based on the language specification of the sub-implementation function of each code block in the source language code of each target programming language and the feature derivation information of each target programming language, a sub-code package of each function of each target programming language is generated, including: Based on the language specification of each target programming language for the sub-implementation function of each code block in the source language code, assembling the feature derivative information of each target programming language according to the template to generate an initial code package for each function of each target programming language; The initial code package of each function of each target programming language is verified to obtain a sub-code package of each function of each target programming language.

8. The method for generating a cross-language SDK based on offline compilation based on feature derivation according to claim 7, characterized in that: Verify the initial code package of each function of each target programming language to obtain a sub-code package of each function of each target programming language, including: Testing the initial code package of each function of each target programming language to obtain a test result of the initial code package of each function; Based on the test results of the initial code package of each function, the initial code package is optimized and adjusted to obtain a sub-code package of each function of each target programming language.

Citation Information

Patent Citations

  • Method and device for realizing cross-platform multi-language development, medium and electronic equipment

    CN111381817A

  • Generation method and device of universal development kit and system docking method and device

    CN117555622A