Synonymous text prompt method, device and electronic device
By dividing the input text into word units and using preset models such as word2vec model to obtain candidate word collections for weighted sorting, the problem of low accuracy of synonym text recognition is solved, and the accuracy and user experience of synonym recognition are improved.
Patent Information
- Application Number
- CN202011539680.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-23
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-12-23
AI Technical Summary
The prior art has low accuracy in synonymous text recognition, especially due to the recognition inaccuracy problem caused by non-synonyms with small editing distances.
By dividing the input text into word units, the target word unit is determined, and a preset model such as word2vec model is used to obtain the candidate word set, and weighted sorting is performed to improve the accuracy of synonym recognition.
It improves the accuracy of synonym recognition, enables users to obtain synonym text more accurately, and improves the user experience. Users usually only need to select the first few synonyms to select the target synonym text.
Smart Images

Figure CN112559711B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and is particularly applicable to computer synonymous text recognition technology, and more specifically to a synonymous text prompt method, device, electronic device and computer-readable medium. Background Art
[0002] With the development of computer technology and Internet technology, synonymous information plays an indispensable role in application fields such as quality inspection systems, Web search, question-answering systems, and knowledge graph construction. For example, the quality inspection platform searches for texts that are synonymous with the keywords and phrases entered by the user, the search engine searches for texts that are semantically identical or similar to the text entered by the user, or the question-answering platform searches for a collection of questions that are synonymous with the new questions raised by the user.
[0003] When performing synonymous text recognition, the prior art needs to rely on auxiliary tools such as word segmentation tools, part-of-speech analysis, sentence template extraction, etc. to perform auxiliary processing on the text to obtain core words, and then determine whether the two core words are synonyms through the edit distance between the two core words. Among them, the edit distance refers to the number of times a string is processed to become another string, and the edit distance can indicate the degree of difference between the two strings. When the edit distance between two words is less than or equal to a preset value, the two words are determined to be synonyms; when the edit distance between two words is greater than a preset value, the two words are determined to be non-synonymous. In practice, there are non-synonymous pairs with small edit distances, resulting in low recognition accuracy of synonymous text. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] The present invention aims to solve the technical problem of low recognition accuracy of synonymous texts in the prior art.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, one aspect of the present invention provides a synonymous text prompt method, wherein the synonymous text refers to a text with the same or similar meaning as the input text, and the synonymous text includes a text with the same meaning as the input text and / or a text with a similar meaning as the input text, and the text can be a single word or a text composed of at least two words. The method comprises the following steps:
[0008] Split the input text into word units;
[0009] Determining a target word unit from the word units according to a segmentation condition of the input text, wherein the segmentation condition of the input text includes: the input text is segmented into a single word unit, the input text is segmented into at least two word units;
[0010] Obtain candidate words corresponding to the target word unit through a preset model to form a candidate set, wherein the candidate words are synonyms or near synonyms of the target word unit;
[0011] Sorting the candidate words in the candidate set to obtain a comprehensive sorted candidate set corresponding to the target word unit;
[0012] According to the segmentation of the input text and the comprehensive ranking candidate set, synonymous texts of the input text are prompted.
[0013] According to a preferred embodiment of the present invention, obtaining the candidate words corresponding to the target word unit through a preset model to form a candidate set includes:
[0014] Obtain different corpora as training sets to train multiple word2vec models;
[0015] The candidate words corresponding to the target word unit are obtained through each trained word2vec model to form a candidate set.
[0016] According to a preferred embodiment of the present invention, obtaining candidate words corresponding to the target word unit through each trained word2vec model to form a candidate set includes:
[0017] Input the target word unit into a trained word2vec model to obtain the word vector of the target word unit output by the word2vec model;
[0018] Obtaining a candidate word vector whose similarity with the word vector of the target word unit is less than a threshold;
[0019] The candidate word vectors are converted into corresponding candidate words to form a candidate set.
[0020] According to a preferred embodiment of the present invention, the sorting of candidate words in the candidate set includes:
[0021] Get the candidate sets output by each word2vec model;
[0022] Determine the total weight of the candidate word according to the preset weight of the candidate word and the arrangement position of the candidate word in each candidate set;
[0023] The candidate words in the candidate set are sorted according to the total weights of the candidate words.
[0024] According to a preferred embodiment of the present invention, the input text is segmented into a single word unit, and the single word unit is used as the target word unit.
[0025] According to a preferred embodiment of the present invention, the prompting of synonymous texts of the input text according to the segmentation of the input text and the comprehensive ranking candidate set includes:
[0026] Filter out target words that meet the conditions from the comprehensive ranking candidate set according to preset word length, preset part of speech and preset word frequency;
[0027] The target words are prompted according to the order of the target words in the comprehensive ranking candidate set.
[0028] According to a preferred embodiment of the present invention, the input text is segmented into at least two word units, and one of the at least two word units is selected as the target word unit according to part of speech and / or word frequency.
[0029] According to a preferred embodiment of the present invention, the prompting of synonymous texts of the input text according to the segmentation of the input text and the comprehensive ranking candidate set includes:
[0030] Obtain the top N candidate words with the highest total weight in the comprehensive ranking candidate set;
[0031] Merge other word units segmented from the input text with the top N candidate words with the total weight to obtain N candidate texts;
[0032] Sorting the candidate texts according to their historical occurrence frequencies;
[0033] The candidate texts are suggested according to their order.
[0034] According to a preferred embodiment of the present invention, if the historical occurrence frequency of multiple candidate texts is zero, the multiple candidate texts are sorted according to the similarity between the word vectors corresponding to the candidate words in the multiple candidate texts and the word vectors corresponding to the target word unit.
[0035] A second aspect of the present invention provides a synonymous text prompting device, wherein the synonymous text refers to a text having the same or similar meaning as the input text, and the device comprises:
[0036] Segmentation unit, used to segment the input text into word units;
[0037] A determination module, configured to determine a target word unit from the word units according to a segmentation condition of the input text, wherein the segmentation condition of the input text includes: the input text is segmented into a single word unit, and the input text is segmented into at least two word units;
[0038] An acquisition module, used for acquiring candidate words corresponding to the target word unit through a preset model to form a candidate set, wherein the candidate words are synonyms or near synonyms of the target word unit;
[0039] A sorting module, used to sort the candidate words in the candidate set to obtain a comprehensive sorted candidate set corresponding to the target word unit;
[0040] The prompt module is used to prompt synonymous texts of the input text according to the segmentation status of the input text and the comprehensive ranking candidate set.
[0041] A third aspect of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a computer executable program, and when the computer program is executed by the processor, the processor executes the described method.
[0042] A fourth aspect of the present invention further proposes a computer-readable medium storing a computer-executable program, wherein when the computer-executable program is executed, the method described is implemented.
[0043] (III) Beneficial effects
[0044] The present invention obtains a candidate set of a target word unit through a preset model, and then sorts the candidate words in the candidate set, so that the candidate words are sorted in the candidate set according to the accuracy of synonym recognition between them and the target word unit, thereby improving the accuracy of synonym recognition of the target word unit. Finally, the synonymous text of the input text is determined and prompted according to the segmentation of the input text and the sorting of the candidate words corresponding to the target word unit, thereby ensuring that the synonymous text is prompted according to the accuracy of synonym recognition. The present invention improves the recognition rate of synonymous texts while also improving the user experience. The user usually only needs to select the target synonymous text based on the first one or two synonymous texts prompted.
[0045] The present invention trains multiple word2vec models by acquiring different corpora as training sets; and obtains candidate words corresponding to the target word unit through each trained word2vec model to form a candidate set. In this way, a target word unit will have multiple candidate sets, and the candidate words in each candidate set may be the same or different. Multiple word2vec models trained with different corpora ensure the comprehensiveness of the candidate words.
[0046] The present invention adopts a weighted sorting method, by obtaining the candidate sets output by each word2vec model; determining the total weight of the candidate words according to the preset weight of the candidate words and the arrangement position of the candidate words in each candidate set; and sorting the candidate words in each candidate set according to the total weight of the candidate words. Thus, the candidate words output by different word2vec models are sorted according to the accuracy of synonym recognition between them and the target word unit, thereby improving the accuracy of synonym recognition of the target word unit. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1It is a flow chart of a synonymous text prompt method of the present invention;
[0048] Figure 2 It is a schematic diagram of the present invention obtaining candidate words corresponding to a target word unit through a preset model to form a candidate set;
[0049] Figure 3 It is a structural schematic diagram of a synonymous text prompt device of the present invention;
[0050] Figure 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
[0051] Figure 5 is a schematic diagram of a computer-readable recording medium according to an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In the process of introducing specific embodiments, the detailed description of the structure, performance, effect or other characteristics is to enable those skilled in the art to fully understand the embodiments. However, it does not exclude that those skilled in the art can implement the present invention with a technical solution that does not contain the above-mentioned structure, performance, effect or other characteristics under certain circumstances.
[0053] The flowchart in the accompanying drawings is only an exemplary process demonstration, and does not mean that the solution of the present invention must include all the contents, operations and steps in the flowchart, nor does it mean that it must be executed in the order shown in the figure. For example, some operations / steps in the flowchart can be decomposed, some operations / steps can be combined or partially combined, etc. The execution order shown in the flowchart can be changed according to actual conditions without departing from the main purpose of the present invention.
[0054] Frames in the attached figure Figure 1 Generally, it refers to functional entities, which do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processing unit devices and / or microcontroller devices.
[0055] The same reference numerals in the drawings represent the same or similar elements, components or parts, and thus the repeated description of the same or similar elements, components or parts may be omitted below. It should also be understood that although the first, second, third and other attributives representing the numbers may be used herein to describe various devices, elements, components or parts, these devices, elements, components or parts should not be limited by these attributives. In other words, these attributives are only used to distinguish one from another. For example, the first device may also be called the second device, but it does not deviate from the essential technical solution of the present invention. In addition, the terms "and / or" and "and / or" refer to all combinations including any one or more of the listed items.
[0056] In order to solve the above technical problems, the present invention proposes a synonymous text prompting method, wherein the synonymous text refers to a text with the same or similar meaning as the input text, by dividing the input text into word units; determining the target word unit from the word units according to the segmentation of the input text, obtaining the candidate words corresponding to the target word unit through a preset model to form a candidate set, sorting the candidate words in the candidate set, and obtaining a comprehensive sorting candidate set corresponding to the target word unit; and prompting the synonymous text of the input text according to the segmentation of the input text and the comprehensive sorting candidate set. Wherein, the segmentation of the input text includes: the input text is segmented into a single word unit, the input text is segmented into at least two word units; the candidate word is a synonym or near synonym of the target word unit; the present invention obtains the candidate set of the target word unit through a preset model, and then sorts the candidate words in the candidate set, so that the candidate words are sorted in the candidate set according to the accuracy of synonym recognition between them and the target word unit, thereby improving the accuracy of synonym recognition of the target word unit. Finally, the synonymous text of the input text is determined and prompted according to the segmentation of the input text and the ranking of the candidate words corresponding to the target word unit, thereby ensuring that the synonymous text is prompted according to the accuracy of synonym recognition. The present invention improves the recognition rate of synonymous texts while also improving the user experience. Users usually only need to select the target synonymous text based on the first one or two synonymous texts prompted.
[0057] The present invention trains multiple word2vec models by acquiring different corpora as training sets; and obtains candidate words corresponding to the target word unit through each trained word2vec model to form a candidate set. In this way, a target word unit will have multiple candidate sets, and the candidate words in each candidate set may be the same or different. Multiple word2vec models trained with different corpora ensure the comprehensiveness of the candidate words.
[0058] When each word2vec model obtains a candidate set of a target word unit, the target word unit is first input into a trained word2vec model to obtain a word vector of the target word unit output by the word2vec model; a candidate word vector whose similarity with the word vector of the target word unit is less than a threshold is obtained; and the candidate word vector is converted into a corresponding candidate word to form a candidate set.
[0059] In a method for sorting candidate words in a candidate set, a weighted sorting method is adopted, by obtaining the candidate sets output by each word2vec model; determining the total weight of the candidate word according to the preset weight of the candidate word and the arrangement position of the candidate word in each candidate set; and sorting the candidate words in each candidate set according to the total weight of the candidate word. Thus, the candidate words output by different word2vec models are sorted according to the accuracy of synonym recognition between them and the target word unit, thereby improving the accuracy of synonym recognition of the target word unit.
[0060] In a case of segmenting an input text, the input text is segmented into a single word unit, and the single word unit is used as a target word unit. Then, the target words that meet the conditions are first filtered out from the comprehensive ranking candidate set according to the preset word length, preset part of speech and preset word frequency; and then the target words are prompted according to the order of the target words in the comprehensive ranking candidate set.
[0061] In another case of input text segmentation, the input text is segmented into at least two word units, and one of the at least two word units is selected as the target word unit according to part of speech and / or word frequency. Then, the candidate words with the top N total weight in the comprehensive ranking candidate set are first obtained; then, other word units segmented from the input text are merged with the top N total weight candidate words to obtain N candidate texts; the candidate texts are ranked according to the historical occurrence frequency of the candidate texts; and finally, the candidate texts are prompted according to the ranking of the candidate texts.
[0062] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.
[0063] In the process of introducing specific embodiments, the detailed description of the structure, performance, effect or other characteristics is to enable those skilled in the art to fully understand the embodiments. However, it does not exclude that those skilled in the art can implement the present invention with a technical solution that does not contain the above-mentioned structure, performance, effect or other characteristics under certain circumstances.
[0064] The flowchart in the accompanying drawings is only an exemplary process demonstration, and does not mean that the solution of the present invention must include all the contents, operations and steps in the flowchart, nor does it mean that it must be executed in the order shown in the figure. For example, some operations / steps in the flowchart can be decomposed, some operations / steps can be combined or partially combined, etc. The execution order shown in the flowchart can be changed according to actual conditions without departing from the main purpose of the present invention.
[0065] Frames in the attached figure Figure 1 Generally, it refers to functional entities, which do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processing unit devices and / or microcontroller devices.
[0066] The same reference numerals in the drawings represent the same or similar elements, components or parts, and thus the repeated description of the same or similar elements, components or parts may be omitted below. It should also be understood that although the first, second, third and other attributives representing the numbers may be used herein to describe various devices, elements, components or parts, these devices, elements, components or parts should not be limited by these attributives. In other words, these attributives are only used to distinguish one from another. For example, the first device may also be called the second device, but it does not deviate from the essential technical solution of the present invention. In addition, the terms "and / or" and "and / or" refer to all combinations including any one or more of the listed items.
[0067] Figure 1 is a flow chart of a synonymous text prompt method of the present invention, wherein the synonymous text refers to a text having the same or similar meaning as the input text, such as Figure 1 As shown, the method comprises the following steps:
[0068] S1, dividing the input text into word units;
[0069] The input text may be a single word, such as a keyword input by a user, or a phrase composed of multiple words. The word unit may be a Chinese word, an English word, etc. The present invention may specifically use a word segmentation tool (such as Hanlp word segmenter, Ansj word segmentation tool, etc.) to segment the input text into word units.
[0070] S2, determining a target word unit from the word units according to the segmentation of the input text,
[0071] Specifically, if the input text in step S1 is a single word, the segmentation of the input text is as follows: the input text is segmented into a single word unit, and the single word unit is used as the target word unit.
[0072] If the input text is a phrase in step S1, the segmentation of the input text is as follows: the input text is segmented into at least two word units, and one of the at least two word units is selected as the target word unit according to the part of speech and / or word frequency. Wherein, word frequency refers to the frequency of occurrence of a word unit in a predetermined corpus or predetermined document. When the part of speech and word frequency are used to determine the target word unit at the same time, the priority of the part of speech and word frequency is preset, such as setting the part of speech priority higher than the word frequency priority, and then first selecting the target word unit according to the part of speech, if the parts of speech of each word unit are the same, then selecting the target word unit according to the word frequency. Taking the selection of the target word unit according to the part of speech as an example, wherein the part of speech may include: noun, adjective, verb, and words other than the above three parts of speech, the present invention can preset the priority of each part of speech, such as: noun, adjective, verb, and words other than the above three parts of speech have priorities that increase in sequence. Then select the word unit with the highest part of speech priority as the target word unit. For example, when the user inputs "no time", it is segmented into two word units, "no" and "time". The part-of-speech priority of "no" is higher than that of "time", so "no" is the target word unit.
[0073] S3, obtaining the candidate words corresponding to the target word unit through a preset model to form a candidate set,
[0074] The candidate words are synonyms or near synonyms of the target word unit; the present invention trains multiple word2vec models by acquiring different corpora as training sets; and the candidate words corresponding to the target word unit are acquired through each trained word2vec model to form a candidate set. In this way, a target word unit will have multiple candidate sets, and the candidate words in each candidate set may be the same or different. Multiple word2vec models trained with different corpora ensure the comprehensiveness of the candidate words.
[0075] When each word2vec model obtains a candidate set of a target word unit, the target word unit is first input into a trained word2vec model to obtain the word vector of the target word unit output by the word2vec model; a candidate word vector whose similarity with the word vector of the target word unit is less than a threshold is obtained; and the candidate word vector is converted into a corresponding candidate word to form a candidate set. Among them, the word2vec model is a group of models used to generate word vectors. After training, the word2vec model can be used to map each word to a vector, which can be used to represent the relationship between words. In the present invention, the similarity of word vectors can be calculated by the Euclidean distance, cosine distance, edit distance, Hamming distance, etc. between the two.
[0076] For example, Figure 2As shown, taking the use of three word2vec models to obtain a candidate set of target word units as an example, first use different corpora to train the three word2vec models, for example: use open source corpora to train the first word2vec model, use the first corpus within the enterprise (such as a children's subject corpus) to train the second word2vec model, and use the second corpus within the enterprise (such as a high school subject corpus) to train the third word2vec model. If the user inputs the text "test paper", then "test paper" is the target word unit, and "test paper" is input into each trained word2vec model. Each word2vec model will output the word vector of "test paper", calculate the Euclidean distance between the word vector of "test paper" and other word vectors to obtain the similarity between the word vector of "test paper" and other word vectors, and use other word vectors with similarities less than the threshold as candidate word vectors, and convert the candidate word vectors into candidate words to form a candidate word set. For example, the candidate word set for "exam paper" obtained by the first word2vec model is: test paper, test question, test paper, real question, exam, midterm, primary to junior high school, test, final, exercise. The candidate word set for "exam paper" obtained by the second word2vec model is: test question, test paper, examinee, marking, test question, composition, exam, written test, question, exam room. The candidate word set for "exam paper" obtained by the third word2vec model is: minor subject, test paper, final exam paper, midterm exam paper, monthly exam paper, test paper, monthly exam paper, test question, test question, test ticket.
[0077] S4, sorting the candidate words in the candidate set to obtain a comprehensive sorted candidate set corresponding to the target word unit;
[0078] In a method for sorting candidate words in a candidate set, a weighted sorting method is adopted, by obtaining the candidate sets output by each word2vec model; determining the total weight of the candidate word according to the preset weight of the candidate word and the arrangement position of the candidate word in each candidate set; and sorting the candidate words in each candidate set according to the total weight of the candidate word. Thus, the candidate words output by different word2vec models are sorted according to the accuracy of synonym recognition between them and the target word unit, thereby improving the accuracy of synonym recognition of the target word unit. Among them, the arrangement position of the candidate word in each candidate set can be arranged according to the similarity between the word vector of the candidate word and the word vector of the target word unit.
[0079] Specifically, the total weight Pi of candidate word i can be obtained by the following formula:
[0080] Pi=pi×[rank(Ai)+rank(Bi)+…+rank(Ni)]
[0081] Among them, pi is the preset weight of candidate word i, rank(Ai) is the ranking position of candidate word i in the candidate set output by the word2vec model numbered A, rank(Bi) is the ranking position of candidate word i in the candidate set output by the word2vec model numbered B, and rank(Ni) is the ranking position of candidate word i in the candidate set output by the word2vec model numbered N.
[0082] by Figure 2 Taking the candidate word "test question" as an example, assuming that the preset weight of the candidate word "test question" is 0.9, the candidate word "test question" is ranked second in the first word2vec model, ranked first in the second word2vec model, and ranked eighth in the third word2vec model, then the total weight of the candidate word "test question" is: 0.9×(2+1+8).
[0083] S5. Prompt synonymous texts of the input text according to the segmentation of the input text and the comprehensive ranking candidate set.
[0084] Specifically, if the input text in step S1 is a single word, and the segmentation of the input text is: the input text is segmented into a single word unit, then this step includes:
[0085] S51, filtering out target words that meet the conditions from the comprehensive ranking candidate set according to preset word length, preset part of speech and preset word frequency;
[0086] Exemplarily, the preset word length can be set to: greater than 1 byte and less than 4 bytes; the preset part of speech can be set to be the same as the part of speech of the target word unit, and the preset word frequency refers to the frequency of occurrence of the candidate word in a predetermined corpus or a predetermined document, which can be specifically set according to the training sample of the word2vec model.
[0087] S52: Prompt the target words according to the order of the target words in the comprehensive ranking candidate set.
[0088] Specifically, the target words may be displayed in sequence from front to back according to the order of the target words in the comprehensive ranking candidate set.
[0089] If the input text in step S1 is a phrase, and the segmentation of the input text is: the input text is segmented into at least two word units, then this step includes:
[0090] S501, obtaining the top N candidate words in the comprehensive ranking candidate set by total weight;
[0091] Among them, N can be set according to user needs.
[0092] S502, merging other word units segmented from the input text with the top N candidate words by total weight to obtain N candidate texts;
[0093] Take the input text "what time" as an example, it is segmented into "what" and "time", "what" is the target word unit, and "time" is other word units segmented from the input text. If the top 9 candidate words with the highest total weight in the comprehensive ranking candidate set corresponding to "what" are: any, what, other, other, which, each, where, various, everything; then 9 candidate texts are obtained: any time, what time, other time, other time, which time, each time, where time, various time, all time.
[0094] S503, sorting the candidate texts according to their historical occurrence frequencies;
[0095] The historical occurrence frequency refers to the frequency in the historical query document. If there are multiple candidate texts with a historical occurrence frequency of zero, the candidate texts with a historical occurrence frequency of zero are sorted according to the similarity between the word vectors corresponding to these candidate words and the word vectors corresponding to the target word unit.
[0096] S504: Prompt candidate texts according to the order of the candidate texts.
[0097] Figure 3 Schematic diagram of a framework of a synonymous text prompt device of the present invention, wherein the synonymous text refers to a text having the same or similar meaning as the input text, such as Figure 3 As shown, the device comprises:
[0098] A segmentation unit 31, used for segmenting the input text into word units;
[0099] A determination module 32, configured to determine a target word unit from the word units according to a segmentation condition of the input text, wherein the segmentation condition of the input text includes: the input text is segmented into a single word unit, the input text is segmented into at least two word units;
[0100] An acquisition module 33, used for acquiring candidate words corresponding to the target word unit through a preset model to form a candidate set, wherein the candidate words are synonyms or near synonyms of the target word unit;
[0101] A sorting module 34 is used to sort the candidate words in the candidate set to obtain a comprehensive sorted candidate set corresponding to the target word unit;
[0102] The prompt module 35 is used to prompt synonymous texts of the input text according to the segmentation status of the input text and the comprehensive ranking candidate set.
[0103] In a specific implementation, the acquisition module 33 includes:
[0104] The first acquisition module is used to acquire different corpora as training sets to train multiple word2vec models;
[0105] The second acquisition module is used to obtain candidate words corresponding to the target word unit through each trained word2vec model to form a candidate set.
[0106] Furthermore, the second acquisition module includes:
[0107] An input module, used for inputting the target word unit into a trained word2vec model to obtain a word vector of the target word unit output by the word2vec model;
[0108] A sub-acquisition module, used to acquire a candidate word vector whose similarity with the word vector of the target word unit is less than a threshold;
[0109] The conversion module is used to convert the candidate word vectors into corresponding candidate words to form a candidate set.
[0110] The sorting module 34 includes:
[0111] The third acquisition module is used to obtain the candidate sets output by each word2vec model;
[0112] A sub-determination module, used to determine the total weight of the candidate word according to the preset weight of the candidate word and the arrangement position of the candidate word in each candidate set;
[0113] The sub-ranking module is used to rank the candidate words in the candidate set according to the total weight of the candidate words.
[0114] In one example, the input text is segmented into a single word unit, and the single word unit is used as the target word unit. The prompt module 35 includes:
[0115] A filtering module, used to filter out target words that meet the conditions from the comprehensive ranking candidate set according to a preset word length, a preset part of speech and a preset word frequency;
[0116] The first prompting module is used to prompt the target word according to the order of the target word in the comprehensive ranking candidate set.
[0117] In another example, the input text is segmented into at least two word units, and one of the at least two word units is selected as the target word unit according to part of speech and / or word frequency. The prompt module 35 includes:
[0118] A fourth acquisition module is used to acquire the top N candidate words with the highest total weight in the comprehensive ranking candidate set;
[0119] A merging module, used for merging other word units segmented from the input text with the top N candidate words with the total weight, to obtain N candidate texts;
[0120] The first sorting module is used to sort the candidate texts according to the historical occurrence frequency of the candidate texts; if the historical occurrence frequency of multiple candidate texts is zero, the first sorting module sorts the multiple candidate texts according to the similarity between the word vectors corresponding to the candidate words in the multiple candidate texts and the word vectors corresponding to the target word units.
[0121] The second prompting module is used to prompt the candidate texts according to the order of the candidate texts.
[0122] Those skilled in the art will appreciate that the modules in the above device embodiments may be distributed in the device as described, or may be changed accordingly and distributed in one or more devices different from the above embodiments. The modules in the above embodiments may be combined into one module, or may be further split into multiple submodules.
[0123] Figure 4 It is a structural diagram of an electronic device of an embodiment of the present invention. The electronic device includes a processor and a memory. The memory is used to store a computer executable program. When the computer program is executed by the processor, the processor executes a synonymous text prompt method.
[0124] like Figure 4 As shown, the electronic device is presented in the form of a general computing device. The processor may be one or more and work in coordination. The present invention does not exclude distributed processing, that is, the processor may be dispersed in different physical devices. The electronic device of the present invention is not limited to a single entity, but may also be the sum of multiple physical devices.
[0125] The memory stores a computer executable program, which is usually a machine-readable code. The computer-readable program can be executed by the processor to enable the electronic device to perform the method of the present invention, or at least part of the steps in the method.
[0126] The memory includes a volatile memory, such as a random access memory unit (RAM) and / or a cache memory unit, and may also be a non-volatile memory, such as a read-only memory unit (ROM).
[0127] Optionally, in this embodiment, the electronic device further includes an I / O interface, which is used for the electronic device to exchange data with an external device. The I / O interface can represent one or more of several types of bus structures, including a storage unit bus or a storage unit controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of a variety of bus structures.
[0128] It should be understood that Figure 4 The electronic device shown is only an example of the present invention, and the electronic device of the present invention may also include elements or components not shown in the above examples. For example, some electronic devices also include display units such as display screens, and some electronic devices also include human-computer interaction elements such as buttons, keyboards, etc. As long as the electronic device can execute the computer-readable program in the memory to implement the method of the present invention or at least part of the steps of the method, it can be considered as an electronic device covered by the present invention.
[0129] Figure 5 Schematic diagram of a computer readable recording medium according to an embodiment of the present invention. Figure 5 As shown, a computer executable program is stored in a computer-readable recording medium, and when the computer executable program is executed, the synonymous text prompt method of the present invention is implemented. The computer-readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, device, or device. The program code contained on the readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0130] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0131] Through the above description of the implementation mode, it is easy for those skilled in the art to understand that the present invention can be implemented by hardware capable of executing a specific computer program, such as the system of the present invention, and the electronic processing unit, server, client, mobile phone, control unit, processor, etc. contained in the system. The present invention can also be implemented by a vehicle comprising at least a part of the above system or components. The present invention can also be implemented by computer software that executes the method of the present invention, such as control software executed by a microprocessor, an electronic control unit, a client, a server, etc. of a live broadcast device. However, it should be noted that the computer software that executes the method of the present invention is not limited to being executed by one or a specific hardware entity, and it can also be implemented in a distributed manner by unspecified specific hardware. For computer software, the software product can be stored in a computer-readable storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.), or it can be distributed and stored on the network, as long as it enables the electronic device to execute the method according to the present invention.
[0132] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the present invention is not inherently related to any specific computer, virtual device or electronic device, and various general devices can also implement the present invention. The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A synonymous text prompting method, wherein the synonymous text refers to a text with the same or similar meaning as the input text, characterized in that: The method comprises the following steps: Split the input text into word units; Determining a target word unit from the word units according to a segmentation condition of the input text, wherein the segmentation condition of the input text includes: the input text is segmented into a single word unit, and the input text is segmented into at least two word units; wherein, if the input text is segmented into a single word unit, the single word unit is used as the target word unit; and if the input text is segmented into at least two word units, one of the at least two word units is selected as the target word unit based on part of speech and / or word frequency; Obtain candidate words corresponding to the target word unit through a preset model to form a candidate set, wherein the candidate words are synonyms or near synonyms of the target word unit, and one target word unit may have multiple candidate sets; Sorting the candidate words in the candidate set to obtain a comprehensive sorted candidate set corresponding to the target word unit; Prompting synonymous texts of the input text according to the segmentation of the input text and the comprehensive ranking candidate set, including: for a word unit that is segmented into only one word unit, filtering out qualified target words from the comprehensive ranking candidate set according to a preset word length, a preset part of speech and a preset word frequency, and prompting the target words according to the order of the target words in the comprehensive ranking candidate set; for a word unit that is segmented into at least two word units, obtaining the top N candidate words in the comprehensive ranking candidate set with the total weight, merging other word units segmented from the input text with the top N candidate words with the total weight to obtain N candidate texts, sorting the candidate texts according to the historical occurrence frequency of the N candidate texts, and prompting according to the sorting of the candidate texts.
2. The synonymous text prompt method according to claim 1, characterized in that: The step of obtaining the candidate words corresponding to the target word unit through a preset model to form a candidate set includes: Obtain different corpora as training sets to train multiple word2vec models; The candidate words corresponding to the target word unit are obtained through each trained word2vec model to form a candidate set.
3. The synonymous text prompt method according to claim 2, characterized in that: The step of obtaining candidate words corresponding to the target word unit through each trained word2vec model to form a candidate set includes: Input the target word unit into a trained word2vec model to obtain the word vector of the target word unit output by the word2vec model; Obtaining a candidate word vector whose similarity to the word vector of the target word unit is less than a threshold; The candidate word vectors are converted into corresponding candidate words to form a candidate set.
4. The synonymous text prompt method according to claim 2 or 3, characterized in that: The sorting of the candidate words in the candidate set includes: Get the candidate sets output by each word2vec model; Determine the total weight of the candidate word according to the preset weight of the candidate word and the arrangement position of the candidate word in each candidate set; The candidate words in the candidate set are sorted according to the total weight of the candidate words.
5. The synonymous text prompt method according to claim 4, characterized in that: The input text is segmented into a unique word unit. The input text is segmented into at least two word units including: when the input text is a single word, the input text is segmented into a unique word unit; when the input text is a phrase, the input text is segmented into at least two word units.
6. The synonymous text prompt method according to claim 1, characterized in that: Prompting the target words according to the order of the target words in the comprehensive ranking candidate set includes: displaying the target words in sequence from front to back according to the order.
7. The synonymous text prompt method according to claim 4, characterized in that: The priority of the part of speech is preset to be higher than the priority of the word frequency. If the parts of speech of various word units are the same, the target word unit is selected based on the word frequency.
8. A synonymous text prompt device, characterized in that: The synonymous text refers to a text having the same or similar meaning as the input text, and is characterized in that the device includes: Segmentation unit, used to segment the input text into word units; a determination module, configured to determine a target word unit from the word units based on a segmentation condition of the input text, wherein the segmentation condition of the input text includes: the input text is segmented into a single word unit, or the input text is segmented into at least two word units; wherein, if the input text is segmented into a single word unit, the single word unit is used as the target word unit; and if the input text is segmented into at least two word units, one of the at least two word units is selected as the target word unit based on part of speech and / or word frequency; An acquisition module is used to acquire candidate words corresponding to the target word unit through a preset model to form a candidate set, wherein the candidate words are synonyms or near synonyms of the target word unit, and one target word unit may have multiple candidate sets; A sorting module, configured to sort the candidate words in the candidate set to obtain a comprehensive sorted candidate set corresponding to the target word unit; A prompt module is used to prompt synonymous texts of the input text according to the segmentation of the input text and the comprehensive ranking candidate set, including: for being segmented into a single word unit, filtering out qualified target words from the comprehensive ranking candidate set according to a preset word length, a preset part of speech and a preset word frequency, and prompting the target words according to the order of the target words in the comprehensive ranking candidate set; for being segmented into at least two word units, obtaining the top N candidate words in the comprehensive ranking candidate set with the total weight, merging other word units segmented from the input text with the top N candidate words with the total weight to obtain N candidate texts, sorting the candidate texts according to the historical occurrence frequency of the N candidate texts and prompting according to the sorting of the candidate texts.
9. An electronic device comprising a processor and a memory, wherein the memory is used to store a computer executable program, wherein: When the computer-executable program is executed by the processor, the processor performs the method according to any one of claims 1 to 7.
10. A computer-readable medium storing a computer-executable program, characterized in that: When the computer executable program is executed, the method according to any one of claims 1 to 7 is implemented.
