CN114201525A - Method and device for querying data - Google Patents

Method and device for querying data Download PDF

Info

Publication number
CN114201525A
CN114201525A CN202210135283.5A CN202210135283A CN114201525A CN 114201525 A CN114201525 A CN 114201525A CN 202210135283 A CN202210135283 A CN 202210135283A CN 114201525 A CN114201525 A CN 114201525A
Authority
CN
China
Prior art keywords
target
data set
key
attribute
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.)
Granted
Application number
CN202210135283.5A
Other languages
Chinese (zh)
Other versions
CN114201525B (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.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information 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 Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202210135283.5A priority Critical patent/CN114201525B/en
Priority to CN202210813870.5A priority patent/CN115168435A/en
Publication of CN114201525A publication Critical patent/CN114201525A/en
Application granted granted Critical
Publication of CN114201525B publication Critical patent/CN114201525B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/245Query processing
    • G06F16/2457Query processing with adaptation to user needs
    • 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/23Updating

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Machine Translation (AREA)

Abstract

The specification provides a method and a device for querying data, wherein the method comprises the following steps: acquiring a character string input by a user in a natural language aiming at a target data set; acquiring at least one alternative filtering condition from a target dictionary which is generated aiming at the target data set in advance based on the character string; any alternative filter condition includes a key-value pair composed of an attribute and an attribute value using a natural language; outputting the alternative filtering condition to the user for selection by the user; and querying data from the target data set according to the target filtering condition selected by the user from the alternative filtering conditions.

Description

Method and device for querying data
Technical Field
One or more embodiments of the present disclosure relate to the field of data query technologies, and in particular, to a method and an apparatus for querying data.
Background
Currently, in the Query field, SQL (Structured Query Language) is generally used for querying data. Since SQL is a programming language and has a certain usage threshold, it is not user-friendly and affects the efficiency of data query.
Disclosure of Invention
One or more embodiments of the present specification provide a method and apparatus for querying data.
According to a first aspect, there is provided a method of querying data, the method comprising:
acquiring a character string input by a user in a natural language aiming at a target data set;
acquiring at least one alternative filtering condition from a target dictionary which is generated aiming at the target data set in advance based on the character string; any alternative filter condition includes a key-value pair composed of an attribute and an attribute value using a natural language;
outputting the alternative filtering condition to the user for selection by the user;
and querying data from the target data set according to the target filtering condition selected by the user from the alternative filtering conditions.
Optionally, the target dictionary includes key-value pairs each formed by each attribute in at least part of the attributes in the target data set and each attribute value corresponding to each attribute.
Optionally, the obtaining at least one candidate filtering condition from a target dictionary generated for the target data set in advance based on the character string includes:
traversing each key-value pair in the target dictionary to determine at least one target key-value pair; the attribute value corresponding to any target key value comprises the character string;
obtaining the alternative filtering condition based on the at least one target key-value pair.
Optionally, the obtaining the alternative filtering condition based on the at least one target key-value pair includes:
sequencing the at least one target key value pair according to a preset sequencing mode;
and selecting a preset number of target key value pairs in the sequence as the alternative filtering condition.
Optionally, the sorting according to a preset sorting manner includes:
sorting according to the sequence of the total times of historical queries; or
Sequencing according to the sequence of the query times in a preset time period; or
The characters are sorted from the number of the included characters.
Optionally, the outputting the alternative filtering condition to the user includes:
displaying the alternative filtering condition in a selectable mode in a preset area on a user interface.
Optionally, before obtaining the character string input by the user for the target data set, the method further comprises:
acquiring the target data set;
and analyzing the target data set to generate the target dictionary.
Optionally, the parsing the target data set to generate the target dictionary includes:
analyzing natural language data in the target data set to obtain each attribute in at least part of attributes in the target data set and each attribute value corresponding to each attribute;
forming a plurality of key value pairs which are different from each other by using each attribute and each attribute value corresponding to each attribute;
generating the target dictionary from the plurality of key-value pairs.
Optionally, the at least part of the attributes are attributes corresponding to discrete attribute values.
Optionally, the method further comprises:
after updating the target data set, acquiring update data;
determining newly added key-value pairs based on the update data;
and updating the target dictionary by using the newly added key value pair.
According to a second aspect, there is provided an apparatus for querying data, the apparatus comprising:
the input module is used for acquiring a character string input by a user in a natural language aiming at the target data set;
an obtaining module, configured to obtain at least one candidate filtering condition from a target dictionary generated in advance for the target data set based on the character string; any alternative filter condition includes a key-value pair composed of an attribute and an attribute value using a natural language;
the output module is used for outputting the alternative filtering conditions to the user for the selection of the user;
and the query module is used for querying data from the target data set according to the target filtering condition selected by the user from the candidate filtering conditions.
Optionally, the target dictionary includes key-value pairs each formed by each attribute in at least part of the attributes in the target data set and each attribute value corresponding to each attribute.
Optionally, the obtaining module includes:
the traversal submodule is used for traversing each key-value pair in the target dictionary and determining at least one target key-value pair; the attribute value corresponding to any target key value comprises the character string;
an obtaining sub-module, configured to obtain the candidate filtering condition based on the at least one target key-value pair.
Optionally, the obtaining sub-module is configured to:
sequencing the at least one target key value pair according to a preset sequencing mode;
and selecting a preset number of target key value pairs in the sequence as the alternative filtering condition.
Optionally, the obtaining sub-module performs sorting according to a preset sorting method by:
sorting according to the sequence of the total times of historical queries; or
Sequencing according to the sequence of the query times in a preset time period; or
The characters are sorted from the number of the included characters.
Optionally, the output module is configured to:
displaying the alternative filtering condition in a selectable mode in a preset area on a user interface.
Optionally, the apparatus further comprises:
the data set acquisition module is used for acquiring a target data set before acquiring a character string input by a user aiming at the target data set;
and the generating module is used for analyzing the target data set to generate the target dictionary.
Optionally, the generating module is configured to:
analyzing natural language data in the target data set to obtain each attribute in at least part of attributes in the target data set and each attribute value corresponding to each attribute;
forming a plurality of key value pairs which are different from each other by using each attribute and each attribute value corresponding to each attribute;
generating the target dictionary from the plurality of key-value pairs.
Optionally, the at least part of the attributes are attributes corresponding to discrete attribute values.
Optionally, the apparatus further comprises:
the newly-added module is used for acquiring updated data after the target data set is updated;
a determination module to determine a newly added key-value pair based on the update data;
and the updating module is used for updating the target dictionary by utilizing the newly added key value pair.
According to a third aspect, there is provided a computer readable storage medium storing a computer program which, when executed by a processor, implements the method of any of the first or second aspects described above.
According to a fourth aspect, there is provided a computing device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of any one of the first or second aspects when executing the program.
The technical scheme provided by the embodiment of the specification can have the following beneficial effects:
according to the method and the device for querying data, the character string input by the user in natural language for the target data set is obtained, at least one alternative filtering condition is obtained from the target dictionary generated in advance for the target data set, the at least one alternative filtering condition is output to the user for the user to select, and the data is queried from the target data set according to the target filtering condition selected by the user from the alternative filtering conditions. Therefore, when a user inquires data, the user does not need to input complete filtering conditions on the premise of not using a special programming language, and the efficiency of data inquiry is improved.
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 application.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments described in the present disclosure, and it is obvious for a person skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a schematic diagram illustrating a scenario of querying data, according to an exemplary embodiment;
FIG. 2 is a flow diagram illustrating a method of querying data in accordance with an exemplary embodiment of the present description;
FIG. 3 is an interface diagram illustrating an output of alternative filter terms in a preset area on a user interface according to an exemplary embodiment of the present description;
FIG. 4 is a flow diagram illustrating a method of generating a target dictionary in accordance with one exemplary embodiment of the present description;
FIG. 5 is a block diagram illustrating an apparatus for querying data in accordance with an exemplary embodiment of the present description.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
Currently, in the Query field, SQL (Structured Query Language) is generally used for querying data. Since SQL is a programming language and has a certain usage threshold, it is not user-friendly and affects the efficiency of data query. And if the natural language is adopted for data query, the user is required to input complete filtering conditions. If the filtering condition to be input is too long, or the rarely-used word is contained therein, or the word with wrong pronunciation or the word with wrong spelling is contained therein, the user still needs to be inconvenienced to a certain extent, and therefore, the efficiency of data query is also influenced.
The embodiment of the specification provides a scheme for querying data, and when a user queries data, the user does not need to input complete filtering conditions on the premise of not using a special programming language, so that the efficiency of querying data is improved.
FIG. 1 is a diagram illustrating a scenario of querying data, according to an exemplary embodiment.
In fig. 1, first, a user may input a target data set to be queried in advance, and may analyze natural language data in the target data set to generate a target dictionary. The target dictionary includes a plurality of key-value pairs in natural language composed of attributes and attribute values in the target dataset. After the target dictionary is generated, the data in the target data set can be queried based on the target dictionary for an unlimited number of times. It should be noted that, if the target data set is updated, the target dictionary may also be updated by using the data of the updated target data set.
Then, when the user needs to query the target data set, a character string using a natural language, such as a keyword/word of chinese, or an alphabet of english, etc., may be input. The character string may be a partial character string of attribute values in a filter condition for querying data, and the character string may be obtained by searching for an attribute value including the character string from attribute values of each key-value pair included in the target dictionary according to the character string input by the user, and selecting at least a partial key-value pair from key-value pairs corresponding to the attribute value including the character string as a candidate filter condition.
Then, the alternative filtering conditions can be displayed in a preset area of the user interface for the user to select. The user can select the target filtering condition for inquiring the data from the alternative filtering conditions by means of clicking. And then, inquiring data from the target data set according to the target filtering condition, and returning the obtained inquiry result to the user.
The embodiments provided in the present specification will be described in detail with reference to specific examples.
FIG. 2 is a flow diagram illustrating a method of querying data, an execution body of which may be implemented as any device, platform, server, or cluster of devices having computing, processing capabilities, according to an example embodiment. The method comprises the following steps:
in step 201, a character string input by a user using a natural language for a target data set is obtained.
In this embodiment, the target data set is a data set to be queried, and may include a plurality of attributes and attribute values corresponding to the attributes, where the attributes and the attribute values are represented by natural language data sets. It is to be understood that the target data set may be any form of data set, and the embodiment is not limited to the specific form of the target data set.
In this embodiment, a user may use natural language to input a string associated with a filter condition of query data when querying data from a target data set. For example, if the filter condition of the query data is "county = bosnia and blacksmith republic", where "county" is an attribute (i.e., a key) and "bosnia and blacksmith republic" is an attribute value (i.e., a value), the user may input a character string "wave", or input a character string "dimension", or input any continuous character string included in the attribute value of the filter condition, or the like.
In step 202, at least one candidate filter condition is obtained from a target dictionary generated in advance for the target data set based on the character string, and any candidate filter condition comprises a key-value pair using natural language composed of an attribute and an attribute value.
Specifically, before querying the target data set, the target data set may be input in advance, and the target data set may be analyzed to obtain each attribute of at least some of the attributes in the target data set and each attribute value corresponding to each attribute. And each attribute and the corresponding attribute value form a key value pair (the attribute is a key in the key value pair, and the attribute value is a value in the key value pair), and the obtained key value pair is utilized to generate a target dictionary aiming at the target data set, so that the target dictionary comprises the obtained key value pairs. At least some of the attributes in the target data set may be all of the attributes in the target data set, or may be attributes corresponding to discrete attribute values, for example, the discrete attribute values may be non-numeric attribute values.
At the time of querying, at least one candidate filter condition may be obtained from the target dictionary based on a character string input by a user using natural language for the target data set. Specifically, each key-value pair in the target dictionary may be traversed, and for any key-value pair, it may be determined whether the attribute value corresponding to the key-value pair (i.e., the value of the key-value pair) includes the above-mentioned character string input by the user. And taking the key value pair corresponding to the attribute value containing the character string as a target key value. And obtaining at least one target key value pair after traversing is finished, and acquiring alternative filtering conditions based on the at least one target key value pair.
For example, the target dictionary includes the following key-value pairs: county = china, county = bosnia and blackcurrant, county = japan, county = polan, county = usa, city = nigh, city = boston, city = beijing, city = tokyo, city = washingsa, city = mototal. If the filtering condition of the user query data is "county = bosnia and blackcurrian", the user may input the character string "wave", and the key-value pair corresponding to the attribute value containing the character string "wave" in the target dictionary may be taken as the target key-value pair. Thus, the target key-value pair includes the following four key-value pairs: county = bosnia and the republic of blackcurrian, county = polan, city = nigh, and city = boston. Finally, an alternative filter condition may be obtained based on the target key-value pair.
In one implementation, the obtained target key-value pairs may be used as alternative filtering conditions, and the alternative filtering conditions may be output to the user in a random order or a preset order. In another implementation manner, it may also be determined whether the number of the target key-value pairs is greater than a preset threshold value, and if the number of the target key-value pairs is not greater than the preset threshold value, all the obtained target key-value pairs are used as alternative filtering conditions, and the alternative filtering conditions are output to the user. If the number of the target key-value pairs is larger than the preset threshold value, part of the target key-value pairs can be selected as alternative filtering conditions, and the alternative filtering conditions are output to the user.
Optionally, at least one target key value pair may be sorted according to a preset sorting manner, and then, a preset number of target key values in the sorting are selected as the candidate filtering conditions. The query frequency can be sorted according to the sequence from most to few of the total historical query frequency, or according to the sequence from most to few of the query frequency in a preset time period, or according to the sequence from most to few of the included character number. It can be understood that the target key-value pairs may also be sorted in any other reasonable manner, and the specific manner of sorting is not limited in this embodiment.
In step 203, the at least one alternative filtering condition is output to the user for selection by the user.
In this embodiment, the at least one alternative filtering condition may be output to the user for selection by the user. Optionally, the at least one alternative filtering condition may be displayed in a preset area on the user interface in a selectable manner. As shown in fig. 3, the area 301 is a character string input box, and the user can input a character string for the target data set in the area 301 using natural language, for example, the user inputs the character string "north" in the area 301. Then, the region 302 outputs the candidate filter conditions for selection by the user, for example, the candidate filter conditions "city = north tun city", "city = beijing city", "province = beijing", "province = north province", "city = north sea city" are output in the region 302. The user may select a target filter term for the query data from the alternative filter terms. For example, the user may click "city = north tun city", and may set "city = north tun city" as the target filtering condition.
In step 204, data is queried from the target data set according to a target filter criteria selected by the user from the candidate filter criteria.
In this embodiment, data query may be performed according to a target filtering condition selected by a user from the candidate filtering conditions, and it should be noted that the user may perform data query based on one target filtering condition, or may continue to input a character string and continue to obtain a plurality of target filtering conditions, and then perform data query based on the plurality of target filtering conditions.
In the method for querying data provided in the foregoing embodiments of the present specification, a character string input by a user in a natural language for a target data set is obtained, at least one candidate filtering condition is obtained from a target dictionary generated in advance for the target data set, the at least one candidate filtering condition is output to the user for the user to select, and data is queried from the target data set according to the target filtering condition selected by the user from the candidate filtering conditions. Therefore, when a user inquires data, the user does not need to input complete filtering conditions on the premise of not using a special programming language, and the efficiency of data inquiry is improved.
As shown in fig. 4, fig. 4 is a flowchart illustrating a method of generating a target dictionary before step 201 according to an exemplary embodiment, and an execution subject of the method may be implemented as any device, platform, server or device cluster having computing and processing capabilities. The method comprises the following steps:
in step 401, a target data set is obtained, and in step 402, the target data set is parsed to generate a target dictionary.
Specifically, a target data set to be queried input by a user may be obtained, and natural language data in the target data set may be analyzed to obtain each attribute of at least some of the attributes in the target data set and each attribute value corresponding to each attribute. The at least some attributes may be all attributes in the target dataset or attributes in the target dataset corresponding to discrete attribute values. Then, a plurality of key value pairs different from each other are formed by the attributes and the attribute values corresponding to the attributes, and a target dictionary is generated from the plurality of key value pairs.
For example, after analyzing the natural language data in the target dataset, all attributes in the target dataset, including "province", "city", "region" and "sales", are obtained. Wherein, the "province", "city" and "region" are attributes corresponding to discrete attribute values (non-numeric). The "sales amount" is an attribute corresponding to a continuous type attribute value (number). Therefore, the respective attribute values of province, city and district can be obtained, and the following multiple key value pairs can be obtained after duplication removal: "province = beijing", "province = jiangsu", "province = zhejiang", "province = shandong", "city = beijing city", "city = hangzhou city", "city = nanjing city", "city = ju nan city", … …. A target dictionary is generated such that the target dictionary includes the plurality of key values.
It should be noted that, when the target data set is updated, the target dictionary may be updated based on the updated data at the same time. For example, if an entry of "province = Shandong, City = Qingdao, sales = N" is added to the target dataset, the target dictionary may be updated based on the newly added entry. Specifically, the entry is analyzed to obtain attributes "province", "city", "sales amount", attributes "province" and "city" corresponding to the discrete attribute value are selected and corresponding attribute values are obtained to obtain key value pairs "province = shandong" and "city = Qingdao". Since the target dictionary already has the key-value pair "province = Shandong", only "city = Qingdao" is added to the target dictionary, and the target dictionary is updated.
It should be noted that although in the above embodiments, the operations of the methods of the embodiments of the present specification have been described in a particular order, this does not require or imply that these operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Rather, the steps depicted in the flowcharts may change the order of execution. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
Corresponding to the embodiment of the method for querying data, the specification also provides an embodiment of a device for querying data.
As shown in fig. 5, fig. 5 is a block diagram of an apparatus for querying data according to an exemplary embodiment, and the apparatus may include: an input module 501, an acquisition module 502, an output module 503 and a query module 504.
The input module 501 is configured to obtain a character string input by a user in a natural language for a target data set.
An obtaining module 502, configured to obtain at least one candidate filter condition from a target dictionary generated in advance for a target data set based on the character string, where any candidate filter condition includes a key-value pair composed of an attribute and an attribute value in a natural language.
An output module 503, configured to output the alternative filtering condition to the user for selection by the user.
And the query module 504 is configured to query the data from the target data set according to the target filtering condition selected by the user from the candidate filtering conditions.
In some embodiments, the target dictionary includes key-value pairs each formed from respective ones of at least some of the attributes in the target dataset and respective corresponding respective ones of the attribute values.
In other embodiments, the obtaining module 502 may include: traverse submodule and fetch submodule (not shown in the figure).
And the traversal submodule is used for traversing each key value pair in the target dictionary and determining at least one target key value pair, wherein the attribute value corresponding to any target key value comprises the character string.
And the acquisition submodule is used for acquiring the alternative filtering condition based on at least one target key value pair.
In other embodiments, the acquisition submodule is configured to: and sequencing at least one target key value pair according to a preset sequencing mode, and selecting a front preset number of target key value pairs in the sequencing as alternative filtering conditions.
In other embodiments, the obtaining sub-module performs the sorting according to a preset sorting manner as follows: sorting according to the sequence of the total times of historical queries; or sorting according to the sequence of the query times in a preset time period; or sorted in order of the number of characters involved.
In other embodiments, the output module 503 is configured to: in a preset area on the user interface, alternative filter conditions are displayed in a selectable manner.
In other embodiments, the apparatus may further comprise: a dataset acquisition module and a generation module (not shown in the figure).
The data set acquisition module is used for acquiring the target data set before acquiring the character string input by the user aiming at the target data set.
And the generating module is used for analyzing the target data set to generate a target dictionary.
In other embodiments, the generating module is configured to: analyzing the natural language data in the target data set to obtain each attribute in at least part of the attributes in the target data set and each attribute value corresponding to each attribute. A plurality of key value pairs different from each other are formed by each attribute and each attribute value corresponding to each attribute. A target dictionary is generated from the plurality of key-value pairs.
In other embodiments, the at least some attributes are attributes corresponding to discrete attribute values.
In other embodiments, the apparatus may further comprise: a newly added module, a determined module and an updated module (not shown in the figure).
The newly-added module is used for acquiring the update data after the target data set is updated.
And the determining module is used for determining the newly added key value pair based on the updating data.
And the updating module is used for updating the target dictionary by utilizing the newly added key value pair.
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, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of one or more embodiments of the present specification. One of ordinary skill in the art can understand and implement it without inventive effort.
One or more embodiments of the present specification further provide a computer-readable storage medium storing a computer program, where the computer program can be used to execute the method for querying data provided in any one of fig. 2 to 4.
One or more embodiments of the present specification further provide a computing device, including a memory and a processor, where the memory stores executable codes, and the processor executes the executable codes to implement the method for querying data provided in any one of the embodiments 2 to 4.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (22)

1. A method of querying data, the method comprising:
acquiring a character string input by a user in a natural language aiming at a target data set;
acquiring at least one alternative filtering condition from a target dictionary which is generated aiming at the target data set in advance based on the character string; any alternative filter condition includes a key-value pair composed of an attribute and an attribute value using a natural language;
outputting the alternative filtering condition to the user for selection by the user;
and querying data from the target data set according to the target filtering condition selected by the user from the alternative filtering conditions.
2. The method of claim 1, wherein the target dictionary comprises key-value pairs each comprising a respective one of at least some of the attributes in the target dataset and a respective one of the attribute values to which the respective attribute corresponds.
3. The method of claim 2, wherein the obtaining at least one candidate filter condition from a target dictionary generated for the target data set in advance based on the character string comprises:
traversing each key-value pair in the target dictionary to determine at least one target key-value pair; the attribute value corresponding to any target key value comprises the character string;
obtaining the alternative filtering condition based on the at least one target key-value pair.
4. The method of claim 3, wherein the obtaining the alternative filter criteria based on the at least one target key-value pair comprises:
sequencing the at least one target key value pair according to a preset sequencing mode;
and selecting a preset number of target key value pairs in the sequence as the alternative filtering condition.
5. The method of claim 4, wherein the sorting according to a preset sorting manner comprises:
sorting according to the sequence of the total times of historical queries; or
Sequencing according to the sequence of the query times in a preset time period; or
The characters are sorted from the number of the included characters.
6. The method of claim 1, wherein the outputting the alternative filter criteria to the user comprises:
displaying the alternative filtering condition in a selectable mode in a preset area on a user interface.
7. The method of claim 2, wherein prior to obtaining the string entered by the user for the target data set, the method further comprises:
acquiring the target data set;
and analyzing the target data set to generate the target dictionary.
8. The method of claim 7, wherein the parsing the target data set to generate the target dictionary comprises:
analyzing natural language data in the target data set to obtain each attribute in at least part of attributes in the target data set and each attribute value corresponding to each attribute;
forming a plurality of key value pairs which are different from each other by using each attribute and each attribute value corresponding to each attribute;
generating the target dictionary from the plurality of key-value pairs.
9. The method of claim 2 or 8, the at least part of the attributes being attributes corresponding to discrete attribute values.
10. The method of claim 7, wherein the method further comprises:
after updating the target data set, acquiring update data;
determining newly added key-value pairs based on the update data;
and updating the target dictionary by using the newly added key value pair.
11. An apparatus for querying data, the apparatus comprising:
the input module is used for acquiring a character string input by a user in a natural language aiming at the target data set;
an obtaining module, configured to obtain at least one candidate filtering condition from a target dictionary generated in advance for the target data set based on the character string; any alternative filter condition includes a key-value pair composed of an attribute and an attribute value using a natural language;
the output module is used for outputting the alternative filtering conditions to the user for the selection of the user;
and the query module is used for querying data from the target data set according to the target filtering condition selected by the user from the candidate filtering conditions.
12. The apparatus of claim 11, wherein the target dictionary comprises key-value pairs each formed from a respective one of at least some of the attributes in the target dataset and a respective one of the attribute values to which the respective attribute corresponds.
13. The apparatus of claim 12, wherein the means for obtaining comprises:
the traversal submodule is used for traversing each key-value pair in the target dictionary and determining at least one target key-value pair; the attribute value corresponding to any target key value comprises the character string;
an obtaining sub-module, configured to obtain the candidate filtering condition based on the at least one target key-value pair.
14. The apparatus of claim 13, wherein the acquisition submodule is configured to:
sequencing the at least one target key value pair according to a preset sequencing mode;
and selecting a preset number of target key value pairs in the sequence as the alternative filtering condition.
15. The apparatus of claim 14, wherein the obtaining sub-module is arranged in a preset ordering manner by:
sorting according to the sequence of the total times of historical queries; or
Sequencing according to the sequence of the query times in a preset time period; or
The characters are sorted from the number of the included characters.
16. The apparatus of claim 11, wherein the output module is configured to:
displaying the alternative filtering condition in a selectable mode in a preset area on a user interface.
17. The apparatus of claim 12, wherein the apparatus further comprises:
the data set acquisition module is used for acquiring a target data set before acquiring a character string input by a user aiming at the target data set;
and the generating module is used for analyzing the target data set to generate the target dictionary.
18. The apparatus of claim 17, wherein the generation module is configured to:
analyzing natural language data in the target data set to obtain each attribute in at least part of attributes in the target data set and each attribute value corresponding to each attribute;
forming a plurality of key value pairs which are different from each other by using each attribute and each attribute value corresponding to each attribute;
generating the target dictionary from the plurality of key-value pairs.
19. The apparatus of claim 12 or 18, the at least some attributes being attributes corresponding to discrete attribute values.
20. The apparatus of claim 17, wherein the apparatus further comprises:
the newly-added module is used for acquiring updated data after the target data set is updated;
a determination module to determine a newly added key-value pair based on the update data;
and the updating module is used for updating the target dictionary by utilizing the newly added key value pair.
21. A computer-readable storage medium, having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of any one of claims 1-10.
22. A computing device comprising a memory having executable code stored therein and a processor that, when executing the executable code, implements the method of any of claims 1-10.
CN202210135283.5A 2022-02-15 2022-02-15 Method and device for querying data Active CN114201525B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210135283.5A CN114201525B (en) 2022-02-15 2022-02-15 Method and device for querying data
CN202210813870.5A CN115168435A (en) 2022-02-15 2022-02-15 Method and device for querying data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210135283.5A CN114201525B (en) 2022-02-15 2022-02-15 Method and device for querying data

Related Child Applications (1)

Application Number Title Priority Date Filing Date
CN202210813870.5A Division CN115168435A (en) 2022-02-15 2022-02-15 Method and device for querying data

Publications (2)

Publication Number Publication Date
CN114201525A true CN114201525A (en) 2022-03-18
CN114201525B CN114201525B (en) 2022-05-20

Family

ID=80658951

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210135283.5A Active CN114201525B (en) 2022-02-15 2022-02-15 Method and device for querying data
CN202210813870.5A Pending CN115168435A (en) 2022-02-15 2022-02-15 Method and device for querying data

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202210813870.5A Pending CN115168435A (en) 2022-02-15 2022-02-15 Method and device for querying data

Country Status (1)

Country Link
CN (2) CN114201525B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6993475B1 (en) * 2000-05-03 2006-01-31 Microsoft Corporation Methods, apparatus, and data structures for facilitating a natural language interface to stored information
US20140201187A1 (en) * 2011-08-30 2014-07-17 Johan G. Larson System and Method of Search Indexes Using Key-Value Attributes to Searchable Metadata
CN108241670A (en) * 2016-12-26 2018-07-03 北京国双科技有限公司 Database statement generation method and device
CN110347784A (en) * 2019-05-23 2019-10-18 深圳壹账通智能科技有限公司 Report form inquiring method, device, storage medium and electronic equipment
CN110532282A (en) * 2019-08-09 2019-12-03 合肥工业大学 Data query method and device
CN110674362A (en) * 2019-08-22 2020-01-10 视联动力信息技术股份有限公司 Search recommendation method and device, electronic equipment and readable storage medium
CN110888897A (en) * 2019-11-12 2020-03-17 杭州世平信息科技有限公司 Method and device for generating SQL (structured query language) statement according to natural language
CN111414375A (en) * 2020-02-29 2020-07-14 深圳壹账通智能科技有限公司 Input recommendation method based on database query, electronic device and storage medium
CN111538818A (en) * 2020-03-26 2020-08-14 深圳云天励飞技术有限公司 Data query method and device, electronic equipment and storage medium
CN111813802A (en) * 2020-09-11 2020-10-23 杭州量之智能科技有限公司 Method for generating structured query statement based on natural language
US10922357B1 (en) * 2017-12-07 2021-02-16 Amazon Technologies, Inc. Automatically mapping natural language commands to service APIs
CN113723082A (en) * 2021-08-30 2021-11-30 支付宝(杭州)信息技术有限公司 Method and device for detecting Chinese pinyin from text

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6993475B1 (en) * 2000-05-03 2006-01-31 Microsoft Corporation Methods, apparatus, and data structures for facilitating a natural language interface to stored information
US20140201187A1 (en) * 2011-08-30 2014-07-17 Johan G. Larson System and Method of Search Indexes Using Key-Value Attributes to Searchable Metadata
CN108241670A (en) * 2016-12-26 2018-07-03 北京国双科技有限公司 Database statement generation method and device
US10922357B1 (en) * 2017-12-07 2021-02-16 Amazon Technologies, Inc. Automatically mapping natural language commands to service APIs
CN110347784A (en) * 2019-05-23 2019-10-18 深圳壹账通智能科技有限公司 Report form inquiring method, device, storage medium and electronic equipment
CN110532282A (en) * 2019-08-09 2019-12-03 合肥工业大学 Data query method and device
CN110674362A (en) * 2019-08-22 2020-01-10 视联动力信息技术股份有限公司 Search recommendation method and device, electronic equipment and readable storage medium
CN110888897A (en) * 2019-11-12 2020-03-17 杭州世平信息科技有限公司 Method and device for generating SQL (structured query language) statement according to natural language
CN111414375A (en) * 2020-02-29 2020-07-14 深圳壹账通智能科技有限公司 Input recommendation method based on database query, electronic device and storage medium
CN111538818A (en) * 2020-03-26 2020-08-14 深圳云天励飞技术有限公司 Data query method and device, electronic equipment and storage medium
CN111813802A (en) * 2020-09-11 2020-10-23 杭州量之智能科技有限公司 Method for generating structured query statement based on natural language
CN113723082A (en) * 2021-08-30 2021-11-30 支付宝(杭州)信息技术有限公司 Method and device for detecting Chinese pinyin from text

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ABHILASHA KATE,等: "Conversion of Natural Language Query to SQL Query", 《2018 SECOND INTERNATIONAL CONFERENCE ON ELECTRONICS, COMMUNICATION AND AEROSPACE TECHNOLOGY (ICECA)》 *
吕剑清,等: "面向工业生产的中文Text-to-SQL模型", 《计算机应用》 *

Also Published As

Publication number Publication date
CN114201525B (en) 2022-05-20
CN115168435A (en) 2022-10-11

Similar Documents

Publication Publication Date Title
KR102407510B1 (en) Method, apparatus, device and medium for storing and querying data
CN101131706B (en) Query amending method and system thereof
WO2019169858A1 (en) Searching engine technology based data analysis method and system
CN110795455A (en) Dependency relationship analysis method, electronic device, computer device and readable storage medium
JP2004518226A (en) Database system and query optimizer
US11475065B2 (en) Pre-emptive graph search for guided natural language interactions with connected data systems
WO2014210387A2 (en) Concept extraction
CN111091006B (en) Method, device, equipment and medium for establishing entity intention system
EP3929763B1 (en) Database access methods and apparatuses
CN112115232A (en) Data error correction method and device and server
CN108664509B (en) Method, device and server for ad hoc query
CN112883030A (en) Data collection method and device, computer equipment and storage medium
CN111435406A (en) Method and device for correcting database statement spelling errors
CN113672628A (en) Data blood margin analysis method, terminal device and medium
CN110795526A (en) Mathematical formula index creating method and system for retrieval system
CN110704472A (en) Data query statistical method and device
Mishra et al. A lightweight online framework for query progress indicators
CN114201525B (en) Method and device for querying data
CN111309930A (en) Medical knowledge graph entity alignment method based on representation learning
CN113010539A (en) Data processing method and device
CN110795617A (en) Error correction method and related device for search terms
CN110147396B (en) Mapping relation generation method and device
CN111949684B (en) SQL sentence execution method, device, equipment and storage medium
CN115098365A (en) SQL code debugging method and device, electronic equipment and readable storage medium
CN113536058A (en) Spatial index modification method, device, equipment and storage medium

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