Sql language conversion method, electronic equipment and storage medium

The SQL language conversion method optimizes the process by using two mapping tables and semantic analysis to reduce the complexity of SQL generation, addressing inefficiencies in existing conversion methods and enhancing performance.

CN119201985AActive Publication Date: 2024-12-27MOBILE TECH COMPANY CHINA TRAVELSKY HLDG
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411390528.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2024-12-27
Estimated Expiration
2044-10-08

AI Technical Summary

Technical Problem

The current method of converting natural language into SQL language is inefficient due to the lengthy generation time and high computing power consumption caused by the number of characters in SQL word segmentation, especially when multiple conversion keywords are involved, affecting user experience and resource utilization.

Method used

A SQL language conversion method utilizing two mapping tables: a first table storing target SQL language conversion segmentations with low information entropy and a second table storing rewritten segmentations with reduced character length, along with semantic analysis and character abbreviation rules to optimize SQL generation.

Benefits of technology

The method significantly reduces the generation time of SQL statements by simplifying the conversion process, improving efficiency and reducing computing power requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201985A_ABST
    Figure CN119201985A_ABST
Patent Text Reader

Abstract

The invention provides an sql language conversion method, electronic equipment and a storage medium, and the method comprises the steps: carrying out the splitting processing of a to-be-converted natural statement, so as to obtain a plurality of to-be-converted natural segmented words; performing sql language conversion on each to-be-converted natural segmented word to obtain an initial sql language segmented word corresponding to each to-be-converted natural segmented word; if the initial sql language segmented word is any target sql language conversion segmented word, determining the initial sql language segmented word as a target sql language segmented word; and deleting each target sql language segmented word in the plurality of initial sql language segmented words, and splicing the rest initial sql language segmented words after deletion in sequence to obtain a target sql statement. According to the method, the converted initial sql language segmented words are simplified, so that the generation time of the obtained target sql statement is shortened, and the conversion efficiency of the target sql statement is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] The current method of converting natural language into SQL language is to parse natural language statements, convert natural language statements according to the semantics of natural language statements and specific language conversion templates, and obtain SQL language statements. The generation rate of SQL language statements is related to the number of characters in the SQL word segmentation when performing language conversion. The larger the number of characters in the SQL word segmentation that constitutes the SQL language statement, the longer the generation time of the SQL language statement and the more computing power it occupies. Therefore, when there are more conversion keywords in the natural language statement that needs to be converted, there are more corresponding SQL word segmentations, and the time to generate the corresponding SQL language statement will be extended, which affects the user experience and also occupies a lot of computing power. Summary of the invention

[0003] In view of the above technical problems, the technical solution adopted by the present invention is:

[0004] According to one aspect of the present application, a sql language conversion method is provided, which is applied to a sql language conversion model, in which a first sql language conversion mapping table and a second sql language conversion mapping table are stored;

[0005] The first SQL language conversion mapping table stores a number of target SQL language conversion segmentations, wherein the target SQL language conversion segmentations include preset key fields, and the information entropy is less than a preset information entropy threshold;

[0006] The second SQL language conversion mapping table stores a mapping relationship between a key SQL language conversion participle that meets a preset information entropy difference rule and its corresponding rewritten SQL language conversion participle; the character length of the rewritten SQL language conversion participle is less than the character length of the key SQL language conversion participle corresponding to the rewritten SQL language conversion participle;

[0007] The SQL language conversion method comprises the following steps:

[0008] Step S100: In response to receiving a natural sentence to be converted, splitting the natural sentence to be converted to obtain a plurality of natural participles to be converted included in the natural sentence to be converted;

[0009] Step S200: Perform SQL language conversion on each natural participle to be converted, so as to obtain an initial SQL language participle corresponding to each natural participle to be converted;

[0010] Step S300, traverse each initial SQL language segmentation, if the initial SQL language segmentation is any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, determine the initial SQL language segmentation as the target SQL language segmentation;

[0011] Step S400: Delete each target SQL language segmentation from a number of initial SQL language segmentations, and sequentially concatenate the remaining initial SQL language segmentations after deletion to obtain a target SQL statement.

[0012] In an exemplary embodiment of the present application, the first SQL language conversion mapping table is obtained by the following steps:

[0013] Step S011, obtaining a number of historical natural sentences;

[0014] Step S012, splitting each historical natural sentence to obtain a number of historical natural participles included in each historical natural sentence;

[0015] Step S013: perform SQL language conversion on each historical natural participle to obtain the historical initial SQL language participle corresponding to each historical natural participle;

[0016] Step S014, traversing each historical initial SQL language segmentation, if any historical initial SQL language segmentation includes a preset key field, then determining the historical initial SQL language segmentation as a historical key SQL language segmentation, so as to obtain a plurality of historical key SQL language segmentations;

[0017] Step S015, traverse each historical key SQL language segmentation, if the information entropy of any historical key SQL language segmentation is less than a preset information entropy threshold, determine the historical key SQL language segmentation as the target SQL language conversion segmentation;

[0018] Step S016: Integrate several target SQL language conversion word segments to obtain a first SQL language conversion mapping table.

[0019] In an exemplary embodiment of the present application, step S100 includes:

[0020] Step S110, performing multiple rounds of rewriting processing on the natural sentence to be converted to obtain the corresponding rewritten sentence to be converted;

[0021] Step S120, performing semantic analysis on the sentence to be converted and rewritten to obtain a semantic identifier corresponding to each participle to be converted and rewritten included in the sentence to be converted and rewritten;

[0022] Step S130 , traverse each rewritten participle to be converted, and if the semantic identifier corresponding to the rewritten participle to be converted is a preset key semantic identifier, determine the rewritten participle to be converted as a natural participle to be converted.

[0023] In an exemplary embodiment of the present application, step S300 includes:

[0024] Step S310: If the initial SQL language segmentation is not any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, the initial SQL language segmentation is determined as the SQL language segmentation to be verified;

[0025] Step S320: If the SQL language segmentation to be verified includes a preset key field and the information entropy of the SQL language segmentation to be verified is less than the preset information entropy threshold, the SQL language segmentation to be verified is stored in the first SQL language conversion mapping table, and the SQL language segmentation to be verified is determined as the target SQL language segmentation, and step S400 is executed.

[0026] In an exemplary embodiment of the present application, step S300 further includes:

[0027] Step S301: If the initial SQL language segmentation is not any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, but the initial SQL language segmentation is any key SQL language conversion segmentation stored in the second SQL language conversion mapping table, then the initial SQL language segmentation is rewritten into a rewritten SQL language conversion segmentation having a mapping relationship therewith.

[0028] In an exemplary embodiment of the present application, the second SQL language conversion mapping table is obtained by the following steps:

[0029] Step S021, traversing each historical initial SQL language segmentation, if the historical initial SQL language segmentation does not include a preset key field, or the information entropy of the historical initial SQL language segmentation is greater than or equal to a preset information entropy threshold, then determining the historical initial SQL language segmentation as the first historical SQL language segmentation;

[0030] Step S022: according to the character length of each first historical SQL language segmentation, determine a plurality of second historical SQL language segmentations from a plurality of first historical SQL language segmentations; the second historical SQL language segmentations are first historical SQL language segmentations that meet a preset character length rule;

[0031] Step S023: rewrite each second historical SQL language word segmentation according to a preset character abbreviation rule to obtain a rewritten SQL language conversion word segmentation corresponding to each second historical SQL language word segmentation;

[0032] Step S024: Determine a second SQL language conversion mapping table according to the information entropy of each second historical SQL language word segment and the information entropy of the rewritten SQL language conversion word segment corresponding to the second historical SQL language word segment.

[0033] In an exemplary embodiment of the present application, step S022 includes:

[0034] Step S0221, obtain the character length of each first historical SQL language word segmentation, and obtain a character length list B = (B1, B2, ..., B g ,...,B h ); where g = 1, 2, ..., h; h is the number of word segments in the first historical SQL language; B g is the character length of the gth first historical SQL language word segmentation;

[0035] Step S0222, traverse character length list B, if B g ≥B0, the g-th first historical SQL language word segmentation is determined as the second historical SQL language word segmentation to obtain a plurality of second historical SQL language word segments; wherein B0 is a preset character length threshold.

[0036] In an exemplary embodiment of the present application, step S024 includes:

[0037] Step S0241, obtain the information entropy of each second historical SQL language word segmentation, and obtain the first information entropy list C = (C1, C2, ..., C a ,...,C b ); where a = 1, 2, ..., b; b is the number of word segments in the second historical SQL language; C a The information entropy of the a-th second historical SQL language word segmentation;

[0038] Step S0242: Obtain the information entropy of each rewritten SQL language conversion word segmentation to obtain a second information entropy list

[0039] D=(D1,D2,...,D a ,...,D b ), where D a is the rewrite obtained after rewriting the a-th second historical SQL language word segmentation

[0040] The information entropy of word segmentation in sql language conversion;

[0041] Step S0243, traverse the first information entropy list C and the second information entropy list D, if |D a -C a |≤d, the ath second historical SQL language segmentation is determined as the key SQL language conversion segmentation; where d is the preset information entropy difference threshold;

[0042] Step S0244: store the mapping relationship between each key SQL language conversion participle and its corresponding rewritten SQL language conversion participle in a preset initial mapping relationship table to obtain a second SQL language conversion mapping table.

[0043] According to one aspect of the present application, a non-transitory computer-readable storage medium is provided, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the aforementioned SQL language conversion method.

[0044] According to one aspect of the present application, an electronic device is provided, including a processor and the aforementioned non-transitory computer-readable storage medium.

[0045] The present invention has at least the following beneficial effects:

[0046] The sql language conversion method of the present invention performs splitting processing on the natural sentence to be converted to obtain a plurality of natural participles to be converted, performs sql language conversion on each natural participle to be converted to obtain the initial sql language participle corresponding to each natural participle to be converted, and then traverses each initial sql language participle. If the initial sql language participle is a participle that conforms to the information entropy rule, the initial sql language participle is deleted, and the remaining initial sql language participles after deletion are sequentially spliced ​​to obtain the target sql statement. By simplifying the converted initial sql language participle, the generation time of the target sql statement is shortened, thereby improving the conversion efficiency of the target sql statement. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 The present invention provides a flow chart of a SQL language conversion method. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0050] A sql language conversion method is applied to a sql language conversion model, in which a first sql language conversion mapping table and a second sql language conversion mapping table are stored.

[0051] Currently, in the conversion scenario between natural language and SQL language, it is usually used in user intelligent question and answer systems. Users input natural language question statements into the user intelligent question and answer system, and the user intelligent question and answer system converts the question statements into index conditions in SQL language, and then searches for corresponding retrieval data from the information database through the index conditions, and then converts the SQL language retrieval data into natural language answer statements and outputs them to the user.

[0052] Therefore, the SQL language conversion model of the present application is a model for converting user question statements into SQL in the user intelligent question-answering system.

[0053] The first SQL language conversion mapping table stores a number of target SQL language conversion segmented words, the target SQL language conversion segmented words include preset key fields, and the information entropy is less than a preset information entropy threshold.

[0054] The second SQL language conversion mapping table stores the mapping relationship between the key SQL language conversion participles and their corresponding rewritten SQL language conversion participles that conform to the preset information entropy difference rules; the character length of the rewritten SQL language conversion participle is less than the character length of the key SQL language conversion participle corresponding to the rewritten SQL language conversion participle.

[0055] The first SQL language conversion mapping table is obtained through steps S011 to S016:

[0056] Step S011, obtaining a number of historical natural sentences;

[0057] Historical natural sentences are user question sentences written in natural language during a historical period.

[0058] Step S012, splitting each historical natural sentence to obtain a number of historical natural participles included in each historical natural sentence;

[0059] Semantic analysis is performed on each historical natural sentence to determine a number of historical natural participles that can express semantics in each historical natural sentence. Existing semantic analysis methods are used for the semantic analysis of natural sentences.

[0060] Step S013: perform SQL language conversion on each historical natural participle to obtain the historical initial SQL language participle corresponding to each historical natural participle;

[0061] The method of semantically analyzing each historical natural sentence to obtain several historical natural participles and then converting each historical natural participle into SQL, compared with the method of directly converting the historical natural sentence into SQL, does not need to convert the participles with less semantics into SQL, thereby reducing the data processing amount of language conversion.

[0062] Step S014, traversing each historical initial SQL language segmentation, if any historical initial SQL language segmentation includes a preset key field, then determining the historical initial SQL language segmentation as a historical key SQL language segmentation, so as to obtain a plurality of historical key SQL language segmentations;

[0063] The preset key field is a field set by the developer to represent the amount of information in the historical natural sentence. If the historical initial SQL language word segmentation includes the preset key field, it means that the historical initial SQL language word segmentation is a word that can reflect specific semantics and is determined as a historical key SQL language word segmentation.

[0064] Step S015, traverse each historical key SQL language segmentation, if the information entropy of any historical key SQL language segmentation is less than a preset information entropy threshold, determine the historical key SQL language segmentation as the target SQL language conversion segmentation;

[0065] The information entropy of a historical key SQL language segmentation indicates the amount of information contained in the historical key SQL language segmentation. The larger the information entropy, the more information is contained in the corresponding historical key SQL language segmentation, that is, the more important the historical key SQL language segmentation is when performing information indexing; conversely, the smaller the information entropy, the less information is contained in the corresponding historical key SQL language segmentation, and it has little impact on the results of subsequent information indexing.

[0066] Step S016: Integrate several target SQL language conversion word segments to obtain a first SQL language conversion mapping table.

[0067] The second SQL language conversion mapping table is obtained through steps S021 to S024:

[0068] Step S021, traversing each historical initial SQL language segmentation, if the historical initial SQL language segmentation does not include a preset key field, or the information entropy of the historical initial SQL language segmentation is greater than or equal to a preset information entropy threshold, then determining the historical initial SQL language segmentation as the first historical SQL language segmentation;

[0069] Step S022: according to the character length of each first historical SQL language segmentation, determine a plurality of second historical SQL language segmentations from a plurality of first historical SQL language segmentations; the second historical SQL language segmentations are first historical SQL language segmentations that meet a preset character length rule;

[0070] When indexing data information according to index conditions, the character length of the index conditions is proportional to the index time and the computing power occupied by the index. Therefore, when indexing information, the longer the character length of the index conditions, the greater the computing power occupied by the index and the longer the index time. Therefore, the character length of the index conditions becomes a key factor in reducing the index time. After obtaining the first historical SQL language participle, several second historical SQL language participles are determined according to the character length.

[0071] Further, step S022 includes step S0221-step S0222:

[0072] Step S0221, obtain the character length of each first historical SQL language word segmentation, and obtain a character length list B = (B1, B2, ..., B g ,...,B h ); where g = 1, 2, ..., h; h is the number of word segments in the first historical SQL language; B g is the character length of the gth first historical SQL language word segmentation;

[0073] Step S0222, traverse character length list B, if B g ≥B0, the g-th first historical SQL language word segmentation is determined as the second historical SQL language word segmentation to obtain a plurality of second historical SQL language word segments; wherein B0 is a preset character length threshold.

[0074] If the character length of the first historical SQL language segmentation is too long, the generated index condition will affect the subsequent indexing speed. Therefore, the first historical SQL language segmentation is determined as the second historical SQL language segmentation.

[0075] Step S023: rewrite each second historical SQL language word segmentation according to a preset character abbreviation rule to obtain a rewritten SQL language conversion word segmentation corresponding to each second historical SQL language word segmentation;

[0076] The character abbreviation rule is a character shortening and rewriting rule defined by the user or preset by the system. By counting several historical characters, the characters are shortened without losing the amount of information, so as to achieve the purpose of improving data processing efficiency.

[0077] Step S024, determining a second SQL language conversion mapping table according to the information entropy of each second historical SQL language segmentation and the information entropy of the rewritten SQL language conversion segmentation corresponding to the second historical SQL language segmentation;

[0078] Since the premise of shortening the characters of the second historical SQL language word segmentation is not to lose too much information of the original words and sentences, so as not to reduce the accuracy of the index results, it is necessary to verify whether the information entropy difference between the second historical SQL language word segmentation and its corresponding rewritten SQL language conversion word segmentation is too large. If the difference is within the specified range, it means that the rewritten SQL language conversion word segmentation meets the information entropy difference rule, and the characters of the words and sentences are shortened without a large loss of information, thereby improving the indexing speed.

[0079] Further, step S024 includes steps S0241 to S0244:

[0080] Step S0241, obtain the information entropy of each second historical SQL language word segmentation, and obtain the first information entropy list C = (C1, C2, ..., C a ,...,C b ); where a = 1, 2, ..., b; b is the number of word segments in the second historical SQL language; C a The information entropy of the a-th second historical SQL language word segmentation;

[0081] Step S0242: Obtain the information entropy of each rewritten SQL language conversion word segmentation to obtain a second information entropy list

[0082] D=(D1,D2,...,D a ,...,D b ), where D a is the rewrite obtained after rewriting the a-th second historical SQL language word segmentation

[0083] The information entropy of word segmentation in sql language conversion;

[0084] Step S0243, traverse the first information entropy list C and the second information entropy list D, if |D a -C a |≤d, the ath second historical SQL language segmentation is determined as the key SQL language conversion segmentation; where d is the preset information entropy difference threshold;

[0085] Step S0244: store the mapping relationship between each key SQL language conversion participle and its corresponding rewritten SQL language conversion participle in a preset initial mapping relationship table to obtain a second SQL language conversion mapping table.

[0086] like Figure 1 As shown, the SQL language conversion method described in this application includes the following steps:

[0087] Step S100: In response to receiving a natural sentence to be converted, splitting the natural sentence to be converted to obtain a plurality of natural participles to be converted included in the natural sentence to be converted;

[0088] Perform semantic analysis on the natural sentence to be converted to obtain several natural participles to be converted.

[0089] Further, step S100 includes steps S110 to S130:

[0090] Step S110, performing multiple rounds of rewriting processing on the natural sentence to be converted to obtain the corresponding rewritten sentence to be converted;

[0091] Multiple rounds of rewriting can adopt the existing processing methods. Multiple rounds of rewriting are used to semantically supplement the natural sentence to be converted. If the natural sentence to be converted is too simple, such as lacking a subject, if the natural sentence to be converted is directly converted into SQL language, the converted SQL statement will also lack corresponding keywords, which will cause abnormalities in subsequent indexes. Therefore, the natural sentence to be converted is first subjected to multiple rounds of rewriting, and the semantics of the natural sentence to be converted is expanded by connecting the upper and lower sentences of the natural sentence to be converted, and then SQL language conversion is performed, which can improve the accuracy of user responses.

[0092] Step S120, performing semantic analysis on the sentence to be converted and rewritten to obtain a semantic identifier corresponding to each participle to be converted and rewritten included in the sentence to be converted and rewritten;

[0093] After obtaining the sentence to be converted and rewritten, a semantic analysis is performed on the sentence to be converted and rewritten, that is, keyword splitting is performed on the sentence to be converted and rewritten participles to be converted included in the sentence to be converted and rewritten, wherein the semantic analysis and keyword splitting can adopt the existing analysis methods, and the rewritten participles to be converted have corresponding semantic identifiers, which indicate the semantic type of the corresponding rewritten participles to be converted, such as whether the rewritten participle to be converted is the subject, predicate, or object of the sentence to be converted and rewritten, and through the semantic identifier, it can be determined whether the rewritten participle to be converted plays a key role in information indexing.

[0094] Step S130 , traverse each rewritten participle to be converted, and if the semantic identifier corresponding to the rewritten participle to be converted is a preset key semantic identifier, determine the rewritten participle to be converted as a natural participle to be converted.

[0095] The preset key semantic identifier is the semantic identifier of the indispensable semantic type when indexing information. The key semantic identifier can be obtained by performing keyword splitting statistics on several historical natural languages.

[0096] Step S200: Perform SQL language conversion on each natural participle to be converted, so as to obtain an initial SQL language participle corresponding to each natural participle to be converted;

[0097] The sql language conversion adopts the existing language conversion method.

[0098] Step S300, traverse each initial SQL language segmentation, if the initial SQL language segmentation is any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, determine the initial SQL language segmentation as the target SQL language segmentation;

[0099] Further, step S300 includes step S310-step S320:

[0100] Step S310: If the initial SQL language segmentation is not any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, the initial SQL language segmentation is determined as the SQL language segmentation to be verified;

[0101] Step S320: If the SQL language segmentation to be verified includes a preset key field and the information entropy of the SQL language segmentation to be verified is less than the preset information entropy threshold, the SQL language segmentation to be verified is stored in the first SQL language conversion mapping table, and the SQL language segmentation to be verified is determined as the target SQL language segmentation, and step S400 is executed.

[0102] Further, step S300 also includes step S301:

[0103] Step S301: If the initial SQL language segmentation is not any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, but the initial SQL language segmentation is any key SQL language conversion segmentation stored in the second SQL language conversion mapping table, then the initial SQL language segmentation is rewritten into a rewritten SQL language conversion segmentation having a mapping relationship therewith.

[0104] Step S400: Delete each target SQL language segmentation from a number of initial SQL language segmentations, and sequentially concatenate the remaining initial SQL language segmentations after deletion to obtain a target SQL statement.

[0105] Since the target SQL language conversion word segmentation stored in the first SQL language conversion mapping table is a phrase with a smaller information entropy, it has little impact on the indexing results of the subsequent information index. Therefore, if the initial SQL language word segmentation is any target SQL language conversion word segmentation stored in the first SQL language conversion mapping table, it will be deleted to improve the subsequent indexing speed.

[0106] The sql language conversion method of the present invention performs splitting processing on the natural sentence to be converted to obtain a plurality of natural participles to be converted, performs sql language conversion on each natural participle to be converted to obtain the initial sql language participle corresponding to each natural participle to be converted, and then traverses each initial sql language participle. If the initial sql language participle is a participle that conforms to the information entropy rule, the initial sql language participle is deleted, and the remaining initial sql language participles after deletion are sequentially spliced ​​to obtain the target sql statement. By simplifying the converted initial sql language participle, the generation time of the target sql statement is shortened, thereby improving the conversion efficiency of the target sql statement.

[0107] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.

[0108] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0109] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0110] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.

[0111] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0112] The electronic device according to this embodiment of the present invention is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0113] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: the at least one processor mentioned above, the at least one storage device mentioned above, and a bus connecting different system components (including storage devices and processors).

[0114] The storage stores program codes, which can be executed by the processor, so that the processor executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0115] The memory may include readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory, and may further include read only memory (ROM).

[0116] The storage may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.

[0117] The bus may represent one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.

[0118] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter.

[0119] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0120] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0121] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0122] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0123] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0124] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0125] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0126] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0127] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A SQL language conversion method, characterized in that: Applied to a sql language conversion model, wherein a first sql language conversion mapping table is stored in the sql language conversion mapping table, wherein a plurality of target sql language conversion participles are stored, wherein the target sql language conversion participles include preset key fields, and the information entropy is less than a preset information entropy threshold; The method comprises the following steps: Step S100: In response to receiving a natural sentence to be converted, splitting the natural sentence to be converted to obtain a plurality of natural participles to be converted included in the natural sentence to be converted; Step S200: performing SQL language conversion on each natural participle to be converted, so as to obtain an initial SQL language participle corresponding to each natural participle to be converted; Step S300, traversing each of the initial SQL language segmentations, if the initial SQL language segmentation is any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, determining the initial SQL language segmentation as the target SQL language segmentation; Step S400: Delete each target SQL language segmentation from the plurality of initial SQL language segmentations, and sequentially concatenate the remaining initial SQL language segmentations after deletion to obtain a target SQL statement.

2. The method according to claim 1, characterized in that The first SQL language conversion mapping table is obtained by the following steps: Step S011, obtaining a number of historical natural sentences; Step S012: split each of the historical natural sentences to obtain a number of historical natural participles included in each of the historical natural sentences; Step S013: performing SQL language conversion on each of the historical natural participles to obtain historical initial SQL language participles corresponding to each of the historical natural participles; Step S014, traversing each of the historical initial SQL language participles, if any of the historical initial SQL language participles includes a preset key field, determining the historical initial SQL language participle as a historical key SQL language participle, so as to obtain a plurality of historical key SQL language participles; Step S015, traversing each of the historical key SQL language segmentations, if the information entropy of any of the historical key SQL language segmentations is less than a preset information entropy threshold, determining the historical key SQL language segmentation as the target SQL language conversion segmentation; Step S016: Integrate the target SQL language conversion word segments to obtain the first SQL language conversion mapping table.

3. The method according to claim 2, characterized in that The step S100 includes: Step S110, performing multiple rounds of rewriting processing on the natural sentence to be converted to obtain a corresponding rewritten sentence to be converted; Step S120, performing semantic analysis on the sentence to be converted and rewritten to obtain a semantic identifier corresponding to each rewritten word to be converted included in the sentence to be converted and rewritten; Step S130: traverse each of the rewritten participles to be converted, and if the semantic identifier corresponding to the rewritten participle to be converted is a preset key semantic identifier, determine the rewritten participle to be converted as a natural participle to be converted.

4. The method according to claim 3, characterized in that The step S300 includes: Step S310: If the initial SQL language segmentation is not any target SQL language conversion segmentation stored in the first SQL language conversion mapping table, the initial SQL language segmentation is determined as the SQL language segmentation to be verified; Step S320: If the SQL language word segmentation to be verified includes a preset key field, and the information entropy of the SQL language word segmentation to be verified is less than a preset information entropy threshold, the SQL language word segmentation to be verified is stored in the first SQL language conversion mapping table, and the SQL language word segmentation to be verified is determined as the target SQL language word segmentation, and step S400 is executed.

5. The method according to claim 3, characterized in that: The sql language conversion model also stores a second sql language conversion mapping table, in which a mapping relationship between a key sql language conversion participle and its corresponding rewritten sql language conversion participle that conforms to a preset information entropy difference rule is stored; the character length of the rewritten sql language conversion participle is less than the character length of the key sql language conversion participle corresponding to the rewritten sql language conversion participle; Wherein, the step S300 further includes: Step S301: If the initial SQL language participle is not any target SQL language conversion participle stored in the first SQL language conversion mapping table, but the initial SQL language participle is any key SQL language conversion participle stored in the second SQL language conversion mapping table, then the initial SQL language participle is rewritten into a rewritten SQL language conversion participle having a mapping relationship therewith.

6. The method according to claim 5, characterized in that The second SQL language conversion mapping table is obtained by the following steps: Step S021, traversing each of the historical initial SQL language segmentations, if the historical initial SQL language segmentation does not include a preset key field, or the information entropy of the historical initial SQL language segmentation is greater than or equal to a preset information entropy threshold, then determining the historical initial SQL language segmentation as the first historical SQL language segmentation; Step S022: according to the character length of each of the first historical SQL language segmentation words, determine a plurality of second historical SQL language segmentation words from the plurality of the first historical SQL language segmentation words; the second historical SQL language segmentation words are first historical SQL language segmentation words that meet the preset character length rule; Step S023: rewrite each of the second historical SQL language word segments according to a preset character abbreviation rule to obtain a rewritten SQL language conversion word segment corresponding to each of the second historical SQL language word segments; Step S024: determine a second SQL language conversion mapping table according to the information entropy of each of the second historical SQL language word segments and the information entropy of the rewritten SQL language conversion word segment corresponding to the second historical SQL language word segment.

7. The method according to claim 6, characterized in that The step S022 comprises: Step S0221, obtain the character length of each of the first historical SQL language word segments, and obtain a character length list B = (B1, B2, ..., B g ,...,B h ); where g = 1, 2, ..., h; h is the number of word segments in the first historical SQL language; B g is the length in characters of the gth word segmentation in the first historical SQL language; Step S0222, traverse the character length list B, if B g ≥B0, the g-th first historical SQL language word segmentation is determined as the second historical SQL language word segmentation to obtain a plurality of second historical SQL language word segments; wherein B0 is a preset character length threshold.

8. The method according to claim 7, characterized in that The step S024 comprises: Step S0241: Obtain the information entropy of each of the second historical SQL language word segments to obtain a first information entropy list C = (C1, C2, ..., C a ,...,C b ); where a = 1, 2, ..., b; b is the number of word segments in the second historical SQL language; C a is the information entropy of the ath word segmentation of the second historical SQL language; Step S0242, obtain the information entropy of each rewritten SQL language conversion word segmentation, and obtain a second information entropy list D = (D1, D2, ..., D a ,...,D b ), where D a is the information entropy of the rewritten SQL language conversion segmentation obtained by rewriting the a-th second historical SQL language segmentation; Step S0243, traverse the first information entropy list C and the second information entropy list D, if |D a -C a |≤d, the ath second historical SQL language word segment is determined as the key SQL language conversion word segment; wherein d is a preset information entropy difference threshold; Step S0244: store the mapping relationship between each of the key SQL language conversion participles and their corresponding rewritten SQL language conversion participles in a preset initial mapping relationship table to obtain a second SQL language conversion mapping table.

9. A non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, characterized in that: The at least one instruction or the at least one program is loaded and executed by the processor to implement the SQL language conversion method as described in any one of claims 1-8.

10. An electronic device, characterized in that: The invention comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 9.

Citation Information

Patent Citations

  • Dictionary dimension reducing method and device and information classifying method and device

    CN105512104A

  • Chinese word segmentation scene library updating method and system

    CN106202056A

  • Structured query language conversion method based on natural language, and related equipment thereof

    CN111177184A

  • Method and system for assisting in labeling model training data

    CN114330462A

  • Statement generation model optimization method and device, electronic equipment and medium

    CN115630088A