CN108008947B - Intelligent prompting method and device for programming statement, server and storage medium - Google Patents

Intelligent prompting method and device for programming statement, server and storage medium Download PDF

Info

Publication number
CN108008947B
CN108008947B CN201711422594.5A CN201711422594A CN108008947B CN 108008947 B CN108008947 B CN 108008947B CN 201711422594 A CN201711422594 A CN 201711422594A CN 108008947 B CN108008947 B CN 108008947B
Authority
CN
China
Prior art keywords
statement
programming
information
grammar
prompting
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.)
Active
Application number
CN201711422594.5A
Other languages
Chinese (zh)
Other versions
CN108008947A (en
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.)
Shanghai Dameng Database Co Ltd
Original Assignee
Shanghai Dameng Database Co 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 Shanghai Dameng Database Co Ltd filed Critical Shanghai Dameng Database Co Ltd
Priority to CN201711422594.5A priority Critical patent/CN108008947B/en
Publication of CN108008947A publication Critical patent/CN108008947A/en
Application granted granted Critical
Publication of CN108008947B publication Critical patent/CN108008947B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses an intelligent prompting method and device for a programming statement, a server and a storage medium. The method comprises the following steps: acquiring an input programming statement; analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information associated with the programming statement; and generating prompt content according to the statement information and the state set information. The technical scheme provided by the embodiment of the invention can ensure that the corresponding state set information can be found no matter what position the current programming statement is input to, so that a corresponding prompt is given, developers can write complex programming statements conveniently, and the user experience is improved. In addition, because the grammar parsing module is adopted, no matter how complex and deep the sentence hierarchical relation is, accurate prompt information can be provided.

Description

Intelligent prompting method and device for programming statement, server and storage medium
Technical Field
The invention relates to the technical field of computers, in particular to an intelligent prompting method and device for programming statements, a server and a storage medium.
Background
With the development of computers and databases in recent years, a computer programming language dedicated to a database, SQL (structured Query language), has been widely used. With the upgrading of the SQL version, the intelligent prompt function is added, and the primary database objects such as table names, view names, function names and the like can be prompted.
However, currently, the SQL on the market is relatively incomplete in prompting secondary database objects such as columns in table objects, parameters of functions, and the like. In addition, if the SQL statement is complex, it is not prompted when the SQL statement is input to any position, for example, the SQL developer tool of oracle cannot prompt the column in the sub-query.
Disclosure of Invention
The embodiment of the invention provides an intelligent prompting method and device for programming statements, a server and a storage medium, which can give effective prompts, greatly facilitate developers to write complex programming statements and improve user experience.
In a first aspect, an embodiment of the present invention provides an intelligent prompting method for a programming statement, where the method includes:
acquiring an input programming statement;
analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information associated with the programming statement;
and generating prompt content according to the statement information and the state set information.
In a second aspect, an embodiment of the present invention further provides an intelligent prompting device for programming a statement, where the device includes:
the statement acquisition module is used for acquiring the input programming statement;
the information acquisition module is used for analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information which are associated with the programming statement;
and the prompt content generation module is used for generating prompt content according to the statement information and the state set information.
In a third aspect, an embodiment of the present invention further provides a server, where the server includes:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the method for intelligent prompting of programming statements of any of the first aspects.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the intelligent prompting method for programming statements according to any of the first aspects.
According to the intelligent prompting method, device, server and storage medium for the programming statement, provided by the embodiment of the invention, the programming statement input by a user is analyzed by adopting the grammar analyzer to obtain statement information and state set information associated with the programming statement, and the prompting content corresponding to the programming statement can be obtained according to the statement information and the state set information. The method can ensure that the corresponding state set information can be found no matter where the current programming statement is input, so that corresponding prompt is given, developers can write complex programming statements conveniently, and user experience is improved.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
FIG. 1 is a flowchart of a method for intelligently prompting a programming statement according to a first embodiment of the present invention;
FIG. 2 is a partial state diagram illustration provided in accordance with a first embodiment of the present invention;
fig. 3 is a flowchart of an intelligent prompting method for programming statements provided in the second embodiment of the present invention;
fig. 4 is a schematic diagram of a state sequence in a traversal state diagram provided in the third embodiment of the present invention;
fig. 5 is a block diagram of an intelligent prompting device for programming statements provided in the fourth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a server provided in the fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some but not all of the relevant aspects of the present invention are shown in the drawings.
Example one
Fig. 1 is a flowchart of an intelligent prompting method for a programming statement according to an embodiment of the present invention, which is applicable to a case where a user gives a corresponding prompt to an input programming statement when programming. The method can be executed by the intelligent prompting device/server/computer readable storage medium of the programming statements provided by the embodiment of the invention, and the device/server/computer readable storage medium can be realized in a software and/or hardware manner. Referring to fig. 1, the method specifically includes:
and S110, acquiring the input programming statement.
The programming statement is a statement input by a user on a programming software interface, and for a database language, the programming statement may include: c + +, JAVA or SQL statements, etc. SQL is a special purpose programming language, a database query and programming language, used to access data and query, update, and manage a relational database system, and is also an extension of a database script file, and therefore, the SQL statement is preferred in this embodiment.
And S120, analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information associated with the programming statement.
The grammar parser is used for parsing the programming sentences input by the user; the statement information is information contained in the statement input by the user on the programming interface, is important auxiliary information of the intelligent prompt, and can comprise information such as the type and name of the statement; the statement input by the current user is called a state, and the state set information is a set of all possible next states of the currently input program statement, namely, the state in the state set information comprises at least one state.
The existing intelligent prompting method for the programming statements is not based on grammar rules of the selected programming language, and only can prompt object information of simple statements in a database to cause incomplete prompting contents, so that in order to accurately analyze any statement input by a user at any position to enable the prompting contents to be more comprehensive and complete, a grammar analyzer is constructed based on the grammar rules of the programming language and a finite state machine principle. For example, before obtaining the input programming statement, the parser may be constructed using the following operations: generating a grammar rule file according to a basic grammar rule of a programming language and an input file format; inputting the grammar rule file into a parser generator to generate a grammar parser; and adding the finite state machine principle into the parser to obtain the parser.
The basic syntax rules of a programming language are rules that a programming statement must comply with when a program is written in a certain programming language. When the database is programmed, SQL statements are preferred, and the basic grammar rules of the corresponding programming language are the basic grammar of the SQL statements. The syntax analyzer is a program capable of analyzing the structure of the text file; the analyzer generator is a tool specially used for generating a syntax analyzer, and the analyzer generator corresponding to the SQL statement can select bison; the input file format is a file format that the parser generator can recognize, i.e., a bison input file format. The grammar rule file is a file generated according to a certain rule and a certain writing format, and if the grammar rule file is based on an actual SQL grammar rule and a bison input file format, a grammar rule file can be formulated, wherein the grammar rule file is used for describing the complete grammar of an SQL sentence and recording the information of the intermediate analysis result. After the obtained grammar rule file is input to the analyzer generator, the analyzer generator performs relevant processing on the input file to obtain a grammar analyzer, such as a grammar analyzer generated by a bison program according to the grammar rule file describing SQL grammar.
In order to be able to provide the user with a more comprehensive prompt, it is necessary to determine all possible next states of the currently entered programming statement, and the present embodiment introduces the finite state machine principle on the basis of the parser. Finite state machine principles are mathematical models representing a finite number of states and the behavior of transitions and actions between these states. The finite state machine principle is added into the parser, so that the parser is realized through the finite state machine principle inside the parser, and the condition of the next possible occurrence can be predicted according to the acquired set of all the possible next occurrence states of the currently input programming statement.
Illustratively, parsing the programming statement by using the parser to obtain statement information and state set information may include: analyzing the programming statement according to a syntax analyzer to obtain statement information, wherein the statement information comprises at least one of the type of the statement, a database object contained in the statement, a mapping relation between the database object and an alias, a sub-query, a filtering condition and a query column; and acquiring a set of all possible next states of the programming statement as state set information according to the state diagram in the syntax parser. The filtering condition may be a where filtering condition.
For example, a piece of content in the grammar rule file generated based on the basic grammar rules of the SQL statements and the bison input file format is as follows:
Figure BDA0001523363470000061
correspondingly, the state diagram of the finite state machine principle and the interrelationship can be represented using a partial state diagram as shown in fig. 2, the contents of each circle representing a state. By traversing the state diagram, a set of next states can be obtained.
For example: if the current input state is KW _ SELECT, then the next state obtained by parsing with the parser is: {' }; if the current state is tv _ name, then parsing by the parser obtains the next state: { KW _ AS, alias, ')', KW _ WHERE }; if the current state is KW _ WHERE, the next state is obtained by parsing through the grammar parser: { exp }.
And S130, generating prompt contents according to the statement information and the state set information.
The prompt content is a prompt of a code corresponding to a programming statement, and can be used for prompting a user of statement content which should be written next. After the statement information and the state set information corresponding to the currently input programming statement are acquired, corresponding prompt contents can be given according to a certain rule. Illustratively, the prompting content can be given by an intelligent prompting module, and the intelligent prompting module is a tool specially used for carrying out integration analysis on input content. After the statement information and the state set information are input into the intelligent prompting module, the intelligent prompting module integrates the input statement information and the state set information and outputs corresponding prompting contents.
According to the intelligent prompting method for the programming statement, provided by the embodiment of the invention, the programming statement input by a user is analyzed by adopting the grammar analyzer to obtain statement information and state set information associated with the programming statement, and the prompting content corresponding to the programming statement can be obtained according to the statement information and the state set information. The method can ensure that the corresponding state set information can be found no matter where the current programming statement is input, so that corresponding prompt is given, developers can write complex programming statements conveniently, and user experience is improved. In addition, because the grammar parsing module is adopted, no matter how complex and deep the sentence hierarchical relation is, accurate prompt information can be provided.
Example two
Fig. 3 is a flowchart of an intelligent prompting method for programming a statement according to a second embodiment of the present invention, and in this embodiment, based on the second embodiment, the generation of a prompting content according to statement information and state set information is further optimized. Specifically, referring to fig. 3, the method includes:
s310, acquiring the input programming statement.
S320, analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information associated with the programming statement.
S330, acquiring a prompting method corresponding to each state in the state set information.
The prompting method is a method for giving prompting content based on a certain rule. Each state in the grammar resolver corresponds to a respective prompting method in the intelligent prompting module, namely different states correspond to different prompting methods. The state in the state set information includes at least one state.
And S340, querying a database by combining the statement information according to a prompting method to generate prompting contents.
Specifically, when only one state is in the state set information, the corresponding prompt method can be called according to the state, complete and accurate prompt contents are obtained by querying the database, and finally the prompt contents are output. If a set of states is input, the prompt content of each state in the set is acquired and integrated into a list form to be output together.
Illustratively, according to the prompting method, querying the database in combination with the statement information, and generating the prompting content may include: inquiring a database by combining statement information according to a prompting method to obtain a prompting data set; and integrating the prompt data set to generate prompt contents. Wherein, the prompt data set is all data for generating corresponding prompt content.
To facilitate statistical analysis by the intelligent prompt module, all states are classified into two types: one is a Keyword (KW), and the corresponding prompt content is the keyword itself. For example, KW _ SELECT corresponds to keyword SELECT, KW _ WHERE corresponds to keyword WHERE, and the like.
The other is a database object, which refers to a schema, table, view, index, system, function, etc. The prompt of the database object needs to be connected to the database first, and the name of the database object of the corresponding type is inquired from the database. The database object may be library-level, schema-level, or table-level, and may be implemented according to a particular state.
Further taking the states shown in fig. 2 as an example, the prompting method state corresponding to each state is as follows: KW _ FROM: the beginning of KW _ is a keyword, and the prompting content is the keyword 'FROM'; state tv _ name: the state represents the table name, and the prompt content is the name of all database table objects in the database; state exp: exp here is a where condition, since the parser has parsed the lookup table object in the statement, if there is an alias, it has also parsed the mapping relationship between the table object and the alias. Therefore, the corresponding hint content is all table object names obtained by the statement information and all columns of the table object. In addition, if the table object has a corresponding alias, the table name portion of the hint content is replaced with the alias of the table.
According to the intelligent prompting method for the programming statement, provided by the embodiment of the invention, the programming statement input by a user is analyzed by adopting the grammar analyzer to obtain statement information and state set information associated with the programming statement, and the prompting content corresponding to the programming statement can be obtained by searching in the database according to the prompting method corresponding to each state in the state set information. The method can ensure that all the possible state set information of the corresponding next state can be found no matter what position the current programming statement is input into, thereby giving out more comprehensive prompt content, greatly facilitating developers to write complex programming statements and improving the user experience; meanwhile, the grammar parsing module generated based on grammar rules is adopted, so that accurate prompt information can be provided no matter how complex and deep the sentence hierarchical relation is.
EXAMPLE III
The third embodiment is a preferred example provided on the basis of the above embodiments. With reference to a section of content in the grammar rule file given in the first embodiment and the partial state diagram given in fig. 2, a specific operation process is as follows:
first, a table object test is defined in the database for subsequent query operations. The table definition statement is: create table test (c1int, c2varchar (100)); the table object contains two columns c1 and c 2.
When the SQL statement input by the user on the database input interface is: "SELECT FROM" awhere ". Wherein, (select from test) is the sub-query, and a is the alias corresponding to test.
After the grammar parser parses the input SQL statement, the statement information corresponding to the statement is obtained as follows: table name test, table test corresponding to alias a, etc.; the state set information is: KW _ WHERE, the next set of states from state diagram 2 for KW _ WHERE is { exp }. The specific analysis process is the sequence of states in the sequentially traversed state diagram shown in fig. 4.
And inputting the statement information obtained by the parsing of the grammar parser and the state set information { exp } into an intelligent prompting module together, and giving prompting information after processing by a corresponding prompting method. The final hint content is as follows:
Figure BDA0001523363470000101
according to the intelligent prompting method for the programming statement, provided by the embodiment of the invention, the programming statement input by a user is analyzed by adopting the grammar analyzer to obtain statement information and state set information associated with the programming statement, and the prompting content corresponding to the programming statement can be obtained by searching in the database according to the prompting method corresponding to each state in the state set information. The method can ensure that all the possible state set information of the corresponding next state can be found no matter what position the current programming statement is input into, thereby giving out more comprehensive prompt content, greatly facilitating developers to write complex programming statements and improving the user experience; meanwhile, the grammar parsing module generated based on grammar rules is adopted, so that accurate prompt information can be provided no matter how complex and deep the sentence hierarchical relation is.
Example four
Fig. 5 is a block diagram of an intelligent prompting device for programming statements according to a fourth embodiment of the present invention, which is capable of executing an intelligent prompting method for programming statements according to any embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method. As shown in fig. 5, the apparatus may include:
a statement obtaining module 510, configured to obtain an input programming statement;
an information obtaining module 520, configured to analyze the programming statement by using a syntax parser, to obtain statement information and state set information associated with the programming statement;
and a prompt content generating module 530, configured to generate a prompt content according to the statement information and the state set information.
According to the intelligent prompting device for the programming sentences, provided by the embodiment of the invention, the programming sentences input by a user are analyzed by the grammar analyzer to obtain the sentence information and the state set information associated with the programming sentences, and the prompting contents corresponding to the programming sentences can be obtained according to the sentence information and the state set information. The method can ensure that the corresponding state set information can be found no matter where the current programming statement is input, so that corresponding prompt is given, developers can write complex programming statements conveniently, and user experience is improved.
Optionally, the apparatus may further include:
the rule file generation module is used for generating a grammar rule file according to a basic grammar rule of a programming language and an input file format before acquiring a programming statement;
the grammar analyzer generating module is used for inputting the grammar rule file into the analyzer generator to generate a grammar analyzer;
and the grammar parser generation module is used for adding the finite state machine principle into the grammar parser to obtain the grammar parser.
Illustratively, the information obtaining module 520 may be specifically configured to:
analyzing the programming statement according to a syntax analyzer to obtain statement information, wherein the statement information comprises at least one of the type of the statement, a database object contained in the statement, a mapping relation between the database object and an alias, a sub-query, a filtering condition and a query column;
and acquiring a set of all possible next states of the programming statement as state set information according to the state diagram in the syntax parser.
For example, the prompt content generation module 530 may include:
a prompting method obtaining unit, configured to obtain a prompting method corresponding to each state in the state set information;
and the prompt content generating unit is used for querying the database by combining the statement information according to the prompt method to generate the prompt content.
Optionally, the prompt content generating unit is specifically configured to:
according to the prompting method, querying a database by combining statement information to obtain a prompting data set;
and integrating the prompt data set to generate prompt contents.
EXAMPLE five
Fig. 6 is a schematic structural diagram of a server according to a fifth embodiment of the present invention. FIG. 6 illustrates a block diagram of an exemplary server 12 suitable for use in implementing embodiments of the present invention. The server 12 shown in fig. 6 is only an example, and should not bring any limitation to the function and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the server 12 is in the form of a general purpose computing device. The components of the server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
The server 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by server 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. The server 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, and commonly referred to as a "hard drive"). Although not shown in FIG. 6, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
The server 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with the device, and/or with any devices (e.g., network card, modem, etc.) that enable the server 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, the server 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 20. As shown, the network adapter 20 communicates with the other modules of the server 12 via the bus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the server 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing, such as implementing the intelligent prompting method of programming statements provided by embodiments of the present invention, by running programs stored in the system memory 28.
EXAMPLE six
The sixth embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, can implement the intelligent prompting method for any programming statement in the foregoing embodiments.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer-readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The above example numbers are for description only and do not represent the merits of the examples.
It will be understood by those skilled in the art that the modules or steps of the invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and optionally they may be implemented by program code executable by a computing device, such that it may be stored in a memory device and executed by a computing device, or it may be separately fabricated into various integrated circuit modules, or it may be fabricated by fabricating a plurality of modules or steps thereof into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts in the embodiments are referred to each other.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (7)

1. An intelligent prompting method for programming statements is characterized by comprising the following steps:
acquiring an input programming statement;
analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information associated with the programming statement;
generating prompt content according to the statement information and the state set information;
adopting a grammar parser to parse the programming statement to obtain statement information and state set information, comprising the following steps:
analyzing the programming statement according to the syntax analyzer to obtain statement information, wherein the statement information comprises at least one of statement type, database objects contained in the statement, mapping relation between the database objects and aliases, sub-queries, filtering conditions and query columns;
acquiring a set of all possible next states of the programming statement as the state set information according to the state diagram in the grammar parser;
generating prompt content according to the statement information and the state set information, wherein the prompt content comprises:
acquiring a prompt method corresponding to each state in the state set information; the prompting method is a method for giving prompting contents based on a certain rule, and different states correspond to different prompting methods;
and according to the prompting method, querying a database by combining the statement information to generate the prompting content.
2. The method of claim 1, wherein prior to obtaining the programming statement, further comprising:
generating a grammar rule file according to a basic grammar rule of a programming language and an input file format;
inputting the grammar rule file into a parser generator to generate a grammar parser;
and adding a finite state machine principle into the parser to obtain the parser.
3. The method of claim 1, wherein querying a database in conjunction with the statement information to generate the prompting content according to the prompting method comprises:
according to the prompting method, a database is queried by combining the statement information to obtain a prompting data set;
and integrating the prompt data set to generate the prompt content.
4. An intelligent prompting device for programming a sentence, comprising:
the statement acquisition module is used for acquiring the input programming statement;
the information acquisition module is used for analyzing the programming statement by adopting a grammar analyzer to obtain statement information and state set information which are associated with the programming statement;
the prompt content generation module is used for generating prompt content according to the statement information and the state set information;
the information acquisition module is specifically configured to:
analyzing the programming statement according to the syntax analyzer to obtain statement information, wherein the statement information comprises at least one of statement type, database objects contained in the statement, mapping relation between the database objects and aliases, sub-queries, filtering conditions and query columns;
acquiring a set of all possible next states of the programming statement as the state set information according to the state diagram in the grammar parser;
the prompt content generation module comprises:
a prompting method obtaining unit, configured to obtain a prompting method corresponding to each state in the state set information; the prompting method is a method for giving prompting contents based on a certain rule, and different states correspond to different prompting methods;
and the prompt content generating unit is used for querying a database by combining the statement information according to the prompt method to generate the prompt content.
5. The apparatus of claim 4, further comprising:
the rule file generation module is used for generating a grammar rule file according to a basic grammar rule of a programming language and an input file format before acquiring a programming statement;
the grammar analyzer generating module is used for inputting the grammar rule file into an analyzer generator to generate a grammar analyzer;
and the grammar parser generation module is used for adding the finite state machine principle into the grammar parser to obtain the grammar parser.
6. A server, characterized in that the server comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the smart hinting method of programming statements recited in any one of claims 1-3.
7. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a smart hinting method of a programming statement according to any one of claims 1 to 3.
CN201711422594.5A 2017-12-25 2017-12-25 Intelligent prompting method and device for programming statement, server and storage medium Active CN108008947B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711422594.5A CN108008947B (en) 2017-12-25 2017-12-25 Intelligent prompting method and device for programming statement, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711422594.5A CN108008947B (en) 2017-12-25 2017-12-25 Intelligent prompting method and device for programming statement, server and storage medium

Publications (2)

Publication Number Publication Date
CN108008947A CN108008947A (en) 2018-05-08
CN108008947B true CN108008947B (en) 2020-08-25

Family

ID=62061206

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711422594.5A Active CN108008947B (en) 2017-12-25 2017-12-25 Intelligent prompting method and device for programming statement, server and storage medium

Country Status (1)

Country Link
CN (1) CN108008947B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114328572A (en) * 2020-09-28 2022-04-12 北京鸿享技术服务有限公司 Data query method, device, system and medium based on SQL parser
CN113485715A (en) * 2021-07-30 2021-10-08 浙江大华技术股份有限公司 Code prompting method and system based on data center platform and data computing platform

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156740A (en) * 2011-04-15 2011-08-17 国都兴业信息审计系统技术(北京)有限公司 SQL (structured query language) statement processing method and system
CN105354035A (en) * 2015-11-17 2016-02-24 天津橙子科技有限公司 Method for compiling test case of web engineering
CN107239264A (en) * 2016-03-28 2017-10-10 阿里巴巴集团控股有限公司 The generation method and device of code prompt message

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156740A (en) * 2011-04-15 2011-08-17 国都兴业信息审计系统技术(北京)有限公司 SQL (structured query language) statement processing method and system
CN105354035A (en) * 2015-11-17 2016-02-24 天津橙子科技有限公司 Method for compiling test case of web engineering
CN107239264A (en) * 2016-03-28 2017-10-10 阿里巴巴集团控股有限公司 The generation method and device of code prompt message

Also Published As

Publication number Publication date
CN108008947A (en) 2018-05-08

Similar Documents

Publication Publication Date Title
Shah et al. Resolving ambiguities in natural language software requirements: a comprehensive survey
CN110633292B (en) Query method, device, medium, equipment and system for heterogeneous database
CN109582691B (en) Method and apparatus for controlling data query
US9934220B2 (en) Content revision using question and answer generation
US9122540B2 (en) Transformation of computer programs and eliminating errors
CN110502227B (en) Code complement method and device, storage medium and electronic equipment
CN110688544A (en) Method, device and storage medium for querying database
CN110554875B (en) Code conversion method and device, electronic equipment and storage medium
CN111078729B (en) Medical data tracing method, device, system, storage medium and electronic equipment
CN112560100A (en) Data desensitization method and device, computer readable storage medium and electronic equipment
CN113468204A (en) Data query method, device, equipment and medium
CN108008947B (en) Intelligent prompting method and device for programming statement, server and storage medium
CN115599386A (en) Code generation method, device, equipment and storage medium
CN116842042A (en) Universal method, device, electronic equipment and storage medium for dissimilating database
CN112182637A (en) Safety control system, method, device and storage medium
CN112905620A (en) Data query method and device, electronic equipment and storage medium
CN108932225B (en) Method and system for converting natural language requirements into semantic modeling language statements
US9720905B2 (en) Augmented text search with syntactic information
CN111475534B (en) Data query method and related equipment
EP3816814A1 (en) Crux detection in search definitions
CN114020774A (en) Method, device and equipment for processing multiple rounds of question-answering sentences and storage medium
CN113868375A (en) Data query method, device, equipment and storage medium based on structured query language
CN113468207A (en) Query method, device, equipment and storage medium
CN112948419A (en) Query statement processing method and device
CN113312373A (en) Method and equipment for analyzing data structured query statement

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
GR01 Patent grant
GR01 Patent grant