CN117851542A - Information query method, device, equipment, storage medium and program product - Google Patents

Information query method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN117851542A
CN117851542A CN202311725404.2A CN202311725404A CN117851542A CN 117851542 A CN117851542 A CN 117851542A CN 202311725404 A CN202311725404 A CN 202311725404A CN 117851542 A CN117851542 A CN 117851542A
Authority
CN
China
Prior art keywords
template
query
preset
target
templates
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
CN202311725404.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.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network 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 Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202311725404.2A priority Critical patent/CN117851542A/en
Publication of CN117851542A publication Critical patent/CN117851542A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses an information query method, an information query device, an information query apparatus, a storage medium and a program product, wherein the information query method comprises the following steps: acquiring a query text, wherein the query text comprises keywords to be queried; acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier; acquiring a template item set based on a preset template set; acquiring a query template containing template items corresponding to a query text and a target identification of the query template according to the template item set; matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results; and acquiring a query result corresponding to the query text based on the target template. The method and the device can improve the matching efficiency and the matching speed and reduce the occupation of system resources.

Description

Information query method, device, equipment, storage medium and program product
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an information query method, an apparatus, a device, a storage medium, and a program product.
Background
The special results mainly refer to structured data which are differentially displayed according to different content characteristics in the search results, and can meet the requirements of users at the first time, so that the search experience and the result satisfaction are greatly improved.
Rule retrieval refers to a certain mode which is usually met by a query word query expressed by a user, and a query analysis method for summarizing the query with the same mode into a template is called rule retrieval.
The traditional rule recall scheme adopts a prefix matching mode, and the residual query after prefix matching is carried out on different templates is usually different, so that the traditional scheme only accepts one template in one matching process, and a plurality of templates need multiple matching processes, so that the matching efficiency is low and the matching speed is low.
Disclosure of Invention
The embodiment of the application provides an information query method, an information query device, information query equipment, an information query storage medium and an information query program product, which can improve the matching efficiency and the matching speed and reduce the occupation of system resources.
In one aspect, an embodiment of the present application provides an information query method, where the method includes:
acquiring a query text, wherein the query text comprises keywords to be queried;
acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier;
Acquiring a template item set based on the preset template set;
acquiring a query template containing template items corresponding to the query text and a target identification of the query template according to the template item set;
matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results;
and acquiring a query result corresponding to the query text based on the target template.
In another aspect, an embodiment of the present application provides an information query apparatus, including:
the first acquisition unit is used for acquiring query texts, wherein the query texts comprise keywords to be queried;
the second acquisition unit is used for acquiring a preset template set according to the keywords to be queried, and each preset template in the preset template set has a corresponding preset identifier;
a third obtaining unit, configured to obtain a template item set based on the preset template set;
a fourth obtaining unit, configured to obtain, according to the template item set, a query template corresponding to the query text and including a template item, and a target identifier of the query template;
the matching unit is used for matching preset identifiers of all preset templates in the preset template set with the target identifiers of the query templates so as to determine target templates according to matching results;
And the query unit is used for acquiring a query result corresponding to the query text based on the target template.
In another aspect, an embodiment of the present application provides a computer device, where the computer device includes a processor and a memory, where the memory stores a computer program, and the processor is configured to execute the information query method according to any one of the embodiments above by calling the computer program stored in the memory.
In another aspect, embodiments of the present application provide a computer readable storage medium storing a computer program adapted to be loaded by a processor to perform the information query method of any of the embodiments above.
In another aspect, embodiments of the present application provide a computer program product, including a computer program, which when executed by a processor implements the information query method according to any of the embodiments above.
According to the method and the device, the query text is obtained, and the query text comprises keywords to be queried; acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier; acquiring a template item set based on a preset template set; acquiring a query template containing template items corresponding to a query text and a target identification of the query template according to the template item set; matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results; and acquiring a query result corresponding to the query text based on the target template. According to the embodiment of the application, the target template can be obtained by matching the preset identification of each preset template in the preset template set with the target identification of the query template, so that the matching efficiency and the matching speed can be improved, the waiting time of a user is shortened, and the user experience is improved; the target template can be obtained through one-time matching process, so that the occupation of system resources can be reduced, and the system can be operated more efficiently.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of an information query method according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of an information query apparatus according to an embodiment of the present application.
Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
The embodiment of the application provides an information query method, an information query device, information query equipment, a storage medium and a program product. Specifically, the information query method of the embodiment of the application may be executed by a computer device, where the computer device may be a terminal or a server. The terminal can be smart phones, tablet computers, notebook computers, desktop computers, smart televisions, smart speakers, wearable smart devices, smart vehicle-mounted terminals and other devices, and also can comprise a client, wherein the client can be a financial client, a browser client or an instant messaging client and the like. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution network services, basic cloud computing services such as big data and an artificial intelligence platform, but is not limited thereto.
The special results mainly refer to structured data which are differentially displayed according to different content characteristics in the search results, and can meet the requirements of users at the first time, so that the search experience and the result satisfaction are greatly improved.
Rule retrieval refers to a certain mode which is usually met by a query word query expressed by a user, and a query analysis method for summarizing the query with the same mode into a template is called rule retrieval.
And (3) a template: in rule retrieval, a template refers to a combination of vocabulary names capable of expressing a query pattern, for example, the template is "[ university name ] + [ province name ] + [ admission score line ], which can represent query=" admission score line of a province of university ".
Template item: the template item is a template item corresponding to each vocabulary in the template, such as "[ university name ], which represents a vocabulary containing all university names.
In general, the types of special results are clear, the types of the train are all train-related, and the types of the calculators are all often digitally related. I.e. the same type of results, can be represented by one or several templates that can recall their query sets. The basic steps of rule retrieval therefore include the following steps:
1. A set of queries that are expected to recall a specialized result is obtained. For example, a special result showing a college score line may be recalled, and the query of the special result includes "a university a score line," "a university b score line," "a university c score line," and the like.
2. The query set is generalized into templates. By observing the query set in the step 1, all queries can be summarized into three templates, wherein the template 1 is "[ university name ] + [ provincial name ] + [ admission score line ], the template 2 is" [ provincial name ] + [ university name ] + [ admission score line ], and the template 3 is "[ university name ] + [ county city name ] + [ admission score line ].
3. Judging whether the query carried by the flow in the production environment is consistent with the template, and if so, recalling the special result. For example, query 1= "a university of a saves score line", hit template 1, and recall; query 2= "certain university a province records score line" and "certain university" is not a specific university name, cannot hit the template, and thus cannot be recalled.
The first two steps mainly correspond to the pre-preparation work for realizing rule retrieval, and the third step corresponds to the process of applying the generalized templates on line to realize rule retrieval, namely judging whether the query can recall a special result.
For the traditional rule recall scheme, the third step mentioned in the rule retrieval part is the most core step, whether the query hits the well-induced template is judged, and the scheme commonly used in the industry is based on prefix matching is carried out on the query and the template for a plurality of times to judge whether the query can hit the template, for example, a 'university a' records score line 'and a' university 1 '+' records score line 'are adopted, and the original query can judge that the template 1 is hit according to a' university 'and a' prefix 2 'a' + 'records score line' through three times of prefix matching.
The traditional rule recall scheme adopts a prefix matching mode, and the residual query after prefix matching is carried out on different templates is usually different, so that the traditional scheme only accepts one template at a time in a flow, and multiple templates need multiple flows.
Assume that a template list is shown in table 1 below:
TABLE 1
Template name Template mode
Template 1 University name + [ provincial name + [ admission score line ]
Form 2 [ provincial name + [ university name + [ admission score line ]
Template 3 University name + [ county city name + [ admission score line ]
In order to consider performance, the traditional scheme puts three templates in three parallel flows, for query= "a-saving admission score line of certain university", the residual query before first matching can be regarded as query itself, the residual templates are also templates of each template scheme, and after two rounds of prefix matching are executed, the following two rounds of results are obtained:
The state after the first match can be referred to as table 2 below:
TABLE 2
The state after the second match can be referred to as table 3 below:
TABLE 3 Table 3
Referring to tables 1 to 3, since the rule search adopts prefix matching, for the process 1, only matching is completed first [ certain university ], then matching is completed [ a province ], then matching is completed [ admission sharing line ], and then the template 1 hit can be judged; for flow 3, it can be determined that the template 3 cannot be hit only if the matching is completed [ certain university ] and then the matching is missed [ county city ].
However, in the matching process, as long as the first template item of the current remaining template is the same as the remaining query, the round of prefix matching can be considered to be common. However, in the prefix matching mode, it is difficult to determine which templates are matched in a common intermediate state after several rounds of matching, and thus common prefix matching cannot be multiplexed.
The embodiment of the application provides an information query method, which comprises the steps of acquiring a query text, wherein the query text comprises keywords to be queried; acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier; acquiring a template item set based on a preset template set; acquiring a query template containing template items corresponding to a query text and a target identification of the query template according to the template item set; matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results; and acquiring a query result corresponding to the query text based on the target template. According to the embodiment of the application, the target template can be obtained by matching the preset identification of each preset template in the preset template set with the target identification of the query template, so that the matching efficiency and the matching speed can be improved, the waiting time of a user is shortened, and the user experience is improved; the template can be obtained through one-time matching process, so that the occupation of system resources can be reduced, and the system can operate more efficiently.
The following will describe in detail. It should be noted that the following description order of embodiments is not a limitation of the priority order of embodiments.
Referring to fig. 1, fig. 1 is a flow chart of an information query method according to an embodiment of the present application. The method comprises the following steps 110 to 160:
in step 110, query text is obtained, where the query text includes keywords to be queried.
The query text is text input when information is retrieved. Wherein the query text relates to the needs of the user. Which contains the keywords to be queried. These keywords represent the needs of the user and the query intent.
For example, a user enters query text via an input device. This may be text input through an input device such as a keyboard, a touch screen, or a microphone, or may be non-text input provided by uploading pictures. The query text entered by the user may be in the form of text, speech, or pictures, etc. After the user enters the query text, the system may perform text preprocessing, such as removing spaces, punctuation, word segmentation, etc., to facilitate subsequent query processing. For voice query text, voice recognition may be performed to convert to text. For the picture query text, image recognition can be performed to convert the picture into text. After the text preprocessing, each word in the query text may be labeled with a part of speech, such as nouns, verbs, adjectives, etc., or may be labeled with a part of speech according to the attribute or purpose of each word. This facilitates a more thorough understanding and analysis of the query text. After part-of-speech tagging, the intent of the query text may be analyzed by intent recognition techniques. For example, if keywords such as "booking", "hotel" and the like are included in the query text, it may be determined that the query intention of the user is to book a hotel. Through intent recognition, the user's needs can be better understood and more accurate query results provided.
For example, the query text query is "a score line for recording a university a", for example, the keyword to be queried is "score line for recording". "a-province score line of university" is a noun phrase, wherein "a-province" and "score line of score" are three nouns, and "score line of score" can be divided into two phrases of "score" and "score line". The three nouns of "certain university", "a province" and "score line of recording" can also be labeled with parts of speech according to the attribute or purpose of each word, for example, "certain university" is the university name, "a province" is the place name, and "score line of recording" is the user intention.
For example, the query text may be text entered by the user, such as query text query "a university, a province, score line of admission," such as a keyword to be queried "score line of admission.
For example, the query text may be text corresponding to a voice query of the user so that the user can implement the query function while driving a vehicle or the like.
For example, the query text may also be text corresponding to the picture query input by the user, and the like, so as to implement the picture query function.
Step 120, obtaining a preset template set according to the keyword to be queried, wherein each preset template in the preset template set has a corresponding preset identifier.
The preset template set refers to a predefined template set, and each template is associated with a keyword to be queried and has a corresponding preset identifier.
In the information query method, a group of templates related to the keywords to be queried can be established in advance, each template has a corresponding preset identifier, and the templates can be summarized and generalized according to information such as domain knowledge, query history, user feedback and the like. The set of preset templates may be stored in a template library for later use, which may be a database, knowledge base or storage system for storing and managing the preset templates. After the user inputs the query text, keywords in the query text can be matched, and a preset template set most relevant to the keywords to be queried is found from a template library, which can be realized through technologies such as keyword matching, semantic analysis and the like. According to the matching result, one or more preset templates related to the keywords to be queried can be selected, and the selected preset templates are output as a preset template set for subsequent query processing and use.
In addition, the preset template set can be updated and optimized according to the information such as user feedback, query history and the like, so that the query efficiency and accuracy are improved.
For example, as shown in fig. 2, for example, the query text query is "a score line of record of a university, a province", and the keyword to be queried is "score line of record". Template 1, template 2 and template 3 shown in table 4 can be obtained according to a preset template set obtained by the keywords to be queried.
TABLE 4 Table 4
In some embodiments, after the obtaining the preset template set according to the keyword to be queried, the method further includes:
and generating preset identifiers corresponding to the preset templates based on the first characters of the template items corresponding to the preset templates.
After the preset template set is obtained according to the keyword to be queried, preset identifiers corresponding to the preset templates can be generated based on the first characters of the template items corresponding to the preset templates.
Firstly, word segmentation processing is carried out on template items in each preset template, and the first character of each word is extracted, so that a first character set of each template item can be obtained.
Then, a preset identifier is generated for each preset template based on the extracted first character set. These preset identifications may be based on some specific conversion or encoding of the first character, for example using a hash function or a letter mapping function to convert the first character into a unique identifier.
And then, the generated preset identification and the corresponding preset template are stored in an index table so as to be quickly searched and matched. The index table may be a hash table in which keys are preset identifiers and values are corresponding preset templates.
The method for generating the preset mark based on the first character has the advantages of efficient inquiry, reduced calculation amount, reduced storage space and the like. Specifically, because the preset identifier is generated based on the first character, the relevant preset template can be quickly found by matching the first character of the input query with the preset identifier in the query process, so that the query efficiency is improved. By word segmentation processing and preset identification generation of the template items, the comparison and matching calculation amount of the whole template content in the query process can be reduced, and the query speed is further improved. Because the preset mark is generated by converting and encoding the first character, the preset mark occupies less storage space than the original template item, thereby reducing the consumption of storage resources. It should be noted that uniqueness and stability need to be considered in generating the preset identity. I.e. the generated identity should be able to uniquely represent the corresponding preset template and for the same input template the generated identity should be the same. To achieve this, a suitable hash function or letter mapping function may be selected to ensure identity uniqueness and stability.
In some embodiments, the preset identifier corresponding to each preset template generated based on the first character of the template item corresponding to each preset template includes:
preset identifiers corresponding to the preset templates are generated based on initial letters of initial characters of template items corresponding to the preset templates.
The first letters of each template item can be extracted, and the corresponding preset identification can be generated by utilizing the first letters. The initial-based identification generation mode is simple and effective, and different preset templates can be quickly identified and distinguished.
First, for a template item in each preset template, its initial is extracted. The initial herein refers to the letter at the beginning of each word or phrase.
Then, the extracted initial letters are combined according to a certain rule to generate a unique character string as a preset identifier. The combining rule may be to concatenate the initials in the order of the template items or to concatenate the initials using a specific separator.
Then, for the generated preset mark, normalization processing may be performed, such as removing a space, converting to a lowercase, and the like, so as to ensure consistency and accuracy of the mark.
Because only the first letter of the template item is used, the generated preset mark is relatively short, and the storage and the transmission are convenient. In addition, the preset identification based on the initial letters can be used for fast matching and comparison operation, so that the query processing efficiency is improved. Although only the first letter is used, the generated preset mark still has higher accuracy due to the application of the combination rule and the normalization processing, and different preset templates can be effectively identified and distinguished.
It should be noted that, when generating the preset mark based on the initial, it is necessary to ensure the uniqueness and stability of the generated mark. This can be achieved by selecting appropriate combination rules and normalization processing methods. Furthermore, if the initial combination of two or more templates is the same, it is contemplated that other features or rules may be used to further distinguish them to ensure accurate matching and query results.
In summary, the preset identifier generated based on the initial of the first character of the template item corresponding to each preset template is an effective identifier generating manner in the information query method. The method can improve the query efficiency and accuracy and reduce the calculation amount and the resource consumption of the system.
For example, for template 1, template 2, and template 3, the generated preset identifiers are as shown in table 5 below.
TABLE 5
Template name Template mode Preset mark
Template 1 University name + [ provincial name + [ admission score line ] DSL
Form 2 [ provincial name + [ university name + [ admission score line ] SDL
Template 3 University name + [ county city name + [ admission score line ] DXL
And step 130, acquiring a template item set based on the preset template set.
The main purpose of this step is to extract all the template items from the preset template set to form a template item set for subsequent query processing and matching. First, traversing each preset template in a preset template set, and extracting template items contained in each preset template. When the template items are extracted, each preset template can be decomposed into single template items through natural language processing technologies such as word segmentation, part-of-speech tagging and the like. These template items may include words, phrases, or other units of semantic meaning. All the extracted template items are then collected into a collection to form a template item collection. This set of template items may be a list, array, or other data structure for storing and processing the template items.
In some embodiments, the obtaining a set of template items based on the set of preset templates includes:
and acquiring the template item set according to the union set of the template items corresponding to each preset template of the preset template set.
The union operation refers to an operation of combining a plurality of sets into one single set. In this process, the template item set corresponding to each preset template in the preset template set is combined into a total template item set. This set contains all the template items that appear in the preset template and can be used in subsequent query processing and matching procedures. During the union operation, duplicate template items may appear. These duplicate template items may be caused by the inclusion of the same keyword or phrase in multiple preset templates. In order to ensure the uniqueness of the acquired template item set, a deduplication process may be performed to remove duplicate template items.
For example, for the three templates in table 4, four template items are finally fetched [ university name ], [ provincial name ], [ admission score line ], [ county level city name ].
And 140, acquiring a query template containing template items corresponding to the query text and a target identification of the query template according to the template item set.
In some embodiments, the obtaining, according to the template item set, a query template including a template item corresponding to the query text and a target identifier of the query template includes:
performing word segmentation processing on the query text according to the template items in the template item set to obtain word segmentation data, wherein the word segmentation data comprises word segmentation, template items corresponding to the word segmentation and positions of the word segmentation in the query text;
and performing word segmentation and splicing processing based on the word segmentation data to obtain a query template containing template items corresponding to the query text and a target identification of the query template.
And performing word segmentation processing on the query text according to the template items in the template item set. Word segmentation refers to the breaking up of query text into individual words or phrases, which are referred to as word segmentation. Through word segmentation processing, word segmentation data containing words, template items corresponding to the words and position information of the words in the query text can be obtained.
Then, based on the word segmentation data, word segmentation splicing processing is performed. Word segmentation and concatenation refers to the recombination of the words into a complete query sentence according to the sequence and semantic relation of the words in the query text. And obtaining a query template which corresponds to the query text and contains the template items through word segmentation and splicing. I.e., converting the original query text into a query template consisting of template items.
Then, after obtaining the query template, the target identifier of the query template may be further obtained. The target identification is an identifier associated with the query template for identifying information such as the location of the template item of the query template.
By the method, the query template containing the template items corresponding to the query text and the target identification of the query template can be obtained. The query templates and the target identifiers can be used for subsequent query matching, result display and other operations, and the accuracy and the efficiency of the query are improved.
It should be noted that some errors or uncertainties may occur during the word segmentation process and the word segmentation concatenation process. In order to improve the accuracy and reliability of the query, the segmentation algorithm and the splicing logic can be optimized and improved. Meanwhile, the query processing process can be further improved and optimized by combining domain knowledge, user feedback and other information.
In some embodiments, the performing word segmentation and concatenation processing based on the word segmentation data to obtain a query template including a template item corresponding to the query text and a target identifier of the query template includes:
splicing the template items corresponding to each word in the word segmentation data according to the positions of each word in the query text to obtain a query template corresponding to the query text and containing the template items;
and generating a target identifier of the query template based on the first character of the template item corresponding to the query template.
First, according to the word segmentation data, a template item corresponding to each word segment can be determined. The correspondence is based on matching of the segmentation word with a certain template item of the set of template items during processing. The word segmentation data not only provides the corresponding relation between the word segmentation and the template item, but also provides the position information of the word segmentation in the original query text. This is important context information and the location information of the tokens in the original query text can be used to understand the relative order of the tokens and the logical relationship of the individual tokens in the query. Then, by utilizing the position information of the segmented words, the template items corresponding to the segmented words can be spliced according to the original sequence of the segmented words in the query text, so that a preliminary query template containing the template items is obtained. Wherein, each template item in the query template is used for associating corresponding segmentation in the query text.
When the query template is obtained, a target identification of the query template may also be generated based on the first character of the template item in the query template. Similar to the previous description, this generally means extracting the first character of each template item and then forming a string that uniquely identifies the query template according to some rule. For example, the target identification may be based on some specific conversion or encoding of the first character, e.g., using a hash function or a letter mapping function to convert the first character to a unique identifier.
In some embodiments, the generating the target identifier of the query template based on the first character of the template item corresponding to the query template includes:
and generating a target identifier of the query template based on the initial letter of the first character of the template item corresponding to the query template.
Wherein the corresponding target identification may be generated by extracting the initials of each template item and using these initials. First, for a template item in a query template, its initials are extracted. The initial herein refers to the letter at the beginning of each word or phrase.
Then, the extracted initial letters are combined according to a certain rule to generate a unique character string as a preset identifier. The combining rule may be to concatenate the initials in the order of the template items or to concatenate the initials using a specific separator.
For example, for the query text query= "XX university XX score line" 4 word (token) data as shown in table 6 may be obtained.
TABLE 6
Then, based on depth-first traversal, word-segmentation token which can be spliced into the original query file query is found.
Among these, depth-first search (Depth First Search, DFS) is an algorithm for traversing or searching trees or graphs. The depth-first traversal starts from an initial access node, which may have a plurality of adjacent nodes, and the depth-first traversal is performed by first accessing a first adjacent node, and then accessing the first adjacent node by using the accessed adjacent node as the initial node. I.e., each time after having accessed the current node, first accesses the first neighbor node of the current node.
For example, the process of depth-first traversal is as follows steps a through c:
a. starting to search from the 0 position, wherein token1 is XX, the template item corresponds to the name of province, the position is 0-1, then the token beginning with the position of 2 is searched, and the process is not ended.
b. Continuing to search from the 0 position, wherein the token3 is 'XX university', the template item corresponds to 'university name', the position is 0-3, the token2 is 'XX' when the template item is searched for at the beginning of 4, the position is 4-5, the token4 is searched for at the beginning of 6, the token4 is 'recording score line', the template item corresponds to 'recording score line', the found token3, token2 and token4 are spliced into token3-token2-token4, and the spliced content can form an original query text query.
c. And so on until all possible token combinations are found.
Then, combining the spliced content token3-token2-token4 found in the third step to obtain a target template corresponding to the query text, and then generating a unique identifier (actually generating the unique identifier by using a hash algorithm, here only by way of example) through, for example, the first character of the template item of token3 is D, the first character of the template item of token2 is S, and the first character of the template item of token3 is L, so that a unique identifier "DSL" is obtained.
Step 150, matching the preset identifier of each preset template in the preset template set with the target identifier of the query template, so as to determine a target template according to the matching result.
In some embodiments, the matching the preset identifier of each preset template in the preset template set with the target identifier of the query template to determine a target template according to the matching result includes:
and determining a preset template with a preset mark matched with the target mark of the query template in the preset template set as the target template.
The target templates are obtained by matching the preset identifiers of the preset templates in the preset template set with the target identifiers of the query templates, so that the matching efficiency and the matching speed can be improved, the waiting time of a user is shortened, and the user experience is improved. The target template can be obtained through one-time matching process, so that the occupation of system resources can be reduced, and the system can be operated more efficiently.
For example, comparing whether the preset identifier in the preset template set is consistent with the target identifier of the query template, if the preset identifier DSL of the template 1 is consistent with the target identifier DSL of the query template, determining that the query text query may hit the template 1.
Step 160, obtaining a query result corresponding to the query text based on the target template.
For example, query results related to query text retrieved from a database, knowledge base, or other data source based on the target template. For example, query results may also be processed and integrated in preparation for presentation or further analysis. Such as sorting, filtering, aggregating, etc., the query results.
For example, the query results may also be presented in a particular format (e.g., table, chart, text, etc.), or sent to other systems or services.
The embodiment of the application adopts a mode containing the matching word to replace prefix matching, so that the sharing of the matching cost of the same template item (such as the template item corresponding to the matching word (the admission score line) appears in all templates) among different templates is realized, the matching speed is improved to more than 3 times of that of the traditional scheme in the actual special result rule retrieval production, and the utilization rate of a CPU (central processing unit) is reduced to less than half of that of the traditional scheme.
Wherein the matching word can be determined by the keyword to be queried in the query text. According to the method and the device, a preset template set containing matching words is searched, then a template item set is obtained based on the preset template set, then all the segmented words of the query text are obtained based on the target item set, then a possible template set is obtained through segmented word splicing, further a target template of the query text is determined, and a scheme of special result rule recall is achieved by judging the intersection of the target template and the existing preset template set. Because the mode of containing the matching words (namely the keywords to be queried in the query text) does not need to pay attention to the intermediate state generated by prefix matching, the sharing of the matching results is realized to the greatest extent, in the actual special result rule retrieval production, the matching speed is improved to be more than 3 times that of the traditional scheme, and the CPU utilization rate is reduced to be less than half of that of the traditional scheme.
All the above technical solutions may be combined to form an optional embodiment of the present application, which is not described here in detail.
According to the method and the device, the query text is obtained, and the query text comprises keywords to be queried; acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier; acquiring a template item set based on a preset template set; acquiring a query template containing template items corresponding to a query text and a target identification of the query template according to the template item set; matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results; and acquiring a query result corresponding to the query text based on the target template. According to the embodiment of the application, the target template can be obtained by matching the preset identification of each preset template in the preset template set with the target identification of the query template, so that the matching efficiency and the matching speed can be improved, the waiting time of a user is shortened, and the user experience is improved; the target template can be obtained through one-time matching process, so that the occupation of system resources can be reduced, and the system can be operated more efficiently.
In order to facilitate better implementation of the information query method of the embodiment of the application, the embodiment of the application also provides an information query device. Referring to fig. 2, fig. 2 is a schematic structural diagram of an information query apparatus according to an embodiment of the present application. The information query apparatus 200 may include:
a first obtaining unit 210, configured to obtain a query text, where the query text includes keywords to be queried;
a second obtaining unit 220, configured to obtain a preset template set according to the keyword to be queried, where each preset template in the preset template set has a corresponding preset identifier;
a third obtaining unit 230, configured to obtain a template item set based on the preset template set;
a fourth obtaining unit 240, configured to obtain, according to the template item set, a query template corresponding to the query text and including a template item and a target identifier of the query template;
a matching unit 250, configured to match preset identifiers of each preset template in the preset template set with target identifiers of the query template, so as to determine a target template according to a matching result;
and the query unit 260 is configured to obtain a query result corresponding to the query text based on the target template.
In some embodiments, the fourth obtaining unit 240 is configured to:
performing word segmentation processing on the query text according to the template items in the template item set to obtain word segmentation data, wherein the word segmentation data comprises word segmentation, template items corresponding to the word segmentation and positions of the word segmentation in the query text;
and performing word segmentation and splicing processing based on the word segmentation data to obtain a query template containing template items corresponding to the query text and a target identification of the query template.
In some embodiments, when performing word segmentation and concatenation processing based on the word segmentation data to obtain a query template including a template item corresponding to the query text and a target identifier of the query template, the fourth obtaining unit 240 may be configured to:
splicing the template items corresponding to each word in the word segmentation data according to the positions of each word in the query text to obtain a query template corresponding to the query text and containing the template items;
and generating a target identifier of the query template based on the first character of the template item corresponding to the query template.
In some embodiments, when generating the target identifier of the query template based on the first character of the template item corresponding to the query template, the fourth obtaining unit 240 may be configured to:
And generating a target identifier of the query template based on the initial letter of the first character of the template item corresponding to the query template.
In some embodiments, the matching unit 250 is configured to:
and determining a preset template with a preset mark matched with the target mark of the query template in the preset template set as the target template.
In some embodiments, the second obtaining unit 220 may be further configured to, after obtaining the preset template set according to the keyword to be queried:
and generating preset identifiers corresponding to the preset templates based on the first characters of the template items corresponding to the preset templates.
In some embodiments, the second obtaining unit 220 may be configured to, when generating the preset identifier corresponding to each preset template based on the first character of the template item corresponding to each preset template:
preset identifiers corresponding to the preset templates are generated based on initial letters of initial characters of template items corresponding to the preset templates.
In some embodiments, the third obtaining unit 230 is configured to:
and acquiring the template item set according to the union set of the template items corresponding to each preset template of the preset template set.
All the above technical solutions may be combined to form an optional embodiment of the present application, which is not described here in detail.
It should be understood that the information query apparatus embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, no further description is provided here. Specifically, the information query apparatus shown in fig. 2 may execute the above-mentioned information query method embodiment, and the foregoing and other operations and/or functions of each unit in the information query apparatus implement the corresponding flow of the above-mentioned method embodiment, which are not repeated herein for brevity.
Optionally, the application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
Fig. 3 is a schematic structural diagram of a computer device provided in an embodiment of the present application, where the computer device may be a terminal or a server. As shown in fig. 3, the computer device 300 may include: a communication interface 301, a memory 302, a processor 303 and a communication bus 304. Communication interface 301, memory 302, and processor 303 enable communication with each other via communication bus 304. The communication interface 301 is used for data communication between the computer device 300 and an external device. The memory 302 may be used to store software programs and modules, and the processor 303 may execute the software programs and modules stored in the memory 302, such as the software programs for corresponding operations in the foregoing method embodiments.
Alternatively, the processor 303 may call a software program and module stored in the memory 302 to perform the following operations:
acquiring a query text, wherein the query text comprises keywords to be queried; acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier; acquiring a template item set based on the preset template set; acquiring a query template containing template items corresponding to the query text and a target identification of the query template according to the template item set; matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results; and acquiring a query result corresponding to the query text based on the target template.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application provide a computer readable storage medium having stored therein a plurality of computer programs that can be loaded by a processor to perform steps in any of the information query methods provided by the embodiments of the present application. The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Wherein the storage medium may include: read Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic or optical disk, and the like.
The steps in any information query method provided in the embodiments of the present application may be executed by the computer program stored in the storage medium, so that the beneficial effects that any information query method provided in the embodiments of the present application may be achieved, which are detailed in the previous embodiments and are not repeated herein.
Embodiments of the present application also provide a computer program product comprising computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes a corresponding flow in any information query method in the embodiments of the present application, which is not described herein for brevity.
Embodiments of the present application also provide a computer program comprising computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes a corresponding flow in any information query method in the embodiments of the present application, which is not described herein for brevity.
It should be appreciated that the processor of an embodiment of the present application may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method embodiments may be implemented by integrated logic circuits of hardware in a processor or instructions in software form. The processor may be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
It will be appreciated that the memory in embodiments of the present application may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (Double Data Rate SDRAM), enhanced SDRAM (ESDRAM), synchronous DRAM (SLDRAM), and Direct RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the present embodiment, the term "module" or "unit" refers to a computer program or a part of a computer program having a predetermined function, and works together with other relevant parts to achieve a predetermined object, and may be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Also, a processor (or multiple processors or memories) may be used to implement one or more modules or units. Furthermore, each module or unit may be part of an overall module or unit that incorporates the functionality of the module or unit.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown 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 units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in the form of a software product stored in a storage medium, comprising several instructions for causing a terminal device (which may be a personal computer, a server) to perform all or part of the steps of the method described in the various embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk, etc.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. An information query method, the method comprising:
acquiring a query text, wherein the query text comprises keywords to be queried;
acquiring a preset template set according to the keywords to be queried, wherein each preset template in the preset template set has a corresponding preset identifier;
acquiring a template item set based on the preset template set;
acquiring a query template containing template items corresponding to the query text and a target identification of the query template according to the template item set;
matching preset identifiers of all preset templates in the preset template set with target identifiers of the query templates to determine target templates according to matching results;
and acquiring a query result corresponding to the query text based on the target template.
2. The information query method as claimed in claim 1, wherein said obtaining, according to the template item set, a query template corresponding to the query text and including a template item and a target identifier of the query template includes:
performing word segmentation processing on the query text according to the template items in the template item set to obtain word segmentation data, wherein the word segmentation data comprises word segmentation, template items corresponding to the word segmentation and positions of the word segmentation in the query text;
and performing word segmentation and splicing processing based on the word segmentation data to obtain a query template containing template items corresponding to the query text and a target identification of the query template.
3. The information query method of claim 2, wherein the performing word segmentation and concatenation processing based on the word segmentation data to obtain a query template corresponding to the query text and including a template item and a target identifier of the query template includes:
splicing the template items corresponding to each word in the word segmentation data according to the positions of each word in the query text to obtain a query template corresponding to the query text and containing the template items;
and generating a target identifier of the query template based on the first character of the template item corresponding to the query template.
4. The information query method as claimed in claim 3, wherein said generating a target identifier of the query template based on a first character of a template item corresponding to the query template comprises:
and generating a target identifier of the query template based on the initial letter of the first character of the template item corresponding to the query template.
5. The information query method as claimed in claim 1, wherein said matching the preset identifier of each preset template in the preset template set with the target identifier of the query template to determine the target template according to the matching result comprises:
and determining a preset template with a preset mark matched with the target mark of the query template in the preset template set as the target template.
6. The information query method as claimed in claim 1, further comprising, after said obtaining a preset template set according to the keyword to be queried:
and generating preset identifiers corresponding to the preset templates based on the first characters of the template items corresponding to the preset templates.
7. The information query method as claimed in claim 6, wherein the preset identifiers corresponding to the preset templates generated based on the first characters of the template items corresponding to the preset templates, comprises:
Preset identifiers corresponding to the preset templates are generated based on initial letters of initial characters of template items corresponding to the preset templates.
8. The information query method of claim 1, wherein the obtaining a set of template items based on the set of preset templates comprises:
and acquiring the template item set according to the union set of the template items corresponding to each preset template of the preset template set.
9. An information query apparatus, the apparatus comprising:
the first acquisition unit is used for acquiring query texts, wherein the query texts comprise keywords to be queried;
the second acquisition unit is used for acquiring a preset template set according to the keywords to be queried, and each preset template in the preset template set has a corresponding preset identifier;
a third obtaining unit, configured to obtain a template item set based on the preset template set;
a fourth obtaining unit, configured to obtain, according to the template item set, a query template corresponding to the query text and including a template item, and a target identifier of the query template;
the matching unit is used for matching preset identifiers of all preset templates in the preset template set with the target identifiers of the query templates so as to determine target templates according to matching results;
And the query unit is used for acquiring a query result corresponding to the query text based on the target template.
10. A computer device, characterized in that it comprises a processor and a memory, in which a computer program is stored, the processor being arranged to execute the information query method according to any of claims 1-8 by invoking the computer program stored in the memory.
11. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program, which is adapted to be loaded by a processor for performing the information query method of any of claims 1-8.
12. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the information query method of any of claims 1-8.
CN202311725404.2A 2023-12-14 2023-12-14 Information query method, device, equipment, storage medium and program product Pending CN117851542A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311725404.2A CN117851542A (en) 2023-12-14 2023-12-14 Information query method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311725404.2A CN117851542A (en) 2023-12-14 2023-12-14 Information query method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN117851542A true CN117851542A (en) 2024-04-09

Family

ID=90537430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311725404.2A Pending CN117851542A (en) 2023-12-14 2023-12-14 Information query method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN117851542A (en)

Similar Documents

Publication Publication Date Title
CN109670163B (en) Information identification method, information recommendation method, template construction method and computing device
US10423649B2 (en) Natural question generation from query data using natural language processing system
US8577882B2 (en) Method and system for searching multilingual documents
CN110929125B (en) Search recall method, device, equipment and storage medium thereof
CN110457672B (en) Keyword determination method and device, electronic equipment and storage medium
CN117056471A (en) Knowledge base construction method and question-answer dialogue method and system based on generation type large language model
CN109508458B (en) Legal entity identification method and device
WO2008014702A1 (en) Method and system of extracting new words
CN110162768B (en) Method and device for acquiring entity relationship, computer readable medium and electronic equipment
WO2021189951A1 (en) Text search method and apparatus, and computer device and storage medium
CN114610845B (en) Intelligent question-answering method, device and equipment based on multiple systems
CN110134780B (en) Method, device, equipment and computer readable storage medium for generating document abstract
TW202001621A (en) Corpus generating method and apparatus, and human-machine interaction processing method and apparatus
CN110245357B (en) Main entity identification method and device
CN111950729A (en) Knowledge base construction method and device, electronic equipment and readable storage device
CN111552798A (en) Name information processing method and device based on name prediction model and electronic equipment
CN110705285B (en) Government affair text subject word library construction method, device, server and readable storage medium
CN112765976A (en) Text similarity calculation method, device and equipment and storage medium
CN111859079B (en) Information searching method, device, computer equipment and storage medium
CN109918661B (en) Synonym acquisition method and device
CN115510247A (en) Method, device, equipment and storage medium for constructing electric carbon policy knowledge graph
CN115357765A (en) Data searching method and device, electronic equipment and storage medium
CN114842982A (en) Knowledge expression method, device and system for medical information system
CN117851542A (en) Information query method, device, equipment, storage medium and program product
CN111401034B (en) Semantic analysis method, semantic analysis device and terminal for text

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