A text processing method, apparatus, and related equipment

By using the knowledge graph in the automatic question answering system to identify entities and predicates in the user's natural language input and combining them into query text, the problem of redundant character interference is solved and the accuracy and correctness of the answer are improved.

CN116483973BActive Publication Date: 2024-08-23TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202310466539.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-08-13
Publication Date
2024-08-23
Estimated Expiration
2038-08-13

AI Technical Summary

Technical Problem

When the automatic question and answer system processes user natural language input, redundant characters interfere with query intent recognition, resulting in a decrease in answer accuracy.

Method used

By obtaining the target text and knowledge map, search for entity strings and predicate strings, combine them into query text, find corresponding results in the knowledge base, exclude irrelevant characters, and accurately identify query intentions.

Benefits of technology

It improves the accuracy of finding answers in the knowledge base and enhances the correctness of answers in the automatic question and answer system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116483973B
    Figure CN116483973B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a text processing method, device and related equipment, the method comprising: obtaining a target text and a knowledge graph; the knowledge graph comprises entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates; searching for entity strings belonging to the target text in all entity strings as target entity strings, and searching for predicate strings belonging to the target text in all predicate strings as target predicate strings; combining the target entity strings and the target predicate strings into a target query text, searching for query results corresponding to the target query text in a knowledge base as target query results, and outputting the target query results. The present invention can identify the query intention of a user, thereby improving the accuracy of pushing answers to questions to the user.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the Chinese patent application filed with the China Patent Office on August 13, 2018, with application number 201810915717.7 and application name “A text processing method, device and related equipment”, all contents of which are incorporated by reference into this application. Technical Field

[0002] The present invention relates to the field of computer technology, and in particular to a text processing method, apparatus and related equipment. Background Art

[0003] Automatic question-answering systems, also known as human-computer dialogue systems, allow users to describe questions in natural language. The system then searches through vast amounts of data for accurate, concise, and user-friendly answers and provides them to the user. Automatic question-answering systems are a key area in natural language processing, enabling users to directly ask questions and receive answers in natural language. For example, a user might ask, "Where is Shanghai Jiao Tong University?" and the system might respond, "No. 800, Dongchuan Road, Minhang District, Shanghai." Compared to traditional search engines that return large collections of documents based on keywords, automatic question-answering systems eliminate the need for users to search for relevant information and can quickly provide answers.

[0004] Because users input directly using natural language, the voice signal may contain information irrelevant to the question being asked. For example, if a user inputs, "Can you tell me where Shanghai Jiao Tong University is?" or "Do you know exactly where Shanghai Jiao Tong University is located?", when converted into query text, the query text may contain characters irrelevant to the question. When the automatic question-answering system recognizes the query text, these extraneous characters interfere with the system's ability to identify the query intent, reducing the system's accuracy in identifying the query intent and, in turn, the accuracy of the answers it delivers to the user. Summary of the Invention

[0005] Embodiments of the present invention provide a text processing method, apparatus, and related equipment that can identify query intent and thereby improve the accuracy of answering questions pushed to users.

[0006] One aspect of the present invention provides a text processing method, comprising:

[0007] Obtaining a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to a plurality of entities and predicate strings corresponding to a plurality of predicates;

[0008] Searching for an entity string belonging to the target text among all entity strings as a target entity string, and searching for a predicate string belonging to the target text among all predicate strings as a target predicate string;

[0009] The target entity character string and the target predicate character string are combined into a target query text, a query result corresponding to the target query text is searched in a knowledge base as a target query result, and the target query result is output.

[0010] The step of combining the target entity character string and the target predicate character string into a target query text includes:

[0011] Combining the target entity string and the target predicate string into a first auxiliary text;

[0012] Obtaining a target domain identifier corresponding to a target entity string in the first auxiliary text, and obtaining a target synonym corresponding to a target predicate string in the first auxiliary text; the target domain identifier is used to represent the business domain of the target entity corresponding to the target entity string;

[0013] If a mapping relationship between the target domain identifier and the target synonym exists in the first relationship library, the first auxiliary text is determined as the target query text; the first relationship library includes multiple domain identifiers and at least one synonym corresponding to each domain identifier.

[0014] The step of determining the first auxiliary text as the target query text includes:

[0015] Extracting, from a second relational database, predicate aliases corresponding to the target domain identifier and the target synonym as sample predicate aliases; the second relational database includes a plurality of domain identifiers, at least one synonym corresponding to each domain identifier, and at least one predicate alias corresponding to each synonym;

[0016] If there is a sample predicate alias that is identical to the target predicate character string, the first auxiliary text is determined as the target query text.

[0017] The step of searching for an entity string belonging to the target text among all entity strings as the target entity string includes:

[0018] Constructing a first dictionary tree based on all the entity character strings; wherein a node in the first dictionary tree includes a character in an entity character string;

[0019] According to a breadth-first search, setting a mismatch pointer for each node in the first dictionary tree;

[0020] Performing multi-mode string matching on the target text according to the first dictionary tree and the mismatch pointers corresponding to the nodes in the first dictionary tree to obtain first position information of a character string in the target text that matches the entity character string in the first dictionary tree;

[0021] In the target text, the character string between the start position and the end position in the first position information is used as the target entity character string, and the target domain identifier corresponding to the target entity character string is obtained from the first dictionary tree.

[0022] Among them, also include:

[0023] Extract target entity strings with the same target domain identifier;

[0024] According to the first position information corresponding to the extracted target entity string, the target entity string with the largest first position information is retained, and the target entity strings other than the target entity string with the largest first position information are deleted among all target entity strings with the same target domain identifier; the target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to all target entity strings with the same target domain identifier.

[0025] The step of searching for a predicate string belonging to the target text among all predicate strings as the target predicate string includes:

[0026] Constructing a second dictionary tree based on all the predicate character strings; wherein a node in the second dictionary tree includes a character in a predicate character string;

[0027] According to a breadth-first search, setting a mismatch pointer for each node in the second dictionary tree;

[0028] performing multi-pattern string matching on the target text according to the second dictionary tree and the mismatch pointers corresponding to the nodes in the second dictionary tree to obtain second position information of a character string in the target text that matches the predicate character string in the second dictionary tree;

[0029] In the target text, the character string between the start position and the end position in the second position information is used as the target predicate character string, and a target synonym corresponding to the target predicate character string is obtained from the second dictionary tree.

[0030] The step of combining the target entity character string and the target predicate character string into a target query text includes:

[0031] combining the target entity string and the target predicate string into a second auxiliary text;

[0032] If there is overlapping position information between the first position information and the second position information corresponding to the second auxiliary text, the second auxiliary text with the overlapping position information is deleted; the starting position and the ending position in the overlapping position information are both within the range of the first position information and the range of the second position information;

[0033] The second auxiliary text remaining after the deletion is determined as the target query text.

[0034] Among them, also include:

[0035] Acquire multiple texts to be tested, and set polling priorities for the multiple texts to be tested;

[0036] selecting, according to the polling priority, an auxiliary test text for current polling from the plurality of texts to be tested;

[0037] Searching for an entity string belonging to the auxiliary test text among all the entity strings, and searching for a predicate string belonging to the auxiliary test text among all the predicate strings;

[0038] Combining the found entity string and predicate string into a test query text, searching the knowledge base for a query result corresponding to the test query text as the test query result;

[0039] When each to-be-tested text is determined to be an auxiliary test text, polling is stopped, and the number of test query texts having the same test query result is counted.

[0040] Another aspect of the present invention provides a text processing device, comprising:

[0041] An acquisition module, configured to acquire a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to a plurality of entities and predicate strings corresponding to a plurality of predicates;

[0042] A first search module is configured to search for an entity string belonging to the target text among all entity strings as a target entity string;

[0043] A second search module is used to search for a predicate string belonging to the target text among all predicate strings as a target predicate string;

[0044] A combining module, configured to combine the target entity character string and the target predicate character string into a target query text;

[0045] The output module is used to search the knowledge base for a query result corresponding to the target query text as the target query result, and output the target query result.

[0046] Wherein, the combination module includes:

[0047] A first combining unit, configured to combine the target entity character string and the target predicate character string into a first auxiliary text;

[0048] an acquisition unit, configured to acquire a target domain identifier corresponding to a target entity string in the first auxiliary text, and acquire a target synonym corresponding to a target predicate string in the first auxiliary text; the target domain identifier is used to represent a business domain in which a target entity corresponding to the target entity string belongs;

[0049] A determination unit is configured to determine the first auxiliary text as the target query text if a mapping relationship between the target domain identifier and the target synonym exists in a first relationship library; the first relationship library includes multiple domain identifiers and at least one synonym corresponding to each domain identifier.

[0050] Wherein, the determining unit includes:

[0051] an extraction subunit, configured to extract, from a second relational database, predicate aliases corresponding to the target domain identifier and the target synonym as sample predicate aliases; the second relational database comprising a plurality of domain identifiers, at least one synonym corresponding to each domain identifier, and at least one predicate alias corresponding to each synonym;

[0052] The first determining subunit is configured to determine the first auxiliary text as the target query text if there is a sample predicate alias that is identical to the target predicate character string.

[0053] The first search module includes:

[0054] A first construction unit is configured to construct a first dictionary tree based on all entity character strings; a node in the first dictionary tree includes a character in an entity character string;

[0055] A first setting unit is configured to set a mismatch pointer for each node in the first dictionary tree according to a breadth-first search;

[0056] a first matching unit, configured to perform multi-pattern string matching processing on the target text according to the first dictionary tree and mismatch pointers corresponding to each node in the first dictionary tree, to obtain first position information of a character string in the target text that matches an entity character string in the first dictionary tree;

[0057] The first extraction unit is configured to use, in the target text, a character string between a start position and an end position in the first position information as the target entity character string, and obtain a target domain identifier corresponding to the target entity character string from the first dictionary tree.

[0058] Among them, it also includes;

[0059] An extraction module, used for extracting target entity strings having the same target domain identifier;

[0060] A deletion module is used to retain the target entity string with the largest first position information based on the first position information corresponding to the extracted target entity string, and delete the target entity string other than the target entity string with the largest first position information among all target entity strings with the same target domain identifier; the target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to all target entity strings with the same target domain identifier.

[0061] The second search module includes:

[0062] A second construction unit is configured to construct a second dictionary tree based on all the predicate character strings; a node in the second dictionary tree includes a character in a predicate character string;

[0063] A second setting unit is configured to set a mismatch pointer for each node in the second dictionary tree according to a breadth-first search;

[0064] a second matching unit, configured to perform multi-pattern string matching processing on the target text according to the second dictionary tree and the mismatch pointers corresponding to the nodes in the second dictionary tree, to obtain second position information of a character string in the target text that matches the predicate character string in the second dictionary tree;

[0065] The second extraction unit is configured to use, in the target text, the character string between the start position and the end position in the second position information as the target predicate character string, and obtain a target synonym corresponding to the target predicate character string from the second dictionary tree.

[0066] Wherein, the combination module further includes:

[0067] A second combining unit, configured to combine the target entity character string and the target predicate character string into a second auxiliary text;

[0068] a deleting unit, configured to delete the second auxiliary text having overlapping position information if there is overlapping position information between the first position information and the second position information corresponding to the second auxiliary text, wherein the starting position and the ending position of the overlapping position information are both within the range of the first position information and the range of the second position information;

[0069] The deleting unit is further configured to determine the second auxiliary text remaining after the deletion as the target query text.

[0070] Among them, also include:

[0071] The acquisition module is further configured to acquire a plurality of texts to be tested and set polling priorities for the plurality of texts to be tested;

[0072] A selection module, configured to select an auxiliary test text for current polling from the plurality of texts to be tested according to the polling priority;

[0073] The first search module is further configured to search for an entity string belonging to the auxiliary test text among all the entity strings, and search for a predicate string belonging to the auxiliary test text among all the predicate strings;

[0074] The combining module is further configured to combine the found entity character string and predicate character string into a test query text, and search the knowledge base for a query result corresponding to the test query text as the test query result;

[0075] The statistics module is used to stop polling when each to-be-tested text is determined to be an auxiliary test text, and to count the number of test query texts having the same test query result.

[0076] Another aspect of the present invention provides an electronic device, comprising: a processor and a memory;

[0077] The processor is connected to a memory, wherein the memory is used to store program code, and the processor is used to call the program code to execute the method in one aspect of the embodiment of the present invention.

[0078] Another aspect of the present invention provides a computer storage medium storing a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the method according to one aspect of the embodiments of the present invention is executed.

[0079] The embodiment of the present invention obtains a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates; among all entity strings, the entity string belonging to the target text is searched as the target entity string, and among all predicate strings, the predicate string belonging to the target text is searched as the target predicate string; the target entity string and the target predicate string are combined into a target query text, and the query result corresponding to the target query text is searched in the knowledge base as the target query result, and the target query result is output. As can be seen from the above, based on the entity string and predicate string contained in the knowledge graph, the target entity string and the target predicate string are searched from the target text itself, and the query intent of the target text is determined based on the target entity string and the target predicate string. It can discard characters in the query text that are not related to the question, accurately identify the query intent of the target text, and improve the accuracy of finding the answer to the target text in the knowledge base. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0081] Figure 1a This is a system architecture diagram of a text processing method provided by an embodiment of the present invention;

[0082] Figure 1b-Figure 1c Schematic diagram of a text processing method provided by an embodiment of the present invention;

[0083] Figure 2a This is a flowchart of a text processing method provided by an embodiment of the present invention;

[0084] Figure 2b is a schematic diagram of a knowledge graph provided by an embodiment of the present invention;

[0085] Figure 2c is a schematic diagram of a multi-pattern string matching provided by an embodiment of the present invention;

[0086] Figure 3 is a flowchart of another text processing method provided by an embodiment of the present invention;

[0087] Figure 4 is a flowchart of another text processing method provided by an embodiment of the present invention;

[0088] Figure 5is a structural diagram of a text processing device provided by an embodiment of the present invention;

[0089] Figure 6 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0090] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0091] See Figure 1a , is a system architecture diagram of a text processing method provided by an embodiment of the present invention. Server 20a provides services for a user terminal cluster, and the user terminal cluster may include: user terminal 10b, user terminal 20c, ..., user terminal 20d. When a user (which may be user 10a, 20e or 20f) needs to ask a question, he or she may send voice or input text to the user terminal (which may be user terminal 10b, user terminal 20c or user terminal 20d). After the user terminal obtains the voice or text, it sends it to server 20a, and server 20a identifies the user's query intention and searches for answers to the questions based on the query intention. Server 20a sends the found answer to the user terminal, and the user terminal displays the answer to the user. Of course, if the user terminal itself has the function of identifying the user's query intention and the function of finding answers to questions, then the identification and search can be performed directly in the user terminal without having to send it to the server. The following Figure 1b-Figure 1c Taking a user 10a and a user terminal 10b as an example, how to identify the query intent of the text and how to find the answer to the question is explained.

[0092] Among them, user terminals may include mobile phones, tablets, laptops, PDAs, smart speakers, smart robots, smart homes, mobile Internet devices (MID), POS (Point of Sales) machines, wearable devices (such as smart watches, smart bracelets, etc.), etc.

[0093] See Figure 1b — Figure 1c , is a scene diagram of a text processing method provided by an embodiment of the present invention. Figure 1bAs shown, the user terminal 10b (here taking the smart speaker as an example) includes a question-and-answer system, which can answer questions asked by users in natural language. User 10a sends a voice to the smart speaker 10b: the zip code of Shenzhen City, Guangdong Province. The smart speaker 10b converts the acquired voice signal into text 10c. After the smart speaker 10b obtains the text 10c to be queried, it performs multi-mode string matching on the text 10c based on the dictionary tree 10d to find the string that matches the text 10c in all entity strings in the dictionary tree 10d. The result output after matching is the position information of the successfully matched string in the text 10c (the position information includes the starting position and the ending position) and the domain identifier carried by the string, and the string corresponding to the output position information in the text 10c is extracted as the target entity string. After the matching process, the output results are: [0, 2, 1] and [3, 5, 1]. For the output result "[0, 2, 1]", the string between the first and third positions (in computers, counting starts at 0, that is, the starting position is represented by the value 0) in text 10c is the target entity string, that is, the string "Guangdong Province" is the target entity string, and the domain identifier corresponding to the target entity string "Guangdong Province" is 1 (the business domain corresponding to the domain identifier "1" is the administrative unit). Similarly, for the output result "[3, 5, 1]", the string between the fourth and sixth positions in text 10c is also the target entity string, that is, the string "Shenzhen City" is the target entity string, and the domain identifier corresponding to the target entity string "Shenzhen City" is also 1.

[0094] like Figure 1bAs shown in the figure, the trie 10d is constructed based on the entity strings corresponding to multiple entities in the knowledge graph 10p. Each node in the trie 10d includes a character of an entity, and the trie 10d is a prefix tree. For entity strings with the same prefix, nodes can be shared. Using this data structure of the trie can save storage space. At the same time, in the trie 10d, the nodes corresponding to the last character of each entity string are all carried with the domain identifier corresponding to the entity string. The number of domain identifiers can be one or more. The domain identifier is used to represent the business domain where the entity corresponding to the entity string is located. For the carrying method, the key in the key-value pair of the node can be set as a character of the entity string, and the value can be set as the domain identifier of the business domain where the entity corresponding to the entity string is located. For example, for the entity string "Tsinghua University", the corresponding business domains are administrative units and education. Among them, the domain identifier corresponding to the business domain "administrative unit" is: 1; the domain identifier corresponding to the business domain "education" is: 4. Therefore, 4 nodes are set in the trie for the entity string "Tsinghua University". Each node includes the characters "清", "华", "大", "学" respectively, and the node where the character "学" is located carries the domain identifiers: 1, 4.

[0095] Similarly, based on the trie 10e, multi-pattern string matching is performed on the text 10c to find the string that matches the text 10c among all the predicate strings in the trie 10e as the target predicate string. After the matching process, the output is: [6, 7, zip code]. For the output result "[6, 7, zip code]", the string "邮编" between the seventh and eighth positions in the text 10c is the target predicate string, and the synonym corresponding to the target predicate string "邮编" is zip code (zip code is the English synonym of 邮编). As Figure 1b As shown in the figure, the trie 10e is constructed based on the predicate strings corresponding to multiple predicates in the knowledge graph 10p. Each node in the trie 10e includes a character of a predicate. At the same time, in the trie 10e, the nodes corresponding to the last character of each predicate string are all carried with the synonym corresponding to the predicate string. The synonym can be the English word of the corresponding predicate string.

[0096] Combining the found target entity string with the domain identifier and the target predicate string with the synonym yields two texts: Guangdong Province 1, zip code; Shenzhen City 1, zip code. These combined texts contain a target entity string and a target predicate string. Since the target entity strings in both texts carry the business domain identifier 1, the text with the target entity string at the larger starting position in the target entity string locations is selected as the query text. That is, text 10g "Shenzhen City 1, zip code" is selected as the query text 10g.

[0097] The specific process of selecting text 10g as the query text is as follows: the entity strings in the above two texts are: Guangdong Province and Shenzhen City. When matching the entity strings, the position information of the successfully matched entity string "Guangdong Province" in the text to be queried 10c is: [0, 2], and the position information of the entity string "Shenzhen City" in the text to be queried 10c is: [3, 5]. The values ​​"0" and "3" in the above position information respectively represent the starting positions of the two entity strings in the text to be queried 10c, and the values ​​"2" and "5" in the position information respectively represent the ending positions of the two entity strings in the text to be queried 10c. Since the starting position "3" is greater than the starting position "0" in the two starting positions, the target entity string with the largest starting position in the above two entity strings is: Shenzhen City, that is, the text 10g where the entity string "Shenzhen City" is located is the target text 10g.

[0098] Next, query text 10g is verified. In database 10f, a mapping relationship is detected between the domain identifier "1" in query text 10g and the synonym "zip code" in query text 10g. Since database 10f stores the record "1#mayor, zip code, population," indicating a mapping relationship between the domain identifier "1" in query text 10g and the synonym "zip code," query text 10g is verified. The target entity string "Shenzhen City" and the target predicate string "Zip Code" in query text 10g can be combined into target text 10h: Shenzhen City, Zip Code. Here, the entity string in target text 10h does not need to include the domain identifier, and the predicate string does not need to include synonyms. This target text 10h represents the query intent of "Zip Code, Shenzhen City, Guangdong Province." Database 10f contains multiple records, each of which is a two-tuple: one tuple represents the domain identifier; the other tuple represents all possible synonyms for the predicate corresponding to the business domain of the domain identifier. For example, for domain ID 1 (domain ID 1 indicates the business domain of administrative units), all possible predicates are: mayor, zip code, and population. The corresponding synonyms for these predicates are: mayor, zip code, and population. Therefore, database 10f includes the record "1#mayor, zip code, population." After determining target text 10h, the answer to target text 10h is searched in knowledge base 10k, and the result is: 518000, indicating that 518000 is the zip code of Shenzhen City. The answer "518000" is announced or displayed on the screen, allowing the user to directly understand the answer to the question "Zip code of Shenzhen City, Guangdong Province."

[0099] The query text is searched for all possible entities and predicates, and the found entities and predicates are combined to obtain the target text. The target text that fails validation is then deleted, retaining only the target text that passes validation. The remaining target text represents the user's query intent. The knowledge base is searched for the answer to the validated target text and the answer is displayed to the user. By determining the query intent of the query text, the accuracy of finding answers in the knowledge base can be improved.

[0100] The specific process of finding the target entity string and the target predicate string can be found in the following Figures 2a to 4 The corresponding embodiment.

[0101] Further, see Figure 2a , is a flowchart of a text processing method provided by an embodiment of the present invention. Figure 2a As shown, the text processing method may include:

[0102] Step S101, obtain target text and a knowledge graph; the knowledge graph includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates.

[0103] Specifically, get the target text (as mentioned above Figure 1b In the corresponding embodiment, the target text can be obtained by manually inputting text by the user, and the text input by the user is used as the target text; or the user's voice can be collected, and the voice is converted into text, and the converted text is called the target text. Figure 1c The corresponding embodiment of the knowledge graph 10p) includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates. The entity strings are composed of characters corresponding to the entities; the predicate strings are composed of characters corresponding to the predicates. Figure 2b , is a schematic diagram of a knowledge graph provided by an embodiment of the present invention, such as Figure 2b As shown in the figure, the knowledge graph of Beijing is displayed, including population, area, postal code, mayor, neighboring cities, telephone area code, etc. Figure 2b In the example, entity strings include: Beijing, Tianjin, and Chen; predicate strings include: population, area, postal code, mayor, borders, and telephone area code. A knowledge graph is a mapping of knowledge domains, primarily used to visualize entity attributes, attribute values, and relationships between entities. A predicate represents the relationship between two entities and their attributes. For example, for the text "China's population," the entity is "China" and the predicate is "population." Another example is the text "Who is A's wife?" The entity is "A" and the predicate is "wife."

[0104] Step S102 : searching for an entity string belonging to the target text in all entity strings as a target entity string, and searching for a predicate string belonging to the target text in all predicate strings as a target predicate string.

[0105] Specifically, in order to extract all possible entity strings and all possible predicate strings in the target text, the entity strings belonging to the target text can be searched for in all entity strings corresponding to the knowledge graph, which are called target entity strings; and the predicate strings belonging to the target text can be searched for in all predicate strings corresponding to the knowledge graph, which are called target predicate strings. In other words, the target entity strings and target predicate strings found belong to both the knowledge graph and the target text. For example, the knowledge graph includes the entity strings: Beijing, Shanghai, Guangzhou, Tianjin, Chongqing, and the target text is: I love Beijing and Shanghai. Then, the entity strings belonging to the target text found in the above five entity strings are: Beijing, Shanghai, that is, the target entity strings are: Beijing, Shanghai. Searching for strings (pattern strings) belonging to the target text in all entity strings (multiple pattern strings) belongs to multi-pattern string matching in the field of character matching. Multi-pattern string matching algorithms may include: AC automata, hash function matching, etc.

[0106] The following uses AC automaton as an example (the algorithm complexity of AC automaton is linear O(n), which is the most widely used multi-pattern string matching algorithm) to explain how to determine the target entity string and the target predicate string. Based on all entity strings in the knowledge graph, a dictionary tree is constructed, which is called the first dictionary tree (as mentioned above). Figure 1b The dictionary tree 10d in the corresponding embodiment, at the same time, in the first dictionary tree, the node corresponding to the last character of each entity string carries the domain identifier corresponding to the entity string, and the number of domain identifiers can be one or more, and the domain identifier is used to indicate the business domain of the entity corresponding to the entity string. A node in the first dictionary tree includes a character of an entity string, and the first dictionary tree can share the prefix of the entity string, but not the suffix. For example, the entity string "Tsinghua Primary School" corresponds to 4 nodes in the first dictionary tree, and for the entity string "Tsinghua Middle School", the two nodes "Qing" and "Hua" can be reused, and only two more nodes need to be created to represent the characters "Zhong" and "Xue" respectively.

[0107] After constructing the first dictionary tree, a mismatch pointer is set for each node in the first dictionary tree. The mismatch pointer is used to jump to the node indicated by the mismatch pointer when the node in the dictionary tree fails to match the target text and continue matching. For nodes directly connected to the root node, the mismatch pointer of the above node points directly to the root node. For nodes not connected to the root node, according to the principle of breadth-first search, among all nodes that do not have a mismatch pointer, the node for currently setting the mismatch pointer is selected as the target node. The node pointed to by the mismatch pointer of the parent node of the target node is used as an auxiliary node. If the characters contained in all the child nodes of the auxiliary node include the characters contained in the target node, the mismatch pointer of the target node is pointed to the child node of the auxiliary node that contains the same characters as the target node. If the characters contained in all the child nodes of the auxiliary node do not include the characters contained in the target node, the node pointed to by the mismatch pointer of the above auxiliary node is used as the auxiliary node and judged again. If the auxiliary node cannot be found, the mismatch pointer of the target node is pointed to the root node. Using the above method, mismatch pointers can be set for all nodes of the first dictionary tree respectively.

[0108] Among them, breadth-first search is one of the graph search algorithms, which expands outward through the boundary between found and unfound vertices. That is, breadth-first search first searches all vertices with a distance k from s, and then searches other vertices with a distance k+l from s. In this scheme, according to the principle of breadth-first search, the nodes with a distance of 1 from the root node are first used as target nodes, and then mismatch pointers are set for each target node; then the nodes with a distance of 2 from the root node are used as target nodes, until all nodes are set with mismatch pointers.

[0109] Next, multi-mode string matching is performed based on the first dictionary tree and the target text. The matching process is as follows: the first character in the target text is used as the target character. If the target character matches the current character, it means that there is a path from the current node along the first dictionary tree to the target character. At this time, it is only necessary to follow the path to the next node to continue matching, and the character adjacent to the target character in the target text is used as the target character; if the target character does not match the current character, then the node pointed to by the mismatch pointer of the current node is continued to match. The matching process ends when the pointer points to the root node until all characters of the target text are determined to be target characters. After the matching is completed, the output is the position information of the successfully matched entity string in the target text (called the first position information) and the domain identifier corresponding to the entity string, where the position information includes the starting position and the ending position. The character string between the starting position and the ending position in the first position information in the target text is used as the target entity string, and the domain identifier corresponding to the target entity string is called the target domain identifier. It should be noted that after constructing the first dictionary tree and the mismatch pointers of each node, multi-mode string matching can be performed directly based on the first dictionary tree without having to construct the first dictionary tree again.

[0110] Please also see Figure 2c , is a schematic diagram of a multi-pattern string matching provided by an embodiment of the present invention. Figure 2c The first dictionary tree is constructed by the entity strings "Nanchang City", "Nanjing City", "Kyoto", and "Changping District" (the connection relationship between each node in the first dictionary tree is represented by a solid line), and the leaf nodes of the first dictionary tree all carry the domain identifier corresponding to the entity string, among which the entity strings "Nanchang City" and "Nanjing City" can share a prefix, that is, share node 1. Using the breadth-first search principle, mismatch pointers are set for node 1, node 2, and node 3 in turn. Since the above three nodes are connected to the root node "root", the mismatch pointers of the above three nodes all point to the root node "root". According to the breadth-first search principle, mismatch pointers are continued to be set for node 4, node 5, node 6, and node 7. For node 4, this node is used as the target node. Since the mismatch pointer of the target node's father node (that is, node 1) points to the root node "root", and the child nodes of the root node "root" include the node "Chang" (node ​​3 "Chang"), the mismatch pointer of the target node is pointed to the child node "Chang" of the root node "root", that is, the mismatch pointer of node 4 points to node 3. According to the above method, mismatch pointers can be set for all remaining nodes, such as Figure 2c The dotted line in represents the node pointed to by the mismatch pointer of the corresponding node.

[0111] After setting the mismatch pointers of all nodes, according to Figure 2cThe first trie performs multi-pattern string matching for the target text "Nanjing City, Nanjing Capital Gate". First, starting from the first character in the target text, it is matched with the above-mentioned first trie. "Nanjing City" in the target text can be successfully matched, and the node "City" is a leaf node. The position information (start position, end position) of the successfully matched entity string "Nanjing City" in the target text, as well as the domain identifier corresponding to the entity string "Nanjing City", can be output, that is, output [1, 3, 34], where the domain identifier "34" corresponds to administrative units.

[0112] Start matching the remaining characters in the target text again from the root node "root". Start matching again from the fourth character "Nan" in the target text. The fourth character "Nan" and the fifth character "Jing" can be successfully matched with nodes 1 and node 5 respectively, but there is no node in the first trie that can match the sixth character "Du". Therefore, in the first trie, turn to the node pointed to by the mismatch pointer of node 5 (i.e., node 2) to continue matching. The fifth character "Jing" and the sixth character "Du" are successfully matched with nodes 2 and node 6 respectively, and the node 6 "Du" is a leaf node. The position information (start position, end position) of the successfully matched entity string "Kyoto" in the target text, as well as the domain identifier corresponding to the entity string "Kyoto", can be output, that is, output [5, 6, 34], where the domain identifier "34" corresponds to administrative units. Start matching the remaining characters in the target text again from the root node "root". The remaining characters "Men" and "Qian" both fail to match. Therefore, after the above target text is matched with the first trie in Figure 2c the output is [1, 3, 34] and [5, 6, 34], that is, the successfully matched entity strings are "Nanjing City" and "Kyoto".

[0113] Similarly, based on all predicate strings in the knowledge graph, a trie is constructed, called the second trie (such as the trie 10e in the corresponding embodiment above Figure 1b ), and at the same time, in the second trie, the node corresponding to the last character of each predicate string carries the synonym corresponding to the predicate string. A synonym is a word with the same meaning as the corresponding predicate string, and multiple predicate strings with the same meaning can correspond to the same synonym. For example, the predicate strings: wife, wife, lover, daughter-in-law all correspond to the synonym: wife (wife is the English word for wife). After constructing the second trie, set the mismatch pointer for each node in the second trie. The specific process of setting the mismatch pointer can refer to the steps of setting the mismatch pointer for each node in the first trie above.

[0114] According to the second dictionary tree and the target text, a multi-mode string matching process is performed (the specific process of the multi-mode string matching process can be found in the above-mentioned step of performing multi-mode string matching based on the target text in the first dictionary tree). After the matching is completed, the position information of the successfully matched predicate string in the target text (called the second position information) and the synonyms corresponding to the predicate string are output. In the target text, the string between the starting position and the ending position in the second position information is used as the target predicate string, and the synonyms corresponding to the target predicate string are called target synonyms. Similarly, after constructing the second dictionary tree and the mismatch pointers of each node, multi-mode string matching can be performed directly based on the second dictionary tree without having to construct the second dictionary tree again. It should be noted that the first dictionary tree and the second dictionary tree can be the same, that is, the first dictionary tree and the second dictionary tree are both constructed based on all entity strings and all predicate strings of the knowledge graph. You only need to input the target text into the first dictionary tree (or the second dictionary tree) and perform a multi-mode string match. From the first dictionary tree (or the second dictionary tree), you can output the first position information and target domain identifier that match the entity string in the first dictionary tree (or the second dictionary tree), as well as the second position information and target synonyms that match the predicate string in the first dictionary tree (or the second dictionary tree).

[0115] Optionally, if there are more than one target entity strings with the same domain identifier, the target entity strings with the same target domain identifier can be first extracted. Based on the first position information of the extracted entity strings, only the target entity string with the largest first position information is retained, and all target entity strings except the target entity string with the largest first position information are deleted from all extracted entity strings. The target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to the target entity strings with the same target domain identifier.

[0116] For example, the target text is "Sichuan Province Chengdu City Postal Code." Based on the first dictionary tree, the output is the first position information (starting position, ending position) and target domain identifier of the target entity string: (1, 3, 34) and (4, 6, 34). The values ​​"1," "3," and "34" in (1, 3, 34) represent the starting position, ending position, and target domain identifier of a target entity string in the target text, indicating that the target entity string is Sichuan Province. The values ​​"4," "6," and "34" in (4, 6, 34) represent the starting position, ending position, and target domain identifier of a target entity string in the target text, indicating that the target entity string is Chengdu City. Since the starting position "4" of the target entity string "Chengdu City" is greater than the starting position "1" of the target entity string "Sichuan Province," the target entity string with the largest starting position is Chengdu City. That is, the target entity string with the largest first position information is Chengdu City. Subsequently, the target entity string "Sichuan Province" can be deleted, leaving only the target entity string "Chengdu City."

[0117] Step S103: combining the target entity character string and the target predicate character string into a target query text, searching for a query result corresponding to the target query text in a knowledge base as a target query result, and outputting the target query result.

[0118] Specifically, the target entity string determined by the first position information and the target predicate string determined by the second position information are combined according to preset grammatical rules. The combined text is referred to as the second auxiliary text. The grammatical rules may be such that the target entity string precedes the target predicate string. This prevents confusion between the target entity string and the target predicate string when searching for query results, further improving the efficiency of finding answers to questions. Each second auxiliary text includes a target entity string and a target predicate string. A check is performed to determine whether there is overlapping position information between the first position information corresponding to the target entity string in the second auxiliary text and the second position information corresponding to the target predicate string in the second auxiliary text. The starting and ending positions of the overlapping position information are both within the range of the first position information and the range of the second position information. The second auxiliary text with overlapping position information is deleted, retaining only the second auxiliary text without overlapping position information. The retained second auxiliary text is used as the target query text, which is the target text and the user's query intent. A search is performed in the knowledge base for a query result corresponding to the target query text. The resulting target query result is output as a voice broadcast or subtitle display.

[0119] For example, if the first and second dictionary tries are identical, and the target text is Chang'an District, Xi'an, the first position information output after matching is (1, 3), corresponding to the target entity string "Xi'an City"; the first position information output is (4, 6), corresponding to the target entity string "Chang'an District"; and the second position information output is (3, 4), corresponding to the target predicate string "Mayor". These two target entity strings and one target predicate string can be combined to obtain two second auxiliary texts: Mayor of Xi'an City and Mayor of Chang'an District. Since the first position information "(1, 3)" and the second position information "(3, 4)" corresponding to the second auxiliary text "Mayor of Xi'an City" overlap, the second auxiliary text "Mayor of Xi'an City" is deleted. Similarly, since the first position information "(4, 6)" and the second position information "(3, 4)" corresponding to the second auxiliary text "Mayor of Chang'an District" also overlap, the second auxiliary text "Mayor of Chang'an District" is also deleted. In other words, the target text "Chang'an District, Xi'an" does not correspond to the target query.

[0120] The embodiment of the present invention searches for target entity strings and target predicate strings that match the knowledge graph from the target text based on the entity strings and predicate strings contained in the knowledge graph, thereby determining the query intent of the target text based on the target entity strings and target predicate strings. This can discard characters in the query text that are not related to the question, accurately identify the query intent of the target text, and improve the accuracy of finding answers to the target text in the knowledge base.

[0121] Please also see Figure 3 , is a flow chart of another text processing method provided by an embodiment of the present invention, the text processing method comprising the following steps:

[0122] Step S201 obtains the target text and the knowledge graph; the knowledge graph includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates.

[0123] Step S202 : searching for an entity string belonging to the target text in all entity strings as a target entity string, and searching for a predicate string belonging to the target text in all predicate strings as a target predicate string.

[0124] The specific implementation of steps S201-S202 can be found in the above Figure 2a The corresponding steps S101 and S102 are described in the embodiment.

[0125] Step S203: combining the target entity character string and the target predicate character string into a first auxiliary text.

[0126] Specifically, the target entity string and the target predicate string are combined into a text, called a first auxiliary text, according to preset grammatical rules. A first auxiliary text consists of a target entity string and a target predicate string. If there are M target entity strings and N target predicate strings, the number of combined first auxiliary texts is M*N.

[0127] Step S204 , obtaining a target domain identifier corresponding to the target entity string in the first auxiliary text, and obtaining a target synonym corresponding to the target predicate string in the first auxiliary text; the target domain identifier is used to represent the business domain of the target entity corresponding to the target entity string.

[0128] Specifically, the following steps S204-S205 take a first auxiliary text as an example to illustrate how to determine the target query text. If there are multiple first auxiliary texts, the same steps can be used to determine the target query texts respectively. Obtain the target domain identifier corresponding to the target entity string in the first auxiliary text, and obtain the target synonym corresponding to the target predicate string in the first auxiliary text. Among them, the target domain identifier is used to represent the business field where the target entity corresponding to the target entity string is located. The target domain identifier can be represented by letters, numbers, or a combination of letters and numbers. For example, star A is a singer, actor, and director, so singer, actor, and director are the business fields where star A is located.

[0129] Step S205: If a mapping relationship between the target domain identifier and the target synonym exists in the first relationship library, the first auxiliary text is determined as the target query text, and a query result corresponding to the target query text is searched in the knowledge base as the target query result, and the target query result is output; the first relationship library includes multiple domain identifiers and at least one synonym corresponding to each domain identifier.

[0130] Specifically, the first relationship library (as mentioned above Figure 1bThe database 10f) in the first relational database includes multiple domain identifiers and synonyms of all possible predicates corresponding to each domain identifier. For example, the business domain corresponding to the domain identifier "5" is: director, and all possible predicates corresponding to the domain identifier "5" are: name, gender, wife, children, song, and the synonyms of the above predicates are: name, gender, wife, son, song. Therefore, the first relational database includes: 5#name, gender, wife, son, song. If there is a mapping relationship between the target domain identifier and the target synonym in the first relational database, the first auxiliary text is determined as the target query text. If there is no mapping relationship between the target domain identifier and the target synonym in the first relational database, the first auxiliary text is deleted. The existence of a mapping relationship between the target domain identifier and the target synonym means that in the first relational database, among all the synonyms corresponding to the target domain identifier, there is a synonym that is the same as the target synonym. For example, the first relational database includes: 5#name, gender, wife, son, song. If the target domain identifier is 5 and the target synonym is wife, then a mapping relationship exists between the target domain identifier "5" and the target synonym "wife" in the first relational database. However, if the target domain identifier is 5 and the target synonym is birthday, then no mapping relationship exists between the target domain identifier "5" and the target synonym "birthday" in the first relational database. After determining the target query text, the knowledge base is searched for the query result of the target query text, and the target query result is output as a voice broadcast or subtitle display.

[0131] Optionally, after determining that there is a mapping relationship between the target entity string and the target predicate string, further verification can be performed. Still taking one first auxiliary text as an example to perform further verification, if there are multiple first auxiliary texts, the same steps can be used to perform further verification separately. The verification steps are as follows: the second relationship library includes multiple domain identifiers, synonyms of all possible predicates corresponding to each domain identifier, and predicate aliases corresponding to each synonym. For example, the business domain corresponding to the domain identifier "5" is: director, and the synonyms corresponding to the domain identifier "5" are: name, gender, birthday. The predicate aliases corresponding to the synonym "name" include: name, given name, title, and full name. Therefore, the second relationship library includes: (5|name#name, 5|name#name, 5|name#title, 5|name#full name). In the second relationship library, all predicate aliases corresponding to the target domain identifier and target synonym in the first auxiliary text are extracted, and are all called sample predicate aliases. If one of the multiple sample predicate aliases is identical to the target predicate string, the verification is successful, and the first auxiliary text that has passed the verification can be determined as the target query text. If none of the multiple sample predicate aliases is identical to the target predicate string, the verification is unsuccessful, and the first auxiliary text that has failed the verification is deleted.

[0132] After the target query text is determined, the query result of the target query text is searched in the knowledge base, and the target query result is output as the target query result in the form of voice broadcast or subtitle display. For example, the second relational database includes: (5|name#name, 5|name#name, 5|name#title, 5|name#full name), if the target domain identifier corresponding to the target entity string in the first auxiliary text is: 5, the target predicate string in the first auxiliary text is: name, and the target synonym corresponding to the target predicate string "name" is: name; since all predicate aliases (sample predicate aliases) corresponding to the target domain identifier "5" and the target synonym "name" include: name, name, title, full name; and the target predicate string "name" does not exist in the above four predicate aliases, the first auxiliary text fails verification, that is, the first auxiliary text cannot be determined as the target query text.

[0133] Optionally, in order to obtain the business areas that users are concerned about and improve the accuracy of product decisions, users' high-frequency intentions can be counted from massive query texts. Obtain multiple texts to be tested. In order to improve the accuracy of the statistical results, the more texts to be tested, the better. Set polling priorities for the above multiple texts to be tested. According to the polling priority, the text to be tested for the current poll is selected from the multiple texts to be tested, which is called the auxiliary test text. Of course, the higher the polling priority of the text to be tested, the sooner it will be determined as the auxiliary test text. Among all the entity strings in the knowledge graph, search for the entity string belonging to the auxiliary test text, and among all the predicate strings in the knowledge graph, search for the predicate string belonging to the auxiliary test text.

[0134] According to the preset grammar rules, the found entity string and the found predicate string are combined into a text, which is called the test query text. The specific process of finding the entity string and the predicate string can be found in the above Figure 2a The specific process of combining the entity string and predicate string found out into text can be seen in the above step S102. Figure 2a Step S102 in the above Figure 3 Steps S203 to S205 in the process are performed. In the knowledge base, a query result corresponding to the test query text is searched and used as the test query result. If there are multiple texts to be tested, the multiple texts to be tested are sequentially selected as auxiliary test texts according to the polling priority, and the test query text and test query result corresponding to each text to be tested are searched respectively. When each text to be tested is determined to be an auxiliary test text, the polling is stopped, and the number of test query texts with the same query result is counted. Based on the counted number, the business areas that users are most concerned about can be determined, which can provide data support for later product decisions.

[0135] The embodiment of the present invention searches for target entity strings and target predicate strings that match the knowledge graph from the target text based on the entity strings and predicate strings contained in the knowledge graph, thereby determining the query intent of the target text based on the target entity strings and target predicate strings. This can discard characters in the query text that are not related to the question, accurately identify the query intent of the target text, and improve the accuracy of finding answers to the target text in the knowledge base.

[0136] Please also see Figure 4 , is a flow chart of another text processing method provided by an embodiment of the present invention, the text processing method comprising the following steps:

[0137] Step S301, obtain the target text and the knowledge graph; the knowledge graph includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates.

[0138] Step S302 : searching for an entity string belonging to the target text in multiple entity strings as the target entity string, and searching for a predicate string belonging to the target text in multiple predicate strings as the target predicate string.

[0139] The specific implementation of steps S301-S302 can be found in the above Figure 2a The corresponding steps S101 and S102 are described in the embodiment.

[0140] Step S303: Combine the target entity character string and the target predicate character string into text.

[0141] Specifically, the target entity string carrying the target domain identifier and the target predicate string carrying the target synonym are combined into a text according to preset grammatical rules. A text includes a target entity string and a target predicate string. The grammatical rule may be that the target entity string comes first and the target predicate string comes second.

[0142] Step S304: Verify and filter the text.

[0143] Specifically, based on the multiple domain identifiers recorded in the first relationship library, and the multiple synonyms corresponding to each domain identifier, it is detected whether there is a mapping relationship between the target domain identifier and the target synonym. If there is a mapping relationship, the verification passes; if there is no mapping relationship, the verification fails. Furthermore, based on the multiple domain identifiers recorded in the second relationship library, the multiple synonyms corresponding to each domain identifier, and the multiple predicate aliases corresponding to each synonym, it is detected whether there is a predicate alias identical to the target predicate string among all the predicate aliases corresponding to the target synonym. If so, the verification passes; if not, the verification fails. Furthermore, it is also possible to detect whether there is overlapping position information between the first position information corresponding to the target entity string in the text and the second position information corresponding to the target predicate string in the text. If there is overlapping position information, the verification fails; if there is no overlapping position information, the verification passes. Text that fails the verification can be deleted.

[0144] Step S305: The verified text is used as the target query text and the target query text is output.

[0145] Specifically, the text that has passed the verification is determined as the target query text, and the target query text is displayed for subsequent manual annotation. The target query text is manually annotated to determine whether it can express the query intent of the target text, that is, to manually detect whether the target entity string and target predicate string in the target query text accurately correspond to the entities and predicates in the target text.

[0146] Step S306: searching the knowledge base for a query result corresponding to the target query text as the target query result, and outputting the target query result.

[0147] Specifically, the query result of the target query text is searched in the knowledge base, and the target query result is output as the target query result in a voice broadcast or subtitle display manner, so that the user can directly obtain the target query result.

[0148] The embodiment of the present invention obtains a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates; among all entity strings, the entity string belonging to the target text is searched as the target entity string, and among all predicate strings, the predicate string belonging to the target text is searched as the target predicate string; the target entity string and the target predicate string are combined into a target query text, and the query result corresponding to the target query text is searched in the knowledge base as the target query result, and the target query result is output. As can be seen from the above, based on the entity string and predicate string contained in the knowledge graph, the target entity string and the target predicate string are searched from the target text itself, and the query intent of the target text is determined based on the target entity string and the target predicate string. It can discard characters in the query text that are not related to the question, accurately identify the query intent of the target text, and improve the accuracy of finding the answer to the target text in the knowledge base.

[0149] For further information, see Figure 5 , is a structural diagram of a text processing device provided by an embodiment of the present invention. Figure 5 As shown, the text processing device 1 may include: an acquisition module 11, a first search module 12, a second search module 13, a combination module 14, and an output module 15;

[0150] An acquisition module 11 is configured to acquire a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to a plurality of entities and predicate strings corresponding to a plurality of predicates;

[0151] Specifically, the acquisition module 11 acquires the target text. The target text can be acquired by manually inputting text by the user, and the text input by the user is used as the target text; or the user's voice can be collected, the voice is converted into text, and the converted text is called the target text. The acquisition module 11 acquires the knowledge graph. The knowledge graph includes entity strings corresponding to multiple entities and predicate strings corresponding to multiple predicates. The entity string is composed of characters corresponding to the entity; the predicate string is composed of characters corresponding to the predicate. The knowledge graph is a mapping map of the knowledge field, which is mainly used to visualize the attributes, attribute values, and relationships between entities. The predicate represents the relationship between two entities and the attributes of the entity. For example, for the text "China's population", the entity is "China" and the predicate is "population"; for another example, for the text "Who is A's wife", the entity is "A" and the predicate is "wife".

[0152] A first search module 12 is configured to search for an entity string belonging to the target text among all entity strings as a target entity string;

[0153] Specifically, in order to extract all possible entity strings and all possible predicate strings in the target text, the first search module 12 can perform multi-mode string matching processing based on the first dictionary tree and the target text, that is, to search for the entity string belonging to the target text among all the entity strings corresponding to the knowledge graph, which is called the target entity string. After the matching is completed, the first search module 12 outputs the position information of the successfully matched entity string in the target text (called the first position information) and the domain identifier corresponding to the entity string, wherein the position information includes the starting position and the ending position. The string between the starting position and the ending position in the first position information in the target text is taken as the target entity string, and the domain identifier corresponding to the target entity string is called the target domain identifier. The first dictionary tree is a dictionary tree constructed by multiple entity strings. In the first dictionary tree, the node corresponding to the last character of each entity string carries the domain identifier corresponding to the entity string. The number of domain identifiers can be one or more. The domain identifier is used to indicate the business field of the entity corresponding to the entity string.

[0154] A second search module 13 is configured to search for a predicate string belonging to the target text among all predicate strings as a target predicate string;

[0155] Specifically, the second search module 13 can perform multi-mode string matching processing based on the second dictionary tree and the target text, and search for the predicate string belonging to the target text among all the predicate strings corresponding to the knowledge graph, which is called the target predicate string. The second search module 13 outputs the position information of the successfully matched predicate string in the target text (called the second position information) and the synonym corresponding to the predicate string. In the target text, the string between the starting position and the ending position in the second position information is used as the target predicate string, and the synonym corresponding to the target predicate string is called the target synonym. The second dictionary tree is a dictionary tree constructed by multiple predicate strings. In the second dictionary tree, the node corresponding to the last character of each predicate string carries the synonym corresponding to the predicate string. The synonym is a word with the same meaning as the corresponding predicate string, and multiple predicate strings with the same meaning can correspond to the same synonym. For example, the synonyms corresponding to the predicate strings: wife, wife, lover, and daughter-in-law are all: wife (wife is the English word for wife).

[0156] A combining module 14 is configured to combine the target entity character string and the target predicate character string into a target query text;

[0157] Specifically, the target entity string and the target predicate string are combined according to preset grammatical rules. The text combined by the combination module 14 is called the second auxiliary text. The grammatical rules can be that the target entity string comes first and the target predicate string comes second. This prevents confusion between the target entity string and the target predicate string when searching for query results, further improving the efficiency of finding answers to questions. A second auxiliary text includes a target entity string and a target predicate string. The combination module 14 detects whether there is overlapping position information between the first position information corresponding to the target entity string in the second auxiliary text and the second position information corresponding to the target predicate string in the second auxiliary text. The starting position and ending position of the overlapping position information are both within the range of the first position information and the range of the second position information. The combination module 14 deletes the second auxiliary text with overlapping position information, retaining only the second auxiliary text without overlapping position information. The retained second auxiliary text is used as the target query text, which is the target text and the user's query intent.

[0158] The output module 15 is configured to search the knowledge base for a query result corresponding to the target query text as the target query result, and output the target query result.

[0159] Specifically, the output module 15 searches for a query result of the target query text in the knowledge base, and outputs the searched target query result as the target query result in a voice broadcast or subtitle display manner.

[0160] See Figure 5 The combining module 14 may include: a first combining unit 141 , an acquiring unit 142 , and a determining unit 143 .

[0161] A first combining unit 141 is configured to combine the target entity character string and the target predicate character string into a first auxiliary text;

[0162] An acquiring unit 142 is configured to acquire a target domain identifier corresponding to a target entity string in the first auxiliary text, and acquire a target synonym corresponding to a target predicate string in the first auxiliary text; the target domain identifier is used to indicate a business domain in which a target entity corresponding to the target entity string belongs;

[0163] The determining unit 143 is configured to determine the first auxiliary text as the target query text if a mapping relationship between the target domain identifier and the target synonym exists in a first relationship library; the first relationship library includes multiple domain identifiers and at least one synonym corresponding to each domain identifier.

[0164] The specific functional implementation of the first combining unit 141, the obtaining unit 142, and the determining unit 143 can be found in the above Figure 3 Steps S203 to S205 in the corresponding embodiment are not described in detail here.

[0165] See Figure 5 The determining unit 143 may include: an extracting subunit 1431 and a first determining subunit 1432 .

[0166] The extraction subunit 1431 is configured to extract, from a second relational database, predicate alternatives corresponding to the target domain identifier and the target synonym as sample predicate alternatives; the second relational database includes a plurality of domain identifiers, at least one synonym corresponding to each domain identifier, and at least one predicate alternative corresponding to each synonym;

[0167] The first determining subunit 1432 is configured to determine the first auxiliary text as the target query text if there is a sample predicate nickname that is identical to the target predicate character string.

[0168] The specific functional implementation of the extraction subunit 1431 and the first determination subunit 1432 can be found in the above Figure 3 Step S205 in the corresponding embodiment will not be described again here.

[0169] See Figure 5The first search module 12 may include: a first construction unit 121 , a first setting unit 122 , a first matching unit 123 , and a first extraction unit 124 .

[0170] A first construction unit 121 is configured to construct a first dictionary tree based on all entity character strings; a node in the first dictionary tree includes a character in an entity character string;

[0171] A first setting unit 122 is configured to set a mismatch pointer for each node in the first dictionary tree according to a breadth-first search;

[0172] A first matching unit 123 is configured to perform multi-pattern string matching on the target text based on the first dictionary tree and the mismatch pointers corresponding to the nodes in the first dictionary tree, to obtain first position information of a character string in the target text that matches an entity character string in the first dictionary tree;

[0173] The first extraction unit 124 is configured to use, in the target text, the character string between the start position and the end position in the first position information as the target entity character string, and obtain a target domain identifier corresponding to the target entity character string from the first dictionary tree.

[0174] The specific functional implementation of the first construction unit 121, the first setting unit 122, the first matching unit 123, and the first extraction unit 124 can be found in the above Figure 2a The step S102 in the corresponding embodiment will not be described again here.

[0175] See Figure 5 The text processing device 1 may include: an acquisition module 11, a first search module 12, a second search module 13, a combination module 14, an output module 15, and may also include: an extraction module 16, and a deletion module 17.

[0176] Extraction module 16, used to extract target entity character strings with the same target domain identifier;

[0177] The deletion module 17 is used to retain the target entity string with the largest first position information based on the first position information corresponding to the extracted target entity string, and delete the target entity string other than the target entity string with the largest first position information among all target entity strings with the same target domain identifier; the target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to all target entity strings with the same target domain identifier.

[0178] The specific functional implementation of the extraction module 16 and the deletion module 17 can be found in the above Figure 2a The corresponding step S103 in the embodiment will not be described again here.

[0179] See Figure 5 The second search module 13 may include: a second construction unit 131 , a second setting unit 132 , a second matching unit 133 , and a second extraction unit 134 .

[0180] A second construction unit 131 is configured to construct a second dictionary tree based on all the predicate character strings; a node in the second dictionary tree includes a character in a predicate character string;

[0181] A second setting unit 132 is configured to set a mismatch pointer for each node in the second dictionary tree according to a breadth-first search;

[0182] A second matching unit 133 is configured to perform multi-pattern string matching processing on the target text based on the second dictionary tree and the mismatch pointers corresponding to the nodes in the second dictionary tree, to obtain second position information of a string in the target text that matches the predicate string in the second dictionary tree;

[0183] The second extraction unit 134 is configured to use, in the target text, the character string between the start position and the end position in the second position information as the target predicate character string, and obtain a target synonym corresponding to the target predicate character string from the second dictionary tree.

[0184] The specific functional implementation of the second construction unit 131, the second setting unit 132, the second matching unit 133, and the second extraction unit 134 can be found in the above Figure 2a The step S102 in the corresponding embodiment will not be described again here.

[0185] See Figure 5 , the first dictionary tree and the second dictionary tree are the same, and the first dictionary tree and the second dictionary tree are both constructed by all the entity strings and all the predicate strings;

[0186] The combining module may include: a first combining unit 141 , an acquiring unit 142 , a determining unit 143 , and may further include: a second combining unit 144 , and a deleting unit 145 .

[0187] A second combining unit 144 is configured to combine the target entity character string and the target predicate character string into a second auxiliary text;

[0188] a deleting unit 145 configured to delete the second auxiliary text with the overlapping position information if there is overlapping position information between the first position information and the second position information corresponding to the second auxiliary text, wherein the starting position and the ending position of the overlapping position information are both within the range of the first position information and the range of the second position information;

[0189] The deleting unit 145 is further configured to determine the second auxiliary text remaining after the deletion as the target query text.

[0190] The specific functional implementation of the second combining unit 144 and the deleting unit 145 can be found in the above Figure 2a The corresponding step S103 in the embodiment will not be described again here.

[0191] See Figure 5 The text processing device 1 may include: an acquisition module 11, a first search module 12, a second search module 13, a combination module 14, an output module 15, an extraction module 16, a deletion module 17, and may also include: a selection module 18, and a statistics module 19.

[0192] The acquisition module 11 is further configured to acquire a plurality of texts to be tested and set polling priorities for the plurality of texts to be tested;

[0193] A selection module 18, configured to select an auxiliary test text for current polling from the plurality of to-be-tested texts according to the polling priority;

[0194] The first search module 12 is further configured to search for an entity string belonging to the auxiliary test text among all the entity strings, and search for a predicate string belonging to the auxiliary test text among all the predicate strings;

[0195] The combining module 15 is further configured to combine the found entity character string and predicate character string into a test query text, and search the knowledge base for a query result corresponding to the test query text as a test query result;

[0196] The counting module 19 is configured to stop polling when each to-be-tested text is determined to be an auxiliary test text, and to count the number of test query texts having the same test query result.

[0197] The specific functional implementation of the acquisition module 11, the selection module 18, the first search module 12, the combination module 15, and the statistical module 19 can be found in the above Figure 3 Step S305 in the corresponding embodiment will not be described again here.

[0198] The embodiment of the present invention searches for target entity strings and target predicate strings that match the knowledge graph from the target text based on the entity strings and predicate strings contained in the knowledge graph, thereby determining the query intent of the target text based on the target entity strings and target predicate strings. This can discard characters in the query text that are not related to the question, accurately identify the query intent of the target text, and improve the accuracy of finding answers to the target text in the knowledge base.

[0199] Further, see Figure 6 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 6 As shown above Figure 6 The text processing device 1 in the embodiment can be applied to the electronic device 1000, and the electronic device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the electronic device 1000 may also include: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Figure 6 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.

[0200] exist Figure 6 In the electronic device 1000 shown, the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0201] Obtaining a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to a plurality of entities and predicate strings corresponding to a plurality of predicates;

[0202] Searching for an entity string belonging to the target text among all entity strings as a target entity string, and searching for a predicate string belonging to the target text among all predicate strings as a target predicate string;

[0203] The target entity character string and the target predicate character string are combined into a target query text, a query result corresponding to the target query text is searched in a knowledge base as a target query result, and the target query result is output.

[0204] In one embodiment, when the processor 1001 combines the target entity string and the target predicate string into a target query text, the processor 1001 specifically performs the following steps:

[0205] Combining the target entity string and the target predicate string into a first auxiliary text;

[0206] Obtaining a target domain identifier corresponding to a target entity string in the first auxiliary text, and obtaining a target synonym corresponding to a target predicate string in the first auxiliary text; the target domain identifier is used to represent the business domain of the target entity corresponding to the target entity string;

[0207] If a mapping relationship between the target domain identifier and the target synonym exists in the first relationship library, the first auxiliary text is determined as the target query text; the first relationship library includes multiple domain identifiers and at least one synonym corresponding to each domain identifier.

[0208] In one embodiment, when determining the first auxiliary text as the target query text, the processor 1001 specifically performs the following steps:

[0209] Extracting, from a second relational database, predicate aliases corresponding to the target domain identifier and the target synonym as sample predicate aliases; the second relational database includes a plurality of domain identifiers, at least one synonym corresponding to each domain identifier, and at least one predicate alias corresponding to each synonym;

[0210] If there is a sample predicate alias that is identical to the target predicate character string, the first auxiliary text is determined as the target query text.

[0211] In one embodiment, when searching for an entity string belonging to the target text among all entity strings as the target entity string, the processor 1001 specifically performs the following steps:

[0212] Constructing a first dictionary tree based on all the entity character strings; wherein a node in the first dictionary tree includes a character in an entity character string;

[0213] According to a breadth-first search, setting a mismatch pointer for each node in the first dictionary tree;

[0214] Performing multi-mode string matching on the target text according to the first dictionary tree and the mismatch pointers corresponding to the nodes in the first dictionary tree to obtain first position information of a character string in the target text that matches the entity character string in the first dictionary tree;

[0215] In the target text, the character string between the start position and the end position in the first position information is used as the target entity character string, and the target domain identifier corresponding to the target entity character string is obtained from the first dictionary tree.

[0216] In one embodiment, the processor 1001 further performs the following steps:

[0217] Extract target entity strings with the same target domain identifier;

[0218] According to the first position information corresponding to the extracted target entity string, the target entity string with the largest first position information is retained, and the target entity strings other than the target entity string with the largest first position information are deleted among all target entity strings with the same target domain identifier; the target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to all target entity strings with the same target domain identifier.

[0219] In one embodiment, when searching for a predicate string belonging to the target text among all predicate strings as a target predicate string, the processor 1001 specifically performs the following steps:

[0220] Constructing a second dictionary tree based on all the predicate character strings; wherein a node in the second dictionary tree includes a character in a predicate character string;

[0221] According to a breadth-first search, setting a mismatch pointer for each node in the second dictionary tree;

[0222] performing multi-pattern string matching on the target text according to the second dictionary tree and the mismatch pointers corresponding to the nodes in the second dictionary tree to obtain second position information of a character string in the target text that matches the predicate character string in the second dictionary tree;

[0223] In the target text, the character string between the start position and the end position in the second position information is used as the target predicate character string, and a target synonym corresponding to the target predicate character string is obtained from the second dictionary tree.

[0224] In one embodiment, when the processor 1001 combines the target entity string and the target predicate string into a target query text, the processor 1001 specifically performs the following steps:

[0225] combining the target entity string and the target predicate string into a second auxiliary text;

[0226] If there is overlapping position information between the first position information and the second position information corresponding to the second auxiliary text, the second auxiliary text with the overlapping position information is deleted; the starting position and the ending position in the overlapping position information are both within the range of the first position information and the range of the second position information;

[0227] The second auxiliary text remaining after the deletion is determined as the target query text.

[0228] In one embodiment, the processor 1001 further performs the following steps:

[0229] Acquire multiple texts to be tested, and set polling priorities for the multiple texts to be tested;

[0230] selecting, according to the polling priority, an auxiliary test text for current polling from the plurality of texts to be tested;

[0231] Searching for an entity string belonging to the auxiliary test text among all the entity strings, and searching for a predicate string belonging to the auxiliary test text among all the predicate strings;

[0232] Combining the found entity string and predicate string into a test query text, searching the knowledge base for a query result corresponding to the test query text as the test query result;

[0233] When each to-be-tested text is determined to be an auxiliary test text, the polling is stopped, and the number of test query texts having the same test query result is counted.

[0234] The embodiment of the present invention searches for target entity strings and target predicate strings that match the knowledge graph from the target text based on the entity strings and predicate strings contained in the knowledge graph, thereby determining the query intent of the target text based on the target entity strings and target predicate strings. This can discard characters in the query text that are not related to the question, accurately identify the query intent of the target text, and improve the accuracy of finding answers to the target text in the knowledge base.

[0235] It should be understood that the electronic device 1000 described in the embodiment of the present invention can execute the above Figures 2a to 4 The description of the text processing method in the corresponding embodiment can also be performed Figure 5The description of the text processing device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here either.

[0236] In addition, it should be noted that: the embodiment of the present invention further provides a computer storage medium, and the computer storage medium stores the computer program executed by the text processing device 1 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above-mentioned text processing device 1. Figures 2a to 4 The description of the text processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated here. For technical details not disclosed in the computer storage medium embodiment involved in the present invention, please refer to the description of the method embodiment of the present invention.

[0237] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0238] The above disclosure is merely a preferred embodiment of the present invention and certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A text processing method, characterized in that: include: Obtaining a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to a plurality of entities and predicate strings corresponding to a plurality of predicates; Among all entity strings, an entity string belonging to the target text is searched as a target entity string, and among all predicate strings, a predicate string belonging to the target text is searched as a target predicate string; Combining the target entity character string and the target predicate character string to obtain a combined text; If there is overlapping position information between the first position information corresponding to the target entity string in the combined text and the second position information corresponding to the target predicate string in the combined text, the combined text with the overlapping position information is deleted; the starting position and the ending position in the overlapping position information are both within the range of the first position information and within the range of the second position information; the first position information refers to the position information of the target entity string in the target text; the second position information refers to the position information of the target predicate string in the target text; The combined text remaining after the deletion is determined as the target query text, a query result corresponding to the target query text is searched in the knowledge base as the target query result, and the target query result is output.

2. The method according to claim 1, characterized in that The step of searching for an entity string belonging to the target text in all entity strings as the target entity string includes: Constructing a first dictionary tree according to all the entity character strings; a node in the first dictionary tree includes a character in an entity character string; According to a breadth-first search, setting a mismatch pointer for each node in the first dictionary tree; According to the first dictionary tree and the mismatch pointers corresponding to each node in the first dictionary tree, the target text is subjected to multi-mode string matching processing to obtain first position information of a string in the target text that matches the entity string in the first dictionary tree; In the target text, the character string between the start position and the end position in the first position information is used as the target entity character string, and the target domain identifier corresponding to the target entity character string is obtained from the first dictionary tree.

3. The method according to claim 2, characterized in that Also includes: Extract target entity strings with the same target domain identifier; According to the first position information corresponding to the extracted target entity string, the target entity string with the largest first position information is retained, and the target entity strings other than the target entity string with the largest first position information are deleted among all target entity strings with the same target domain identifier; the target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to all target entity strings with the same target domain identifier.

4. The method according to claim 1, characterized in that The searching of the predicate string belonging to the target text among all the predicate strings as the target predicate string includes: Constructing a second dictionary tree according to all the predicate character strings; a node in the second dictionary tree includes a character in a predicate character string; According to a breadth-first search, setting a mismatch pointer for each node in the second dictionary tree; According to the second dictionary tree and the mismatch pointers corresponding to each node in the second dictionary tree, the target text is subjected to multi-mode string matching processing to obtain second position information of a string in the target text that matches the predicate string in the second dictionary tree; In the target text, the character string between the start position and the end position in the second position information is used as the target predicate character string, and a target synonym corresponding to the target predicate character string is obtained from the second dictionary tree.

5. The method according to claim 1, characterized in that Also includes: Acquire multiple texts to be tested, and set polling priorities for the multiple texts to be tested; According to the polling priority, selecting an auxiliary test text for current polling from the plurality of texts to be tested; Searching for an entity string belonging to the auxiliary test text among all the entity strings, and searching for a predicate string belonging to the auxiliary test text among all the predicate strings; Combining the found entity string and predicate string into a test query text, searching the knowledge base for a query result corresponding to the test query text as the test query result; When each to-be-tested text is determined to be an auxiliary test text, the polling is stopped, and the number of test query texts having the same test query result is counted.

6. A text processing device, characterized in that: include: An acquisition module, used to acquire a target text and a knowledge graph; the knowledge graph includes entity strings corresponding to a plurality of entities and predicate strings corresponding to a plurality of predicates; A first search module is used to search for an entity string belonging to the target text in all entity strings as a target entity string; A second search module is used to search for a predicate string belonging to the target text among all predicate strings as a target predicate string; A combining module, used for combining the target entity string and the target predicate string to obtain a combined text; The combining module is further used for deleting the combined text with overlapping position information if there is overlapping position information between the first position information corresponding to the target entity string in the combined text and the second position information corresponding to the target predicate string in the combined text; the starting position and the ending position in the overlapping position information are both within the range of the first position information and within the range of the second position information; the first position information refers to the position information of the target entity string in the target text; the second position information refers to the position information of the target predicate string in the target text; The combining module is further used to determine the combined text remaining after the deletion as the target query text; The output module is used to search the knowledge base for a query result corresponding to the target query text as the target query result, and output the target query result.

7. The device according to claim 6, characterized in that The first search module includes: A first construction unit is used to construct a first dictionary tree according to all the entity character strings; a node in the first dictionary tree includes a character in an entity character string; A first setting unit, configured to set a mismatch pointer for each node in the first dictionary tree according to a breadth-first search; A first matching unit, configured to perform multi-mode string matching processing on the target text according to the first dictionary tree and the mismatch pointers corresponding to the nodes in the first dictionary tree, to obtain first position information of a string in the target text that matches the entity string in the first dictionary tree; The first extraction unit is used to use the character string between the start position and the end position in the first position information as the target entity character string in the target text, and obtain the target domain identifier corresponding to the target entity character string from the first dictionary tree.

8. The device according to claim 7, characterized in that Also includes; An extraction module, used for extracting target entity strings having the same target domain identifier; A deletion module is used to retain the target entity string with the largest first position information according to the first position information corresponding to the extracted target entity string, and delete the target entity string other than the target entity string with the largest first position information among all target entity strings with the same target domain identifier; the target entity string with the largest first position information is the target entity string with the largest starting position among the first position information corresponding to all target entity strings with the same target domain identifier.

9. An electronic device, characterized in that: include: Processor and memory; The processor is connected to a memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the method according to any one of claims 1 to 5.

10. A computer storage medium, characterized in that: The computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 5 is executed.

Citation Information

Patent Citations

  • Method and device for generation of Chinese general knowledge atlas with entity relation attributes

    CN107391677A

  • Search method and device and electronic equipment

    CN107526812A

  • Vector space model based relative mapping method

    CN108153736A

  • Knowledge graph-based search method and apparatus

    CN108241649A

  • Chinese knowledge graph construction method and system

    CN108376160A