Field conversion method and device, storage medium and electronic equipment
By using automated annotation and conversion models, the high time cost of cross-engine SQL statement conversion has been solved, achieving efficient and accurate statement conversion and improving operational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2023-07-21
- Publication Date
- 2026-05-01
AI Technical Summary
In scenarios with multiple structured query language engines, data analysts need to manually write multiple SQL statements, which increases time costs. Furthermore, the single management node architecture used in Ansible operation and maintenance scenarios results in high time costs for operation and maintenance work.
By determining the conversion information corresponding to the conversion instruction, the fields in the SQL statement are automatically labeled and converted using the annotation model and the conversion model. The accuracy is improved by combining the training and validation models, thus achieving automated statement conversion across engines.
It reduces the time cost of manually converting SQL statements, improves the efficiency and accuracy of cross-engine conversion, relieves the workload of analysts, and enhances work efficiency.
Smart Images

Figure CN116910084B_ABST
Abstract
Description
Field conversion methods, devices and storage media, electronic devices Technical Field
[0001] This invention relates to the field of artificial intelligence, and more specifically, to a field conversion method, apparatus, storage medium, and electronic device. Background Technology
[0002] In scenarios where data analysts interact with databases, when multiple Structured Query Language (SQL) engines exist, analysts need to write multiple SQL statements for each engine to achieve the same data analysis requirements. Currently, the syntax for writing SQL statements for different engines is provided in document form, requiring each analyst to learn it before using it, thus failing to utilize existing SQL statement data with the same logic but different engines.
[0003] Regarding the technical issues that most Ansible (an open-source automation platform) operation and maintenance scenarios use a single management node architecture, which leads to a significant increase in the time cost of operation and maintenance work, no effective solution has yet been proposed.
[0004] Therefore, it is necessary to improve the relevant technology to overcome the aforementioned defects. Summary of the Invention
[0005] This invention provides a field conversion method, apparatus, storage medium, and electronic device to at least solve the problem in related technologies where statement conversion can only rely on manual methods, resulting in a significant increase in the time cost of conversion work.
[0006] According to one aspect of the present invention, a field conversion method is provided, comprising: determining conversion information corresponding to a conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; sending the conversion information to an annotation model to obtain an annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate a first field in the statement to be converted to which a conversion operation is to be performed; and determining a second field after the conversion of the first field based on the first field, the first statement engine, and the target statement engine.
[0007] In an exemplary embodiment, before sending the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted, the method further includes: if the annotation model has been trained based on sample data in a first database, verifying the annotation model using verification data in a second database to obtain a verification result, wherein the verification result is used to indicate the accuracy of the annotation model in annotating the verification data, and the sample data includes: a first sample statement and a statement engine corresponding to the first sample statement; if the accuracy is less than a first preset value, determining to adjust the annotation parameters of the annotation model to obtain an adjusted annotation model.
[0008] In an exemplary embodiment, after sending the conversion information to the annotation model, the method further includes: extracting a plurality of fields constituting the statement to be converted; determining a first positional feature for each of the plurality of fields, wherein the first positional feature is used to indicate the position of the corresponding field in the statement to be converted; comparing a second sample statement allowed to run in the first statement engine with a third sample statement allowed to run in the target statement engine to determine a compositional difference between the second sample statement and the third sample statement, wherein the compositional difference is used to indicate the positional difference between the fields constituting the second sample statement and the fields constituting the third sample statement; comparing the first positional feature with the positional difference, and determining the field to be converted based on the comparison result.
[0009] In an exemplary embodiment, after comparing the first position feature with the position difference and determining the field to be converted based on the comparison result, the method further includes: determining the statement segment to which the field to be converted belongs based on the first position feature; determining all fields constituting the statement segment as a segment to be labeled, wherein the segment to be labeled is used to determine the labeling result.
[0010] In an exemplary embodiment, comparing the first location feature with the location difference and determining the field to be converted based on the comparison result includes: determining the difference value between the first location feature and the location difference; if the difference value is greater than a preset threshold, confirming that the field corresponding to the first location feature is not the field to be converted; if the difference value is less than the preset threshold, confirming that the field corresponding to the first location feature is the field to be converted.
[0011] In an exemplary embodiment, before determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, the method further includes: training a conversion model using a third database, wherein the conversion model is used to indicate the second field corresponding to the first field, the third database including multiple sample fields, a statement engine corresponding to each of the multiple sample fields, and a fourth sample statement corresponding to the sample fields; inputting the first field, the first statement engine, and the target statement engine into the conversion model to obtain a conversion result, wherein the conversion result is used to indicate the second field.
[0012] In an exemplary embodiment, after determining the second field transformed from the first field based on the first field, the first statement engine, and the target statement engine, the method further includes: determining the target statement to which the second field belongs, wherein the target statement is the statement to be converted; sending the target statement and the statement to be converted to a mobile terminal used by the target object, receiving a feedback instruction issued by the mobile terminal based on the target statement and the statement to be converted, wherein the feedback instruction is used to indicate the similarity between the target statement and the statement to be converted; and determining that the annotation model needs to be adjusted if the similarity is less than a second preset value.
[0013] According to another aspect of the present invention, a field conversion apparatus is also provided, comprising: a first determining module, configured to determine conversion information corresponding to a conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; a labeling module, configured to send the conversion information to a labeling model to obtain a labeling result corresponding to the statement to be converted, wherein the labeling result is used to indicate a first field in the statement to be converted to which a conversion operation is to be performed; and a first conversion module, configured to determine a second field after the first field is converted based on the first field, the first statement engine, and the target statement engine.
[0014] In one exemplary embodiment, the above apparatus further includes: a second determining module, configured to determine conversion information corresponding to a conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; an annotation module, configured to send the conversion information to an annotation model to obtain an annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate a first field in the statement to be converted from which a conversion operation is to be performed; and a first conversion module, configured to determine a second field after the first field is converted based on the first field, the first statement engine, and the target statement engine.
[0015] In an exemplary embodiment, the above apparatus further includes: a third determining module, configured to: before sending the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted; if the annotation model has been trained based on sample data in the first database, verify the annotation model using verification data in the second database to obtain a verification result, wherein the verification result is used to indicate the accuracy of the annotation model in annotating the verification data, the sample data including: a first sample statement and a statement engine corresponding to the first sample statement; if the accuracy is less than a first preset value, determine to adjust the annotation parameters of the annotation model to obtain an adjusted annotation model.
[0016] In an exemplary embodiment, the above apparatus further includes: an extraction module, configured to: extract a plurality of fields constituting the statement to be converted; determine a first position feature for each of the plurality of fields, wherein the first position feature is used to indicate the position of the corresponding field in the statement to be converted; compare a second sample statement allowed to run in the first statement engine with a third sample statement allowed to run in the target statement engine to determine a compositional difference between the second sample statement and the third sample statement, wherein the compositional difference is used to indicate the positional difference between the fields constituting the second sample statement and the fields constituting the third sample statement; compare the first position feature with the positional difference, and determine the field to be converted based on the comparison result.
[0017] In an exemplary embodiment, the above apparatus further includes: a fourth determining module, configured to compare the first position feature with the position difference, and after determining the field to be converted based on the comparison result: determine the statement segment to which the field to be converted belongs based on the first position feature; and determine all fields constituting the statement segment as a segment to be labeled, wherein the segment to be labeled is used to determine the labeling result.
[0018] In an exemplary embodiment, the above apparatus further includes: a fifth determining module, configured to determine the difference value between the first position feature and the position difference; if the difference value is greater than a preset threshold, confirm that the field corresponding to the first position feature is not a field to be converted; if the difference value is less than the preset threshold, confirm that the field corresponding to the first position feature is a field to be converted.
[0019] In an exemplary embodiment, the apparatus further includes: a second conversion module, configured to train a conversion model using a third database before determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, wherein the conversion model is used to indicate the second field corresponding to the first field, and the third database includes multiple sample fields, a statement engine corresponding to each of the multiple sample fields, and a fourth sample statement corresponding to each sample field; and inputs the first field, the first statement engine, and the target statement engine into the conversion model to obtain a conversion result, wherein the conversion result is used to indicate the second field.
[0020] In an exemplary embodiment, the above apparatus further includes: a sending module, configured to: determine the target statement to which the second field belongs after determining the second field transformed from the first field based on the first field, the first statement engine, and the target statement engine; send the target statement and the statement to be converted to a mobile terminal used by the target object; receive a feedback instruction issued by the mobile terminal based on the target statement and the statement to be converted, wherein the feedback instruction is used to indicate the similarity between the target statement and the statement to be converted; and determine that the annotation model needs to be adjusted if the similarity is less than a second preset value.
[0021] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described method for transmitting energy efficiency information when it is run.
[0022] According to another aspect of the present invention, an electronic device is also provided, the electronic device including one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are configured to run the programs, wherein the programs are configured to execute the above-described field conversion method at runtime.
[0023] The aforementioned device determines the conversion information corresponding to the conversion instruction. This conversion information includes: the statement to be converted, the first statement engine to which the statement belongs, and the target statement engine corresponding to the statement. The conversion information is sent to the annotation model to obtain the annotation result corresponding to the statement to be converted. The annotation result indicates the first field in the statement to be converted, from which the conversion operation is to be performed. Based on the first field, the first statement engine, and the target statement engine, the second field after conversion of the first field is determined. In other words, based on the user-input statement, the engine to which the statement belongs, and the target engine to which the statement needs conversion, the annotation module annotates the fields that need to be modified, and the conversion module converts the annotated fields. This solves the problem in related technologies where statement conversion relies solely on manual methods, leading to a significant increase in the time cost of the conversion work. Attached Figure Description
[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0025] Figure 1 is a flowchart of an optional field conversion method according to an embodiment of the present invention;
[0026] Figure 2 is a schematic diagram of an optional field conversion method according to an embodiment of the present invention;
[0027] Figure 3 is a schematic diagram of an optional field conversion device according to an embodiment of the present invention;
[0028] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. Detailed Implementation
[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0031] This invention can be applied to the program code of various software products, control systems, and clients (including but not limited to mobile clients, PCs, etc.) of financial institutions. Taking software products as an example, by scanning the program code of software products installed on mobile clients, the stable operation of software programs that realize the business content of financial institutions (including but not limited to business functions such as transfer, wealth management, funds, bill payment, account inquiry, advertising, and recommendations) can be guaranteed.
[0032] For ease of description, the following explains some of the nouns or terms used in the embodiments of the present invention:
[0033] SQL: Structured Query Language, abbreviated as SQL, is a standard computer language used to access and manipulate databases.
[0034] transformer: a neural network model structure.
[0035] The present invention will be further illustrated below with reference to various embodiments.
[0036] According to an embodiment of the present invention, an embodiment of a field conversion method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0037] Figure 1 is a flowchart of an optional field conversion method according to an embodiment of the present invention. As shown in Figure 1, the method includes the following steps:
[0038] Step S101: Determine the conversion information corresponding to the conversion instruction, wherein the conversion information includes: the statement to be converted, the first statement engine to which the statement to be converted belongs, and the target statement engine corresponding to the statement to be converted;
[0039] Step S102: Send the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate the first field in the statement to be converted to perform the conversion operation;
[0040] Step S103: Determine the second field after the transformation of the first field based on the first field, the first statement engine, and the target statement engine.
[0041] Through the above steps, the conversion information corresponding to the conversion instruction is determined. This conversion information includes: the statement to be converted, the first statement engine to which the statement belongs, and the target statement engine corresponding to the statement. The conversion information is sent to the annotation model to obtain the annotation result corresponding to the statement to be converted. The annotation result indicates the first field in the statement to be converted, from which the conversion operation is to be performed. Based on the first field, the first statement engine, and the target statement engine, the second field after the conversion of the first field is determined. In other words, based on the user-input statement, the engine to which the statement belongs, and the target engine to which the statement needs conversion, the annotation module annotates the fields that need to be modified, and the conversion module converts the annotated fields. This solves the problem in related technologies where statement conversion relies solely on manual methods, leading to a significant increase in the time cost of the conversion work.
[0042] In an exemplary embodiment, before sending the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted, the method further includes: if the annotation model has been trained based on sample data in the first database, verifying the annotation model using validation data in the second database to obtain a validation result, wherein the validation result is used to indicate the accuracy of the annotation model in annotating the validation data, and the sample data includes: a first sample statement and the statement engine corresponding to the first sample statement; if the accuracy is less than a first preset value, determining to adjust the annotation parameters of the annotation model to obtain an adjusted annotation model. That is, there are two databases, wherein the first database is used to train the annotation model, and the second database is used to validate the trained annotation model, wherein the first database includes: statements with multiple different statement engines, and the statement engines corresponding to these statements. It should be noted that the statements with different statement engines in the first database are annotated with their corresponding statement engines. The second database includes validation statements for validation and the statement engines corresponding to the validation statements; optionally, the validation statements in the second database may already be annotated. The statements from the second database are input into the annotation model, which then performs the annotations. The annotation results output by the annotation model are then compared with the annotations in the second database. If the accuracy is less than a first preset value, it indicates that the current annotation model is inaccurate, and the annotation parameters of the annotation model need to be adjusted.
[0043] In an exemplary embodiment, after sending the conversion information to the annotation model, the method further includes: extracting multiple fields constituting the statement to be converted; determining a first positional feature for each of the multiple fields, wherein the first positional feature indicates the position of the corresponding field in the statement to be converted; comparing a second sample statement allowed to run in the first statement engine with a third sample statement allowed to run in the target statement engine to determine the structural differences between the second sample statement and the third sample statement, wherein the structural differences indicate the positional differences between the fields constituting the second sample statement and the fields constituting the third sample statement; comparing the first positional feature with the positional differences, and determining the fields to be converted based on the comparison result. That is, the fields to be annotated are determined based on the position of the fields constituting the statement to be converted. The statements that can run in the statement engine corresponding to the current statement are compared with the statements that can run in the target statement engine to obtain the differences in the structure or position of the fields between the two engines. The positions of the fields constituting the statement to be converted are compared with the positional differences to determine the fields to be converted.
[0044] In an optional embodiment, the annotation model can be a transformer model. Due to the characteristics of SQL statements, the importance of distant associations is relatively low; that is, two fields that are far apart have a weak correlation. Therefore, the calculation method of the non-normalized attention weight in the transformer is modified. The original calculation method of the non-normalized attention weight is K(w i ,w j )= <w i ,w j >, where i and j represent the positions of words, which are modified to K(w) in this module. i ,w j )= <w i ,w j >-exp(λ|ij|), where λ is a user-defined parameter that determines the magnitude of the influence of the position difference weights. This modification allows the model to focus more on local relationships, achieving a localized attention mechanism.
[0045] In an exemplary embodiment, after comparing the first positional feature with the positional difference and determining the field to be converted based on the comparison result, the method further includes: determining the statement segment to which the field to be converted belongs based on the first positional feature; and determining all fields constituting the statement segment as a segment to be labeled, wherein the segment to be labeled is used to determine the labeling result. That is, when a field to be converted is determined, the statement segment corresponding to that field is determined, and the entire statement segment is determined as the labeling result. It should be noted that a statement to be converted consists of multiple statement segments, and a statement segment consists of multiple fields. In some special cases, a statement may also include only one statement segment and one field.
[0046] In an exemplary embodiment, comparing the first positional feature with the positional difference and determining the field to be converted based on the comparison result includes: determining the difference value between the first positional feature and the positional difference; if the difference value is greater than a preset threshold, confirming that the field corresponding to the first positional feature is not the field to be converted; if the difference value is less than the preset threshold, confirming that the field corresponding to the first positional feature is the field to be converted. In other words, the difference value between the first positional feature and the positional difference determines whether the field corresponding to the first positional feature is the field to be converted.
[0047] In an exemplary embodiment, before determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, the method further includes: training a conversion model using a third database, wherein the conversion model is used to indicate the second field corresponding to the first field, and the third database includes multiple sample fields, a statement engine corresponding to each of the multiple sample fields, and a fourth sample statement corresponding to each sample field; inputting the first field, the first statement engine, and the target statement engine into the conversion model to obtain a conversion result, wherein the conversion result is used to indicate the second field. That is, by training the conversion model using the third database, the first field, the first statement engine, and the target statement engine are input into the conversion model to obtain the conversion result corresponding to the first field.
[0048] In an exemplary embodiment, after determining the second field transformed from the first field based on the first field, the first statement engine, and the target statement engine, the method further includes: determining the target statement to which the second field belongs, wherein the target statement is obtained by performing a transformation operation on the statement to be transformed; sending the target statement and the statement to be transformed to a mobile terminal used by the target object, receiving feedback instructions from the mobile terminal based on the target statement and the statement to be transformed, wherein the feedback instructions are used to indicate the similarity between the target statement and the statement to be transformed; and determining that the annotation model needs to be adjusted if the similarity is less than a second preset value. That is, after the transformation model completes the transformation, the transformed statement and the original statement can be sent together to the target object's mobile terminal, and then the need to adjust the annotation model is determined based on the feedback instructions from the target object on the mobile terminal. It should be noted that the similarity refers to the similarity of the tasks performed by the two statements after execution. Taking a preset value of 100% as an example, if the similarity between the two statements is less than 100%, it indicates that the annotation model needs to be adjusted.
[0049] Obviously, the embodiments described above are merely some embodiments of the present invention, and not all embodiments. To better understand the response method of the above functions, the following description, in conjunction with embodiments, illustrates the process, but is not intended to limit the technical solutions of the embodiments of the present invention. Specifically:
[0050] This invention also provides an optional field conversion method, as shown in Figure 2. Figure 2 is a schematic diagram of an optional field conversion method according to an embodiment of this invention, which specifically includes the following steps:
[0051] The target SQL engine, the SQL statement from any engine, and the SQL engine of the input statement are input into the modification range annotation module. This module annotates the SQL statement from any engine to determine the SQL statement fragment that needs modification. Then, the SQL statement fragment to be modified, the target SQL engine, and the SQL engine of the input statement are input into the statement conversion module to obtain the target engine SQL statement fragment. This fragment is then used to replace the target engine SQL statement, resulting in a SQL statement with the same logic as the target engine.
[0052] It should be noted that the range labeling modification module is a sequence labeling task, and the output SQL statement fragments that need to be modified are used by subsequent modules.
[0053] In one alternative embodiment:
[0054] The input statement belongs to SQL engine A, and the target SQL engine is SQL engine B. If the input SQL statement is "Select * from table where a != 3", the annotation module will compare engine A and engine B after receiving this information, and then annotate the SQL statement based on the comparison results. Annotations include, for example, "B", "I", and "O", with each field or symbol corresponding to a specific flag.
[0055] The parts marked with 'O' do not need to be modified, while the parts marked with 'B' or 'I' need to be passed to the statement conversion module for modification. The annotation results can be as follows:
[0056] When the input SQL statement is "Select * from table where a!=3", the annotation module outputs: OOOOOBII;
[0057] In the above example, “Select” corresponds to “O”; “*” corresponds to “O”; “from” corresponds to “O”; “table” corresponds to “O”; “where” corresponds to “O”; “a” corresponds to “O”; “!=" corresponds to “I”; and “3” corresponds to “I”.
[0058] It should be noted that B represents the beginning of the statement marker; I represents the middle of the statement marker; and O represents the end of the statement marker.
[0059] The data required for training the range annotation module includes: the input and output SQL engine and the SQL statement with the range annotated. The SQL statement with the range annotated has the same format as the example above.
[0060] The training model used is a Transformer. Due to the characteristics of SQL statements, the importance of long-range associations is relatively low. Therefore, the calculation method of non-normalized attention weights in the Transformer is modified. The original calculation method for non-normalized attention weights is: where i and j represent word positions. In this module, it is modified to: where λ is a user-defined parameter that determines the influence of position difference weights. This modification allows the model to focus more on local associations, achieving a localized attention mechanism.
[0061] The statement transformation module is a sequence generation task. It takes as input the SQL statement fragment to be modified, the input SQL engine, and the target SQL engine, and outputs the SQL statement fragment for the target engine. A specific example is provided below:
[0062] The SQL engine to which the input statement belongs: Engine A;
[0063] Target SQL engine: Engine B;
[0064] The SQL statement fragment needs to be modified: a! = 3;
[0065] After receiving the above information, the statement conversion module will convert the SQL statement fragment that needs to be modified. The conversion result is as follows:
[0066] The SQL statement fragment needs to be modified: a! = 3;
[0067] Target engine SQL statement fragment: a<>3;
[0068] In other words, once it is determined that ! = needs to be converted to <>.
[0069] The input format required for training the statement conversion module is the same as in the example above, including the SQL statement fragment to be modified, the SQL engine to which the input statement belongs, the target SQL engine, and the SQL statement fragment of the target engine.
[0070] Since SQL statements from different engines have a high degree of similarity, a parameter for whether to copy the original input is introduced into the sequence generation model and added to the probability distribution of the final output. This makes the model more likely to copy the original input and improves the accuracy of SQL statement conversion.
[0071] After generating the target engine's SQL statement fragment, replace the fragments that need to be modified in the original engine's SQL statement with the target engine's SQL statement fragment to obtain the SQL statement with the same logic as the target engine. At this point, the function of this system is complete.
[0072] It should be noted that the above solution employs a deep learning-based approach, thus offering the advantage of strong scalability. Specifically, the rules for modifying SQL statements are similar across different SQL engines. When a new SQL engine is added, the model already stores information from the existing engines for reference, rather than randomly initializing parameters. Therefore, the amount of training data required to achieve high accuracy with the new SQL engine is significantly reduced.
[0073] In the field of data analysis, the traditional method of manually writing SQL statements for different engines based on documents is inefficient and cannot be automated. This significantly impacts work efficiency in practice. The method described above frees analysts from tedious engine switching tasks, allowing them to focus more on business-related analysis and greatly improving work efficiency.
[0074] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, 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 is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention. In this embodiment, an energy efficiency information transmitting device is also provided. This device is used to implement the above embodiments and preferred embodiments, and will not be repeated for those already described. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0075] The solution of the present invention will be further described below with reference to Figure 3, which is a schematic diagram of the structure of an optional field conversion device according to an embodiment of the present invention:
[0076] The first determining module 32 is used to determine the conversion information corresponding to the conversion instruction, wherein the conversion information includes: the statement to be converted, the first statement engine to which the statement to be converted belongs, and the target statement engine corresponding to the statement to be converted;
[0077] The annotation module 34 is used to send the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate the first field in the statement to be converted to perform the conversion operation;
[0078] The first conversion module 36 is used to determine the second field after the first field is converted based on the first field, the first statement engine, and the target statement engine.
[0079] The aforementioned device determines the conversion information corresponding to the conversion instruction. This conversion information includes: the statement to be converted, the first statement engine to which the statement belongs, and the target statement engine corresponding to the statement. The conversion information is sent to the annotation model to obtain the annotation result corresponding to the statement to be converted. The annotation result indicates the first field in the statement to be converted, from which the conversion operation is to be performed. Based on the first field, the first statement engine, and the target statement engine, the second field after conversion of the first field is determined. In other words, based on the user-input statement, the engine to which the statement belongs, and the target engine to which the statement needs conversion, the annotation module annotates the fields that need to be modified, and the conversion module converts the annotated fields. This solves the problem in related technologies where statement conversion relies solely on manual methods, leading to a significant increase in the time cost of the conversion work.
[0080] In one exemplary embodiment, the above apparatus further includes: a second determining module, configured to determine conversion information corresponding to a conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; an annotation module, configured to send the conversion information to an annotation model to obtain an annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate a first field in the statement to be converted from which a conversion operation is to be performed; and a first conversion module, configured to determine a second field after the first field is converted based on the first field, the first statement engine, and the target statement engine.
[0081] In an exemplary embodiment, the above apparatus further includes: a third determining module, configured to: before sending the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted; if the annotation model has been trained based on sample data in the first database, verify the annotation model using verification data in the second database to obtain a verification result, wherein the verification result is used to indicate the accuracy of the annotation model in annotating the verification data, the sample data including: a first sample statement and a statement engine corresponding to the first sample statement; if the accuracy is less than a first preset value, determine to adjust the annotation parameters of the annotation model to obtain an adjusted annotation model.
[0082] In an exemplary embodiment, the above apparatus further includes: an extraction module, configured to: extract a plurality of fields constituting the statement to be converted; determine a first position feature for each of the plurality of fields, wherein the first position feature is used to indicate the position of the corresponding field in the statement to be converted; compare a second sample statement allowed to run in the first statement engine with a third sample statement allowed to run in the target statement engine to determine a compositional difference between the second sample statement and the third sample statement, wherein the compositional difference is used to indicate the positional difference between the fields constituting the second sample statement and the fields constituting the third sample statement; compare the first position feature with the positional difference, and determine the field to be converted based on the comparison result.
[0083] In an exemplary embodiment, the above apparatus further includes: a fourth determining module, configured to compare the first position feature with the position difference, and after determining the field to be converted based on the comparison result: determine the statement segment to which the field to be converted belongs based on the first position feature; and determine all fields constituting the statement segment as a segment to be labeled, wherein the segment to be labeled is used to determine the labeling result.
[0084] In an exemplary embodiment, the above apparatus further includes: a fifth determining module, configured to determine the difference value between the first position feature and the position difference; if the difference value is greater than a preset threshold, confirm that the field corresponding to the first position feature is not a field to be converted; if the difference value is less than the preset threshold, confirm that the field corresponding to the first position feature is a field to be converted.
[0085] In an exemplary embodiment, the apparatus further includes: a second conversion module, configured to train a conversion model using a third database before determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, wherein the conversion model is used to indicate the second field corresponding to the first field, and the third database includes multiple sample fields, a statement engine corresponding to each of the multiple sample fields, and a fourth sample statement corresponding to each sample field; and inputs the first field, the first statement engine, and the target statement engine into the conversion model to obtain a conversion result, wherein the conversion result is used to indicate the second field.
[0086] In an exemplary embodiment, the above apparatus further includes: a sending module, configured to: determine the target statement to which the second field belongs after determining the second field transformed from the first field based on the first field, the first statement engine, and the target statement engine; send the target statement and the statement to be converted to a mobile terminal used by the target object; receive a feedback instruction issued by the mobile terminal based on the target statement and the statement to be converted, wherein the feedback instruction is used to indicate the similarity between the target statement and the statement to be converted; and determine that the annotation model needs to be adjusted if the similarity is less than a second preset value.
[0087] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0088] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0089] S1, determine the conversion information corresponding to the conversion instruction, wherein the conversion information includes: the statement to be converted, the first statement engine to which the statement to be converted belongs, and the target statement engine corresponding to the statement to be converted;
[0090] S2, the conversion information is sent to the annotation model to obtain the annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate the first field in the statement to be converted to perform the conversion operation;
[0091] S3, determine the second field after the transformation of the first field based on the first field, the first statement engine, and the target statement engine.
[0092] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0093] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0094] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0095] S1, determine the conversion information corresponding to the conversion instruction, wherein the conversion information includes: the statement to be converted, the first statement engine to which the statement to be converted belongs, and the target statement engine corresponding to the statement to be converted;
[0096] S2, the conversion information is sent to the annotation model to obtain the annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate the first field in the statement to be converted to perform the conversion operation;
[0097] S3, determine the second field after the transformation of the first field based on the first field, the first statement engine, and the target statement engine.
[0098] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here. In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0099] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0100] This invention provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements a method for extracting the information.
[0101] This invention provides a processor for running a program, wherein the program executes a method for extracting the information during runtime.
[0102] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. As shown in Figure 4, the present invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: determining conversion information corresponding to a conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; sending the conversion information to an annotation model to obtain an annotation result corresponding to the statement to be converted, wherein the annotation result is used to indicate a first field in the statement to be converted from which a conversion operation is to be performed; and determining a second field after the conversion of the first field based on the first field, the first statement engine, and the target statement engine.
[0103] Optionally, before sending the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted, the process includes: if the annotation model has been trained based on sample data in the first database, verifying the annotation model using verification data in the second database to obtain a verification result, wherein the verification result is used to indicate the accuracy of the annotation model in annotating the verification data, and the sample data includes: a first sample statement and a statement engine corresponding to the first sample statement; if the accuracy is less than a first preset value, determining to adjust the annotation parameters of the annotation model to obtain an adjusted annotation model.
[0104] Optionally, after sending the conversion information to the annotation model, the process includes: extracting multiple fields constituting the statement to be converted, determining a first positional feature for each of the multiple fields, wherein the first positional feature is used to indicate the position of the corresponding field in the statement to be converted; comparing a second sample statement allowed to run in the first statement engine with a third sample statement allowed to run in the target statement engine to determine the compositional differences between the second sample statement and the third sample statement, wherein the compositional differences are used to indicate the positional differences between the fields constituting the second sample statement and the fields constituting the third sample statement; comparing the first positional feature with the positional differences, and determining the field to be converted based on the comparison result.
[0105] Optionally, after comparing the first position feature with the position difference and determining the field to be converted based on the comparison result, the process includes: determining the statement segment to which the field to be converted belongs based on the first position feature; and determining all fields constituting the statement segment as the segment to be labeled, wherein the segment to be labeled is used to determine the labeling result.
[0106] Optionally, the difference value between the first position feature and the position difference is determined; if the difference value is greater than a preset threshold, it is confirmed that the field corresponding to the first position feature is not the field to be converted; if the difference value is less than the preset threshold, it is confirmed that the field corresponding to the first position feature is the field to be converted.
[0107] Optionally, before determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, the process includes: training a conversion model using a third database, wherein the conversion model is used to indicate the second field corresponding to the first field, the third database including multiple sample fields, a statement engine corresponding to each of the multiple sample fields, and a fourth sample statement corresponding to the sample fields; inputting the first field, the first statement engine, and the target statement engine into the conversion model to obtain a conversion result, wherein the conversion result is used to indicate the second field.
[0108] Optionally, after determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, the process includes: determining the target statement to which the second field belongs, wherein the target statement is the statement to be converted; sending the target statement and the statement to be converted to a mobile terminal used by the target object, receiving feedback instructions from the mobile terminal based on the target statement and the statement to be converted, wherein the feedback instructions are used to indicate the similarity between the target statement and the statement to be converted; and determining that the annotation model needs to be adjusted if the similarity is less than a second preset value.
[0109] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0110] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0111] In the several embodiments provided by this invention, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed can be through some interfaces; the indirect coupling or communication connection of units or modules can be electrical or other forms.
[0112] 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 units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0113] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0114] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part 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 of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0115] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0116] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A field conversion method, characterized in that, include: The method involves determining conversion information corresponding to a conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; sending the conversion information to an annotation model to obtain annotation results corresponding to the statement to be converted, wherein the annotation results are used to indicate a first field in the statement to be converted from which a conversion operation is to be performed; determining a second field after the first field is converted based on the first field, the first statement engine, and the target statement engine; after sending the conversion information to the annotation model, the method further includes: extracting multiple fields constituting the statement to be converted, and determining a first position feature for each of the multiple fields, wherein the first position feature is used to indicate the position of the corresponding field in the statement to be converted; comparing a second sample statement allowed to run in the first statement engine with a third sample statement allowed to run in the target statement engine to determine the structural differences between the second sample statement and the third sample statement, wherein the structural differences are used to indicate the positional differences between the fields constituting the second sample statement and the fields constituting the third sample statement; comparing the first position feature with the positional differences, and determining the field to be converted based on the comparison result.
2. The method according to claim 1, characterized in that, Before sending the conversion information to the annotation model to obtain the annotation result corresponding to the statement to be converted, the method further includes: if the annotation model has been trained based on sample data in the first database, verifying the annotation model using verification data in the second database to obtain a verification result, wherein the verification result is used to indicate the accuracy of the annotation model in annotating the verification data, and the sample data includes: a first sample statement and a statement engine corresponding to the first sample statement; if the accuracy is less than a first preset value, determining to adjust the annotation parameters of the annotation model to obtain an adjusted annotation model.
3. The method according to claim 1, after comparing the first location feature with the location difference and determining the field to be converted based on the comparison result, the method further includes: The statement segment to which the field to be converted belongs is determined based on the first positional feature; All fields constituting the statement fragment are identified as fragments to be annotated, wherein the fragments to be annotated are used to determine the annotation results.
4. The method according to claim 1, wherein the first location feature is compared with the location difference, and the field to be converted is determined based on the comparison result, comprising: Determine the difference value between the first location feature and the location difference; If the difference value is greater than a preset threshold, it is confirmed that the field corresponding to the first position feature is not the field to be converted; if the difference value is less than the preset threshold, it is confirmed that the field corresponding to the first position feature is the field to be converted.
5. The method according to claim 1, characterized in that, Before determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, the method further includes: training a conversion model using a third database, wherein the conversion model is used to indicate the second field corresponding to the first field, the third database including multiple sample fields, a statement engine corresponding to each of the multiple sample fields, and a fourth sample statement corresponding to the sample fields; inputting the first field, the first statement engine, and the target statement engine into the conversion model to obtain a conversion result, wherein the conversion result is used to indicate the second field.
6. The method according to claim 1, characterized in that, After determining the second field after conversion of the first field based on the first field, the first statement engine, and the target statement engine, the method further includes: determining the target statement to which the second field belongs, wherein the target statement is obtained after performing a conversion operation on the statement to be converted; sending the target statement and the statement to be converted to a mobile terminal used by the target object, and receiving feedback instructions issued by the mobile terminal based on the target statement and the statement to be converted, wherein the feedback instructions are used to indicate the similarity between the target statement and the statement to be converted; and determining that the annotation model needs to be adjusted if the similarity is less than a second preset value.
7. A field conversion device, characterized in that, include: A first determining module is used to determine the conversion information corresponding to the conversion instruction, wherein the conversion information includes: a statement to be converted, a first statement engine to which the statement to be converted belongs, and a target statement engine corresponding to the statement to be converted; a labeling module is used to send the conversion information to a labeling model to obtain a labeling result corresponding to the statement to be converted, wherein the labeling result is used to indicate the first field in the statement to be converted to be converted to perform a conversion operation; a first conversion module is used to determine the second field after the first field is converted based on the first field, the first statement engine, and the target statement engine; the labeling module is further used to extract multiple fields constituting the statement to be converted, and determine the first position feature of each of the multiple fields, wherein the first position feature is used to indicate the position of the corresponding field in the statement to be converted; compare a second sample statement that is allowed to run in the first statement engine with a third sample statement that is allowed to run in the target statement engine to determine the structural difference between the second sample statement and the third sample statement, wherein the structural difference is used to indicate the positional difference between the fields constituting the second sample statement and the fields constituting the third sample statement; compare the first position feature with the positional difference, and determine the field to be converted based on the comparison result.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the field conversion method according to any one of claims 1 to 6 when it is run.
9. An electronic device, characterized in that, The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to be configured to run the programs, wherein the programs are configured to execute the field conversion method of any one of claims 1 to 6 at runtime.
Citation Information
Patent Citations
SQL conversion method and device, computer equipment and computer readable storage medium
CN112328621A
SQL dialect conversion method, device and system and storage medium
CN114764558A