Sentence recommendation method, device and computer readable storage medium
Through the sentence recommendation method, using technologies such as corpus and LASER algorithm, sentences with high semantic similarity but low syntactic structure similarity are recommended, which solves the problem in the existing technology that users cannot learn new expressions and improves the effect of language learning. .
Patent Information
- Application Number
- CN202011480795.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-15
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-12-15
AI Technical Summary
Existing search engines can only search for sentences that are almost identical to the input sentence. As a result, users cannot learn new knowledge from these expressions and cannot obtain expressions that are semantically similar but have different syntactic structures.
Provide a sentence recommendation method that obtains the sentence to be processed input by the user, determines the target sentence with high semantic similarity but low syntactic structure similarity, and recommends it to the user, using technologies such as corpus, LASER algorithm, and tree kernel function Implement sentence vectorization and syntactic structure similarity calculation.
Users can obtain sentences that are similar in meaning to the input sentence but expressed in different ways, so as to learn the language better and improve the effect of language learning.
Smart Images

Figure CN114638211B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of information processing technology, and in particular, to a syntax recommendation method, device, and computer-readable storage medium. Background Art
[0002] To learn a language well, in addition to memorizing the words, phrases, and grammar of the language, you also need to master different ways of expressing the same or similar meanings when you are making further progress. Here, we can take English as an example. For example, the sentence "Undoubtedly, I love reading" can have multiple ways of expressing the same or similar meanings, such as "Undoubtedly, I like reading", "Undoubtedly, reading is my favourite", etc. However, current search engines can only search for sentences that are almost the same as the input sentences and provide them to users. Users cannot learn new knowledge from these sentences that are almost the same. Summary of the invention
[0003] In order to solve the technical problem that the expressions of sentences searched out by existing search engines are almost the same as the original sentences input, resulting in users being unable to learn new expressions, the embodiments of the present application provide a syntax recommendation method, device and computer-readable storage medium.
[0004] According to a first aspect of an embodiment of the present application, a sentence recommendation method is provided, comprising:
[0005] Get the sentence to be processed input by the user;
[0006] Determine a plurality of candidate sentences whose semantic similarity with the sentence to be processed meets a preset condition;
[0007] Respectively determining the syntactic structure similarity between each of the candidate sentences and the sentence to be processed;
[0008] At least based on the syntactic structure similarity, a preset number of target sentences are determined from the multiple candidate sentences and recommended to the user, wherein the difference in syntactic structure between the target sentence and the sentence to be processed is greater than that of other sentences in the multiple candidate sentences.
[0009] According to a second aspect of an embodiment of the present application, a sentence recommendation device is provided, the device comprising:
[0010] An acquisition module is used to acquire the sentence to be processed input by the user;
[0011] A determination module, used to determine multiple candidate sentences whose semantic similarity with the sentence to be processed meets preset conditions, used to respectively determine the syntactic structure similarity between each of the candidate sentences and the sentence to be processed, and used to determine a target sentence from the multiple candidate sentences according to the syntactic structure similarity, wherein the target sentence includes the candidate sentences whose syntactic structure similarity is lower than a preset threshold, or a preset number of candidate sentences with the lowest syntactic structure similarity;
[0012] The recommendation module is used to recommend the target sentence to the user.
[0013] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the sentence recommendation method provided in the embodiment of the present application is implemented.
[0014] The technical solution provided by this application may have the following beneficial effects:
[0015] The sentence recommendation method provided in the embodiment of the present application can determine a target sentence whose semantics are highly similar to the sentence to be processed but whose syntactic structure is low similar to the sentence to be processed based on the sentence to be processed input by the user, and can recommend the target sentence to the user, so that the user can obtain different expressions that are similar in meaning to the sentence to be processed, thereby better helping the user learn the language.
[0016] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory and do not limit the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings herein are incorporated into the specification and constitute a part of the embodiments of the present application, illustrate embodiments consistent with the embodiments of the present application, and together with the description are used to explain the principles of the embodiments of the present application.
[0018] Figure 1 It is a flowchart of the sentence recommendation method provided in an embodiment of the present application.
[0019] Figure 2 It is a schematic diagram of syntax tree splitting provided in an embodiment of the present application.
[0020] Figure 3 It is a schematic diagram of a subtree set provided in an embodiment of the present application.
[0021] Figure 4 It is a structural diagram of a sentence recommendation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the embodiments of the present application. Instead, they are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0023] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0024] It should be understood that, although the terms first, second, third, etc. may be used to describe various information in the embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the embodiments of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at..." or "when..." or "in response to determination".
[0025] Learning a language well is not an easy task. In addition to memorizing the words, phrases, and grammar of the language, you also need to master different ways of expressing the same or similar meanings when you are trying to improve your language. Here, we can take English as an example. For example, the sentence "Undoubtedly, I love reading" can have many ways of expressing the same or similar meanings, such as "Undoubtedly, I like reading", "Undoubtedly, reading is my favorite", etc.
[0026] However, not all expressions that are different from the original sentence have the same learning value for users. For example, in the example above where the original sentence is "Undoubtedly, I love reading", there are sentences with similar meanings but different expressions such as "Undoubtedly, I like reading" and "Undoubtedly, reading is my favourite". However, "Undoubtedly, I like reading" only replaces the love in the original sentence with the synonym "like", which does not have much learning value for users. On the other hand, "Undoubtedly, reading is my favourite" has a similar meaning to the original sentence but is expressed in a very different way. Therefore, it provides users with truly different expressions, which is of great help to users in learning English.
[0027] In order to help users understand different expressions of the same or similar meanings, the present application embodiment provides a sentence recommendation method. Figure 1 , Figure 1 : is a flowchart of a sentence recommendation method provided by an embodiment of the present application. The method may include the following steps:
[0028] S102: Obtain the sentence to be processed input by the user.
[0029] In one implementation, the method provided in the embodiment of the present application can be applied in an application, and the application can be installed on a smart device such as a mobile phone, a tablet, or a computer. The application can provide a search bar on the display page, and the user can enter the sentence to be processed in the search bar. Here, the sentence to be processed entered by the user can be in various languages, such as Chinese, English, Japanese, Korean, etc.
[0030] In one embodiment, the sentence to be processed input by the user may be preprocessed. Specifically, the preprocessing of the sentence to be processed may include one or more of the following: stop word filtering, part-of-speech tagging, part-of-speech restoration, synonym replacement, etc. The subsequent processing of the sentence to be processed may be the processing of the preprocessed sentence to be processed.
[0031] S104: Determine a plurality of candidate sentences whose semantic similarity with the sentence to be processed meets preset conditions.
[0032] To ensure that the recommended sentences are valuable for users to learn, the recommended sentences need to be the same or similar in meaning to the sentences to be processed input by the user. Here, the similarity of the meanings expressed between the sentences can be represented by semantic similarity.
[0033] In one implementation, a corpus may be pre-established, the corpus may include a plurality of sentences, and the plurality of candidate sentences may be determined from the pre-established corpus.
[0034] In one embodiment, before using the sentences in the corpus for processing, the sentences in the corpus may also be preprocessed. Here, the preprocessing of the sentences in the corpus may be the same as the preprocessing of the sentences to be processed in the previous text, for example, it may also include one or more of stop word filtering, part-of-speech tagging, part-of-speech restoration, synonym replacement, etc.
[0035] Considering that there are too many sentences in the corpus, it takes a lot of time to directly determine the candidate sentences from the corpus. Moreover, the candidate sentences are determined based on semantic features. In a corpus containing a large number of sentences, searching directly based on semantic features will likely cause semantic drift (that is, the determined candidate sentences and the sentences to be processed are mistakenly considered by the machine to be semantically similar, but the semantics of the two sentences are completely different in the eyes of people). Therefore, in one embodiment, the sentences in the corpus can be literally searched for the sentences to be processed input by the user to determine multiple literally matching sentences, so that the candidate sentences can be determined from the multiple literally matching sentences. By first screening out the literally matching sentences through the literal search, a large number of irrelevant sentences in the corpus can be quickly filtered out, thereby improving the retrieval efficiency. Moreover, since the determined sentences and the sentences to be processed have a literal matching relationship (for example, the two sentences have at least some of the same words), the probability of semantic drift in the determined candidate sentences can be greatly reduced.
[0036] In one implementation, Elasticsearch (ES for short) can be used to perform literal search on the corpus. Specifically, for the sentences to be processed, each sentence in the corpus can be scored based on the TF-IDF technology (term frequency-inverse document frequency technology), and multiple literal matching sentences can be determined by matching, querying, fuzzy matching, etc.
[0037] After determining multiple literal matching sentences, the semantic similarity between each literal matching sentence and the sentence to be processed can be determined. Here, there are multiple ways to determine the semantic similarity. In one embodiment, the literal matching sentences and the sentence to be processed can be converted into sentence vectors first, and then the cosine similarity between the sentence vector corresponding to the literal matching sentence and the sentence vector corresponding to the sentence to be processed can be calculated, and the semantic similarity between the literal matching sentence and the sentence to be processed can be determined based on the cosine similarity.
[0038] There are also many ways to convert literal matching sentences, pending sentences and other sentences into sentence vectors, such as using word2vec, fasttext and other algorithms to vectorize the sentences. However, when these algorithms vectorize sentences, they need to first split the sentences into multiple parts, digitize each part and then fuse them to obtain the sentence vector corresponding to the entire sentence, wherein the splitting and fusion process will introduce certain errors, resulting in inaccurate semantic similarity. Therefore, in one embodiment, the LASER algorithm can be used to vectorize literal matching sentences, pending sentences and other sentences to obtain sentence vectors corresponding to these sentences. Since the LASER algorithm can directly map the entire sentence into a high-dimensional sentence vector, its calculation process does not involve the splitting and fusion of sentences, so the determined semantic similarity can be made more accurate, and the LASER algorithm is a universal language-independent sentence embedding, that is, it can be applied to various languages and has stronger applicability.
[0039] After determining the semantic similarity corresponding to each literally matching sentence, a plurality of candidate sentences whose semantic similarity satisfies a preset condition can be determined. Here, in one embodiment, the preset condition can be that the semantic similarity is higher than a preset threshold, that is, if the semantic similarity corresponding to the literally matching sentence is higher than the preset threshold, the literally matching sentence can be determined as a candidate sentence. In one embodiment, the preset condition can also be that the semantic similarity is ranked in the first N places of the target sequence (the target sequence is sorted from large to small) or the last N places (the target sequence is sorted from small to large), where N is a preset integer value, and the target sequence can be obtained according to the semantic similarity ranking corresponding to each literally matching sentence.
[0040] It should be noted that, when the semantic similarity between a candidate sentence and the sentence to be processed is 100%, the candidate sentence and the sentence to be processed are actually the same sentence, that is, the sentence to be processed input by the user is a sentence that already exists in the corpus. In this case, the sentence with a semantic similarity of 100% can be eliminated, because recommending to the user the same sentence as the one he inputs has no learning value for the user.
[0041] S106: Determine the syntactic structure similarity between each of the candidate sentences and the sentence to be processed.
[0042] S108: Determine a preset number of target sentences from the plurality of candidate sentences according to the syntactic structure similarity and recommend them to the user, wherein the difference in syntactic structure between the target sentence and the sentence to be processed is greater than that between other sentences in the plurality of candidate sentences.
[0043] As can be seen from the previous description, sentences with similar meanings but different expressions are more valuable for users to learn. The meaning of a sentence can be measured or evaluated by the semantics of the sentence, and the expression of a sentence can be measured or evaluated by the syntactic structure of the sentence. Therefore, if a sentence has a higher semantic similarity and a lower syntactic structure similarity with the sentence to be processed input by the user (that is, the syntactic structure is very different from the sentence to be processed), it can be determined that the sentence has a higher learning value for the user.
[0044] The sentence recommendation method provided in the embodiment of the present application can determine a target sentence whose semantics are highly similar to the sentence to be processed but whose syntactic structure is low similar to the sentence to be processed based on the sentence to be processed input by the user, and can recommend the target sentence to the user, so that the user can obtain different expressions that are similar in meaning to the sentence to be processed, thereby better helping the user learn the language.
[0045] When determining the syntactic structure similarity between the candidate sentence and the sentence to be processed, in one embodiment, a tree kernel function may be used for calculation. Specifically, the candidate sentence and the sentence to be processed may be converted into a syntactic tree, and the syntactic tree of the candidate sentence and the subtree contained in the syntactic tree of the sentence to be processed may be extracted. Afterwards, the subtree corresponding to the candidate sentence may be matched with the subtree corresponding to the sentence to be processed, so that the syntactic structure similarity between the candidate sentence and the sentence to be processed may be determined based on the matching result.
[0046] For easier understanding, please refer to Figure 2 , Figure 2 Schematic diagram of syntax tree splitting provided by the embodiment of the present application. Figure 2 In the example shown, sentence A "the screen is very good" and sentence B "the CPU is very good" can both be converted into syntax trees, namely syntax tree T1 and syntax tree T2. By splitting the two syntax trees, multiple subtrees contained in the syntax trees can be obtained. When matching the subtrees corresponding to the two sentences, in one embodiment, each subtree obtained by splitting can be used to establish a subtree set, and the subtree set can refer to Figure 3. After establishing the subtree set, the syntactic tree of each sentence can be vectorized according to the subtree set. For example, sentence A can be represented by the vector h(T1) = [1,1,1,1,1,0,0], where the components in the vector correspond one-to-one to the subtrees in the subtree set. For example, if the first component is 1, it means that the first subtree in the subtree set exists in the syntactic tree T1 of sentence A, and if the sixth component is 0, it means that the sixth subtree in the subtree set does not exist in the syntactic tree T1 of sentence A. Correspondingly, sentence B can be represented by the vector h(T2) = [1,0,1,0,1,1,1]. At this point, by calculating the cosine similarity between vector h(T1) and vector h(T2), the syntactic structure similarity between sentence A and sentence B can be obtained. The calculation process of the syntactic structure similarity described above can be expressed by the following mathematical expression:
[0047]
[0048] Among them, Treesim(T1, T2) represents the syntactic structure similarity between sentence A and sentence B. i (T1) indicates whether the i-th subtree of T appears in T1, 1 indicates it appears, and 0 indicates it does not appear.
[0049] It should be noted that Figure 2 The / a, / n, / ws and / d are the marked parts of speech, corresponding to adjective, noun, foreign word and adverb respectively. SBV and ADV are the grammatical relationship types, among which SBV corresponds to the subject-predicate relationship and ADV corresponds to the adverbial-predicate structure.
[0050] After determining the syntactic structure similarity between each candidate sentence and the sentence to be processed, a sentence with low syntactic structure similarity can be determined from the candidate sentences and recommended to the user as a target sentence. Specifically, in one embodiment, the target sentence with low syntactic structure similarity can be a candidate sentence with a syntactic structure similarity lower than a preset threshold. In one embodiment, the candidate sentences can also be sorted according to the syntactic structure similarity corresponding to each other. If sorted from small to large, the candidate sentences ranked in the first N positions can be determined as the target sentences. If sorted from large to small, the candidate sentences ranked in the last N positions can be determined as the target sentences, and N is a preset integer value.
[0051] In one embodiment, the target sentence can also be determined based on the word repetition. For example, in the example of "Undoubtedly, I love reading" in the previous text, in addition to love being replaced by like, undoubtedly can also be replaced by synonyms such as certainly and surely. For user learning, the lower the repetition of words with the original sentence, the more effective learning information can be provided to the user. Therefore, in this embodiment, the target sentence can be determined from the multiple candidate sentences based on the word repetition and the syntactic structure similarity. Specifically, in one example, after determining the word repetition of each candidate sentence and the sentence to be processed, the word repetition and syntactic structure similarity corresponding to the candidate sentence can be fused to obtain the target similarity, so that the candidate sentence with low target similarity can be determined as the target sentence. Here, there are many ways to fuse the word repetition and syntactic structure similarity, such as weighted average.
[0052] In one embodiment, the method of obtaining the sentence to be processed input by the user may include: obtaining the original sentence input by the user, translating the original sentence into a target language, and obtaining the sentence to be processed. Correspondingly, the method may also include: recommending the sentence to be processed together with the target sentence to the user. For example, the original input by the user may be a Chinese sentence. In the scenario of learning English, the original Chinese sentence may be translated into English to obtain the sentence to be processed, and a target sentence may be determined that is semantically similar to the sentence to be processed but has a large syntactic result different from the sentence to be processed, and both the target sentence and the sentence to be processed may be recommended to the user.
[0053] The sentence recommendation method provided in the embodiment of the present application can determine a target sentence whose semantics are highly similar to the sentence to be processed but whose syntactic structure is low similar to the sentence to be processed based on the sentence to be processed input by the user, and can recommend the target sentence to the user, so that the user can obtain different expressions that are similar in meaning to the sentence to be processed, thereby better helping the user learn the language.
[0054] An example is provided below. In this example, the sentence to be processed obtained from the user input may be: This is no doubt that this activity is very important in my life. Here, the sentence to be processed may be recorded as S.
[0055] The sentence to be processed S can be preprocessed to obtain the preprocessed sentence to be processed S1. According to sentence S1, literal matching can be performed in the corpus through ES to obtain multiple literal matching sentences. Here, the sentence set consisting of multiple literal matching sentences can be recorded as S2. The LASER algorithm can be used to vectorize each sentence in the sentence set S2 and sentence S1, and the cosine similarity between the sentence vector of each sentence in the sentence set S2 and the sentence vector of sentence S1 can be calculated, so as to obtain the semantic similarity between each sentence in the sentence set S2 and sentence S1.
[0056] Here, the sentences in the sentence set S2 can be sorted from large to small according to the semantic similarity, and the three sentences with the highest semantic similarity can be selected. The three sentences can be recorded as the sentence set S3. The sentence set S3 includes: There is no doubt that this activity is very important in my life.
[0057] This activity is very important in my life.
[0058] Undoubtedly, this activity is very important in my life.
[0059] For each sentence in the sentence set S3, its syntactic structure similarity with sentence S1 can be calculated, and the sentence set S3 can be sorted from small to large according to the syntactic structure similarity, and the following sentence sorting can be obtained:
[0060] Undoubtedly, this activity is very important in my life.
[0061] This activity is very important in my life.
[0062] There is no doubt that this activity is very important in my life.
[0063] The sentence with the lowest sentence structure similarity and ranked first can be recommended to the user as the target sentence, so that the user can obtain different expressions with similar meanings to the sentence to be processed, thereby better helping the user learn the language.
[0064] You can refer to the following Figure 4 , Figure 4 : is a schematic diagram of the structure of a sentence recommendation device provided in an embodiment of the present application. The device may include:
[0065] An acquisition module 410 is used to acquire a sentence to be processed input by a user;
[0066] A determination module 420 is used to determine a plurality of candidate sentences whose semantic similarity with the sentence to be processed meets a preset condition, to respectively determine the syntactic structure similarity between each of the candidate sentences and the sentence to be processed, and to determine a target sentence from the plurality of candidate sentences according to the syntactic structure similarity, wherein the target sentence includes a candidate sentence whose syntactic structure similarity is lower than a preset threshold, or a preset number of candidate sentences with the lowest syntactic structure similarity;
[0067] The recommendation module 430 is used to recommend the target sentence to the user.
[0068] Optionally, when determining multiple candidate sentences whose semantic similarity with the sentence to be processed meets preset conditions, the determination module is used to perform a literal search of the corpus based on the sentence to be processed to determine multiple literally matching sentences; and determine multiple candidate sentences whose semantic similarity with the sentence to be processed meets preset conditions from the multiple literally matching sentences.
[0069] Optionally, the semantic similarity is determined based on the cosine similarity between the sentence vector corresponding to the literal matching sentence and the sentence vector corresponding to the sentence to be processed.
[0070] Optionally, the sentence vector is obtained by vectorizing the sentence using a LASER algorithm.
[0071] Optionally, the preset conditions include: the semantic similarity is higher than a preset threshold, or the semantic similarity is ranked in the top N of a target order, the target order is obtained by sorting the grammatical similarities corresponding to each of the literal matching sentences from large to small, and N is a preset integer value.
[0072] Optionally, the device further comprises:
[0073] The elimination module is used to eliminate candidate sentences whose semantic similarity with the sentence to be processed is 100%.
[0074] Optionally, when determining the syntactic structure similarity, the determination module is used to extract subtrees contained in the syntactic tree for the candidate sentence and the sentence to be processed respectively; match the subtree corresponding to the candidate sentence with the subtree corresponding to the sentence to be processed, and determine the syntactic structure similarity between the candidate sentence and the sentence to be processed based on the matching result.
[0075] Optionally, the target sentence is also determined based on the degree of word repetition between each of the candidate sentences and the sentence to be processed.
[0076] The specific implementation of the sentence recommendation device in the various embodiments provided above can refer to the relevant description in the previous text, which will not be repeated here.
[0077] The sentence recommendation device provided in the embodiment of the present application can determine a target sentence whose semantics are highly similar to the sentence to be processed but whose syntactic structure is low similar to the sentence to be processed based on the sentence to be processed input by the user, and can recommend the target sentence to the user, so that the user can obtain different expressions with similar meanings to the sentence to be processed, thereby better helping the user learn the language.
[0078] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the sentence recommendation method provided by the embodiment of the present application is implemented.
[0079] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0080] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiment scheme of the present application. Those of ordinary skill in the art can understand and implement it without paying creative work.
[0081] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0082] As long as there is no conflict or contradiction in the technical features provided in the above embodiments, those skilled in the art can combine the various technical features according to actual conditions to form various different embodiments. However, due to the limited length of this application document, various different embodiments are not described in detail, but it can be understood that various different embodiments also fall within the scope disclosed in the embodiments of this application.
[0083] Those skilled in the art will readily come to other embodiments of the present application after considering the specification and practicing the inventions applied for herein. The present application embodiments are intended to cover any variations, uses or adaptations of the present application embodiments, which follow the general principles of the present application embodiments and include common knowledge or customary technical means in the art that are not applied for by the present application embodiments. The specification and embodiments are to be regarded as exemplary only, and the true scope and spirit of the present application embodiments are indicated by the following claims.
[0084] It should be understood that the embodiments of the present application are not limited to the precise structures described above and shown in the drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the embodiments of the present application is limited only by the appended claims.
[0085] The above description is only a preferred embodiment of the embodiments of the present application and is not intended to limit the embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the embodiments of the present application.
Claims
1. A sentence recommendation method, characterized in that: include: Get the sentence to be processed input by the user; Determine a plurality of candidate sentences whose semantic similarity with the sentence to be processed meets a preset condition; The multiple candidate sentences are determined from multiple literally matching sentences determined by literally searching the corpus according to the sentences to be processed; the preset conditions include: the semantic similarity is higher than a preset threshold, or the semantic similarity is ranked in the first N places of the target sequence, and the target sequence is obtained by sorting the grammatical similarities corresponding to each of the literally matching sentences from large to small, or the semantic similarity is ranked in the last N places of the target sequence, and the target sequence is obtained by sorting the grammatical similarities corresponding to each of the literally matching sentences from small to large, and N is a preset integer value; Respectively determining the syntactic structure similarity between each of the candidate sentences and the sentence to be processed; At least based on the syntactic structure similarity, a preset number of target sentences are determined from the multiple candidate sentences and recommended to the user, wherein the difference in syntactic structure between the target sentence and the sentence to be processed is greater than that of other sentences in the multiple candidate sentences.
2. The method according to claim 1, characterized in that The semantic similarity is determined based on the cosine similarity between the sentence vector corresponding to the literal matching sentence and the sentence vector corresponding to the sentence to be processed.
3. The method according to claim 2, characterized in that The sentence vector is obtained by vectorizing the sentence using the LASER algorithm.
4. The method according to claim 1, characterized in that: The method further comprises: Eliminate candidate sentences whose semantic similarity with the sentence to be processed is 100%.
5. The method according to claim 1, characterized in that The syntactic structure similarity is determined in the following way: Extracting subtrees contained in the syntax tree for the candidate sentence and the sentence to be processed respectively; The subtree corresponding to the candidate sentence is matched with the subtree corresponding to the sentence to be processed, and the syntactic structure similarity between the candidate sentence and the sentence to be processed is determined according to the matching result.
6. The method according to claim 1, characterized in that The target sentence is also determined based on the word repetition between each of the candidate sentences and the sentence to be processed.
7. A sentence recommendation device, characterized in that: The device comprises: An acquisition module is used to acquire sentences to be processed input by the user; A determination module, for determining a plurality of candidate sentences whose semantic similarity with the sentence to be processed meets preset conditions, for respectively determining the syntactic structure similarity between each of the candidate sentences and the sentence to be processed, and for determining a target sentence from the plurality of candidate sentences according to the syntactic structure similarity, wherein the target sentence includes the candidate sentences whose syntactic structure similarity is lower than a preset threshold, or a preset number of candidate sentences with the lowest syntactic structure similarity; the plurality of candidate sentences are determined from a plurality of literally matching sentences determined by literally searching a corpus according to the sentence to be processed; the preset conditions include: the semantic similarity is higher than a preset threshold, or the semantic similarity is ranked in the first N places of a target sequence, and the target sequence is obtained by sorting the grammatical similarities corresponding to each of the literally matching sentences from large to small, or the semantic similarity is ranked in the last N places of a target sequence, and the target sequence is obtained by sorting the grammatical similarities corresponding to each of the literally matching sentences from small to large, and N is a preset integer value; The recommendation module is used to recommend the target sentence to the user.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the sentence recommendation method according to any one of claims 1 to 6 is implemented.
