WO2022083103A1 - 问题语句的改写方法、装置、计算机设备和存储介质 - Google Patents
问题语句的改写方法、装置、计算机设备和存储介质 Download PDFInfo
- Publication number
- WO2022083103A1 WO2022083103A1 PCT/CN2021/091700 CN2021091700W WO2022083103A1 WO 2022083103 A1 WO2022083103 A1 WO 2022083103A1 CN 2021091700 W CN2021091700 W CN 2021091700W WO 2022083103 A1 WO2022083103 A1 WO 2022083103A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- node
- sentence
- question
- edge
- directed graph
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
- G06F16/3329—Natural language query formulation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/237—Lexical tools
- G06F40/247—Thesauruses; Synonyms
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
Definitions
- the present application relates to the technical field of artificial intelligence, and in particular, to a method, device, computer equipment and storage medium for rewriting question sentences.
- the generation of the reply answer is mainly completed by matching the user's question with the question template. But in some cases the user question is semantically similar to the template question, but the answer cannot be recalled. For example, the user asks “Can depression be covered by insurance?”, and the template asks "Can mental illness be covered by insurance?”.
- the input question sentence can be expanded by means of synonym rewriting. For example, the synonym of "depression” is "Psychotic", you can improve the recall rate to a certain extent.
- the database will store multiple question templates in advance, and when the user asks a question, the corresponding template question will be matched to automatically reply.
- the main purpose of the present application is to provide a method, device, computer equipment and storage medium for rewriting problem sentences, aiming at overcoming the defect that the current synonym rewriting does not fit the context.
- the present application provides a method for rewriting question sentences, comprising the following steps:
- the candidate synonym of each said word is used as a node, the starting point of the problem statement is used as a starting node, and the end point of the problem statement is used as an end node;
- the sentence fragments between the candidate synonyms are used as the edges connecting the nodes, and edges are respectively constructed between the starting nodes, ending nodes and the nodes; based on the starting nodes, ending nodes, each of the node and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, the directed graph starts from the start node and ends with the end node, and The direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the problem sentence points to the node corresponding to the candidate synonyms arranged behind in the problem sentence;
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten into the problem sentence, and the result is Rewritten question statement.
- the present application also provides a device for rewriting question sentences, including:
- the acquisition unit is used to acquire the question statement entered by the user
- a first identifying unit for identifying each replaceable word in the question sentence based on synonym matching, and replacing candidate synonyms for each of the words
- the first construction unit is used to use the candidate synonym of each of the words as a node, the starting point of the problem sentence as a starting node, and the end point of the problem sentence as an end node;
- the second construction unit is configured to use the sentence fragment between the candidate synonyms as the edge connecting the nodes, and build the edge between the start node, the end node and the node respectively; based on the start node , the end node, each of the nodes, and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, and the directed graph starts from the starting node , ending at the end node, and the direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the question statement points to the node corresponding to the candidate synonyms arranged in the question statement;
- a first computing unit configured to calculate the edge weight of each edge in the directed graph based on the N-gram language model
- the rewriting unit is configured to calculate the shortest path through the N shortest path algorithm based on the directed graph and the edge weights of each edge in the directed graph, and rewrite the candidate synonyms corresponding to each node in the shortest path to the In the problem sentence, the rewritten problem sentence is obtained.
- the present application also provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements a method for rewriting a problem statement when executing the computer program, including:
- the candidate synonym of each said word is used as a node, the starting point of the problem statement is used as a starting node, and the end point of the problem statement is used as an end node;
- the sentence fragments between the candidate synonyms are used as the edges connecting the nodes, and edges are respectively constructed between the starting nodes, ending nodes and the nodes; based on the starting nodes, ending nodes, each of the node and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, the directed graph starts from the start node and ends with the end node, and The direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the problem sentence points to the node corresponding to the candidate synonyms arranged behind in the problem sentence;
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten into the problem sentence, and the result is Rewritten question statement.
- the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, a method for rewriting a question statement is implemented, including:
- the candidate synonym of each said word is used as a node, the starting point of the problem statement is used as a starting node, and the end point of the problem statement is used as an end node;
- the sentence fragments between the candidate synonyms are used as the edges connecting the nodes, and edges are respectively constructed between the starting nodes, ending nodes and the nodes; based on the starting nodes, ending nodes, each of the node and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, the directed graph starts from the start node and ends with the end node, and The direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the problem sentence points to the node corresponding to the candidate synonyms arranged behind in the problem sentence;
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten into the problem sentence, and the result is Rewritten question statement.
- the method, device, computer device and storage medium for rewriting question sentences obtained by the present application obtain the question sentences input by the user; based on synonym matching, identify each replaceable word in the question sentence, and replace each of the words
- the candidate synonyms of each word are used as nodes, the starting point of the question sentence is used as the starting node, and the end point of the problem sentence is used as the end node; the sentence fragments between the candidate synonyms are used as the connection.
- Edges between nodes build edges between the start node, end node and the nodes respectively; build a directed graph based on the start node, end node, each of the nodes and the edges; based on N-gram language model, calculate the edge weights of each edge in the directed graph; calculate the shortest path through the N shortest path algorithm, and rewrite the candidate synonyms corresponding to each node in the shortest path into the problem sentence to obtain Rewritten question statement.
- the present application finds out the synonyms that best fit the context through the calculation of the shortest path, so as to rewrite the textual and graphic sentences.
- FIG. 1 is a schematic diagram of steps of a method for rewriting question sentences in an embodiment of the present application
- Fig. 2 is a structural block diagram of a device for rewriting problem sentences in an embodiment of the present application
- FIG. 3 is a schematic structural block diagram of a computer device according to an embodiment of the present application.
- an embodiment of the present application provides a method for rewriting a question sentence, including the following steps:
- Step S1 obtaining the question statement input by the user
- Step S2 based on synonym matching, identify each replaceable word in the problem statement, and replace the candidate synonym of each said word;
- Step S3 the candidate synonym of each described word is used as a node, the starting point of the problem statement is used as a starting node, and the end point of the problem sentence is used as an end node;
- Step S4 take the sentence fragment between the candidate synonyms as the edge between the connection nodes, and build the edge between the start node, the end node and the node respectively; based on the start node, end node, Each of the nodes and the edges constructs a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, and the directed graph starts from the start node and ends at the end node. end, and the direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the problem sentence points to the node corresponding to the candidate synonyms arranged in the problem sentence;
- Step S5 based on the N-gram language model, calculate the edge weight of each edge in the directed graph
- Step S6 based on the directed graph and the edge weights of each edge in the directed graph, calculate the shortest path through the N shortest path algorithm, and rewrite the candidate synonyms corresponding to each node in the shortest path to the problem statement. , get the rewritten question statement.
- the above method can be applied in the technical field of smart cities to promote the construction of smart cities.
- the above-mentioned question sentence is a sentence input by the user on the user terminal by voice or text, for example: Can I surrender Jinxinsheng during the payment period?
- an offline synonym mining system is configured, and the system continuously supplements the synonym dictionary after long-term synonym mining.
- the synonyms in the above synonym dictionary are stored in the form of key-value, where the key is the word to be matched, and the value is a number of words that may become synonyms with the word.
- synonym matching identify each replaceable word from the above problem sentence, that is, identify each word with a synonym in the problem sentence, and obtain candidate synonyms to replace each word according to the thesaurus dictionary .
- each candidate synonym is regarded as a "node", and the sentence segment between the candidate synonym and the candidate synonym is regarded as an "edge", and a directed graph G(V, E) is constructed. If there is no intersection between the candidate synonym v 1 and the candidate synonym v 2 , a directed edge e 12 is established. Let the position of the candidate synonym v 1 in the sentence be before the candidate synonym v 2 , then the direction of the edge e 12 is from v 1 to v 2 .
- a start node " ⁇ Start>” and an end node “ ⁇ End>” are added, and edges are also constructed in sequence between the above start node and end node and the nodes corresponding to the above candidate synonyms.
- edges are also constructed in sequence between the above start node and end node and the nodes corresponding to the above candidate synonyms.
- the above N-gram language model is used to calculate the sentence fluency score after each candidate synonym is substituted into the question sentence, and calculate the edge of each edge in the directed graph based on the above fluency score Weights.
- the above N-gram language model is trained using large-scale general corpus (People's Daily, Sogou corpus, etc.) and vertical domain corpus (such as the corpus in FAQ).
- N-gram is a statistical language model algorithm, which obtains the sentence perplexity score (that is, the smoothness score) by modeling the occurrence probability of the sentence.
- N shortest paths are used to solve the shortest path from the start node to the end node (that is, the probability score is the largest), and for the shortest path, the corresponding nodes on the path are selected in turn.
- the candidate synonyms of are rewritten to obtain the rewritten question sentence.
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten.
- the question statement after step S6 of obtaining the rewritten question statement, it includes:
- Step S7 calculating the semantic similarity between the question statement and the rewritten question statement
- Step S8 judging whether the semantic similarity is greater than a threshold
- Step S9 if not greater than, then based on the directed graph and the edge weights of each edge in the directed graph, the second short path is calculated by the N shortest path algorithm, and each node in the second short path corresponds to The candidate synonyms of , are rewritten into the problem sentence, and the rewritten problem sentence is obtained;
- Step S10 if it is greater than that, match the answer corresponding to the rewritten question sentence in the database, and push the matched answer to the user terminal where the user is located.
- the second short path can be calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the second short path can be rewritten to Among the problem sentences, rewritten problem sentences are obtained.
- the step S7 of calculating the semantic similarity between the question sentence and the rewritten question sentence includes:
- Ai is the numerical value of the ith component vector of the first vector matrix
- Bi is the numerical value of the ith component vector of the second vector matrix
- the first vector matrix and the second vector matrix are both Include n component vectors.
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten.
- the question statement after step S6 of obtaining the rewritten question statement, it includes:
- Step S71 identifying the user's intention based on the rewritten question statement
- Step S81 judging whether the intention is a designated intention; the designated intention is an intention to purchase a product;
- Step S91 if yes, obtain the product information text corresponding to the specified intention, and perform a hash calculation on the product information text to obtain a corresponding hash value and store it in the database;
- Step S101 sending the product information text and the hash value to the user terminal where the user is located, and reminding the user to input user information in the product information text, and based on the hash value
- the product information text is encrypted.
- intention identification can be performed on the text-graphic sentence to determine whether the user has an intention to purchase a product; if the user's intention is to purchase a product, in order to speed up the communication with the user
- the product information text corresponding to the specified intention can be recommended
- the product information text records the relevant introduction information of the product that the user intends to purchase
- the product information text also has a text box for inputting user information.
- the encrypted password for the above-mentioned product information text is the hash value of the above-mentioned product information text before user information is input.
- the calculation formula of the edge weight is:
- the question statement includes m words, and the question statement is expressed as:
- P(w) is the probability score of the word in the question sentence, i, j are the positions of the two nodes corresponding to the question sentence; event Represents the simultaneous occurrence of events w j-n+1 ... w j-1 , n is the window size of the N-gram language model;
- the occurrence probability of the title sentence s can be expressed as:
- the node set of the directed graph is defined as the set of all candidate synonyms, and the set of edges is the probability score of the n-gram disassembly between all the candidate synonyms and the candidate synonyms.
- the above question statement is: Can I surrender Jin Xinsheng during the payment period? Among them, the candidate synonym for payment is "payment", and the possible candidate synonym is "can or not”. Take the calculation of the edge weight of the edge between "payment” and “can or not” as an example:
- the edge weight calculation of the edge between the vertex of the above problem statement (ie the starting node, the ending node) and the node of the candidate synonym takes the starting node as an example (the calculation method of the edge weight from the ending position is the same), and the calculation formula is as follows:
- an embodiment of the present application also provides a device for rewriting question sentences, including:
- an obtaining unit 10 for obtaining the question statement input by the user
- the first identification unit 20 is used to identify each replaceable word in the problem sentence based on synonym matching, and replace the candidate synonyms of each of the words;
- the first construction unit 30 is used to use the candidate synonym of each of the words as a node, the starting point of the problem sentence as a starting node, and the end point of the problem sentence as an end node;
- the second construction unit 40 is configured to use the sentence fragments between the candidate synonyms as the edges connecting the nodes, and build edges between the start node, the end node and the nodes respectively; based on the start node node, end node, each of the nodes, and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, and the directed graph consists of the starting node Begin, end by the end node, and the direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the question statement points to the node corresponding to the candidate synonyms arranged in the question statement;
- the first computing unit 50 is used to calculate the edge weight of each edge in the directed graph based on the N-gram language model
- the rewriting unit 60 is configured to calculate the shortest path through the N shortest path algorithm based on the directed graph and the edge weights of each edge in the directed graph, and rewrite the candidate synonyms corresponding to each node in the shortest path to all the shortest paths. In the above question sentence, the rewritten question sentence is obtained.
- it also includes:
- a second calculating unit configured to calculate the semantic similarity between the question sentence and the rewritten question sentence
- a judging unit for judging whether the semantic similarity is greater than a threshold
- the third calculation unit is configured to calculate the second short path through the N shortest path algorithm based on the directed graph and the edge weights of each edge in the directed graph if it is not greater than
- the candidate synonyms corresponding to each node in the above are rewritten into the problem sentence, and the rewritten problem sentence is obtained;
- a matching unit configured to match the answer corresponding to the rewritten question statement in the database if it is greater than the value, and push the matched answer to the user terminal where the user is located.
- the second computing unit is specifically used for:
- Ai is the numerical value of the ith component vector of the first vector matrix
- Bi is the numerical value of the ith component vector of the second vector matrix
- the first vector matrix and the second vector matrix are both Include n component vectors.
- the above-mentioned apparatus further includes:
- a second identifying unit configured to identify the user's intention based on the rewritten question sentence
- an intention judgment unit used to judge whether the intention is a designated intention; the designated intention is an intention to purchase a product;
- a hash calculation unit configured to obtain the product information text corresponding to the specified intention, and perform hash calculation on the product information text to obtain a corresponding hash value and store it in the database;
- a sending unit configured to send the product information text and the hash value to the user terminal where the user is located, and remind the user to input user information in the product information text, and based on the hash value
- the product information text is encrypted.
- the calculation formula of the edge weight is:
- the question statement includes m words, and the question statement is expressed as:
- P(w) is the probability score of the word in the question sentence, i, j are the positions of the two nodes corresponding to the question sentence; event Represents the simultaneous occurrence of events w j-n+1 ... w j-1 , n is the window size of the N-gram language model;
- an embodiment of the present application further provides a computer device.
- the computer device may be a server, and its internal structure may be as shown in FIG. 3 .
- the computer device includes a processor, memory, a network interface, and a database connected by a system bus. Among them, the processor of the computer design is used to provide computing and control capabilities.
- the memory of the computer device includes a non-volatile storage medium, an internal memory.
- the nonvolatile storage medium stores an operating system, a computer program, and a database.
- the internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium.
- the computer device's database is used to store question statements and the like.
- the network interface of the computer device is used to communicate with an external terminal through a network connection.
- the computer program when executed by a processor, implements a method of rewriting a problem statement, comprising:
- the candidate synonym of each said word is used as a node, the starting point of the problem sentence is used as a starting node, and the end point of the problem sentence is used as an end node;
- the sentence fragments between the candidate synonyms are used as the edges connecting the nodes, and edges are respectively constructed between the starting nodes, ending nodes and the nodes; based on the starting nodes, ending nodes, each of the node and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, the directed graph starts from the start node and ends with the end node, and The direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the problem sentence points to the node corresponding to the candidate synonyms arranged behind in the problem sentence;
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten into the problem sentence, and the result is Rewritten question statement.
- FIG. 3 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied.
- An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, a method for rewriting a problem statement is implemented, including:
- the candidate synonym of each said word is used as a node, the starting point of the problem sentence is used as a starting node, and the end point of the problem sentence is used as an end node;
- the sentence fragments between the candidate synonyms are used as the edges connecting the nodes, and edges are respectively constructed between the starting nodes, ending nodes and the nodes; based on the starting nodes, ending nodes, each of the node and the edge to construct a directed graph; wherein, there is no intersection between the candidate synonyms corresponding to each node in the directed graph, the directed graph starts from the start node and ends with the end node, and The direction of the edge connecting the nodes is that the node corresponding to the candidate synonyms arranged in the front in the problem sentence points to the node corresponding to the candidate synonyms arranged behind in the problem sentence;
- the shortest path is calculated by the N shortest path algorithm, and the candidate synonyms corresponding to each node in the shortest path are rewritten into the problem sentence, and the result is Rewritten question statement.
- the computer-readable storage medium in this embodiment may be a volatile readable storage medium, and may also be a non-volatile readable storage medium.
- a question sentence input by a user is obtained; based on synonym matching, each replaceable question sentence in the question sentence is identified. words, and the candidate synonyms that replace each of the words; the candidate synonyms of each of the words are used as nodes, the starting point of the problem sentence is used as a starting node, and the end point of the problem sentence is used as an end node; the Sentence fragments between candidate synonyms are used as edges connecting nodes, and edges are respectively constructed between the start node, end node and the node; based on the start node, end node, each of the nodes and all Describe the edges to construct a directed graph; based on the N-gram language model, calculate the edge weights of each edge in the directed graph; calculate the shortest path through the N shortest path algorithm, and assign the candidate synonyms corresponding to each node in the shortest path Rewriting into the problem sentence to obtain the rewritten problem
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Computational Linguistics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Mathematical Physics (AREA)
- General Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Human Computer Interaction (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Machine Translation (AREA)
Abstract
本申请涉及人工智能技术领域,提供一种问题语句的改写方法、装置、计算机设备和存储介质,获取用户输入的问题语句;基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;将所述候选同义词之间的句子片段作为连接节点之间的边,构建有向图;基于N-gram语言模型,计算所述有向图中各个边的边权重;通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。本申请通过最短路径的计算,找出最符合语境同义词,从而对文图语句进行改写。
Description
本申请要求于2020年10月23日提交中国专利局、申请号为202011149730X,发明名称为“问题语句的改写方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及人工智能技术领域,特别涉及一种问题语句的改写方法、装置、计算机设备和存储介质。
在FAQ(问题解答)模块中,针对用户的问题,其回复答案生成主要将用户的问题与问题模板匹配的方式完成。但是在某些情况下用户问题与模板问题语义相近,却无法召回答案。比如:用户问“抑郁症可以投保吗?”,而模板问为“精神病可以投保吗?”,这种情况下可以通过同义词改写的方式扩充输入的问题语句,如:“抑郁症”的同义词为“精神病”,则可以在一定程度上提高召回率。
在具体的应用场景,比如在FAQ问答机器人中,数据库会事先存储多个问题的模板,当用户提问时会匹配到相应的模板问题从而进行自动回复。
然而,对于同一类问题,用户的提问方式却多种多样,同时也包含大量的口语表述,如:“注射疫苗->打疫苗”、“腿骨折->腿瘸了”、“取消->退保”等。
因此,在实际中虽然用户问题与模板问题的语义相近,却无法正确匹配到相应的回复。
因此,可以对用户的问题语句中的词进行同义词替换,但是发明人意识到在不同语境下同义词的合理性却存在差异。如“打疫苗”可以改写为“注射疫苗”,此时,“打”与“注射”是一组同义词,然而将“打篮球”改写为“注射篮球”却十分不合理。这样的例子普遍存在,如“可以投保吗?”可以改写为“能投保吗?”,而将“这个想法可以”改写为“这个想法能”却很滑稽。因此,目前的同义词替换存在不符合语境的缺陷。
本申请的主要目的为提供一种问题语句的改写方法、装置、计算机设备和存储介质,旨在克服目前同义词改写时出现不符合语境的缺陷。
为实现上述目的,本申请提供了一种问题语句的改写方法,包括以下步骤:
获取用户输入的问题语句;
基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
基于N-gram语言模型,计算所述有向图中各个边的边权重;
基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
本申请还提供了一种问题语句的改写装置,包括:
获取单元,用于获取用户输入的问题语句;
第一识别单元,用于基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
第一构建单元,用于将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
第二构建单元,用于将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
第一计算单元,用于基于N-gram语言模型,计算所述有向图中各个边的边权重;
改写单元,用于基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
本申请还提供一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器执行所述计算机程序时实现一种问题语句的改写方法,包括:
获取用户输入的问题语句;
基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
基于N-gram语言模型,计算所述有向图中各个边的边权重;
基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
本申请还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现一种问题语句的改写方法,包括:
获取用户输入的问题语句;
基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
基于N-gram语言模型,计算所述有向图中各个边的边权重;
基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
本申请提供的问题语句的改写方法、装置、计算机设备和存储介质,获取用户输入的问题语句;基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;基于N-gram语言模型,计算所述有向图中各个边的边权重;通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。本申请通过最短路径的计算,找出最符合语境同义词,从而对文图语句进行改写。
图1是本申请一实施例中问题语句的改写方法步骤示意图;
图2是本申请一实施例中问题语句的改写装置结构框图;
图3为本申请一实施例的计算机设备的结构示意框图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
参照图1,本申请一实施例中提供了一种问题语句的改写方法,包括以下步骤:
步骤S1,获取用户输入的问题语句;
步骤S2,基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
步骤S3,将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
步骤S4,将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
步骤S5,基于N-gram语言模型,计算所述有向图中各个边的边权重;
步骤S6,基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
在本实施例中,上述方法可应用于智慧城市技术领域中,以推动智慧城市的建设。具体地,如上述步骤S1所述的,应用于智能解答的场景中,上述问题语句为用户在用户终端上语音输入或者文字输入的语句,例如:请问交费期间可以退保金鑫盛吗?
如上述步骤S2所述的,配置有离线同义词挖掘系统,该系统经过长期的同义词挖掘,从而不断补充同义词词典。上述同义词词典中的同义词以key-value形式存储,key为待匹配的词语,value为若干可能与该词成为同义词的词语。基于上述同义词词典,利用同义词匹配,从上述问题语句中识别出每个可被替换的词,即识别出问题语句中每个具有同义词的词,以及根据同义词词典获取到替换每个词的候选同义词。
如上述步骤S3-S4所述的,将每个候选同义词看作为一个“节点”,候选同义词与候选同义词之间的句子片段看作“边”,构建有向图G(V,E)。候选同义词v
1与候选同义词v
2不存在交叉则建立有向边e
12,设:候选同义词v
1在句中的位置在候选同义词v
2之前,则边e
12的方向由v
1指向v
2。同时添加起始节点“<Start>”与结束节点“<End>”,上述起始节点以及结束节点与上述候选同义词对应的节点之间也依次构建边。如下图所示,因“交费”、“期间”两个匹配词间无交叉,所以存在有向边,而因“交费期间”、“期间”两个匹配词间存在交叉则不存在有向边。
如上述步骤S5所述的,上述N-gram语言模型用于计算上个各个候选同义词代入至问题语句后的句子通顺度分数,并基于上述通顺度分数计算所述有向图中各个边的边权重。上述N-gram语言模型采用大规模通用语料(人民日报、搜狗语料等)以及垂直领域语料(如:FAQ中的语料)训练得到。其中,N-gram是一种统计语言模型算法,通过对语句的出现概率进行建模从而得到句子困惑度分数(即顺畅度分数)。
如上述步骤S6所述的,根据上述构造好的有向图,使用N最短路径进行求解出起始节点至结束节点的最短路径(即概率分数最大),针对最短路径,依次选择路径上节点对应的候选同义词进行改写即得到了改写后的问题句子。
在一实施例中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤S6之后,包括:
步骤S7,计算所述问题语句与所述改写后的问题语句的语义相似度;
步骤S8,判断所述语义相似度是否大于阈值;
步骤S9,若不大于,则基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句;
步骤S10,若大于,则在数据库中匹配对应所述改写后的问题语句的答案,并将匹配出的所述答案推送至所述用户所在的用户终端。
在本实施例中,得到改写后问题语句,为了避免上述模型训练不够造成改写不正确的缺陷,还需要计算上述改写后的问题语句与用户原输入的问题语句的语义相似度;当该语义相似度大于预设的阈值时,则表明其语义与原问题语句的语义近似,则可以在数据库中获取该改写后的问题语句所对应的答案。若语义相似度不大于预设的阈值时,则表明其语义与原问题语句的语义不够近似,此时有可能是计算出现误差,或者模型训练过程中出现问题。因此,可以基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
在一实施例中,所述计算所述问题语句与所述改写后的问题语句的语义相似度的步骤S7,包括:
基于预设的编码器,得到所述问题语句对应的第一向量矩阵,以及得到所述改写后的问题语句对应的第二向量矩阵;
计算第一向量矩阵与所述第二向量矩阵的相似度。
相似度的计算公式为:
其中,Ai为所述第一向量矩阵的第i个分向量的数值,Bi为所述第二向量矩阵的第i个分向量的数值,所述第一向量矩阵和所述第二向量矩阵均包括n个分向量。
在一实施例中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤S6之后,包括:
步骤S71,基于所述改写后的问题语句,识别所述用户的意图;
步骤S81,判断所述意图是否为指定意图;所述指定意图为购买产品意图;
步骤S91,若是,则获取对应所述指定意图的产品信息文本,并对所述产品信息文本进行哈希计算,得到对应的哈希值存储于数据库中;
步骤S101,将所述产品信息文本以及所述哈希值发送至所述用户所在的用户终端,并提醒所述用户在所述产品信息文本中输入用户信息,并基于所述哈希值对所述产品信息文本进行加密。
在本实施例中,在得到改写后的问题语句之后,可以对该文图语句进行意图识别,判断该用户是否具有购买产品的意图;若用户的意图为购买产品,为了加快与用户之间的信息沟通,则可以推荐对应所述指定意图的产品信息文本,该产品信息文本中记载有所述用户意图购买产品的相关介绍信息,且该产品信息文本中还具有输入用户信息的文本框。为了保障用户在上述产品信息文本中输入用户信息之后进行传输的安全性,因此需要对其进行加密传输。在本实施例中,约定对上述产品信息文本的加密密码为上述产品信息文本未输入用户信息之前的哈希值。
在一实施例中,所述边权重的计算公式为:
其中,所述问题语句中包括m个字,所述问题语句表示为:
s=w
1,w
2,w
3,…,w
m
计算最短路径时,为了使乘法变成加法,此处边权重进行log处理,因此,上述最短路径的计算公式为:
在本实施例中,以一个包括m个字的问题语句为例,该问题语句表示为:s=w
1,w
2,w
3,…,w
m。
文题语句s的出现概率可表示为:
p(s)=P(w
1,w
2,w
3,…,w
m)=P(w
1)P(w
2|w
1)…P(w
m|w
1…w
m-1)
利用马尔科夫假设可以对上式进行近似求解,以N-gram语言模型的窗口n=4为例:
p(s)=P(w
1,w
2,w
3,…,w
m)=P(w
1)P(w
2|w
1)…P(w
m|w
m-3…w
m-1)
定义有向图的节点集合为所有候选同义词集,边集合为所有候选同义词与候选同义词间的n-gram拆解后的概率分数。
在一具体实施例中,以N-gram语言模型的窗口n=4为例,上述问题语句为:请问交费期间可以退保金鑫盛吗?其中交费的候选同义词为“缴费”,可以的候选同义词为“能不能”,以计算上述“缴费”与“能不能”之间的边的边权重为例:
上述问题语句的顶点(即起始节点、结束节点)至候选同义词的节点之间边的边权重计算以起始节点为例(距终止位的边权重计算方式同理),其计算公式如下:
参照图2,本申请一实施例中还提供了一种问题语句的改写装置,包括:
获取单元10,用于获取用户输入的问题语句;
第一识别单元20,用于基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
第一构建单元30,用于将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
第二构建单元40,用于将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
第一计算单元50,用于基于N-gram语言模型,计算所述有向图中各个边的边权重;
改写单元60,用于基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
在一实施例中,还包括:
第二计算单元,用于计算所述问题语句与所述改写后的问题语句的语义相似度;
判断单元,用于判断所述语义相似度是否大于阈值;
第三计算单元,用于若不大于,则基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句;
匹配单元,用于若大于,则在数据库中匹配对应所述改写后的问题语句的答案,并将匹配出的所述答案推送至所述用户所在的用户终端。
在一实施例中,所述第二计算单元具体用于:
基于预设的编码器,得到所述问题语句对应的第一向量矩阵,以及得到所述改写后的问题语句对应的第二向量矩阵;
计算第一向量矩阵与所述第二向量矩阵的相似度。
相似度的计算公式为:
其中,Ai为所述第一向量矩阵的第i个分向量的数值,Bi为所述第二向量矩阵的第i个分向量的数值,所述第一向量矩阵和所述第二向量矩阵均包括n个分向量。
在一实施例中,上述装置还包括:
第二识别单元,用于基于所述改写后的问题语句,识别所述用户的意图;
意图判断单元,用于判断所述意图是否为指定意图;所述指定意图为购买产品意图;
哈希计算单元,用于若是,则获取对应所述指定意图的产品信息文本,并对所述产品信息文本进行哈希计算,得到对应的哈希值存储于数据库中;
发送单元,用于将所述产品信息文本以及所述哈希值发送至所述用户所在的用户终端,并提醒所述用户在所述产品信息文本中输入用户信息,并基于所述哈希值对所述产品信息文本进行加密。
在一实施例中,所述边权重的计算公式为:
其中,所述问题语句中包括m个字,所述问题语句表示为:
s=w
1,w
2,w
3,…,w
m
所述最短路径的计算公式为:
在本实施例中,上述各个单元的具体实现请参照上述方法实施例中所述,在此不再进行赘述。
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储问题语句等。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种问题语句的改写方法,包括:
获取用户输入的问题语句;
基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
基于N-gram语言模型,计算所述有向图中各个边的边权重;
基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。
本申请一实施例还提供一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现一种问题语句的改写方法,包括:
获取用户输入的问题语句;
基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;
将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;
将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;
基于N-gram语言模型,计算所述有向图中各个边的边权重;
基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
可以理解的是,本实施例中的计算机可读存储介质可以是易失性可读存储介质,也可以为非易失性可读存储介质。
综上所述,为本申请实施例中提供的问题语句的改写方法、装置、计算机设备和存储介质,获取用户输入的问题语句;基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;基于N-gram语言模型,计算所述有向图中各个边的边权重;通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。本申请通过最短路径的计算,找出最符合语境同义词,从而对文图语句进行改写。
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其它相关的技术领域,均同理包括在本申请的专利保护范围内。
Claims (20)
- 一种问题语句的改写方法,其中,包括以下步骤:获取用户输入的问题语句;基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;基于N-gram语言模型,计算所述有向图中各个边的边权重;基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
- 根据权利要求1所述的问题语句的改写方法,其中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤之后,包括:计算所述问题语句与所述改写后的问题语句的语义相似度;判断所述语义相似度是否大于阈值;若不大于,则基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句;若大于,则在数据库中匹配对应所述改写后的问题语句的答案,并将匹配出的所述答案推送至所述用户所在的用户终端。
- 根据权利要求1所述的问题语句的改写方法,其中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤之后,包括:基于所述改写后的问题语句,识别所述用户的意图;判断所述意图是否为指定意图;所述指定意图为购买产品意图;若是,则获取对应所述指定意图的产品信息文本,并对所述产品信息文本进行哈希计算,得到对应的哈希值存储于数据库中;将所述产品信息文本以及所述哈希值发送至所述用户所在的用户终端,并提醒所述用户在所述产品信息文本中输入用户信息,并基于所述哈希值对所述产品信息文本进行加密。
- 一种问题语句的改写装置,其中,包括:获取单元,用于获取用户输入的问题语句;第一识别单元,用于基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;第一构建单元,用于将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;第二构建单元,用于将所述候选同义词之间的句子片段作为连接节点之间的边,分别 在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;第一计算单元,用于基于N-gram语言模型,计算所述有向图中各个边的边权重;改写单元,用于基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
- 根据权利要求6所述的问题语句的改写装置,其中,还包括:第二计算单元,用于计算所述问题语句与所述改写后的问题语句的语义相似度;判断单元,用于判断所述语义相似度是否大于阈值;第三计算单元,用于若不大于,则基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句;匹配单元,用于若大于,则在数据库中匹配对应所述改写后的问题语句的答案,并将匹配出的所述答案推送至所述用户所在的用户终端。
- 根据权利要求6所述的问题语句的改写装置,其中,还包括:第二识别单元,用于基于所述改写后的问题语句,识别所述用户的意图;意图判断单元,用于判断所述意图是否为指定意图;所述指定意图为购买产品意图;哈希计算单元,用于若是,则获取对应所述指定意图的产品信息文本,并对所述产品信息文本进行哈希计算,得到对应的哈希值存储于数据库中;发送单元,用于将所述产品信息文本以及所述哈希值发送至所述用户所在的用户终端,并提醒所述用户在所述产品信息文本中输入用户信息,并基于所述哈希值对所述产品信息文本进行加密。
- 一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机程序,其中,所述处理器执行所述计算机程序时实现一种问题语句的改写方法,包括:获取用户输入的问题语句;基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;基于N-gram语言模型,计算所述有向图中各个边的边权重;基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
- 根据权利要求11所述的计算机设备,其中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤之后,包括:计算所述问题语句与所述改写后的问题语句的语义相似度;判断所述语义相似度是否大于阈值;若不大于,则基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句;若大于,则在数据库中匹配对应所述改写后的问题语句的答案,并将匹配出的所述答案推送至所述用户所在的用户终端。
- 根据权利要求11所述的计算机设备,其中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤之后,包括:基于所述改写后的问题语句,识别所述用户的意图;判断所述意图是否为指定意图;所述指定意图为购买产品意图;若是,则获取对应所述指定意图的产品信息文本,并对所述产品信息文本进行哈希计算,得到对应的哈希值存储于数据库中;将所述产品信息文本以及所述哈希值发送至所述用户所在的用户终端,并提醒所述用户在所述产品信息文本中输入用户信息,并基于所述哈希值对所述产品信息文本进行加密。
- 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现一种问题语句的改写方法,包括:获取用户输入的问题语句;基于同义词匹配,识别所述问题语句中每个可被替换的词,以及替换每个所述词的候选同义词;将每个所述词的候选同义词作为节点,将所述问题语句的起点作为起始节点,所述问题语句的终点作为结束节点;将所述候选同义词之间的句子片段作为连接节点之间的边,分别在所述起始节点、结束节点与所述节点之间构建边;基于所述起始节点、结束节点、各个所述节点以及所述边,构建有向图;其中,所述有向图中的各个节点对应的候选同义词之间不存在交叉,所述有向图中由起始节点开始,由结束节点结束,且连接所述节点之间的边的方向为所述问题语句中排列在前的候选同义词对应的节点指向所述问题语句中排列在后的候选同义词对应的节点;基于N-gram语言模型,计算所述有向图中各个边的边权重;基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句。
- 根据权利要求16所述的计算机可读存储介质,其中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤之后,包括:计算所述问题语句与所述改写后的问题语句的语义相似度;判断所述语义相似度是否大于阈值;若不大于,则基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出第二短路径,将所述第二短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句;若大于,则在数据库中匹配对应所述改写后的问题语句的答案,并将匹配出的所述答 案推送至所述用户所在的用户终端。
- 根据权利要求16所述的计算机可读存储介质,其中,所述基于所述有向图以及所述有向图中各个边的边权重,通过N最短路径算法计算出最短路径,将所述最短路径中各个节点对应的候选同义词改写至所述问题语句中,得到改写后的问题语句的步骤之后,包括:基于所述改写后的问题语句,识别所述用户的意图;判断所述意图是否为指定意图;所述指定意图为购买产品意图;若是,则获取对应所述指定意图的产品信息文本,并对所述产品信息文本进行哈希计算,得到对应的哈希值存储于数据库中;将所述产品信息文本以及所述哈希值发送至所述用户所在的用户终端,并提醒所述用户在所述产品信息文本中输入用户信息,并基于所述哈希值对所述产品信息文本进行加密。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011149730.XA CN112287080B (zh) | 2020-10-23 | 2020-10-23 | 问题语句的改写方法、装置、计算机设备和存储介质 |
| CN202011149730.X | 2020-10-23 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2022083103A1 true WO2022083103A1 (zh) | 2022-04-28 |
Family
ID=74423800
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2021/091700 Ceased WO2022083103A1 (zh) | 2020-10-23 | 2021-04-30 | 问题语句的改写方法、装置、计算机设备和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN112287080B (zh) |
| WO (1) | WO2022083103A1 (zh) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115292477A (zh) * | 2022-07-18 | 2022-11-04 | 盐城金堤科技有限公司 | 推送相似文章判定方法和装置、及存储介质和电子设备 |
| CN115757731A (zh) * | 2022-11-16 | 2023-03-07 | 中国平安财产保险股份有限公司 | 对话问句改写方法、装置、计算机设备及存储介质 |
| CN116978509A (zh) * | 2023-09-22 | 2023-10-31 | 山东百康云网络科技有限公司 | 一种电子处方流转方法 |
| CN120106082A (zh) * | 2025-05-06 | 2025-06-06 | 浙江大学 | 面向自然语言查数的规范问题重构方法 |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112287080B (zh) * | 2020-10-23 | 2023-10-03 | 平安科技(深圳)有限公司 | 问题语句的改写方法、装置、计算机设备和存储介质 |
| CN113435213B (zh) * | 2021-07-09 | 2024-04-30 | 支付宝(杭州)信息技术有限公司 | 针对用户问题和知识库返回答案的方法和装置 |
| CN113704428B (zh) * | 2021-08-30 | 2023-10-24 | 康键信息技术(深圳)有限公司 | 智能问诊方法、装置、电子设备及存储介质 |
| CN113742454B (zh) * | 2021-09-09 | 2023-07-21 | 平安科技(深圳)有限公司 | 基于人工智能的应答语料生成方法及相关设备 |
| CN115357695B (zh) * | 2022-08-09 | 2026-04-28 | 腾讯科技(深圳)有限公司 | 数据处理方法、装置、电子设备及存储介质 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105095178A (zh) * | 2014-05-09 | 2015-11-25 | 安徽科大讯飞信息科技股份有限公司 | 实现文本语义容错理解的方法及系统 |
| CN110543555A (zh) * | 2019-08-15 | 2019-12-06 | 阿里巴巴集团控股有限公司 | 一种用于智能客服中的标问召回方法和装置 |
| WO2020205047A1 (en) * | 2019-03-29 | 2020-10-08 | Microsoft Technology Licensing, Llc | Querying knowledge graph with natural language input |
| CN112287080A (zh) * | 2020-10-23 | 2021-01-29 | 平安科技(深圳)有限公司 | 问题语句的改写方法、装置、计算机设备和存储介质 |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR101548096B1 (ko) * | 2015-02-02 | 2015-08-27 | 숭실대학교산학협력단 | 문서 자동 요약 방법 및 서버 |
| CN105868236A (zh) * | 2015-12-09 | 2016-08-17 | 乐视网信息技术(北京)股份有限公司 | 一种同义词数据挖掘方法和系统 |
| CN105701253B (zh) * | 2016-03-04 | 2019-03-26 | 南京大学 | 中文自然语言问句语义化的知识库自动问答方法 |
| CN108509474B (zh) * | 2017-09-15 | 2022-01-07 | 腾讯科技(深圳)有限公司 | 搜索信息的同义词扩展方法及装置 |
| CN110347796A (zh) * | 2019-07-05 | 2019-10-18 | 神思电子技术股份有限公司 | 向量语义张量空间下的短文本相似度计算方法 |
| CN110955761A (zh) * | 2019-10-12 | 2020-04-03 | 深圳壹账通智能科技有限公司 | 文书中问答数据获取方法、装置、计算机设备和存储介质 |
-
2020
- 2020-10-23 CN CN202011149730.XA patent/CN112287080B/zh active Active
-
2021
- 2021-04-30 WO PCT/CN2021/091700 patent/WO2022083103A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105095178A (zh) * | 2014-05-09 | 2015-11-25 | 安徽科大讯飞信息科技股份有限公司 | 实现文本语义容错理解的方法及系统 |
| WO2020205047A1 (en) * | 2019-03-29 | 2020-10-08 | Microsoft Technology Licensing, Llc | Querying knowledge graph with natural language input |
| CN110543555A (zh) * | 2019-08-15 | 2019-12-06 | 阿里巴巴集团控股有限公司 | 一种用于智能客服中的标问召回方法和装置 |
| CN112287080A (zh) * | 2020-10-23 | 2021-01-29 | 平安科技(深圳)有限公司 | 问题语句的改写方法、装置、计算机设备和存储介质 |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115292477A (zh) * | 2022-07-18 | 2022-11-04 | 盐城金堤科技有限公司 | 推送相似文章判定方法和装置、及存储介质和电子设备 |
| CN115292477B (zh) * | 2022-07-18 | 2024-04-16 | 盐城天眼察微科技有限公司 | 推送相似文章判定方法和装置、及存储介质和电子设备 |
| CN115757731A (zh) * | 2022-11-16 | 2023-03-07 | 中国平安财产保险股份有限公司 | 对话问句改写方法、装置、计算机设备及存储介质 |
| CN116978509A (zh) * | 2023-09-22 | 2023-10-31 | 山东百康云网络科技有限公司 | 一种电子处方流转方法 |
| CN116978509B (zh) * | 2023-09-22 | 2023-12-19 | 山东百康云网络科技有限公司 | 一种电子处方流转方法 |
| CN120106082A (zh) * | 2025-05-06 | 2025-06-06 | 浙江大学 | 面向自然语言查数的规范问题重构方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN112287080A (zh) | 2021-01-29 |
| CN112287080B (zh) | 2023-10-03 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2022083103A1 (zh) | 问题语句的改写方法、装置、计算机设备和存储介质 | |
| CN111984766B (zh) | 缺失语义补全方法及装置 | |
| US11016966B2 (en) | Semantic analysis-based query result retrieval for natural language procedural queries | |
| WO2024207587A1 (zh) | 问答评分方法、问答评分装置、电子设备及存储介质 | |
| US10706084B2 (en) | Method and device for parsing question in knowledge base | |
| CN109800307B (zh) | 产品评价的分析方法、装置、计算机设备及存储介质 | |
| US9904675B2 (en) | Automatic question generation from natural text | |
| WO2021000676A1 (zh) | 问答方法、问答装置、计算机设备及存储介质 | |
| US9342499B2 (en) | Round-trip translation for automated grammatical error correction | |
| US10810193B1 (en) | Querying a data graph using natural language queries | |
| US12106230B2 (en) | Implementing relation linking for knowledge bases | |
| WO2020119075A1 (zh) | 通用文本信息提取方法、装置、计算机设备和存储介质 | |
| Koundinya et al. | Smart college chatbot using ML and python | |
| CN105608218A (zh) | 智能问答知识库的建立方法、建立装置及建立系统 | |
| WO2017092380A1 (zh) | 用于人机对话的方法、神经网络系统和用户设备 | |
| US12106045B2 (en) | Self-learning annotations to generate rules to be utilized by rule-based system | |
| CN110555205A (zh) | 否定语义识别方法及装置、电子设备、存储介质 | |
| CN110019304A (zh) | 扩展问答知识库的方法及存储介质、终端 | |
| US12596737B2 (en) | Method for generating user interest profile, electronic device and storage medium | |
| WO2025091924A1 (zh) | 人机交互方法、装置、电子设备以及存储介质 | |
| WO2020001329A1 (zh) | 一种输入预测方法及装置 | |
| CN110019749A (zh) | 生成vqa训练数据的方法、装置、设备和计算机可读介质 | |
| TWI553491B (zh) | 問句處理系統及其方法 | |
| CN110019305A (zh) | 知识库扩展方法及存储介质、终端 | |
| WO2019085118A1 (zh) | 基于主题模型的关联词分析方法、电子装置及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21881527 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 21881527 Country of ref document: EP Kind code of ref document: A1 |





