Disclosure of Invention
The information query method and device provided by the application aim to solve the problems that in the prior art, due to the fact that query results are long, a large amount of storage space is occupied, the readability of a user is poor, and the user experience is low.
According to the information query method provided by the embodiment of the application, the method comprises the following steps:
receiving an answer set which is sent by a user and provided according to the question set; wherein the answer set consists of answers to at least one question;
matching in a preset information tree according to the answer set and the question set; wherein, the questions in the question set correspond to the answers in the answer set one by one, and the information tree is: the system comprises a node set which is composed of at least one node and has a tree-shaped hierarchical relationship, wherein a non-leaf node represents judgment information, the judgment information is a question, the non-leaf node is respectively associated with different child nodes thereof through different condition information, each condition information is an answer, the leaf node represents a question-answer pair and an information template, and the information template is provided with a field to be filled;
when the leaf node is matched in the information tree, acquiring a question-answer pair and an information template represented by the leaf node;
and writing the answers in the answer set and the matched answers represented by the leaf nodes into the matched fields to be filled of the information template, thereby generating a query result.
Optionally, matching is performed in a preset information tree according to the answer set and the question set, and specifically includes:
a1: determining a root node in the information tree as a current node;
a2: acquiring condition information associated with the current node and different child nodes of the current node under the condition that the judgment information represented by the current node is successfully matched with any problem in the problem set;
a3: under the condition that the answer corresponding to the successfully matched question is successfully matched with any condition information, acquiring a child node associated with the successfully matched condition information;
a4: determining the child node as the current node, and repeatedly executing A2 until the current node is a leaf node.
Optionally, writing the answer in the answer information set and the answer in the matched leaf node into the field to be filled of the matched information template, specifically including:
under the condition that the question in the question set is the same as the field to be filled in the matched information template, giving the answer corresponding to the question in the answer set to the field to be filled in;
and in the case that the question in the matched question-answer pair is the same as the field to be filled in the matched information template, giving the field to be filled with the answer in the matched question-answer pair.
Optionally, the method further includes:
and returning the query result to the user.
According to an embodiment of the present application, an information query apparatus is provided, the apparatus includes:
the receiving unit is used for receiving an answer set which is sent by a user and provided according to the question set; wherein the answer set consists of answers to at least one question;
the matching unit is used for matching in a preset information tree according to the answer set and the question set; wherein, the questions in the question set correspond to the answers in the answer set one by one, and the information tree is: the system comprises a node set which is composed of at least one node and has a tree-shaped hierarchical relationship, wherein a non-leaf node represents judgment information, the judgment information is a question, the non-leaf node is respectively associated with different child nodes thereof through different condition information, each condition information is an answer, the leaf node represents a question-answer pair and an information template, and the information template is provided with a field to be filled;
the acquisition unit is used for acquiring a question-answer pair and an information template represented by a leaf node when the leaf node is matched in the information tree;
and the generating unit writes the answers in the answer set and the answers represented by the matched leaf nodes into the fields to be filled of the matched information template so as to generate a query result.
Optionally, the matching unit specifically includes:
a determining subunit, configured to determine a root node in the information tree as a current node;
the first obtaining subunit is used for obtaining the condition information associated with the current node and different child nodes of the current node under the condition that the judgment information represented by the current node is successfully matched with any problem in the problem set;
the second obtaining subunit is used for obtaining the child node associated with the successfully matched condition information under the condition that the answer corresponding to the successfully matched question is successfully matched with any one of the condition information;
and the circulation control subunit determines the child node as a current node, and when the current node is a non-leaf node, the first acquisition subunit is repeatedly executed until the current node is a leaf node.
Optionally, the generating unit specifically includes:
the first writing subunit, under the condition that the question in the question set is the same as the field to be filled in the matched information template, endowing the answer corresponding to the question in the answer set to the field to be filled in;
the second writing subunit, under the condition that the question in the matched question-answer pair is the same as the field to be filled in the matched information template, endowing the matched answer in the question-answer pair to the field to be filled in;
and generating a subunit, and determining the information template after assignment as a query result.
Optionally, the apparatus further comprises:
and the return unit returns the query result to the user.
In the embodiment of the application, the data structure of the tree is used, the contents which are repeatedly used in the original static text are stored in the leaf nodes of the information tree in the form of the information template, and the answers are stored in the same leaf node in the form of the 'question-answer' pair. Therefore, the content repeatedly stored in the original query result only needs to be stored once, so that the occupation of more storage space is avoided; compared with the prior art, the query result obtained by the dynamic assembly mode is simple, and personalized answers are provided for the user, so that the readability is better, and the user experience is improved.
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 embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application 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 is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such 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 application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
Referring to fig. 1, a flowchart of an information query method provided in an embodiment of the present application is described in the embodiment from a server side, and the method may specifically include the following steps:
step 110: and receiving an answer set provided according to the question set and sent by the user.
In this embodiment, the answer set is composed of answers to at least one question.
For example, the following steps are carried out:
example 1, as shown in the schematic diagram of fig. 2, in which the user provides answers according to questions, the whole process is from (a) to (h), through multiple information interactions between the user and the application platform, and after (h), the answer set is sent to the server, and the answer set is formed by combining answers corresponding to each question, so that the server can receive the answer set.
(a) In the method, a user enters an autonomous service window, the user firstly inputs a content to be inquired, namely ' manual urgent transfer time ', and an application platform replies ' asking for a question whether you are account for now? "the user enters" not to check out "in the information input box and clicks the send button;
(b) in the application platform, the application platform receives and caches "not account for", and then replies "ask what type of transfer you use? "the user enters" bank "in the information input box and clicks the send button;
(c) in the application platform, the application platform receives and caches "bank", and then replies "ask for which bank specifically? "the user enters" Binresner Bank "in the information input box and clicks the send button;
(d) in (1), the application platform receives and caches "recruiter bank" and then replies "ask for what time do you transfer? ", the user enters" 2016-07-2514:24:30 "in the information entry box and clicks the send button;
(e) in this case, the application platform receives and caches "2016-07-2514: 24: 30" and then replies with "does the request then be time for the bank to service? ", the user enters" service time "in the information input box and clicks the send button;
(f) in the application platform, the application platform receives and caches the service time, and then replies with a reply of "how much do you ask for a transfer amount? ", the user enters" 3000 "in the information input box and clicks the send button;
(g) in (1), the application platform receives and caches "3000", and then replies "is the bank expected account time? ", the user enters" 2016-07-2516:24:30 "in the information entry box and clicks the send button;
(h) in the method, the application platform receives and caches '2016-07-2516: 24: 30', and then replies 'whether the query can be manually urgent or not for you, please wait for a little time';
and then, combining the cached answers by the application platform to generate an answer set.
The answer set in this example 1 may be 2016-07-2514:24:30, recruiter bank, outstanding, bank, time of service, 3000,2016-07-2516: 24: 30;
it is worth mentioning that the answers in the answer set correspond to the questions in the corresponding question set one to one.
Generally, since the content of the question is long, a corresponding field name is used instead of the question. For example, the problem set in this example 1 may be { TRANSFER _ TIME, TRANSFER _ BANK, TRANSFER _ STATE, TRANSFER _ TPYE, TRANSFER _ TIME _ TPYE, TRANSFER _ AMOUNT, TRANSFER _ PREDICT _ TIME }
Wherein, TRANSFER _ TIME represents that the TRANSFER TIME is the question, 2016-07-2514:24:30 is the answer of the question (TRANSFER TIME);
TRANSFER _ BANK indicates that the BANK noun is the question, and the advertiser BANK acts as the answer of the question (BANK noun);
the TRANSFER _ STATE indicates that the account-arriving situation is a question, and the account-not-arriving situation is an answer to the question (the account-arriving situation);
TRANSFER _ TPYE indicates that the TRANSFER type is a question, and the bank is the answer to the question (TRANSFER type);
TRANSFER _ TIME _ TPYE indicates whether a question is served at a service TIME, which is an answer to the question (TRANSFER TIME);
TRANSFER _ AMOUNT indicates that the TRANSFER AMOUNT is a question, 3000 is an answer to the question (TRANSFER AMOUNT);
TRANSFER _ PREDICT _ TIME indicates that the estimated tie-out TIME is the question, and 2016-07-2516:24:30 is the answer to the question (estimated tie-out TIME).
It is worth mentioning that in practical applications, the set sent by the user may also be composed in the form of "question-answer" pairs. In particular, it may be a combination of key-value pairs, i.e. the question corresponds to a key and the answer corresponds to a value.
Step 120: and matching in a preset information tree according to the answer set and the question set.
In this embodiment, after receiving the answer set sent by the user, the server may perform matching in a preset information tree in combination with the question set. As mentioned above, the questions in the question set and the answers in the answer set correspond to each other one to one.
The information tree is a tree-shaped data structure, and the data structure is a way for storing and organizing data in a computer.
The tree structure shown in fig. 3 is referred to as a tree because the structure looks like an inverted tree with the root up and the leaves down. The tree has the following characteristics:
nodes of different adjacent layers are associated through condition information, for example, a line associated with a node 1 and a node 2 in fig. 3 is a piece of condition information;
a child node has only one parent node, such as node 8 in fig. 3 has only one parent node 3;
nodes without parents are called root nodes, and the root nodes in a tree structure are only 1, such as the node 1 in fig. 3;
nodes without children are called leaf nodes, such as nodes 5, 6, 7, 8, …, or 14 in FIG. 3;
nodes with children nodes are called non-leaf nodes, such as nodes 1, 2, 3, or 4 in FIG. 3;
in this embodiment, the information tree may be pre-configured in the server,
specifically, the information tree is:
the system comprises a node set which is formed by at least one node and has a tree-shaped hierarchical relationship, wherein a non-leaf node represents judgment information, the judgment information is a question, the non-leaf node is respectively associated with different child nodes thereof through different condition information, each condition information is an answer, the leaf node represents a question-answer pair and an information template, and the information template is provided with a field to be filled.
In this embodiment, the step 120 may specifically include the following steps:
a1: determining a root node in the information tree as a current node;
a2: acquiring condition information associated with the current node and different child nodes of the current node under the condition that the judgment information represented by the current node is successfully matched with any problem in the problem set;
a3: under the condition that the answer corresponding to the successfully matched question is successfully matched with any condition information, acquiring a child node associated with the successfully matched condition information;
a4: determining the child node as the current node, and repeatedly executing A2 until the current node is a leaf node.
For example, the following steps are carried out:
example 2, continue with the answer set of 2016-07-2514:24:30, recruiter bank, outstanding, bank, time of service, 3000,2016-07-2516: 24:30 as shown in example 1 in step 110;
the problem set is { TRANSFER _ TIME, TRANSFER _ BANK, TRANSFER _ STATE, TRANSFER _ TPYE, TRANSFER _ TIME _ TPYE, TRANSFER _ AMOUNT, TRANSFER _ PREDICT _ TIME };
the steps A1-A3 are performed as follows according to the above mentioned answer set and question set matching in the information tree shown in FIG. 4:
executing A1, and determining the root node in the information tree, namely the node 1, as the current node;
executing a2, since the judgment information "TRANSFER _ STATE" in the node 1 is the same as "TRANSFER _ STATE" in the problem set, the condition information, i.e., "account already" and "account not yet", in the node 1 can be obtained;
executing a3, since the answer corresponding to the question "TRANSFER _ STATE" in the answer set is "not yet billed", which is the same as the condition information "not yet billed" in the node 1, further acquiring a child node associated with the condition information "not yet billed", that is, the node 3;
execution a4 determines node 3 to be the current node, since node 3 is a non-leaf node,
therefore, a2 is repeatedly executed, and since the judgment information "TRANSFER _ TPYE" in the node 3 is the same as "TRANSFER _ TPYE" in the problem set, the condition information of the node 3, that is, "balance of the payment instrument" and "bank" can be obtained;
executing a3, since the question "TRANSFER _ TPYE" corresponds to the answer "bank" in the answer set, and is the same as the condition information "bank" under the node 3, further acquiring a child node associated with the condition information "bank", that is, the node 5;
execution a4 determines node 5 to be the current node, since node 5 is a non-leaf node,
therefore, a2 is repeatedly executed, and since the judgment information "TRANSFER _ TIME" in the node 5 is the same as "TRANSFER _ TIME" in the problem set, the condition information of the node 5, i.e., "service TIME" and "non-service TIME", can be obtained;
executing a3, since the question "TRANSFER _ TIME _ TPYE" corresponds to the answer "service TIME" in the answer set, and is the same as the condition information "service TIME" under the node 5, further acquiring a child node associated with the condition information "service TIME", that is, the node 6;
execution a4 determines node 6 to be the current node, and since node 6 is a leaf node, the following step 130 may be performed.
Step 130: and when the leaf node is matched in the information tree, acquiring a question-answer pair represented by the leaf node and an information template.
In this embodiment, following the example in the previous step, it is assumed that the "question-answer" pair represented by the node 6 is "CAN _ ACCELERATE: fail", the "CAN _ ACCELERATE" represents a manual emergency, i.e., a question, and "fail" is an answer to the question "CAN _ ACCELERATE". The information template of the node 6 is shown in fig. 5.
In other specific embodiments, the information template of the node 6 may be an information template identifier, and the server queries the corresponding information template according to the information template identifier.
Step 140: and writing the answers of the answer set and the answers represented by the matched leaf nodes into the fields to be filled of the matched information template, thereby generating a query result.
In this embodiment, as shown in fig. 5, there are several fields to be filled in the information template, such as "TRANSFER _ BANK".
After acquiring the question-answer pairs and the information templates represented by the leaf nodes, the server also needs to fill the contents of the fields to be filled with answers from the answer sets and the question-answer pairs. And after all the fields to be filled are filled, a finally generated query result can be obtained. In this way, through a dynamic assembly mode, personalized answers provided by a plurality of users are provided in the query result, so that the query result of each user is different and personalized.
Specifically, the writing of the answer in the answer information set and the answer in the matched leaf node into the field to be filled in of the matched information template in the step 140 may specifically include:
under the condition that the question in the question set is the same as the field to be filled in the matched information template, giving the answer corresponding to the question in the answer set to the field to be filled in;
and in the case that the question in the matched question-answer pair is the same as the field to be filled in the matched information template, giving the field to be filled with the answer in the matched question-answer pair.
For example, the following steps are carried out:
example 3, the question set, answer set shown in example 2 in step 120, and the information template in node 6 and the "question-answer" pair "CAN _ ACCELERATE: not" of node 6 shown in fig. 5 are continued.
Since the field to be filled in the information template "TRANSFER _ TIME" is the same as the "TRANSFER _ TIME" in the question set, the question "TRANSFER _ TIME" may be assigned to the field to be filled in the information template "TRANSFER _ TIME" corresponding to the answer "2016-07-2514: 24: 30" in the answer set;
since the field to be filled in "TRANSFER _ BANK" in the information template is the same as "TRANSFER _ BANK" in the question set, the question "TRANSFER _ BANK" may be assigned to the field to be filled in "TRANSFER _ BANK" of the information template corresponding to the answer "recruiter BANK" in the answer set;
since the field to be filled in the information template "TRANSFER _ AMOUNT" is the same as the "TRANSFER _ AMOUNT" in the question set, the answer "3000" corresponding to the question "TRANSFER _ AMOUNT" in the answer set is given to the field to be filled in the information template "TRANSFER _ AMOUNT";
because the field to be filled in the information template "TRANSFER _ STATE" is the same as the field "TRANSFER _ STATE" in the question set, the question "TRANSFER _ STATE" is corresponding to the answer "not found" in the answer set and is given to the field to be filled in "TRANSFER _ STATE" of the information template;
since the field to be filled in the information template "TRANSFER _ PREDICT _ TIME" is the same as the "TRANSFER _ PREDICT _ TIME" in the question set, the question "TRANSFER _ PREDICT _ TIME" is corresponding to the answer "2016-07-2516: 24: 30" in the answer set, and is given to the field to be filled in the information template "TRANSFER _ PREDICT _ TIME";
since the field to be filled in the message template "CAN _ ACCELERATE" is the same as the "question-answer" centering question "CAN _ ACCELERATE", the answer "CAN not" corresponding to the question "CAN _ ACCELERATE" is given to the field to be filled in the message template "CAN _ ACCELERATE";
thus, the generated query result can be as shown in fig. 6, namely that "hello, you roll out to 3000 yuan of a tenderer bank in 2016-07-2514:24:30, the target is not paid out, the expected payment time 2016-07-2516:24:30 is not enough for manual emergency, and you are waiting for patience. "wherein, the bold text is the written answer.
In this embodiment, after the generating the query result, the method may further include:
and returning the query result to the user.
In the embodiment of the application, the data structure of the tree is used, the contents which are repeatedly used in the original static text are stored in the leaf nodes of the information tree in the form of the information template, and the answers are stored in the same leaf node in the form of node information. Therefore, the content repeatedly stored in the original query result only needs to be stored once, so that the occupation of more storage space is avoided; compared with the prior art, the query result obtained by the dynamic assembly mode is simple, and personalized answers are provided for the user, so that the readability is better, and the user experience is improved.
In practical applications, the information represented by the leaf node is not necessarily a fixed "question-answer" pair, for example, in the case of a user querying the account balance, the information represented by the leaf node finally matched may not be a fixed value, and the account balance is generally required to be queried in the corresponding system.
Therefore, under the condition that the information represented by the leaf nodes is query information, the query is carried out through the query information; the queried information is determined as the answer in the "question-answer" pair. For example, specific data is queried from a SQL query statement to a corresponding system, and the queried data is finally used as an answer in a "question-answer" pair.
In a specific embodiment of the present application, in the step 130, if a plurality of leaf nodes are matched, two information templates may also be used simultaneously, and the two generated query results are used after being spliced.
For example, fig. 7 is a schematic diagram of another query result, which is formed by splicing.
Corresponding to the embodiment of the information query method, the application also provides an embodiment of an information query device.
The embodiments of the information inquiry device can be respectively applied to the information inquiry equipment. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor of the device where the software implementation is located as a logical means. From a hardware aspect, as shown in fig. 8, the hardware structure diagram of the device where the information query apparatus is located in the present application is shown, except for the processor, the network interface, the memory, and the nonvolatile memory shown in fig. 8, the device where the apparatus is located in the embodiment may also include other hardware according to the actual function of the information query, which is not described again.
Referring to fig. 9, a block diagram of an information query apparatus according to an embodiment of the present application is provided, where the embodiment is described from a server side, and the apparatus includes: a receiving unit 210, an input unit 220, a matching unit 230, and a generating unit 240.
The receiving unit 210 receives an answer set provided according to a question set and sent by a user; wherein the answer set consists of answers to at least one question;
a matching unit 220, which matches in a preset information tree according to the answer set and the question set; wherein, the questions in the question set correspond to the answers in the answer set one by one, and the information tree is: the system comprises a node set which is composed of at least one node and has a tree-shaped hierarchical relationship, wherein a non-leaf node represents judgment information, the judgment information is a question, the non-leaf node is respectively associated with different child nodes thereof through different condition information, each condition information is an answer, the leaf node represents a question-answer pair and an information template, and the information template is provided with a field to be filled;
an obtaining unit 230, configured to obtain a "question-answer" pair and an information template represented by a leaf node when the leaf node is matched in the information tree;
the generating unit 240 writes the answers in the answer set and the answers represented by the matched leaf nodes into the fields to be filled in of the matched information template, so as to generate a query result.
In an alternative implementation:
the matching unit 220 specifically includes:
a determining subunit, configured to determine a root node in the information tree as a current node;
the first obtaining subunit is used for obtaining the condition information associated with the current node and different child nodes of the current node under the condition that the judgment information represented by the current node is successfully matched with any problem in the problem set;
the second obtaining subunit is used for obtaining the child node associated with the successfully matched condition information under the condition that the answer corresponding to the successfully matched question is successfully matched with any one of the condition information;
and the circulation control subunit determines the child node as a current node, and when the current node is a non-leaf node, the first acquisition subunit is repeatedly executed until the current node is a leaf node.
In an alternative implementation:
the generating unit specifically includes:
the first writing subunit, under the condition that the question in the question set is the same as the field to be filled in the matched information template, endowing the answer corresponding to the question in the answer set to the field to be filled in;
the second writing subunit, under the condition that the question in the matched question-answer pair is the same as the field to be filled in the matched information template, endowing the matched answer in the question-answer pair to the field to be filled in;
and generating a subunit, and determining the information template after assignment as a query result.
In an alternative implementation:
the device further comprises:
and the return unit returns the query result to the user.
By the embodiment, the data structure of the tree is used, the contents which are repeatedly used in the original static text are stored in the leaf nodes of the information tree in the form of the information template, and the answers are stored in the same leaf node in the form of node information. Therefore, the content repeatedly stored in the original query result only needs to be stored once, so that the occupation of more storage space is avoided; compared with the prior art, the query result obtained by the dynamic assembly mode is simple, and personalized answers are provided for the user, so that the readability is better, and the user experience is improved.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step 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, 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 the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application 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 application is limited only by the appended claims.