CN114676155A - Code prompt information determining method, data set determining method and electronic equipment - Google Patents

Code prompt information determining method, data set determining method and electronic equipment Download PDF

Info

Publication number
CN114676155A
CN114676155A CN202210314942.1A CN202210314942A CN114676155A CN 114676155 A CN114676155 A CN 114676155A CN 202210314942 A CN202210314942 A CN 202210314942A CN 114676155 A CN114676155 A CN 114676155A
Authority
CN
China
Prior art keywords
node
determining
sql statement
information
data set
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210314942.1A
Other languages
Chinese (zh)
Inventor
鲁志强
洪珊珊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202210314942.1A priority Critical patent/CN114676155A/en
Publication of CN114676155A publication Critical patent/CN114676155A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2452Query translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation

Abstract

The code prompt information determining method, the data set determining method and the electronic device provided by the present disclosure relate to a database technology, and include: acquiring SQL sentences to be complemented and a preset characteristic data set; the characteristic data set comprises a completion prompt item and preset characteristics corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value; determining a current node to be edited in an SQL statement, and determining the node characteristics of the current node according to the SQL statement; and determining a completion prompt item for completing the current node according to the node characteristics and preset characteristics, and displaying the node type and the node value included in the completion prompt item. According to the scheme provided by the disclosure, the prompt item to be supplemented of the SQL sentence can be determined and displayed by combining the preset characteristic data set and the content of the SQL sentence to be supplemented, so that the more accurate prompt item to be supplemented can be determined, and the programming efficiency of a user is improved.

Description

Code prompt information determining method, data set determining method and electronic equipment
Technical Field
The present disclosure relates to database technologies, and in particular, to a method for determining code hint information, a method for determining a data set, and an electronic device.
Background
SQL (Structured Query Language) is a Language used for database queries and programming, and specifically for accessing data and querying, updating and managing relational database systems.
When the SQL language is used for programming, a user is generally required to input codes word by word in the programming software, so that the programming efficiency is low.
Disclosure of Invention
The present disclosure provides a method for determining code prompt information, a method for determining a data set, and an electronic device, so as to prompt the programming efficiency of an SQL language.
A first aspect of the present disclosure provides a method for determining code hint information, including:
acquiring SQL sentences to be complemented and a preset characteristic data set; the feature data set comprises a completion prompt item and a preset feature corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value;
determining a current node to be edited in the SQL statement, and determining the node characteristics of the current node according to the SQL statement;
and determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item.
A second aspect of the present disclosure is to provide a method for determining a feature data set, including:
acquiring a document comprising an SQL statement;
determining a plurality of nodes in the SQL statement, and determining the node characteristics of the nodes according to the SQL statement;
determining a completion prompt item according to the node, and generating the feature data set according to the completion prompt item and the node feature of the node; wherein the feature data set comprises a completion prompt item and a node feature corresponding to the completion prompt item.
A third aspect of the present disclosure is to provide a code hint information determination apparatus, including:
the acquiring unit is used for acquiring SQL sentences to be complemented and a preset characteristic data set; the feature data set comprises a completion prompt item and preset features corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value;
the determining unit is used for determining a current node to be edited in the SQL statement and determining the node characteristics of the current node according to the SQL statement;
and the prompting unit is used for determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item.
A fourth aspect of the present disclosure is to provide an apparatus for determining a feature data set, including:
a document acquisition unit configured to acquire a document including an SQL statement;
the characteristic extraction unit is used for determining a plurality of nodes in the SQL statement and determining the node characteristics of the nodes according to the SQL statement;
the set generating unit is used for determining a completion prompt item according to the node and generating the feature data set according to the completion prompt item and the node feature of the node; wherein the feature data set comprises a completion prompt item and a node feature corresponding to the completion prompt item.
A fourth aspect of the present disclosure is to provide an electronic device, including:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of determining code hint information as described in the first aspect above or the method of determining a feature data set as described in the second aspect above.
It is a further aspect of the present disclosure to provide a computer readable storage medium having stored thereon a computer program to be executed by a processor to implement the method of determining a code hint information as described in the first aspect above or the method of determining a feature data set as described in the second aspect above.
A further aspect of the present disclosure is to provide a computer program product comprising a computer program which, when executed by a processor, implements the method of determining code hint information as described in the first aspect above or the method of determining a feature data set as described in the second aspect above.
The code prompt information determining method, the data set determining method and the electronic device provided by the disclosure comprise the following steps: acquiring SQL sentences to be complemented and a preset characteristic data set; the characteristic data set comprises a completion prompt item and preset characteristics corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value; determining a current node to be edited in an SQL statement, and determining the node characteristics of the current node according to the SQL statement; and determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item. According to the code prompt information determining method, the data set determining method and the electronic device, the prompt item to be supplemented of the SQL sentence can be determined and displayed by combining the preset characteristic data set and the content of the SQL sentence to be supplemented, so that the more accurate prompt item to be supplemented can be determined, and the programming efficiency of a user is improved.
Drawings
FIG. 1 is a flow chart illustrating a method for determining code hint information in accordance with an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic diagram of an interface shown in an exemplary embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating a method for determining code hint information according to another exemplary embodiment of the present disclosure;
FIG. 4 is a flow chart illustrating a method of determining a feature data set according to an exemplary embodiment of the present disclosure;
FIG. 5 is a flow chart illustrating a method of determining a feature data set according to another exemplary embodiment of the present disclosure;
FIG. 6 is a diagram illustrating the structure of an abstract syntax tree, in accordance with an illustrative embodiment;
FIG. 7 is a block diagram of a code hint information determination apparatus shown in one exemplary embodiment of the present disclosure;
fig. 8 is a block diagram illustrating a code hint information determination apparatus according to another exemplary embodiment of the present disclosure;
fig. 9 is a block diagram illustrating a characteristic data set determination apparatus according to an exemplary embodiment of the present disclosure;
fig. 10 is a block diagram illustrating a characteristic data set determination apparatus according to another exemplary embodiment of the present disclosure;
fig. 11 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
Detailed Description
SQL (Structured Query Language) is a Language used for database queries and programming, and specifically for accessing data and querying, updating and managing relational database systems.
In many application scenarios, the SQL language is required to be used for programming, and especially when the database management is required, the SQL language is a more frequently used programming language. When a user programs, the user needs to input code contents word by word, in order to improve the programming efficiency, the context contents of the codes and SQL grammar rules can be combined to predict the code contents needed by the user next, and the contents are displayed so as to realize automatic completion of the codes.
However, the context of the code language has strong logic, and the code content that the user needs to input cannot be accurately predicted only by combining the context content of the code and the SQL syntax rules. In order to solve the technical problem, in the method provided by the disclosure, a feature data set is extracted by using a large number of existing SQL codes, and data included in the feature data set is extracted based on the real SQL codes and can embody context logic between the SQL codes.
Fig. 1 is a flowchart illustrating a method for determining code hint information according to an exemplary embodiment of the present disclosure.
As shown in fig. 1, the method for determining code hint information provided by this embodiment includes:
step 101, acquiring an SQL statement to be complemented and a preset characteristic data set; the feature data set comprises a completion prompt item and preset features corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value.
The method provided by the present disclosure may be executed by an electronic device with computing capability, and the electronic device may be, for example, a server or a user terminal.
Specifically, a user can write an SQL code in a user terminal, the user terminal can determine code prompt information based on the method provided by the present disclosure, and can also upload the SQL code being written by the user to a server, and the server determines the code prompt information based on the method provided by the present disclosure.
Further, the electronic device may obtain an SQL statement to be complemented and a preset feature data set.
The SQL statement refers to a statement in the SQL code file, for example, the content between two semicolons in the SQL code file is an SQL statement. The SQL statement to be complemented refers to an SQL statement that is not written, for example, after the user inputs the semicolon, the SQL statement may be considered to be written completely, and if the user is inputting characters, the user may be considered to be writing an SQL statement, which is the SQL statement to be complemented. Based on the scheme provided by the disclosure, the contents which the user wants to input at the tail part of the SQL sentence to be supplemented can be predicted, and then the contents can be displayed for the user to select.
Specifically, the preset feature data set may be obtained by processing an existing complete SQL statement. For example, a large number of SQL code files, which may be written by different persons, may be prepared in advance, and feature extraction may be performed on each SQL statement included in the SQL code files, so as to obtain a feature data set. For each SQL statement, several features may be extracted and placed in a feature dataset.
Furthermore, one SQL statement includes a plurality of nodes, and an abstract syntax tree may be specifically constructed according to the SQL statement, so as to determine each node in the SQL statement. The characteristics of each node can be extracted in advance, the node is stored in a characteristic data set as a completion prompt item, and meanwhile, the characteristics of the node are used as preset characteristics of the completion prompt item.
In practical application, the content of a node includes a node type and a node value, and accordingly, the completion prompt corresponding to the node also has a corresponding node type and a corresponding node value. For example, the node type may be a keyword, a function, a variable, a character string, a number, etc., and the value of the node is a value corresponding to the node type.
Step 102, determining a current node to be edited in the SQL statement, and determining the node characteristics of the current node according to the SQL statement.
For the SQL statement to be complemented, the electronic device may determine a current node to be edited in the SQL statement, where the current node is a node that is not edited, may be a node that is edited partially, or may be a node that is not edited at all, for example, a node corresponding to a position where a user is inputting a character, or a node corresponding to a position after the user has input a character.
In an optional implementation manner, an abstract syntax tree may be constructed according to the SQL statement, and then a current node to be edited is determined in the abstract syntax tree. Specifically, a leaf node corresponding to the content being edited or to be edited may be determined in the abstract syntax tree, and the leaf node may be used as the current node.
For example, when inputting an SQL statement, the character that the user wishes to input is "ABC", and when the user inputs "a", the node is the current node to be edited. For another example, after the user inputs "ABC" and also wants to input other characters, the next position of "ABC" is the current node to be edited.
Specifically, the character included in one node may be a minimum component unit in the SQL language, and may be, for example, a lingdao _ test _ table.
Further, the electronic device may determine the node characteristics of the current node to be edited in combination with the SQL statement to be complemented. The node characteristics of the current node can be determined according to the position of the current node in the SQL statement and the existing content in the SQL statement to be supplemented.
In actual application, a node before the current node can be determined according to the character sequence in the SQL statement to be complemented, so that the characteristics of the current node are determined based on the previous node. For example, if the content before the current node in the SQL statement to be complemented is "ABC", the feature of the current node may be determined according to "a BC".
For another example, an abstract syntax tree may be constructed according to the SQL statement to be complemented, and then the characteristics of the current node may be determined according to the parent node of the current node in the abstract syntax tree.
And 103, determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item.
The method provided by the disclosure determines the completion prompt item of the SQL sentence based on the SQL sentence, and also determines the completion prompt item of the SQL sentence based on the preset characteristic data set, and the preset characteristic data set is extracted from the existing complete SQL sentence, so that the current completion prompt item can be determined by using the existing complete SQL sentence, and the accuracy of the determined completion prompt item is improved.
Specifically, the preset feature data set includes a completion prompt item and preset features corresponding to the completion prompt item, and the node features of the current node and the preset features in the preset feature data set can be compared, so that K preset features similar to the node features are determined. K is a positive integer, and can be, for example, 5, 10, etc.
Further, a completion prompt corresponding to the preset feature may be determined as the completion prompt of the current node. For example, 5 similar preset features 1, 2, 3, 4, and 5 are determined in the preset feature data set according to the node feature of the current node. In the preset feature data set, a prompt item 1 corresponds to the preset feature 1, a prompt item 2 corresponds to the preset feature 2, a prompt item 3 corresponds to the preset feature 3, a prompt item 4 corresponds to the preset feature 4, and a prompt item 5 corresponds to the preset feature 5, so that the prompt item 1, the prompt item 2, the prompt item 3, the prompt item 4, and the prompt item 5 can be determined as the complete prompt item of the current node.
In actual application, the electronic device may further display a completion prompt item of the current node in the code editing interface, and specifically may display a node type and a node value included in the completion prompt item. For example, if the node type of the completion hint is table and the value is table, then "table" and "table" may be displayed.
In an alternative implementation, the node types may be displayed as corresponding icons.
Fig. 2 is a schematic interface diagram illustrating an exemplary embodiment of the present disclosure.
As shown in fig. 2, a user may input an SQL code in the interface, and a prompt box 21 may be displayed at a position of a node to be edited, and a completion prompt determined by the electronic device is displayed in the prompt box 21. Specifically, an icon 211 corresponding to the node type may be displayed, and a value 212 of the node may be displayed.
Optionally, the user may click on the value of any node, and the electronic device may display the value at the current node, thereby increasing the programming speed of the user.
The method for determining the code prompt information provided by the disclosure comprises the following steps: acquiring SQL sentences to be complemented and a preset characteristic data set; the characteristic data set comprises a completion prompt item and preset characteristics corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value; determining a current node to be edited in an SQL statement, and determining the node characteristics of the current node according to the SQL statement; and determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item. The method provided by the disclosure can determine and display the prompt item to be supplemented of the SQL sentence by combining the preset characteristic data set and the content of the SQL sentence to be supplemented, so that the more accurate prompt item to be supplemented can be determined, and the programming efficiency of a user is improved.
Fig. 3 is a flowchart illustrating a method for determining code hint information according to another exemplary embodiment of the present disclosure.
As shown in fig. 3, the method for determining code hint information provided by the present disclosure includes:
301, acquiring an SQL statement to be complemented and a preset characteristic data set; the feature data set comprises a completion prompt item and preset features corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value.
Step 301 is similar to the implementation of step 101, and is not described again.
Step 302, an abstract syntax tree corresponding to the SQL statement is generated.
AST (Abstract Syntax Tree), an Abstract representation of the Syntax structure of the source code. It represents the syntactic structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code. The incidence relation among all nodes in the SQL statement can be determined through the abstract syntax tree, so that more comprehensive and more accurate node characteristics can be extracted by utilizing the abstract syntax tree.
The method for generating the abstract syntax tree can adopt the existing scheme in the prior art.
Step 303, determining a current node to be edited in the SQL statement.
Step 303 is similar to the manner of determining the current node in step 102, and is not described again.
And step 304, determining the node characteristics of the current node according to the abstract syntax tree of the SQL statement.
Specifically, the abstract syntax tree includes a plurality of nodes, and the nodes include the current node. Since the current node is a node that has not been edited, the content of the current node in the abstract syntax tree may be empty or may be a part of the edited content.
Furthermore, each node in the abstract syntax tree has a parent-child relationship, and the characteristics of the current node can be extracted according to the parent node of the current node and can also be extracted according to the parent node of the parent node.
In actual application, the electronic device may determine first information of a parent node of a current node according to an abstract syntax tree of an SQL statement; and/or determining second information of parallel nodes parallel to the father node according to the abstract syntax tree of the SQL statement; and/or determining third information of a root node of the abstract syntax tree of the SQL statement.
Wherein the node characteristics of the current node include at least one of:
the first information, the second information and the third information.
Specifically, the parent node of the current node can be determined through the abstract syntax tree, and the parent node of the parent node can also be determined. In the solution provided by the present disclosure, a child node may be inferred by using a parent node in an abstract syntax tree, and when the child node is a current node, the content of the current node may be predicted by using the parent node of the current node.
In an alternative implementation, the electronic device may determine the first information of the parent node of the current node according to an abstract syntax tree of the SQL statement. So that the content of the current node can be predicted using the information of the parent node.
The first information may include at least one of: a type of a parent node of the current node; sequencing the current node in a father node; parent node ordering in its parent node.
For example, if there is a current node Token i having a parent node Token j, the type of Token j may be used as the first information of Token j, the order of Token i in Token j may also be used as the first information of Token j, and if the parent node Token j also has a parent node Token k, the order of Token j in Token k may also be determined as the first information of Token j.
In an optional implementation manner, the electronic device may further determine, according to an abstract syntax tree of the SQL statement, second information of a parallel node that is parallel to the parent node. So that the contents of the current node can be predicted using the information of the parallel nodes parallel to the parent node.
The second information includes at least one of: a type of left node juxtaposed to a parent node; the value of the left node in parallel with the parent node; a type of a right node juxtaposed to the parent node; the value of the right node juxtaposed to the parent node.
Parallel nodes can be included in the abstract syntax tree, and child nodes belonging to the same father node are parallel nodes. For example, node A has two child nodes A1 and A2, then A1 and A2 are the nodes in parallel. By extracting the information of the parallel node, the content of the current node can be predicted using the information of the node parallel to the parent node of the current node.
For example, if there is a current node Token i having a parent node Token j having a juxtaposed left node Token left and a Token right, information of Token left and Token right may be determined as second information of the juxtaposed node juxtaposed to the parent node.
In an alternative implementation, the electronic device may further determine third information of a root node of an abstract syntax tree of the SQL statement.
In practical applications, the abstract syntax tree includes a plurality of nodes, and one abstract syntax tree has one root node, for example, parent nodes of the nodes can be traversed one by one in the abstract syntax tree, and finally the root node without the parent node is determined.
Wherein the third information comprises a type of the root node and/or a value of the root node. By extracting the information of the root node, the content of the current node can be predicted by using the information of the root node of the current node.
Specifically, the scheme provided by the disclosure can acquire the first information, the second information and the third information, so that the node characteristics of the current node can be accurately determined by using the information of each node which has a closer association relation with the current node.
Step 305, determining the node type of the previous node of the current node and the value of the previous node of the current node according to the SQL statement; wherein the node characteristics of the current node include a node type of the previous node, and a value of the previous node.
In actual application, the SQL statement includes a plurality of nodes, and each node has a front-back relationship. For example, in the SQL statement "select from table t where t.p _ code ═ a'", a plurality of character strings are included, and each character string has a front-back relationship, so that the node characteristics of the current node can be determined according to the contents of other nodes before the current node.
The node features extracted in this way may include the node type of the previous node, and the value of the previous node. For example, the type of the node preceding the current node may be a table and the value may be a table.
It should be noted that the parent node of the current node is determined based on the abstract syntax tree, the previous node of the current node is determined according to the sequence of the character strings in the SQL statement to be complemented, and the previous node of the same current node is not necessarily the same as the parent node.
Step 304 and step 305 may be executed simultaneously, and the execution order of the two steps is not limited.
And step 306, determining K preset characteristics close to the node characteristics in the characteristic data set.
Furthermore, the feature data set comprises completion promoting items and preset features thereof, and the electronic device can compare the node features of the current node with the preset features in the feature data set and determine K preset features closest to the node features.
In actual application, the similarity between the node features and each preset feature can be calculated, so that the K preset features with the highest similarity are screened out.
For example, the extracted node feature of the current node may be an N-dimensional vector, and accordingly, the preset feature in the feature data set is also an N-dimensional vector. Similarity between the node features and each preset feature can be determined based on a KNN (K-nearest neighbor ) algorithm, and then K preset features similar to the node features can be screened out.
And 307, determining the completion prompt items corresponding to the K preset features as completion prompt items for completing the current node, and displaying the node type and the node value included in the completion prompt items of the current node.
The completion promoting items in the feature data set have a corresponding relation with preset features, and after the K preset features are screened out, the electronic equipment can determine the completion promoting items corresponding to the preset features as the completion promoting items of the current node.
Specifically, the screened preset features are relatively close to the node features, so that the content of the completion prompt item corresponding to the preset features is considered to be relatively close to the content of the current node desired to be input by the user, and therefore, the completion prompt item corresponding to the screened preset features can be used as the completion prompt item of the current node.
Further, the node type and the node value included in the completion prompt item of the current node may be displayed, so that the user can select any one of the completion prompt items, and the electronic device can display the value included in the completion prompt item in the interface, so as to improve the programming efficiency of the user.
Fig. 4 is a flowchart illustrating a method for determining a feature data set according to an exemplary embodiment of the present disclosure.
As shown in fig. 4, the present disclosure provides a method for determining a feature data set, including:
step 401, a document comprising an SQL statement is obtained.
The existing SQL files can be integrated to obtain a document comprising a large number of SQL statements, the document comprising the large number of SQL statements is processed, and the features of the SQL statements are extracted, so that a feature data set is obtained.
The SQL files can be written by different personnel, and for each SQL statement, a plurality of features can be extracted and then put into a feature data set.
Step 402, determining a plurality of nodes in the SQL statement, and determining the node characteristics of the nodes according to the SQL statement.
The SQL statements in the document are complete statements, and each SQL statement comprises a plurality of nodes.
For example, an abstract syntax tree may be constructed from the SQL statement, and then each node in the SQL statement may be determined. The features of each node can be extracted according to the SQL statement, and particularly the features of each leaf node in the SQL statement can be extracted.
For example, the node characteristics of a node may be determined from other nodes before the node, and for example, the node characteristics of the node may be determined from the parent node of the node in the abstract syntax tree.
Step 403, determining a completion prompt item according to the node, and generating a feature data set according to the completion prompt item and the node feature of the node; the feature data set comprises a completion prompt item and node features corresponding to the completion prompt item.
In practical application, the content of the node may be used as a completion prompt item, and correspondingly, the node characteristic of the node may be used as a characteristic corresponding to the completion prompt item.
The contents of a node include the node type and the node value, and accordingly, the completion hint corresponding to the node also has the corresponding node type and node value. For example, the node type may be a keyword, a function, a variable, a character string, a number, etc., and the value of the node is a value corresponding to the node type.
The node has a node characteristic and, correspondingly, the completion hint may also have the node characteristic. In this way, therefore, a feature data set can be constructed that includes the completion cue and its features.
In an alternative implementation, the feature data set determined by the present disclosure may be applied to the schemes shown in fig. 1 to 3, so as to provide a completion prompt message when the user programs based on the SQL language, so as to improve the programming efficiency of the user.
Fig. 5 is a flowchart illustrating a method of determining a feature data set according to another exemplary embodiment of the present disclosure.
As shown in fig. 5, the present disclosure provides a method for determining a feature data set, including:
step 501, obtaining a document comprising an SQL statement.
Step 501 is similar to the implementation of step 401, and is not described again.
Step 502, an abstract syntax tree corresponding to the SQL statement is generated.
AST (Abstract Syntax Tree), an Abstract representation of the Syntax structure of the source code. It represents the syntactic structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code. The incidence relation among all nodes in the SQL statement can be determined through the abstract syntax tree, so that more comprehensive and more accurate node characteristics can be extracted by utilizing the abstract syntax tree.
The method for generating the abstract syntax tree can adopt the existing scheme in the prior art.
At step 503, a plurality of leaf nodes are determined in the abstract syntax tree of the SQL statement.
The AST includes a plurality of nodes including leaf nodes. Leaf nodes can characterize the concrete variables operated on in the SQL statement, and therefore, the node characteristics of the leaf nodes in the abstract syntax tree can be determined.
A leaf node refers to a node at the end of each bifurcation in the abstract syntax tree, where each node in the abstract syntax tree has a parent-child relationship, and a leaf node has no child nodes.
FIG. 6 is a diagram illustrating the structure of an abstract syntax tree, in accordance with an illustrative embodiment.
As shown in fig. 6, a plurality of branches are included in the abstract syntax tree, and a node at the end of each branch is a leaf node, for example, nodes 61, 62, 63 are leaf nodes.
The leaf nodes in the abstract syntax tree may be traversed one by one to extract the node characteristics of each leaf node. For example, a node may be randomly acquired in the AST, and the child nodes of the node may be determined, and the determination of the child nodes may be continued until a leaf node having no child nodes is determined.
For each leaf node in the AST, a corresponding node characteristic may be determined.
Step 504, determining the node characteristics of the leaf nodes according to the abstract syntax tree of the SQL statement.
Furthermore, each node in the abstract syntax tree has a parent-child relationship, and the leaf node characteristics can be extracted according to the parent node of the leaf node and can also be extracted according to the parent node of the parent node.
Optionally, the first information of the parent node of the leaf node may be determined according to an abstract syntax tree of the SQL statement; and/or determining second information of parallel nodes parallel to the father node according to the abstract syntax tree of the SQL statement; and/or determining third information of a root node of the abstract syntax tree of the SQL statement.
Wherein, the node characteristics of the leaf node comprise any one of the following items:
the first information, the second information and the third information.
Specifically, the abstract syntax tree can be used for determining a parent node of a leaf node and a parent node of the parent node. In the solution provided by the present disclosure, a parent node of a leaf node in an abstract syntax tree may be utilized to determine a node characteristic of the leaf node.
In an alternative implementation, the electronic device may determine the first information of the parent node of one leaf node according to an abstract syntax tree of the SQL statement. So that the content of the parent node can be used to determine the characteristics of the leaf node.
Optionally, the first information includes at least one of: a type of parent node of the leaf node; sorting leaf nodes in a father node; the ordering of the parent node in its parent node.
For example, if there is a leaf node Token i in the abstract syntax tree, which has a parent node Token j, the type of Token j may be used as the first information of Token j, the order of Token i in Token j may also be used as the first information of Token j, and if the parent node Token j also has a parent node Token k, the order of Token j in Token k may also be determined as the first information of Token j.
Optionally, the electronic device may further determine, according to the abstract syntax tree of the SQL statement, second information of a parallel node that is parallel to the parent node of the leaf node. Such that leaf node characteristics may be determined using a parallel node juxtaposed to a parent node.
The second information includes at least one of: a type of left node juxtaposed to a parent node; the value of the left node juxtaposed to the parent node; a type of a right node juxtaposed to the parent node; the value of the right node juxtaposed to the parent node.
Parallel nodes can be included in the abstract syntax tree, and child nodes belonging to the same father node are parallel nodes. For example, node A has two child nodes A1 and A2, then A1 and A2 are parallel nodes. The node characteristics of a leaf node can be determined by the nodes that are juxtaposed to the parent node of the leaf node.
For example, if there is a node Token i in the abstract syntax tree, which has a parent node Token j with a parallel left node Token left and a Token right, information of Token left and Token right may be determined respectively as the second information of the parallel node parallel to the parent node.
Optionally, third information of a root node of the abstract syntax tree of the SQL statement may also be determined.
In practical applications, the abstract syntax tree includes a plurality of nodes, and one abstract syntax tree has one root node, for example, parent nodes of the nodes can be traversed one by one in the abstract syntax tree, and finally the root node without the parent node is determined.
Wherein the third information comprises a type of the root node and/or a value of the root node. The characteristics of the leaf node can be determined by the root node of the node.
Specifically, the scheme provided by the present disclosure may obtain the first information, the second information, and the third information, so as to determine the node characteristics of the leaf nodes in the abstract syntax tree by using each node having a closer association relationship with the leaf nodes.
Step 505, determining the node type of the previous leaf node of the leaf node and the value of the previous leaf node of the leaf node according to the character sequence in the SQL statement; wherein the node characteristics of a leaf node include the node type of a previous leaf node, and the value of the previous leaf node.
In another implementation, the node characteristics of the leaf nodes may also be determined according to the character strings included in the SQL statements.
The SQL statement comprises a plurality of nodes, and each node has a front-back position relationship. For example, in the SQL statement "select from table t where t.p _ code" a' ", a plurality of character strings are included, and each character string has a front-back relationship, so that the contents of other leaf nodes before the leaf node can be determined according to the position of the leaf node in the SQL statement, and the node feature of the leaf node can be determined.
In an optional implementation manner, a leaf node may be determined in the AST, and a leaf node corresponding to a character content before the leaf node in the AST may be determined according to a character order in an SQL statement, so as to obtain another leaf node before one leaf node.
The node features extracted in this way may include the node type of the previous leaf node, and the value of the previous leaf node, among others. For example, the type of the leaf node preceding one leaf node may be a table, and the value may be a table.
It should be noted that the parent node of the leaf node is determined based on the parent-child relationship between the nodes in the abstract syntax tree, the previous node of the leaf node is determined according to the sequence of the characters in the SQL statement, and the previous node of the same node is not necessarily the same as the parent node.
Step 504 and step 505 can be executed simultaneously, and the execution order of the two steps is not limited.
Step 506, the type and value of the node are determined as the completion prompt item.
Step 507, generating a characteristic data set according to the completion promoting item and the node characteristics of the nodes; wherein the feature data set comprises completion promoting items and node features of the completion promoting items.
After the characteristics of the node are extracted, the type and the value of the node can be determined as a completion prompt item, the node characteristics of the node are used as preset characteristics corresponding to the completion prompt item, and the completion prompt item and the preset characteristics corresponding to the completion prompt item can be stored in a characteristic data set.
By this implementation, a feature dataset including the completion hint item and the node features of the completion hint item can be obtained.
Fig. 7 is a block diagram illustrating a code hint information determination apparatus according to an exemplary embodiment of the present disclosure.
As shown in fig. 7, the apparatus 700 for determining code hint information provided by the present embodiment includes:
an obtaining unit 710, configured to obtain an SQL statement to be complemented and a preset feature data set; the feature data set comprises a completion prompt item and preset features corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value;
a determining unit 720, configured to determine a current node to be edited in the SQL statement, and determine a node feature of the current node according to the SQL statement;
and the prompt unit 730 is configured to determine a completion prompt item for completing the current node according to the node feature and the preset feature, and display a node type and a node value included in the completion prompt item.
The device for determining the code prompt information can determine and display the prompt item to be supplemented of the SQL sentence by combining the preset characteristic data set and the content of the SQL sentence to be supplemented, so that the more accurate prompt item to be supplemented can be determined, and the programming efficiency of a user is improved.
Fig. 8 is a block diagram illustrating a code presentation information determination apparatus according to another exemplary embodiment of the present disclosure.
As shown in fig. 8, the apparatus 800 for determining code hint information provided in this embodiment further includes a tree generating unit 740, configured to generate an abstract syntax tree corresponding to the SQL statement;
the determining unit 720 includes:
a first determining module 721, configured to determine a node characteristic of the current node according to the abstract syntax tree of the SQL statement.
Optionally, the determining unit 720 includes:
a second determining module 722, configured to determine, according to the SQL statement, a node type of a node previous to the current node and a value of the node previous to the current node; wherein the node characteristics of the current node include a node type of a previous node, and a value of the previous node.
Optionally, the first determining module 721 is specifically configured to:
determining first information of a father node of the current node according to the abstract syntax tree of the SQL statement;
and/or determining second information of parallel nodes parallel to the father node according to the abstract syntax tree of the SQL statement;
and/or determining third information of a root node of the abstract syntax tree of the SQL statement;
wherein the node characteristics of the current node include at least one of:
the first information, the second information and the third information.
Optionally, the first information includes at least one of:
a type of a parent node of the current node;
the current node's ranking at the parent node;
the parent node's ranking in its parent node;
the second information includes at least one of:
a type of left node juxtaposed to the parent node;
a value of a left node juxtaposed to the parent node;
a type of a right node juxtaposed to the parent node;
a value of a right node juxtaposed to the parent node;
the third information includes a type of the root node and/or a value of the root node.
Optionally, the prompting unit 730 includes:
a screening module 731, configured to determine K preset features similar to the node features in the feature data set;
a prompt module 732, configured to determine a completion prompt item corresponding to the K preset features as a completion prompt item for completing the current node.
Fig. 9 is a block diagram illustrating a feature data set determination apparatus according to an exemplary embodiment of the present disclosure.
As shown in fig. 9, the apparatus 900 for determining code hint information provided by the present embodiment includes:
a document acquiring unit 910, configured to acquire a document including an SQL statement;
a feature extraction unit 920, configured to determine multiple nodes in the SQL statement, and determine node features of the nodes according to the SQL statement;
a set generating unit 930, configured to determine a completion prompt item according to the node, and generate the feature data set according to the completion prompt item and the node feature of the node; wherein the feature data set comprises a completion prompt item and a node feature corresponding to the completion prompt item.
Fig. 10 is a block diagram illustrating a characteristic data set determination apparatus according to another exemplary embodiment of the present disclosure.
As shown in fig. 10, in the apparatus 1000 for determining code hint information provided in this embodiment, the node is a leaf node;
the apparatus further comprises a tree generation unit 940 for:
generating an abstract syntax tree corresponding to the SQL statement;
the feature extraction unit 920 includes:
a node determining module 921, configured to determine a plurality of leaf nodes in an abstract syntax tree of the SQL statement;
the first feature extraction module 922 is configured to determine node features of the leaf nodes according to the abstract syntax tree of the SQL statement.
Optionally, the nodes include leaf nodes in an abstract syntax tree corresponding to the SQL statement;
the feature extraction unit 920 includes a second feature extraction module 923:
determining the node type of a leaf node before the leaf node and the value of the leaf node before the leaf node according to the character sequence in the SQL statement; wherein the node characteristics of the leaf node include a node type of a previous leaf node, and a value of the previous leaf node.
The optional first feature extraction module 922 is specifically configured to:
determining first information of a father node of the leaf node according to the abstract syntax tree of the SQL statement;
and/or determining second information of parallel nodes parallel to the father node according to the abstract syntax tree of the SQL statement;
and/or determining third information of a root node of the abstract syntax tree of the SQL statement;
wherein the node characteristics of the leaf node include any one of:
the first information, the second information and the third information.
Optionally, the first information includes at least one of:
a type of a parent node of the leaf node;
the ordering of the leaf nodes at the parent node;
the parent node's ranking in its parent node;
the second information includes at least one of:
a type of left node juxtaposed to the parent node;
a value of a left node juxtaposed to the parent node;
a type of a right node juxtaposed to the parent node;
a value of a right node juxtaposed to the parent node;
the third information includes a type of the root node and/or a value of the root node.
Optionally, the set generating unit 930 is specifically configured to determine the type and the value of the node as the content of the completion prompt.
Fig. 11 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
As shown in fig. 11, the electronic device provided in this embodiment includes:
a memory 111;
a processor 112; and
a computer program;
wherein the computer program is stored in the memory 111 and configured to be executed by the processor 112 to implement any of the code hint information determination methods or feature data set determination methods described above.
The present embodiments also provide a computer-readable storage medium, having stored thereon a computer program,
the computer program is executed by a processor to implement any of the code hint information determination methods or feature data set determination methods described above.
The present embodiment also provides a computer program, which includes a program code, and when the computer runs the computer program, the program code executes any one of the above methods for determining code hint information or determining a feature data set.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present disclosure, and not for limiting the same; while the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art will understand that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present disclosure.

Claims (14)

1. A method for determining code hint information, comprising:
acquiring SQL sentences to be complemented and a preset characteristic data set; the feature data set comprises a completion prompt item and a preset feature corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value;
determining a current node to be edited in the SQL statement, and determining the node characteristics of the current node according to the SQL statement;
and determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item.
2. The method of claim 1, further comprising:
generating an abstract syntax tree corresponding to the SQL statement;
the determining the node characteristics of the current node according to the SQL statement comprises the following steps:
and determining the node characteristics of the current node according to the abstract syntax tree of the SQL statement.
3. The method of claim 1, wherein said determining node characteristics of said current node from said SQL statement comprises:
determining the node type of the previous node of the current node and the value of the previous node of the current node according to the SQL statement; wherein the node characteristics of the current node include a node type of a previous node, and a value of the previous node.
4. The method of claim 2, wherein determining the node characteristic of the current node from the abstract syntax tree of the SQL statement comprises:
determining first information of a father node of the current node according to the abstract syntax tree of the SQL statement;
and/or determining second information of parallel nodes parallel to the father node according to the abstract syntax tree of the SQL statement;
and/or determining third information of a root node of the abstract syntax tree of the SQL statement;
wherein the node characteristics of the current node include at least one of:
the first information, the second information and the third information.
5. The method of claim 4,
the first information includes at least one of:
a type of a parent node of the current node;
the current node's ranking at the parent node;
the parent node's ranking in its parent node;
the second information includes at least one of:
a type of left node juxtaposed to the parent node;
a value of a left node juxtaposed to the parent node;
a type of a right node juxtaposed to the parent node;
a value of a right node juxtaposed to the parent node;
the third information includes a type of the root node and/or a value of the root node.
6. The method according to any one of claims 1, 2, 4 and 5, wherein the determining a completion prompt for completing the current node according to the node feature and the preset feature comprises:
k preset features close to the node features are determined in the feature data set;
and determining the completion prompt items corresponding to the K preset characteristics as completion prompt items for completing the current node.
7. A method of determining a feature data set, comprising:
acquiring a document comprising SQL statements;
determining a plurality of nodes in the SQL statement, and determining the node characteristics of the nodes according to the SQL statement;
determining a completion prompt item according to the node, and generating the feature data set according to the completion prompt item and the node feature of the node; wherein the feature data set comprises a completion prompt item and a node feature corresponding to the completion prompt item.
8. The method of claim 7, wherein the node is a leaf node;
the method further comprises the following steps:
generating an abstract syntax tree corresponding to the SQL statement;
the determining a plurality of nodes in the SQL statement and determining the node characteristics of each node according to the SQL statement comprises the following steps:
determining a plurality of leaf nodes in an abstract syntax tree of the SQL statement;
and determining the node characteristics of the leaf nodes according to the abstract syntax tree of the SQL statement.
9. The method of claim 7, wherein the nodes comprise leaf nodes in an abstract syntax tree corresponding to the SQL statement;
determining the node characteristics of each node according to the SQL statement comprises the following steps:
determining the node type of a leaf node before the leaf node and the value of the leaf node before the leaf node according to the character sequence in the SQL statement; wherein the node characteristics of the leaf node include a node type of a previous leaf node, and a value of the previous leaf node.
10. The method of claim 8, wherein determining node characteristics of the leaf nodes from the abstract syntax tree of the SQL statement comprises:
determining first information of a father node of the leaf node according to the abstract syntax tree of the SQL statement;
and/or determining second information of parallel nodes parallel to the father node according to the abstract syntax tree of the SQL statement;
and/or, determining third information of a root node of the abstract syntax tree of the SQL statement;
wherein the node characteristics of the leaf node include any one of:
the first information, the second information and the third information.
11. The method of claim 10, wherein the first information comprises at least one of:
a type of parent node of the leaf node;
the ordering of the leaf nodes at the parent node;
the parent node's ranking in its parent node;
the second information includes at least one of:
a type of a left node juxtaposed to the parent node;
a value of a left node juxtaposed to the parent node;
a type of a right node juxtaposed to the parent node;
a value of a right node juxtaposed to the parent node;
the third information includes a type of the root node and/or a value of the root node.
12. An apparatus for determining a code hint, comprising:
the acquiring unit is used for acquiring SQL sentences to be complemented and a preset characteristic data set; the feature data set comprises a completion prompt item and preset features corresponding to the completion prompt item, and the completion prompt item comprises a node type and a node value;
the determining unit is used for determining a current node to be edited in the SQL statement and determining the node characteristics of the current node according to the SQL statement;
and the prompting unit is used for determining a completion prompt item for completing the current node according to the node characteristics and the preset characteristics, and displaying the node type and the node value included in the completion prompt item.
13. An apparatus for determining a feature data set, comprising:
a document acquisition unit configured to acquire a document including an SQL statement;
the characteristic extraction unit is used for determining a plurality of nodes in the SQL statement and determining the node characteristics of the nodes according to the SQL statement;
the set generating unit is used for determining a completion prompt item according to the node and generating the feature data set according to the completion prompt item and the node feature of the node; wherein the feature data set comprises a completion prompt item and a node feature corresponding to the completion prompt item.
14. An electronic device, comprising:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any of claims 1-11.
CN202210314942.1A 2022-03-28 2022-03-28 Code prompt information determining method, data set determining method and electronic equipment Pending CN114676155A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210314942.1A CN114676155A (en) 2022-03-28 2022-03-28 Code prompt information determining method, data set determining method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210314942.1A CN114676155A (en) 2022-03-28 2022-03-28 Code prompt information determining method, data set determining method and electronic equipment

Publications (1)

Publication Number Publication Date
CN114676155A true CN114676155A (en) 2022-06-28

Family

ID=82076656

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210314942.1A Pending CN114676155A (en) 2022-03-28 2022-03-28 Code prompt information determining method, data set determining method and electronic equipment

Country Status (1)

Country Link
CN (1) CN114676155A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117632106A (en) * 2023-11-21 2024-03-01 广州致远电子股份有限公司 Code complement method, device, equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117632106A (en) * 2023-11-21 2024-03-01 广州致远电子股份有限公司 Code complement method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
US10558754B2 (en) Method and system for automating training of named entity recognition in natural language processing
CN109240901B (en) Performance analysis method, performance analysis device, storage medium, and electronic apparatus
JP2005537532A (en) Comprehensive development tool for building natural language understanding applications
US11301643B2 (en) String extraction and translation service
CN111562920A (en) Method and device for determining similarity of small program codes, server and storage medium
US8122431B2 (en) Device for processing formally defined data
CN111191429A (en) System and method for automatic filling of data table
CN113419721B (en) Web-based expression editing method, device, equipment and storage medium
CN114676155A (en) Code prompt information determining method, data set determining method and electronic equipment
JP5780036B2 (en) Extraction program, extraction method and extraction apparatus
CN113297251A (en) Multi-source data retrieval method, device, equipment and storage medium
US11036478B2 (en) Automated determination of transformation objects
JP5447368B2 (en) NEW CASE GENERATION DEVICE, NEW CASE GENERATION METHOD, AND NEW CASE GENERATION PROGRAM
KR101835994B1 (en) Method and apparatus of providing searching service for electronic books
CN115098365A (en) SQL code debugging method and device, electronic equipment and readable storage medium
CN112698831B (en) Code automatic generation quality evaluation method
US11074401B2 (en) Merging delta object notation documents
CN113919352A (en) Database sensitive data identification method and device
CN117389541B (en) Configuration system and device for generating template based on dialogue retrieval
CN109739835A (en) A kind of versions of data store method and device
CN109710844A (en) The method and apparatus for quick and precisely positioning file based on search engine
US20240086640A1 (en) Method, system, and computer readable storage media for transcript analysis
JP6703698B1 (en) Information provision system
MARGARIDO HANDLING CHANGE IN A PRODUCTION TASKBOT
JP2016095723A (en) Correspondence information creation program, correspondence information creation device, and correspondence information creation method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination