CN115576975A - Data query method, device, equipment and medium - Google Patents

Data query method, device, equipment and medium Download PDF

Info

Publication number
CN115576975A
CN115576975A CN202211223652.2A CN202211223652A CN115576975A CN 115576975 A CN115576975 A CN 115576975A CN 202211223652 A CN202211223652 A CN 202211223652A CN 115576975 A CN115576975 A CN 115576975A
Authority
CN
China
Prior art keywords
query
standard
text
sentence
user
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
CN202211223652.2A
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.)
Zhejiang Geely Holding Group Co Ltd
Zhejiang Zeekr Intelligent Technology Co Ltd
Original Assignee
Zhejiang Geely Holding Group Co Ltd
Zhejiang Zeekr Intelligent Technology 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 Zhejiang Geely Holding Group Co Ltd, Zhejiang Zeekr Intelligent Technology Co Ltd filed Critical Zhejiang Geely Holding Group Co Ltd
Priority to CN202211223652.2A priority Critical patent/CN115576975A/en
Publication of CN115576975A publication Critical patent/CN115576975A/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/2455Query execution

Abstract

The present specification provides a data query method, apparatus, device and medium, the method comprising: responding to a query instruction input by a user, and determining corresponding query text; judging whether the query text has a standard sentence structure; if so, determining a standard query sentence most similar to the query text from a preset standard query sentence library as a target standard query sentence; and determining a query code meeting the query code syntax of the database to be operated according to the data object associated with the target standard query statement and the limiting condition, and executing query operation on the database to be operated based on the query code. By the method, convenience of data query in the database by the user is improved.

Description

Data query method, device, equipment and medium
Technical Field
The present disclosure relates to the field of database storage technologies, and in particular, to a data query method, apparatus, device, and medium.
Background
With the development of storage technology, more and more databases with different advantages and disadvantages are derived, such as a relational database supporting complex queries, an attribute graph database convenient for representing multivariate relations, and the like.
In the prior art, different database query codes need to be set to query data in a database, so as to obtain a query result. Such as querying a relational database using SQL statements, querying a RDF database using SPARQL statements, querying a property graph database using Cypher statements (or Gremlin statements), etc.
However, this method of querying the database in the database language is troublesome for the user, and therefore, it is desirable to provide a simpler database query method.
Disclosure of Invention
To overcome the problems in the related art, the present specification provides a data query method, apparatus, device, and medium.
According to a first aspect of embodiments herein, there is provided a data query method, the method including:
responding to a query instruction input by a user, and determining corresponding query texts;
judging whether the query text has a standard sentence structure;
if so, determining a standard query sentence most similar to the query text from a preset standard query sentence library as a target standard query sentence; the standard query statement in the standard query statement library is associated with a data object targeted by query and a limiting condition which needs to be met by the data object;
and determining a query code meeting the query code syntax of the database to be operated according to the data object associated with the target standard query statement and a limiting condition, and executing query operation on the database to be operated based on the query code.
According to a second aspect of embodiments herein, there is provided a data query apparatus, the apparatus including:
the response module is used for responding to a query instruction input by a user and determining a corresponding query text;
the first judgment module is used for judging whether the query text has a standard sentence structure;
a first determining module, configured to determine, if the determination result is yes, a standard query sentence most similar to the query text from a preset standard query sentence library, as a target standard query sentence; wherein, the standard query statement in the standard query statement library is associated with the data object aimed at by the query and the limiting condition that the data object needs to satisfy;
and the second determining module is used for determining the query code meeting the query code syntax of the database to be operated according to the data object associated with the target standard query statement and the limiting condition, and executing query operation on the database to be operated based on the query code.
According to a third aspect of embodiments herein, there is provided a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the steps of the data query method as in any one of the embodiments provided in the first aspect.
According to a fourth aspect of embodiments herein, there is provided a computer apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor; wherein the processor is configured to perform the steps of the data query method according to any one of the embodiments provided by the first aspect.
The technical scheme provided by the embodiment of the specification can have the following beneficial effects:
in the embodiment of the description, after the query text of the user is obtained, when the query text is judged to have the standard sentence structure, the content expressed by the query text is considered to be rich, and the content which the user wants to query can be determined, so that the query text can be converted into the query code for the database to be operated under the normal condition.
However, since different users have different expression habits, when different users describe the same idea, some differences may appear in the text, such as omitting subjects, predicates, etc., or using abbreviated vocabulary, dialect vocabulary, etc., so that the result of the query with the query code determined according to the query text of the user is not accurate.
In order to improve the query precision, a plurality of standard query sentences are preset in a standard query sentence library, similarity comparison is carried out on a query text and the standard query sentences in the standard query sentence library, the most similar standard query sentences can be matched with the query text, so that query codes meeting the query code grammar of a database to be operated can be determined according to data objects associated with the most similar standard query sentences and the limiting conditions required to be met by the data objects, and then query operation is carried out on the database to be operated through the query codes. By the method, the query text of the user can be determined as the query code, so that the user can conveniently query, and meanwhile, the query precision is improved by setting the standard query sentence library associated with the data object and the limit condition which the data object needs to meet.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the specification.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of the specification.
Fig. 1 shows a flowchart of a data query method provided in an embodiment of the present specification.
Fig. 2 is a flowchart illustrating another data query method provided by an embodiment of the present specification.
Fig. 3 is a flowchart illustrating another data query method provided in an embodiment of the present specification.
Fig. 4 shows a schematic structural diagram of a data query device provided in an embodiment of the present specification.
Fig. 5 shows a schematic structural diagram of a computer device where a data query apparatus is located according to an embodiment of the present specification.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with this description. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the claims that follow.
The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present description. The word "if" as used herein may be interpreted as "at" \8230; "or" when 8230; \8230; "or" in response to a determination ", depending on the context.
The following provides a detailed description of examples of the present specification.
Fig. 1 shows a flowchart of a data query method provided by an embodiment of the present specification, and as shown in fig. 1, the method includes the following steps:
step 101, responding to a query instruction input by a user, determining a corresponding query text.
Specifically, the query instruction may be input by a user through voice or may be input by a user through typing, and the embodiment of the present specification is not limited to a specific input manner. If the query instruction is input by the user through voice (for example, in the driving process, the vehicle controller is awakened through voice, and the query text is input through voice expression), the voice can be converted into the text, so that the text obtained through conversion is determined as the query text. And if the query instruction is the text input by the user, directly determining the text input by the user as the query text.
And 102, judging whether the query text has a standard sentence structure.
Specifically, the sentence has various components, specifically: subject, predicate, object, predicate, idiom, complement. When the more components are contained in a sentence, the more abundant the sentence can be expressed. Therefore, in order to ensure that the content in the query text can express the idea of the user, it is necessary to determine whether the sentence structure of the query text can express enough content.
The preset standard statement structure is as follows: subject + predicate + object; the method can also be as follows: subject + object (predicate omitted). In the specific judgment, as long as the components in the query text are more than or equal to the components in the canonical statement structure, the query text can be considered to have the canonical statement structure.
For example: when the structure of the canonical statement is "subject + predicate + object", if the query text one is: "where air conditioner is located", wherein, through analysis, the "air conditioner" is a subject, the "is a predicate," and the "is an object, the query text is determined to have a canonical statement structure.
When the structure of the canonical statement is "fixed language + subject + predicate + object", if the query text two is: the "where the cooling switch of the air conditioner is located", the "air conditioner" is a fixed term, the "cooling switch" is a subject, the "where" is a predicate, and the "where" is an object, the query text two is determined to have a canonical statement structure.
Further, if the "cooling switch" is further analyzed as "cooling switch", then both "air conditioner" and "cooling" are determinants, the "switch" is the subject, the "yes" is the predicate, and the "where" is the object, then it is determined that the query text two has the canonical expression structure.
Step 103, if the judgment result is yes, determining a standard query sentence most similar to the query text from a preset standard query sentence library as a target standard query sentence; the standard query statement in the standard query statement library is associated with a data object targeted by the query and a limiting condition which needs to be met by the data object.
Specifically, different users have different expression modes, so that two query texts with the same meaning may be matched to different query results according to different forms of query texts expressed by each user, wherein the two query texts are different in expression sequence, different in used word and different in omitted word. Therefore, in order to improve the accuracy of the query result matched to the query text, a standard query sentence library may be preset, so that the standard query sentence most similar to the query text is determined by calculating the similarity between the query text and the standard query sentence in the standard query sentence library.
The standard query sentence library may be provided with a plurality of sentences, each of which is one standard query sentence, each of which is preset with associated "data object" and "constraint". Alternatively, the standard query sentence library may be provided with only "data objects" and "constraints", and the collocation of different "data objects" and "constraints" constitutes different standard query sentences.
For example, a standard query sentence library is provided with a plurality of sentences, each sentence is introduced as an example of a standard query sentence:
the standard query sentence set is "what is the sex of the small red", and the query text determined by the user a is "for women who are men in small red? "it should be noted that, here, the user actually omits the predicate, and the query text actually expresses" is red little male or female? "then" what the gender of small red "is the highest similarity to the query sentence of user a can be determined by the similarity. Therefore, the standard query sentence "what is the sex of reddish dot" in the standard query sentence library is determined as the target standard query sentence. Wherein, in the target standard query statement: "Small Red" is a predicate for "gender," gender "is the subject," yes "is the predicate, and" what "is the object. The data object associated with the target standard query statement is "gender", and the limiting condition to be satisfied by the data object is "small red", that is, by limiting "gender", the final query result is a result for "gender of small red" and not the gender of other people.
For another example, the standard query sentence library may be provided with only "data object" and "constraint condition", and the collocation of different "data object" and "constraint condition" constitutes different standard query sentences for introduction:
standard query statement one: the data object is: sex; the limiting conditions are as follows: reddish (name), 20 years (age). (actually expressed is what is the small red sex born in 1992.
And a standard query statement two: the data object is: age; the limiting conditions are as follows: red, woman. (actually expressed is what is the age of the small red of a female gender.
And (3) standard query statement three: data object: sex; the limiting conditions are as follows: reddish (name). (actually expressed is what the sex of the small red is).
Then, the standard query statement with the highest similarity to the query text can be determined as the standard query statement three through the similarity, and the standard query statement three is determined as the target standard query statement.
And 104, determining a query code meeting the query code syntax of the database to be operated according to the data object associated with the target standard query statement and a limiting condition, and executing query operation on the database to be operated based on the query code.
Specifically, after the target standard query statement is determined according to step 103, the target standard query statement can be converted into a query code supported by the database to be operated by determining the associated data object and the limiting condition in the target query statement, where the query code includes at least one code clause, when the target query statement is associated with the data object and the limiting condition, the data object is converted into one clause, the limiting condition is converted into another clause, and the two clauses jointly form the query code, so that the query code for querying the target standard query statement in the database to be operated can be generated, and the query operation of the user can be completed by calling the query code to perform the query operation in the database to be operated.
In the embodiment of the description, after the query text of the user is obtained, when the query text is judged to have the standard sentence structure, the content expressed by the query text is considered to be rich, and the content which the user wants to query can be determined, so that the query text can be converted into the query code for the database to be operated under the normal condition.
However, since different users have different expression habits, when different users describe the same idea, some differences may appear in the text, such as omitting subjects, predicates, etc., or using abbreviated vocabulary, dialect vocabulary, etc., so that the result of the query code determined according to the query text of the user is inaccurate.
In order to improve the query precision, a plurality of standard query sentences are preset in a standard query sentence library, similarity comparison is carried out on a query text and the standard query sentences in the standard query sentence library, the most similar standard query sentences can be matched with the query text, so that query codes meeting the query code grammar of a database to be operated can be determined according to data objects associated with the most similar standard query sentences and the limiting conditions required to be met by the data objects, and then query operation is carried out on the database to be operated through the query codes. By the method, the query text of the user can be determined as the query code, so that the user can conveniently query, and meanwhile, the query precision is improved by setting the standard query sentence library which is associated with the data object and the limit condition which the data object needs to meet.
In a possible embodiment, when the database is a plurality of different types of databases, the database to be operated is each of the plurality of different types of databases; or, the database to be operated is one of a plurality of databases of different types, and the database to be operated contains the query result of the target standard query statement.
Specifically, when the database is a plurality of different types of databases, since the syntax of the query code supported by the different types of databases is different, when the database to be operated is each of the plurality of different types of databases, the target standard query statement needs to be correspondingly converted into the query code satisfying the syntax of the query code of each database to be operated, so as to perform the query operation in the different types of databases by using different query codes.
When the database to be operated is one of the databases of different types, only the target standard query statement needs to be converted into the query code supported by the database to be operated, and the query operation is only executed in the database to be operated.
In a possible implementation, fig. 2 shows a flowchart of another data query method provided in an embodiment of the present specification, and as shown in fig. 2, when step 103 is executed to determine a standard query sentence most similar to the query text from a preset standard query sentence library, and when the standard query sentence is used as a target standard query sentence, the method specifically includes the following steps:
step 201, extracting keywords in the query text through a keyword extraction model; the keywords characterize the data objects of the user description and/or the definition of the user description.
Specifically, the keyword extraction model is obtained by training a large number of sentences as training samples, and the keyword extraction model can extract the data objects described by the user and/or the limiting conditions described by the user.
For example, the query text described by the user is determined to be: where the air conditioner switch is?
Then "air conditioner switch" is the subject, "is the predicate," which "is the object, and the keyword that can be extracted by the keyword extraction model is" air conditioner "," switch "and" which ", where" switch "is the data object described by the user," air conditioner "is the definition condition described by the user," which "is also the definition condition described by the user, that is, the definition condition that" switch "needs to satisfy in the query is" air conditioner ", and cannot be another switch (for example, a switch of a vehicle door, a switch of an audio/video, etc.), and the definition condition that needs to be satisfied is" which (can be understood as the definition of a position) "rather than the definition of how the switch is used.
Similarly, if the query text described by the user is: "where the switch is? ", then the extracted keywords are: "switch" and "where".
It should be noted that the terms of the data object and the qualifier described by the user and the data object and the qualifier associated with the standard query statement may be the same or different. The closer the user-described data object is to the set criteria of the standard query statement in the standard query statement library, the closer the user-described data object (qualifier) is to the data object (qualifier) associated with the standard query statement.
At step 202, at least one standard query sentence matching the keyword is determined from the standard query sentence library.
Specifically, the matching of the standard query statement to the keyword includes: the standard query statement includes a keyword, the standard query statement includes a word having a meaning similar to the keyword, and the standard query statement can include a meaning represented by the keyword.
Step 203, for each standard query statement in the at least one standard query statement, calculating the similarity between the standard query statement and the query text, and determining the standard query statement with the highest similarity as the target standard query statement.
Specifically, after at least one standard query statement is obtained in step 202, the standard query statement with the highest similarity can be determined by calculating the similarity between each standard query statement and the query text, and the standard query statement with the highest similarity is determined as the target standard query statement.
When there are a plurality of keywords, at least one standard query sentence may be ranked according to the number of keywords matched with the standard query sentence, and then the similarity between the top ranked (the number of matched keywords is large) standard query sentence and the query text is preferentially calculated. The embodiment of the present specification does not limit the calculation method of the similarity, and for example, the calculation may be performed according to a cosine similarity calculation formula, or a similarity result may be obtained by directly inputting a query text and a standard query statement into a model.
By extracting the key words in the query text, at least one standard query sentence can be determined in the standard query sentence library through the key words, so that similarity calculation between each standard query sentence in the standard query sentence library and the query text is not needed, and the similarity calculation amount is greatly reduced.
In a possible embodiment, after extracting the keywords in the query text through the keyword extraction model according to step 201, when the keywords are the defined conditions described by the user, after calculating the similarity between the standard query sentence and the query text, the method further includes:
and if the limiting condition described by the user does not match the limiting condition associated with the standard query statement, reducing the similarity.
Specifically, since the constraint condition described by the user is extracted according to step 201, when the similarity is calculated, the similarity result may be adjusted according to the matching degree between the constraint condition described by the user and the constraint condition associated with the standard query statement.
The description will be given by taking the calculation of the similarity by the cosine similarity calculation formula as an example:
score(q,d)=cos(θ);
wherein q refers to a currently selected standard query statement, d refers to a query text input by a user, score (q, d) represents a similarity numerical value of the standard query statement and the query text, cos (theta) refers to a cosine similarity formula obtained by substituting the standard query statement q and the query text d as two vectors (the detailed formula of the cosine similarity calculation formula can refer to the prior art, and theta is an included angle between the two vectors of the standard query statement q and the query text d).
The qualifier described by the user does not match the qualifier associated with the standard query statement, for example: the query text d of the user is: what is the age of small red? The standard query statement q is: how big is the age of the small white?
Then the user describes the qualifier as "small red", "large"; the standard query statement is qualified as "small white" and "big". It can be known that there is a case where "small red" and "small white" do not match, and therefore, after score (q, d) is obtained according to the similarity calculation formula, the similarity value of the standard query sentence q and the query text d can be reduced by setting the limited condition matching coefficient query _ boost (q).
At this time, the above formula can be characterized as:
scoee(q,d)=cos(θ)×query_boost(q);
the query _ boost (q) is less than or equal to 1, when the query _ boost (q) =1, it is described that the limitation conditions of the standard query statement q and the query text d are completely matched, when the query _ boost (q) < 1, it is described that the limitation conditions of the standard query statement q and the query text d are not matched, and when the query _ boost (q) =0, it is described that the limitation conditions of the standard query statement q and the query text d are completely different.
By further reducing the similarity of these unmatched standard query statements, the query accuracy is improved.
In one possible embodiment, before calculating the similarity between the standard query statement and the query text through step 203, the method further comprises:
and judging whether the length of the query text is greater than that of the standard query sentence. And if so, deleting the redundant vocabulary in the query text, and calculating the similarity based on the query text after the redundant vocabulary is deleted.
Specifically, if the length of the query text is too long, it is considered that the query text may include many redundant words without actual meanings, such as the linguistic words, and therefore the redundant words may be deleted. By the method, the similarity calculation can be performed based on the query text with the redundant vocabulary deleted, and the similarity calculation precision is improved.
In a possible embodiment, when there are at least two keywords with contradictory meanings in the keywords, before calculating the similarity between the standard query sentence and the query text through step 203, the method further comprises:
acquiring a historical query text of a user; setting the weight of each keyword in the at least two keywords with contradictory meanings based on the occurrence frequency of the keywords in the historical query text, so as to calculate the similarity based on the weight.
Specifically, the contradictory keywords are, for example: a refrigeration switch and a heating switch; "open" and "closed". This occurs because, when the query text is input by the user through speech and two people speak simultaneously, the query text of the identified user is: where is the cooling switch and the heating switch?
Since there are two contradictory keywords, it cannot be determined whether the user wants to know the position of the cooling switch or the position of the heating switch, and thus the query accuracy may be lowered. At this time, by acquiring the historical query text of the user, the query frequency of the user for each keyword is acquired, for example, if the user queries "where the cooling switch is located" before, then the analysis user still wants to know the position of the cooling switch, and therefore, the weight of the cooling switch is set to 1, and the weight of the heating switch is set to 0 (or the weight of the cooling switch is set to 0.6, and the weight of the heating switch is set to 0.4).
The concrete formula is as follows:
score(q,d)=cos(θ)×w boost (d);
wherein w boost(d) The weight set for the keyword in the query text is represented by setting the weight of the cooling switch to be 1 and the weight of the heating switch to be 0, and when the keyword is the cooling switch, w boost(d) =1, when the key word is a heating switch, w boost(d) =0。
For example, assume that the standard query statement q1 is: where the refrigeration switch is located; the standard query statement q2 is: where the heating switch is located.
Therefore, when the similarity score (q 1, d) between the standard query sentence q1 and the query text d is calculated, the keyword matched in the standard query sentence q1 is the "cooling switch", so that the standard query sentence q1 is used as the "cooling switch"W in the formula boost(d )=1。
When the similarity score (q 2, d) between the standard query statement q2 and the query text d is calculated, because the keyword matched in the standard query statement q2 is the 'heating switch', w in the formula boost(d) And =0. The method can enable the similarity calculation result to be more accurate. The weight setting method is not specifically limited in the embodiment of the application, and can be changed according to requirements.
It is understood that when there are both at least two keywords having contradictory meanings and a user-described qualifier that does not match the qualifier associated with the standard query statement, the calculation formula may be:
score(q,d)=cos(θ)×w boost(d) ×query_boost(q);
in addition, if the query text of the user cannot be matched with the appropriate standard query sentence, the standard query sentence matched with the keyword is not similar to the query text, and at this time, a few standard query sentences can be selected for similarity calculation, so that the operation pressure is reduced. For example, a co-ordination factor parameter may be set, and by setting the co-ordination factor parameter to a specific value (e.g. 3), the similarity is calculated by selecting the first 3 standard query statements from the at least one query statement matching the keyword. Other values such as 30 may be set as the parameter of the coordination factor, or as a percentage (10%), and the top 10% of the standard query statements may be selected.
In a possible implementation, fig. 3 shows a flowchart of another data query method provided by the embodiments of this specification, and as shown in fig. 3, after determining whether the query text has a canonical statement structure through step 102, the method further includes the following steps:
step 301, if the judgment result is negative, extracting keywords in the query text through a keyword extraction model; the keywords characterize the data objects of the user description and/or the definition of the user description.
Specifically, if the determination result is negative, it indicates that the content described in the query text is too little, and only the data object and only the constraint condition are described.
For example, the query text is: and (6) switching. The data object is "on-off," but lacks a predicate, and/or an object, resulting in no way of determining what the user wants to query.
For another example, the query text is "air conditioner on/off", also lacks a predicate, and/or an object, and cannot judge what the user wants to query.
At this time, the content that the user wants to query needs to be guessed by extracting the key words, so as to perform the subsequent query operation.
Step 302, determining a standard query sentence matched with the keyword from the standard query sentence library. And recommending the at least one standard query statement to the user if the at least one standard query statement matched with the keyword is determined.
Specifically, if the at least one standard query statement can be matched, it is indicated that the at least one standard query statement may be the content that the user wants to query, and therefore, the at least one standard query statement is recommended to the user. In recommendation, the recommendation number may be set (for example, 5), so as to prevent the recommendation content from being too much and complicated.
It should be noted that, when recommending, the sequence of the recommended standard query sentence can be adjusted according to the matching procedure of the historical query text and the keywords by referring to the historical query text before the user.
Step 303, obtaining a standard query statement selected by the user, and determining the standard query statement selected by the user as a new query text.
Specifically, after recommendation is performed according to step 302, the standard query statement selected by the user is continuously obtained, so that the determination selected by the user is a new query text, and the new query text is converted into a query code by executing steps 101 to 104.
By the method, when the content described by the query text is too little and cannot be queried, the content which the user wants to query is guessed and relevant recommendation is carried out, so that the input amount of the user is reduced, and the user can conveniently search.
In one possible embodiment, after extracting the keywords in the query text through the keyword extraction model according to step 301, the method further comprises the steps of:
if at least one standard query sentence matched with the keyword is not determined, acquiring a previous query text of the query text; and determining the text spliced by the query text and the previous query text as the new query text.
Specifically, if no standard query statement is matched, the user cannot be recommended, the previous query text of the query text may be obtained, the two query texts are pieced together to form a new query text, and step 101-104 is executed again to convert the pieced-together new query text into a query code.
In one possible embodiment, after extracting the keywords in the query text through the keyword extraction model according to step 301, the method further comprises the steps of:
step 3021, generating a reminding message for reminding the user to continue to supplement the query text when a preset reminding condition is met; the reminding condition comprises the following steps: at least one standard query statement that matches the keyword is not determined; and/or, not acquiring the standard query statement selected by the user.
Specifically, if the standard query statement is not matched according to the keyword, the content of the query text is considered to be not rich enough, and the user needs to continue to supplement the query text, so that prompt information is generated. If the standard query statement selected by the user is not obtained (at least one standard query statement may not be matched or at least one standard query statement is recommended to the user after the standard query statement is matched), the user is not convenient to select or is not satisfied with the recommended content, so that a reminding message needs to be generated to remind the user to continue completing.
Step 3022, in response to the user's supplement operation, determining the supplemented query text as a new query text.
Specifically, the user's supplementary operation may be manual input or voice input, and the obtained supplementary text and the supplemented query text composed of the query text are determined as a new query text, and the new query text is converted into a query code through steps 101 to 104.
By the method, when the query text is incomplete, the user can be prompted to continue completing the query text, and the query precision is improved.
Fig. 4 is a schematic structural diagram of a data query device provided in an embodiment of the present specification, where, as shown in fig. 4, the device includes:
the response module 401 is configured to determine a corresponding query text in response to a query instruction input by a user.
A first determining module 402, configured to determine whether the query text has a canonical statement structure.
A first determining module 403, configured to determine, if the determination result is yes, a standard query sentence that is most similar to the query text from a preset standard query sentence library, as a target standard query sentence; and the standard query statement in the standard query statement library is associated with a data object to which the query aims and a limiting condition which needs to be met by the data object.
A second determining module 404, configured to determine, according to the data object and the limiting condition associated with the target standard query statement, a query code that meets the query code syntax of the database to be operated, and perform a query operation on the database to be operated based on the query code.
In a possible embodiment, when the database is a plurality of different types of databases, the database to be operated is each of the plurality of different types of databases.
Or the database to be operated is one of a plurality of databases of different types, and the database to be operated contains the query result of the target standard query statement.
In a possible embodiment, the first determining module is configured to determine, from a preset standard query sentence library, a standard query sentence that is most similar to the query text, and when the standard query sentence is used as a target standard query sentence, the first determining module includes:
extracting key words in the query text through a key word extraction model; the keywords characterize the data objects of the user description and/or the definition of the user description.
And determining at least one standard query sentence which is matched with the key word from the standard query sentence library.
And calculating the similarity between the standard query statement and the query text aiming at each standard query statement in the at least one standard query statement, and determining the standard query statement with the highest similarity as the target standard query statement.
In one possible embodiment, the apparatus further comprises:
and the adjusting module is used for reducing the similarity if the limiting condition described by the user is not matched with the limiting condition associated with the standard query statement after calculating the similarity between the standard query statement and the query text when the keyword is the limiting condition described by the user.
In one possible embodiment, the apparatus further comprises:
and the second judging module is used for judging whether the length of the query text is greater than that of the standard query sentence or not before calculating the similarity between the standard query sentence and the query text.
And if so, deleting the redundant vocabulary in the query text to calculate the similarity based on the query text after the redundant vocabulary is deleted.
In one possible embodiment, the apparatus further comprises:
and the first acquisition module is used for acquiring the historical query text of the user before calculating the similarity between the standard query sentence and the query text when at least two keywords with contradictory meanings exist in the keywords.
And the setting module is used for setting the weight of each keyword in the at least two keywords with contradictory meanings based on the occurrence frequency of the keywords in the historical query text so as to calculate the similarity based on the weight.
In one possible embodiment, the apparatus further comprises:
the extraction module is used for extracting the keywords in the query text through a keyword extraction model if the query text is judged to have the standard sentence structure or not; the keywords characterize the data objects of the user description and/or the definition of the user description.
And the third determining module is used for determining the standard query sentence matched with the keyword from the standard query sentence library.
And the fourth determination module is used for recommending the at least one standard query statement to the user if the at least one standard query statement matched with the keyword is determined.
And the fifth determining module is used for acquiring the standard query statement selected by the user and determining the standard query statement selected by the user as a new query text.
In one possible embodiment, the apparatus further comprises:
and the second obtaining module is used for obtaining the previous query text of the query text if at least one standard query sentence matched with the keyword is not determined after the keyword in the query text is extracted through the keyword extraction model.
And the sixth determining module is used for determining the text formed by splicing the query text and the previous query text as the new query text.
In one possible embodiment, the apparatus further comprises:
the reminding module is used for generating reminding information for reminding a user to continuously supplement the query text when a preset reminding condition is met after the keywords in the query text are extracted through the keyword extraction model; the reminding condition comprises the following steps: at least one standard query statement that matches the keyword is not determined; and/or, the standard query statement selected by the user is not obtained.
And the seventh determining module is used for responding to the supplement operation of the user and determining the supplemented query text as the new query text.
The implementation process of the functions and actions of each module in the above device is detailed in the implementation process of the corresponding steps in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, wherein the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the present specification. One of ordinary skill in the art can understand and implement without inventive effort.
Fig. 5 is a schematic structural diagram of a computer device in which a data query device provided by an embodiment of the present specification is located, where the computer device may include: a processor 501, a memory 502, an input/output interface 503, a communication interface 504, and a bus 505. Wherein the processor 501, the memory 502, the input/output interface 503 and the communication interface 504 are communicatively connected to each other within the device via a bus 505.
The processor 501 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute a relevant program to implement the data query method provided in the embodiments of the present specification.
The Memory 502 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. The memory 502 can store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 502 and called to be executed by the processor 501.
The input/output interface 503 is used for connecting an input/output module to realize information input and output. The i/o module may be configured as a component within the device (not shown) or may be external to the device to provide corresponding functionality. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
The communication interface 504 is used to connect a communication module (not shown in the figure) to implement communication interaction between the present device and other devices. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, bluetooth and the like).
Bus 505 comprises a path that transfers information between the various components of the device, such as processor 501, memory 502, input/output interface 503, and communication interface 504.
It should be noted that although the above-mentioned device only shows the processor 501, the memory 502, the input/output interface 503, the communication interface 504 and the bus 505, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only the components necessary to implement the embodiments of the present disclosure, and need not include all of the components shown in the figures.
The embodiments of the present specification further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of any one of the data query methods provided in the embodiments of the present specification.
Computer-readable media, including both permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of other like elements in a process, method, article, or apparatus comprising the element.
The foregoing description of specific embodiments has been presented for purposes of illustration and description. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.

Claims (12)

1. A method for data query, the method comprising:
responding to a query instruction input by a user, and determining corresponding query text;
judging whether the query text has a standard sentence structure;
if so, determining a standard query sentence most similar to the query text from a preset standard query sentence library as a target standard query sentence; the standard query statement in the standard query statement library is associated with a data object targeted by query and a limiting condition which needs to be met by the data object;
and determining a query code meeting the query code syntax of the database to be operated according to the data object associated with the target standard query statement and the limiting condition, and executing query operation on the database to be operated based on the query code.
2. The method according to claim 1, wherein when the database is a plurality of different types of databases, the database to be operated is each of the plurality of different types of databases;
or, the database to be operated is one of a plurality of databases of different types, and the database to be operated contains the query result of the target standard query statement.
3. The method of claim 1, wherein determining a standard query sentence most similar to the query text from a preset standard query sentence library as a target standard query sentence comprises:
extracting key words in the query text through a key word extraction model; the keywords represent data objects of the user description and/or limit conditions of the user description;
determining at least one standard query sentence matched with the keyword from the standard query sentence library;
and calculating the similarity between the standard query statement and the query text aiming at each standard query statement in the at least one standard query statement, and determining the standard query statement with the highest similarity as the target standard query statement.
4. The method of claim 3, wherein when the keyword is a defined condition of the user description, after calculating the similarity between the standard query sentence and the query text, the method further comprises:
and if the limiting condition described by the user does not match the limiting condition associated with the standard query statement, reducing the similarity.
5. The method of claim 3, wherein prior to calculating the similarity of the standard query statement to the query text, the method further comprises:
judging whether the length of the query text is greater than that of the standard query sentence;
and if so, deleting the redundant vocabulary in the query text, and calculating the similarity based on the query text after the redundant vocabulary is deleted.
6. The method of claim 3, wherein when there are at least two keywords with contradictory meanings among the keywords, before calculating the similarity of the standard query sentence and the query text, the method further comprises:
acquiring a historical query text of a user;
setting the weight of each keyword in the at least two keywords with contradictory meanings based on the occurrence frequency of the keywords in the historical query text, so as to calculate the similarity based on the weight.
7. The method of claim 1, wherein after determining whether the query text has a canonical sentence structure, the method further comprises:
if the judgment result is negative, extracting the key words in the query text through a key word extraction model; the keywords represent data objects of the user description and/or limit conditions of the user description;
determining a standard query sentence matched with the keyword from the standard query sentence library;
if at least one standard query statement matched with the keyword is determined, recommending the at least one standard query statement to the user;
and acquiring a standard query statement selected by a user, and determining the standard query statement selected by the user as a new query text.
8. The method of claim 7, wherein after extracting the keywords in the query text through a keyword extraction model, the method further comprises:
if at least one standard query sentence matched with the key words is not determined, acquiring a previous query text of the query text;
and determining the text spliced by the query text and the previous query text as the new query text.
9. The method of claim 7, wherein after extracting keywords in the query text via a keyword extraction model, the method further comprises:
when a preset reminding condition is met, reminding information for reminding a user to continuously supplement the query text is generated; the reminding condition comprises the following steps: at least one standard query statement that matches the keyword is not determined; and/or, not acquiring a standard query statement selected by a user;
and determining the supplemented query text as new query text in response to the user's supplementing operation.
10. A data query apparatus, characterized in that the apparatus comprises:
the response module is used for responding to a query instruction input by a user and determining a corresponding query text;
the first judgment module is used for judging whether the query text has a standard sentence structure;
a first determining module, configured to determine, if the determination result is yes, a standard query sentence most similar to the query text from a preset standard query sentence library, as a target standard query sentence; wherein, the standard query statement in the standard query statement library is associated with the data object aimed at by the query and the limiting condition that the data object needs to satisfy;
and the second determining module is used for determining the query code meeting the query code syntax of the database to be operated according to the data object associated with the target standard query statement and the limiting condition, and executing query operation on the database to be operated based on the query code.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the data query method according to any one of claims 1 to 9.
12. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to perform the steps of the data query method of any one of claims 1 to 9.
CN202211223652.2A 2022-10-08 2022-10-08 Data query method, device, equipment and medium Pending CN115576975A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211223652.2A CN115576975A (en) 2022-10-08 2022-10-08 Data query method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211223652.2A CN115576975A (en) 2022-10-08 2022-10-08 Data query method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN115576975A true CN115576975A (en) 2023-01-06

Family

ID=84585517

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211223652.2A Pending CN115576975A (en) 2022-10-08 2022-10-08 Data query method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115576975A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116108163A (en) * 2023-04-04 2023-05-12 之江实验室 Text matching method, device, equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116108163A (en) * 2023-04-04 2023-05-12 之江实验室 Text matching method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107993724B (en) Medical intelligent question and answer data processing method and device
US11256868B2 (en) Architecture for resolving ambiguous user utterance
US11302330B2 (en) Clarifying questions for rewriting ambiguous user utterance
US10922371B2 (en) Query selection method and system
US20200334008A1 (en) Search and knowledge base question answering for a voice user interface
US10037758B2 (en) Device and method for understanding user intent
US10431214B2 (en) System and method of determining a domain and/or an action related to a natural language input
KR101913191B1 (en) Understanding the language based on domain extraction Performance enhancement device and Method
KR101662450B1 (en) Multi-source hybrid question answering method and system thereof
US9483459B1 (en) Natural language correction for speech input
US9280535B2 (en) Natural language querying with cascaded conditional random fields
JP6310150B2 (en) Intent understanding device, method and program
US20040167875A1 (en) Information processing method and system
CN106503239A (en) A kind of method and apparatus of legal information inquiry
WO2020005601A1 (en) Semantic parsing of natural language query
CN111274267A (en) Database query method and device and computer readable storage medium
US20230205996A1 (en) Automatic Synonyms Using Word Embedding and Word Similarity Models
WO2016178337A1 (en) Information processing device, information processing method, and computer program
CN117093729B (en) Retrieval method, system and retrieval terminal based on medical scientific research information
CN115576975A (en) Data query method, device, equipment and medium
CN109108989A (en) A kind of legal services special purpose robot of semantics recognition
US9785633B2 (en) Foreign language service assisting apparatus, method and program
US11487795B2 (en) Template-based automatic software bug question and answer method
GB2583887A (en) Intelligent automated personal assistant for recipe selection
CN117076636A (en) Information query method, system and equipment for intelligent customer service

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