Code integration methods, devices, equipment, and storage media
By extracting and matching element names in the front-end and back-end code, and utilizing the improved KM algorithm and sliding window technology, the problem of fixed templates for front-end and back-end integration code in existing technologies has been solved, achieving automatic adaptation of front-end and back-end code and language-independent integration.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2021-10-25
- Publication Date
- 2026-06-30
AI Technical Summary
The existing technology generates fixed templates for interface code, which cannot dynamically generate appropriate interface code based on the front-end and back-end framework languages, resulting in the inability to automatically adapt the front-end and back-end interface fields.
By extracting element names from the front-end and back-end code to form an object matrix and performing similarity matching, the improved KM algorithm and sliding window technology are used to determine the correspondence between element names, thus achieving automated integration of front-end and back-end code.
It achieves automated adaptation of fields for front-end and back-end integration, reducing development time and communication costs, and adapting to front-end and back-end integration with different frameworks and languages.
Smart Images

Figure CN116028040B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of front-end and back-end development technology of mobile Internet, specifically to a code integration method, device, equipment and storage medium. Background Technology
[0002] In today's mobile internet field, to accelerate software development and iteration and improve production efficiency, special emphasis is placed on division of labor and collaboration. Therefore, in most cases, the development approach used is a front-end / back-end separation model. Back-end engineers implement the data interfaces for business functions, while front-end engineers implement the human-computer interaction for software functions. That is, back-end engineers generate business data, and front-end engineers present business data. Because the front-end and back-end use different languages and are handled by different engineers, there are significant communication and coordination costs when implementing front-end / back-end integration, which consumes a lot of time and energy.
[0003] In related technologies, the common practice is to manually bind front-end and back-end fields using a configuration page, and then generate the corresponding integration code. However, the generated integration code is a fixed template, which can only adapt to specific languages. For example, it can only adapt to front-end and back-end integration using the Vue framework and back-end using the Spring Boot framework. It cannot dynamically generate suitable integration code based on the front-end and back-end framework languages to achieve automatic adaptation of front-end and back-end integration fields. Summary of the Invention
[0004] This application provides a code integration method, apparatus, device, and storage medium to solve the technical problem that the integration code generated in the prior art is a fixed template and cannot dynamically generate suitable integration code according to the front-end and back-end framework languages, thus achieving automatic adaptation of front-end and back-end integration fields.
[0005] Firstly, embodiments of this application provide a code integration method, including:
[0006] Extract multiple first-element names from the front-end code to form a front-end object matrix;
[0007] Extract multiple second element names from the backend code to form a backend object matrix;
[0008] The front-end object matrix and the back-end object matrix are matched for similarity, and based on the similarity matching results, multiple third element names are determined from the multiple second element names; wherein, the multiple third element names correspond one-to-one with the multiple first element names;
[0009] The front-end code and the back-end code are connected based on the multiple first element names and the multiple third element names.
[0010] In one embodiment, extracting multiple first element names from the front-end code to form a front-end object matrix includes:
[0011] Determine the framework language of the front-end code;
[0012] Based on the framework language of the front-end code, determine the segmentation strategy and extraction strategy of the front-end code;
[0013] The front-end code is divided into multiple code fragments according to the segmentation strategy;
[0014] According to the extraction strategy, multiple first element names are extracted from each code segment as matrix elements to form a first matrix;
[0015] The first matrices corresponding to the multiple code snippets are merged to form a second matrix, and the second matrix is extracted as the front-end object matrix.
[0016] In one embodiment, determining the segmentation and extraction strategies of the front-end code based on the framework language of the front-end code includes:
[0017] Based on the framework language of the front-end code, determine the corresponding code recognition template;
[0018] Based on the code recognition template, determine the cutting labels and extract the labels;
[0019] Based on the cutting tags and the extraction tags, the segmentation strategy and extraction strategy of the front-end code are determined respectively;
[0020] The segmentation strategy for the front-end code includes: reading the front-end code and segmenting the front-end code when the segmentation tag is detected;
[0021] The front-end code extraction strategy includes: reading the front-end code, and when the extraction tag is identified, extracting the element name between the two extraction tags as the first element name.
[0022] In one embodiment, extracting multiple second element names from the backend code to form a backend object matrix includes:
[0023] Determine the framework language of the backend code;
[0024] The interface object mapping strategy is determined based on the framework language of the backend code;
[0025] Find the file set of all input parameters in the interface according to the interface object mapping strategy;
[0026] Multiple second element names are extracted from multiple file sets as matrix elements to form a third matrix, the third matrix having the same dimension as the second matrix;
[0027] The third matrix is extracted as the backend object matrix.
[0028] In one embodiment, the similarity matching of the front-end object matrix and the back-end object matrix includes:
[0029] Construct a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix;
[0030] The front-end and back-end similarity matrix is input into the improved KM model based on a sliding window to match the first element name with the third element name;
[0031] When all of the multiple first element names match the corresponding third element name, the matching result is output.
[0032] In one embodiment, constructing a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix includes:
[0033] Calculate the similarity between the m first element names in the first row of the front-end object matrix and the n second element names in the first row of the back-end object matrix to obtain the front-end and back-end similarity matrix of size m*n.
[0034] In one embodiment, the step of interfacing the front-end code and the back-end code includes:
[0035] Based on the plurality of first element names, a plurality of placeholders are formed in the front-end code, and the plurality of placeholders are used to represent element names in the back-end code that are mapped to the plurality of first element names;
[0036] Replace the placeholders with the corresponding third element names to achieve the connection between the front-end code and the back-end code.
[0037] Secondly, embodiments of this application provide a code interfacing device, the code interfacing device comprising:
[0038] The front-end object matrix extraction module is used to extract multiple first element names from the front-end code to form a front-end object matrix.
[0039] The backend object matrix extraction module is used to extract multiple second element names from the backend code to form a backend object matrix.
[0040] A matrix matching module is used to perform similarity matching between the front-end object matrix and the back-end object matrix, and determine multiple third element names from the multiple second element names based on the similarity matching results; wherein the multiple third element names correspond one-to-one with the multiple first element names;
[0041] The interface module is used to interface the front-end code and the back-end code based on the plurality of first element names and the plurality of third element names.
[0042] Thirdly, embodiments of this application provide an electronic device, including a processor and a memory storing a computer program, wherein the processor executes the program to implement the steps of the code interfacing method described in the first aspect.
[0043] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the code interfacing method described in the first aspect.
[0044] This application provides a code integration method, apparatus, electronic device, and storage medium. By extracting multiple element names from both front-end and back-end code to form a front-end / back-end object matrix, and then performing similarity matching on the matrix, multiple third element names corresponding one-to-one with multiple first element names in the front-end code are determined from the back-end code. This establishes the correspondence between fields in the back-end code and fields in the front-end code. Finally, based on the multiple first and third element names, the front-end and back-end code are integrated, achieving automated adaptation of front-end and back-end integration fields without being limited by development languages or code templates. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is one of the flowcharts illustrating a code integration method provided in an embodiment of this application;
[0047] Figure 2 This is a second flowchart illustrating a code integration method provided in an embodiment of this application;
[0048] Figure 3 This is the third flowchart illustrating a code integration method provided in this application embodiment;
[0049] Figure 4 This is the fourth flowchart illustrating a code integration method provided in this application embodiment;
[0050] Figure 5 This is a schematic diagram of a bipartite graph of front-end and back-end element names and its matching examples provided in an embodiment of this application;
[0051] Figure 6 This is a schematic diagram of the structure of a code docking device provided in an embodiment of this application;
[0052] Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0054] The terms "first," "second," "third," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," "third," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0055] The KM (Edmond-Karp, Network Flow-Maximum Flow) algorithm is a computer algorithm that finds the maximum weighted matching under perfect matching conditions.
[0056] Figure 1 This is one of the flowcharts illustrating a code integration method provided in an embodiment of this application. (Refer to...) Figure 1 The code integration method based on the KM algorithm provided in this application embodiment may include:
[0057] Step 100: Extract multiple first element names from the front-end code to form a front-end object matrix.
[0058] Step 200: Extract multiple second element names from the backend code to form a backend object matrix.
[0059] Step 300: Perform similarity matching between the front-end object matrix and the back-end object matrix, and determine multiple third element names from multiple second element names based on the similarity matching results.
[0060] Among them, multiple third element names correspond one-to-one with multiple first element names.
[0061] In this embodiment, each second element name has a similarity value with each first element name. The purpose of similarity matching is to find the third element names from the multiple second element names that have the highest sum of similarity with the multiple first element names.
[0062] Step 400: Connect the front-end code and the back-end code based on multiple first element names and multiple third element names.
[0063] By extracting multiple element names from both the front-end and back-end code to form a front-end / back-end object matrix, and then performing similarity matching on these matrices, the system identifies multiple third element names in the back-end code that correspond one-to-one with the first element names in the front-end code. This establishes the correspondence between fields in the back-end and front-end code. Finally, based on these first and third element names, the front-end and back-end code are integrated, achieving automated adaptation of front-end and back-end interface fields without being limited by development language or code templates.
[0064] Figure 2 This is a second flowchart illustrating a code integration method provided in this embodiment of the disclosure, as shown below. Figure 2 As shown, based on the above embodiments, step 100 may include:
[0065] Step 110: Determine the framework language for the front-end code.
[0066] The framework language for the front-end code can be, for example, HTML5, Vue, React, AngularJS, etc. Specifically, the front-end code can be input into a pre-trained artificial intelligence model, which will then identify the framework language of the front-end code.
[0067] Step 120: Determine the segmentation and extraction strategies for the front-end code based on the framework language of the front-end code.
[0068] Specifically, the corresponding code recognition template can be determined based on the framework language of the front-end code; the cutting tags and extraction tags can be determined based on the code recognition template; and the segmentation strategy and extraction strategy of the front-end code can be determined based on the cutting tags and extraction tags respectively.
[0069] The front-end code segmentation strategy includes: reading the front-end code and segmenting it when a segmentation tag is detected.
[0070] The front-end code extraction strategy includes: reading the front-end code, and when an extraction tag is identified, extracting the element name between two extraction tags as the first element name.
[0071] In this embodiment, the code recognition template can be pre-stored in a database and retrieved from the database. Different framework languages correspond to different code recognition templates. By matching different code recognition templates to different framework languages and determining different segmentation strategies, the limitation of the development language is no longer present.
[0072] Step 130: Divide the front-end code into multiple code fragments according to the segmentation strategy.
[0073] Step 140: According to the extraction strategy, extract at least one first element name from each code snippet as a matrix element to form a first matrix.
[0074] Step 150: Merge the multiple first matrices corresponding to multiple code snippets to form a second matrix, and extract the second matrix as the front-end object matrix.
[0075] In this embodiment, the first matrix is a one-dimensional matrix and the second matrix is a two-dimensional matrix.
[0076] In one implementation of this embodiment, the div tag can be selected as the cutting tag. The front-end code is first cut according to the div tag, into a list of different code snippets. For example, one of the cut code snippets is:
[0077]
[0078] Then, tags such as `span` and `input` are selected as extraction tags to extract multiple one-dimensional first matrices from various code snippets. For example, one of the extracted first matrices is:
[0079] [Reason for visit, visitReason, placehoder5]
[0080] After identifying all code snippets, the multiple one-dimensional matrices corresponding to the code snippets are merged to form the following two-dimensional second matrix, which serves as the front-end object matrix:
[0081]
[0082] It should be noted that when forming the first matrix and the second matrix, the elements in the matrix may also include the English translation corresponding to the name of the first element and placeholders.
[0083] In the second matrix above, each element in the first row represents one of the extracted first element names. The elements in the second row are the English translations generated from these first element names, primarily for facilitating subsequent similarity calculations, as similarity calculations typically require the same language. The elements in the third row are placeholders, mentioned later, that correspond one-to-one with each of the first element names (see the description of placeholders below for details).
[0084] Figure 3 This is the third flowchart illustrating a code integration method provided in this embodiment of the disclosure, as shown below. Figure 3 As shown, based on the above embodiments, step 200 may include:
[0085] Step 210: Determine the framework language for the backend code.
[0086] The framework language of the backend code can be, for example, C, C++, Java, PHP, Python, Go, etc. Specifically, the backend code can be input into a pre-trained artificial intelligence model, which will then identify the framework language of the backend code.
[0087] Step 220: Determine the interface object mapping strategy based on the framework language of the backend code.
[0088] The interface object mapping strategy is used to implement the conversion strategy between different types of systems in object-oriented programming languages. The interface object mapping strategy can also be pre-stored in a database, and different framework languages have different interface object mapping strategies.
[0089] Step 230: Locate the file set of all input parameters in the interface according to the interface object mapping strategy.
[0090] Step 240: Extract multiple second element names from multiple file sets as matrix elements to form a third matrix. The third matrix has the same dimensions as the second matrix.
[0091] In this embodiment, the file set is an interface object mapping file, and the element names extracted from the file set are the element names. <id>.
[0092] Since backend languages are generally object-oriented, and objects typically have multiple layers, a multi-dimensional matrix can be derived from the backend object file set. However, in subsequent algorithmic matching, it needs to be matched with a two-dimensional second matrix. Therefore, the multi-dimensional matrix needs to be reduced in dimensionality to form a two-dimensional third matrix.
[0093] Specifically, a multidimensional matrix can be recursively unpacked to reduce its dimensionality to a two-dimensional third matrix. The following figure shows one example of a dimensionality-reduced third matrix provided in this embodiment:
[0094]
[0095] It should be noted that when forming the third matrix, the elements in the matrix may also include the file to which each element belongs and the element type corresponding to the name of each second element.
[0096] In the third matrix above, each element in the first row represents one of the extracted second element names. Each element in the second row is the file name to which the element corresponding to each second element name belongs. Each element in the third row represents the type of the element corresponding to each second element name (e.g., integer, character, array).
[0097] Step 250: Extract the third matrix as the backend object matrix.
[0098] Figure 4 This is the fourth flowchart illustrating a code integration method provided in this embodiment of the disclosure, as follows: Figure 4 As shown, step 300 may include:
[0099] Step 310: Construct a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix.
[0100] In one implementation of this disclosure, step 310 may include:
[0101] Calculate the similarity between the m first element names in the first row of the front-end object matrix and the n second element names in the first row of the back-end object matrix to obtain a front-end and back-end similarity matrix of size m*n, as shown below.
[0102]
[0103]
[0104] The m fields in the aforementioned similarity matrix, including "Visitor," "Phone Number," "Visit Time," "Reason for Visit," and "Visitor," are extracted from the first row of the aforementioned front-end object matrix. The n fields in the aforementioned similarity matrix, including "orderId," "visitorTime," "visitorReason," "staffPerson," "staffDepartment," "staffEmail," "visitorPerson," "visitorPhone," and "companyName," are extracted from the first row of the aforementioned back-end object matrix.
[0105] Each similarity value in the above similarity matrix can be calculated using conventional similarity algorithms, which will not be elaborated upon here.
[0106] Step 320: Input the front-end and back-end similarity matrix into the improved KM model based on a sliding window to match the first element name with the third element name.
[0107] Step 330: When multiple first element names match one of the corresponding third element names, output the matching results.
[0108] In real-world front-end and back-end integration, the number of fields on the back-end is much larger than on the front-end. Therefore, during the matching process, for each first element name on the front-end, a suitable second element name needs to be matched from the back-end. A globally optimal strategy is preferred during the matching process.
[0109] For the aforementioned similarity matrix, a globally optimal strategy typically involves m first-element names and n second-element names simultaneously. This can be achieved by comprehensively calculating and selecting q pairs (q being the smaller of n and m) of combinations. While these combinations may not be globally optimal individually, they achieve the best overall matching effect, i.e., the highest overall similarity. In this invention, the combinations formed by multiple third-element names and multiple second-element names exhibit the highest overall similarity.
[0110] For a globally optimal strategy, this invention employs an improved KM algorithm to transform the aforementioned field matching into a bipartite graph matching problem. Here, "bipartite graph" refers to a special model in graph theory. Let G = (V, E) be an undirected graph. If vertices V can be partitioned into two disjoint subsets (A, B), and each edge (i, j) in the graph connects to two vertices i and j belonging to these two distinct sets (i in A, j in B), then graph G is called a bipartite graph. In other words, if the vertices in a graph can be divided into two groups such that all edges cross the boundaries of the groups, then it is a bipartite graph. That is, partitioning the vertices of a graph into two disjoint sets XX and YY, such that each edge connects vertices in XX and YY respectively, if such a partition exists, then the graph is a bipartite graph.
[0111] Figure 5 This is a schematic diagram of a bipartite graph of front-end and back-end element names and its matching examples provided in an embodiment of this application, such as... Figure 5 As shown, Figure 5 In the three figures, the left set of boxes in each figure represents the m first element names in the aforementioned similarity matrix, and the right set of boxes represents the n second element names in the same matrix. The lines connecting the boxes have different weights. These weights represent the corresponding similarity scores in the similarity matrix.
[0112] For example, if the similarity between the fields "visit time" and "visitorTime" in the similarity matrix above is 0.97, then the weight of the line connecting the "visit time" box and the "visitorTime" box is 0.97.
[0113] In this embodiment, the similarity matrix is input into an improved KM model based on a sliding window, and sliding window pruning is performed first. The initial threshold value (i.e., the maximum weight) can be set to 1, and sliding pruning is performed with a window size of 0.05. As the number of sliding operations increases, the sliding threshold gradually decreases, and the number of connections with weights that meet the threshold requirements also gradually increases.
[0114] Figure 5 The three bipartite graphs shown are the result of three sliding window pruning operations. In the leftmost bipartite graph, the threshold slides to 95%, or 0.95, with only two connections having a weight higher than 0.95. In the middle bipartite graph, the threshold slides to 80%, or 0.80, with only four connections having a weight higher than 0.80. In the rightmost bipartite graph, the threshold slides to 65%, or 0.65, with seven connections having a weight higher than 0.65. This means that all m first element names are matched, but there are more than m corresponding second element names, and multiple matching methods exist. In this embodiment, it is necessary to find m third element names from the n second element names that correspond one-to-one with the m first element names, achieving the optimal match. Under the optimal matching method, the sum of the weight values of the connections between the m third element names and the m first element names is maximized.
[0115] Therefore, an improved KM algorithm is needed to calculate the optimal match. The conventional KM algorithm can only calculate the optimal match for a complete even graph m*m matrix, and is not applicable to an incomplete even graph m*n matrix. However, in front-end and back-end field integration, only minimum edge matching (i.e., m first element names matching m second element names) is required. Therefore, compared to the conventional KM algorithm, the improved KM algorithm does not require perfect matching before output; instead, it modifies the process to achieve the minimum number of matching edges (m*n), meaning the number of matching second element names with the first element name must reach m before outputting.
[0116] If the number of optimal matches output reaches the minimum number of edges m, then the optimal matching bipartite graph of the front-end element names and back-end element names is output. If the optimal matching is not found, the similarity matrix is re-input into the improved KM model based on a sliding window, and sliding window pruning and improved KM calculation are continued until the optimal matching is found.
[0117] For example, see Figure 5 In the rightmost bipartite graph, when m element names "visitorPerson", "visitorPhone", "companyName", "visitorTime", "visitorReason", and "staffPerson" are selected from n second element names as third element names, and each corresponds one-to-one with "visitor", "phone number", "visit time", "visit reason", and "visited person" from the m first element names, the sum of the weights of each connection is maximized, i.e., the overall similarity is highest. In this case, this matching method is considered the best match, and the matching result is output.
[0118] This invention employs an improved KM model based on a sliding window. First, it uses a sliding pruning method, prioritizing combinations of element names based on their similarity from high to low, to filter out suitable combinations. Then, it applies the improved KM algorithm to each combination to obtain the optimal match. This eliminates the need to calculate all element name combinations, significantly reducing the computational load and avoiding interference from low-similarity connections, thereby improving overall accuracy and computational efficiency.
[0119] In one implementation of this embodiment, step 400, which involves interfacing the front-end code and the back-end code, may include:
[0120] Based on multiple first element names, multiple placeholders are formed in the front-end code. These placeholders are used to represent element names in the back-end code that map to the multiple first element names.
[0121] Replace multiple placeholders with corresponding third element names to achieve integration between front-end and back-end code.
[0122] Optionally, creating multiple placeholders in the front-end code based on multiple first element names can include:
[0123] Based on the framework language of the front-end code, the corresponding code population template is extracted from the database. An intermediate file is generated based on multiple first element names and the code population template, which is used to populate the front-end code. This intermediate file includes multiple placeholders.
[0124] The code completion templates are pre-stored in the database, and different framework languages have different code completion templates.
[0125] Since the correspondence between backend and frontend elements is not clear at this step, this embodiment introduces the concept of placeholders to temporarily replace the parts that need to be connected. Then, after determining the names of the backend third elements that have the highest overall similarity to the names of the first elements in the frontend, the placeholders are replaced with the corresponding names of the third elements, thus achieving automatic connection between the frontend and backend code.
[0126] For example, based on the above embodiments, multiple placeholders in the front-end code can be replaced with the corresponding m third element names: "visitorPerson", "visitorPhone", "companyName", "visitorTime", "visitorReason", and "staffPerson", ultimately achieving automatic integration between the front-end code and the back-end code.
[0127] The following describes a code docking device provided in an embodiment of this application. The code docking device described below can be referred to in correspondence with the code docking method described above.
[0128] Figure 6 This is a schematic diagram of the structure of a code interfacing device provided in an embodiment of this application, as shown below. Figure 6 As shown, the code docking device 600 includes a front-end object matrix extraction module 610, a back-end object matrix extraction module 620, a matrix matching module 630, and a docking module 640.
[0129] The front-end object matrix extraction module 610 is used to extract multiple first element names from the front-end code to form a front-end object matrix.
[0130] The backend object matrix extraction module 620 is used to extract multiple second element names from the backend code to form a backend object matrix.
[0131] The matrix matching module 630 is used to perform similarity matching between the front-end object matrix and the back-end object matrix, and to determine multiple third element names from multiple second element names based on the similarity matching results; wherein, the multiple third element names correspond one-to-one with multiple first element names.
[0132] The interface module 640 is used to interface the front-end code and the back-end code based on multiple first element names and multiple third element names.
[0133] By extracting multiple element names from both the front-end and back-end code to form a front-end / back-end object matrix, and then performing similarity matching on these matrices, the system identifies multiple third element names in the back-end code that correspond one-to-one with the first element names in the front-end code. This establishes the correspondence between fields in the back-end and front-end code. Finally, based on these first and third element names, the front-end and back-end code are integrated, achieving automated adaptation of front-end and back-end interface fields without being limited by development language or code templates.
[0134] Optionally, the front-end object matrix extraction module 610 is also used for:
[0135] Determine the framework language for the front-end code;
[0136] Based on the framework language of the front-end code, determine the segmentation and extraction strategies for the front-end code;
[0137] The front-end code is divided into multiple code snippets based on the segmentation strategy;
[0138] Based on the extraction strategy, multiple first element names are extracted from each code snippet as matrix elements to form the first matrix;
[0139] Multiple first matrices corresponding to multiple code snippets are merged to form a second matrix, and the second matrix is extracted as the front-end object matrix.
[0140] Optionally, based on the framework language of the front-end code, determine the segmentation and extraction strategies for the front-end code, including:
[0141] Based on the framework language of the front-end code, determine the corresponding code recognition template;
[0142] Based on the code recognition template, determine the cutting and extraction of labels;
[0143] Based on the cutting tags and extraction tags, determine the segmentation strategy and extraction strategy for the front-end code respectively;
[0144] The front-end code segmentation strategy includes: reading the front-end code and segmenting it when a segmentation tag is detected;
[0145] The front-end code extraction strategy includes: reading the front-end code, and when an extraction tag is identified, extracting the element name between two extraction tags as the first element name.
[0146] Optionally, the backend object matrix extraction module 620 is also used for:
[0147] Determine the framework language for the backend code;
[0148] Determine the interface object mapping strategy based on the framework language of the backend code;
[0149] Find the file set of all input parameters of the interface according to the interface object mapping strategy;
[0150] Extract multiple second element names from multiple file sets as matrix elements to form a third matrix. The third matrix has the same dimensions as the second matrix.
[0151] Extract the third matrix as the backend object matrix.
[0152] Optionally, the matrix matching module 630 is also used for:
[0153] Construct a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix;
[0154] The front-end and back-end similarity matrices are input into an improved KM model based on a sliding window to match the names of the first and third elements.
[0155] Output the matching result when multiple first element names match one of their corresponding third element names.
[0156] Optionally, a front-end and back-end similarity matrix is constructed based on the front-end object matrix and the back-end object matrix, including:
[0157] Calculate the similarity between the m first element names in the first row of the front-end object matrix and the n second element names in the first row of the back-end object matrix to obtain a front-end and back-end similarity matrix of size m*n.
[0158] Optionally, the docking module 640 is also used for:
[0159] Based on multiple first element names, multiple placeholders are formed in the front-end code. These placeholders are used to represent element names in the back-end code that map to the multiple first element names.
[0160] Replace multiple placeholders with corresponding third element names to achieve integration between front-end and back-end code.
[0161] Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 7 As shown, the electronic device may include a processor 710, a communication interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 can call the computer program in the memory 730 to execute the steps of the code interfacing method provided in the above embodiments, such as including:
[0162] Extract multiple first-element names from the front-end code to form a front-end object matrix;
[0163] Extract multiple second element names from the backend code to form a backend object matrix;
[0164] The front-end object matrix and the back-end object matrix are matched for similarity. Based on the similarity matching results, multiple third element names are determined from multiple second element names. Each of the multiple third element names corresponds one-to-one with a multiple first element name.
[0165] The front-end code and back-end code are connected based on multiple first element names and multiple third element names.
[0166] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0167] On the other hand, this application also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the steps of the code interfacing methods provided in the above embodiments, such as:
[0168] Extract multiple first-element names from the front-end code to form a front-end object matrix;
[0169] Extract multiple second element names from the backend code to form a backend object matrix;
[0170] The front-end object matrix and the back-end object matrix are matched for similarity. Based on the similarity matching results, multiple third element names are determined from multiple second element names. Each of the multiple third element names corresponds one-to-one with a multiple first element name.
[0171] The front-end code and back-end code are connected based on multiple first element names and multiple third element names.
[0172] On the other hand, embodiments of this application also provide a processor-readable storage medium storing a computer program for causing a processor to perform the steps of the methods provided in the above embodiments, such as including:
[0173] Extract multiple first-element names from the front-end code to form a front-end object matrix;
[0174] Extract multiple second element names from the backend code to form a backend object matrix;
[0175] The front-end object matrix and the back-end object matrix are matched for similarity. Based on the similarity matching results, multiple third element names are determined from multiple second element names. Each of the multiple third element names corresponds one-to-one with a multiple first element name.
[0176] The front-end code and back-end code are connected based on multiple first element names and multiple third element names.
[0177] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)).
[0178] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0179] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0180] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.< / id>
Claims
1. A code interfacing method, characterized by, The code integration method includes: Extract multiple first-element names from the front-end code to form a front-end object matrix; Extract multiple second element names from the backend code to form a backend object matrix; The front-end object matrix and the back-end object matrix are matched for similarity, and based on the similarity matching results, multiple third element names are determined from the multiple second element names; wherein, the multiple third element names correspond one-to-one with the multiple first element names; Based on the multiple first element names and the multiple third element names, the front-end code and the back-end code are connected; The step of performing similarity matching between the front-end object matrix and the back-end object matrix includes: Construct a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix; The front-end and back-end similarity matrix is input into the improved KM model based on a sliding window to match the first element name with the third element name; When all of the multiple first element names match the corresponding third element name, output the matching result; The step of connecting the front-end code and the back-end code includes: Based on the plurality of first element names, a plurality of placeholders are formed in the front-end code, and the plurality of placeholders are used to represent element names in the back-end code that are mapped to the plurality of first element names; Replace the placeholders with the corresponding third element names to achieve the connection between the front-end code and the back-end code.
2. The code docking method of claim 1, wherein, The step of extracting multiple first element names from the front-end code to form a front-end object matrix includes: Determine the framework language of the front-end code; Based on the framework language of the front-end code, determine the segmentation strategy and extraction strategy of the front-end code; The front-end code is divided into multiple code fragments according to the segmentation strategy; According to the extraction strategy, multiple first element names are extracted from each code segment as matrix elements to form a first matrix; The first matrices corresponding to the multiple code snippets are merged to form a second matrix, and the second matrix is extracted as the front-end object matrix.
3. The code docking method of claim 2, wherein, The step of determining the segmentation and extraction strategies of the front-end code based on the framework language of the front-end code includes: Based on the framework language of the front-end code, determine the corresponding code recognition template; Based on the code recognition template, determine the cutting labels and extract the labels; Based on the cutting tags and the extraction tags, the segmentation strategy and extraction strategy of the front-end code are determined respectively; The segmentation strategy for the front-end code includes: reading the front-end code and segmenting the front-end code when the segmentation tag is detected; The front-end code extraction strategy includes: reading the front-end code, and when the extraction tag is identified, extracting the element name between the two extraction tags as the first element name.
4. The code docking method of claim 2, wherein, The step of extracting multiple second element names from the backend code to form a backend object matrix includes: Determine the framework language of the backend code; The interface object mapping strategy is determined based on the framework language of the backend code; Find the file set of all input parameters in the interface according to the interface object mapping strategy; Multiple second element names are extracted from multiple file sets as matrix elements to form a third matrix, the third matrix having the same dimension as the second matrix; The third matrix is extracted as the backend object matrix.
5. The code docking method of claim 1, wherein, The step of constructing a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix includes: Calculate the similarity between the m first element names in the first row of the front-end object matrix and the n second element names in the first row of the back-end object matrix to obtain the front-end and back-end similarity matrix of size m*n. Where m and n are both positive integers.
6. A code docking device, characterized in that The code docking device includes: The front-end object matrix extraction module is used to extract multiple first element names from the front-end code to form a front-end object matrix. The backend object matrix extraction module is used to extract multiple second element names from the backend code to form a backend object matrix. A matrix matching module is used to perform similarity matching between the front-end object matrix and the back-end object matrix, and determine multiple third element names from the multiple second element names based on the similarity matching results; wherein the multiple third element names correspond one-to-one with the multiple first element names; The interface module is used to interface the front-end code and the back-end code based on the multiple first element names and the multiple third element names; The step of performing similarity matching between the front-end object matrix and the back-end object matrix includes: Construct a front-end and back-end similarity matrix based on the front-end object matrix and the back-end object matrix; The front-end and back-end similarity matrix is input into the improved KM model based on a sliding window to match the first element name with the third element name; When all of the multiple first element names match the corresponding third element name, output the matching result; The step of connecting the front-end code and the back-end code includes: Based on the plurality of first element names, a plurality of placeholders are formed in the front-end code, and the plurality of placeholders are used to represent element names in the back-end code that are mapped to the plurality of first element names; Replace the placeholders with the corresponding third element names to achieve the connection between the front-end code and the back-end code.
7. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the code docking method according to any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the code docking method according to any one of claims 1 to 5.