A method and electronic device for extracting idiomatic sentence patterns from natural language text
Through the methods of word segmentation, part-of-speech tagging, dependency syntax analysis and sentence simplification, combined with perceptron algorithms and rule methods, we extract and merge idiomatic sentence patterns in long and difficult Chinese sentences, solving the problem of sentence information loss and processing complex sentences. High accuracy and interpretability are achieved.
Patent Information
- Application Number
- CN202010518026.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-09
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing technology is difficult to effectively extract and process idiomatic sentence patterns in long and difficult Chinese sentences, resulting in serious loss of sentence pattern information, and there is a lack of a general method that can process multiple sentence patterns.
A method for extracting idiomatic sentence patterns from natural language texts is proposed. Through word segmentation, part-of-speech tagging, dependency syntax analysis, sentence simplification and sentence pattern merging, vocabulary, vocabulary candidate sets and part-of-speech tags are used to represent sentence pattern information, combined with perceptron algorithms and Rule-based method, streamline redundant parts and merge similar sentence patterns.
It improves the accuracy and interpretability of sentence extraction, can effectively process simple and complex sentences, retains sentence information, and is suitable for merging multiple sentences with similar structures.
Smart Images

Figure CN113779961B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing, and in particular to a method and an electronic device for extracting idiomatic sentence patterns from natural language texts. Background Art
[0002] With the diversification and convenience of communication technology and the rapid development of computer networks, the speed of information generation and dissemination is changing with each passing day. Among them, the amount of information transmitted in the form of natural language is particularly large, and it has the characteristics of diverse forms and high processing complexity. With the development of machine learning technology in recent years, people's demand for natural language processing technology has become more and more in-depth. On the one hand, they hope to better understand the existing natural language texts and extract more value from them; on the other hand, they begin to explore the ability of computers to speak and write, that is, natural language generation technology. People often follow certain norms when speaking or writing, which can be reflected in some high-frequency sentence patterns in the text. These commonly used sentence patterns are particularly common in certain scenarios, such as advertising, news notices, and written documents. Finding an accurate and universal algorithm to extract these sentence patterns will be of great help to both text understanding tasks and text generation tasks.
[0003] Most Chinese sentence extraction methods are based on dependency syntactic analysis and part-of-speech tagging. However, on the one hand, sentence extraction is in most cases only a small part of other natural language processing tasks, such as automated question-answering systems, information extraction, and semantic understanding, which only needs to meet specific application requirements, resulting in a relatively rough processing method. For example, Chinese patent application CN110597976A discloses a key sentence extraction method and device. On the other hand, the operation objects of sentence extraction are mostly single sentences, and sentence merging is not considered.
[0004] The syntactic structure of Chinese sentences is complex and flexible. To extract sentence patterns, long and difficult sentences must be processed first. There are two existing methods for processing long and difficult sentences: 1. Directly delete the less important components in the sentence based on the results of dependency syntactic analysis, such as attributives, adverbials, auxiliary words, and prepositional structures. However, this method will cause a large amount of effective information to be lost, and the final result is an extremely simple sentence trunk structure; 2. Sentence rewriting (paraphrasing) technology: Since long and difficult sentences are difficult to understand and process, some sentence rewriting technologies have emerged, mainly rule-based rewriting methods and neural network-based rewriting methods. These methods are committed to simplifying or splitting complex sentences into multiple simple sentences while retaining effective information as much as possible, and the original sentence information is destroyed. In terms of sentence extraction and representation, most existing methods directly use part-of-speech tags instead of words. Because too much information is lost, this sentence information is of little help for text classification or text generation.
[0005] Therefore, there is a lack of a more general sentence extraction method that can handle multiple Chinese sentences. Summary of the invention
[0006] The main purpose of the present invention is to provide a method and electronic device for extracting idiomatic sentence patterns from natural language texts, extracting recurring similar sentence patterns as auxiliary information to help subsequent natural language processing tasks improve efficiency and enhance interpretability. On the one hand, this method proposes a method for simplifying long and difficult sentences to meet the needs of sentence pattern extraction. This method can simplify the redundant parts of long and difficult sentences on the basis of destroying the sentence structure; on the other hand, it proposes a method for extracting and merging sentences, performing different processing according to the attributes of different sentence components, and finally representing the sentences in the form of part-of-speech tags and vocabulary and vocabulary candidate set lists when the sentences are merged.
[0007] A method for extracting idiomatic sentence patterns from natural language texts, comprising the following steps:
[0008] 1) Perform word segmentation, part-of-speech tagging and dependency syntactic analysis on each collected sentence;
[0009] 2) Convert each sentence into several single sentences, and extract the main stem of each single sentence based on the results of part-of-speech tagging and dependency syntactic analysis, and represent each single sentence as a list of vocabulary and part-of-speech tags;
[0010] 3) Merge the lists of each single sentence to obtain the idiomatic sentence pattern of each sentence.
[0011] Furthermore, the HanLP Chinese processing toolkit is used to perform word segmentation, part-of-speech tagging and dependency syntax analysis on each sentence.
[0012] Furthermore, each sentence is converted into several single sentences by the following steps:
[0013] 1) If the sentence contains a conjunction or a comma, find out whether the predicate is contained in the sentence before and after the conjunction or comma;
[0014] 2) If both contain predicates, split them at the position of conjunctions or commas, delete the conjunctions or commas, and make the first and second sentences into single sentences;
[0015] 3) Set the sentence that does not contain conjunctions or commas and does not contain a predicate in both the preceding sentence and the following sentence as a single sentence.
[0016] Further, the obtained single sentence is processed by the following steps:
[0017] 1) According to the word segmentation results, each sentence is represented as a vocabulary list;
[0018] 2) Set a sliding window to scan each sentence. If a word with the same part of speech appears n times in the window, keep the first word with the same part of speech and delete the others, where n≥2;
[0019] 3) Based on the results of dependency syntax analysis, the attributive and adverbial components of non-modifying core words in each sentence are reduced.
[0020] Furthermore, the main stem of each single sentence is extracted through the following steps:
[0021] 1) Eliminate entity words that represent the object of action in a single sentence;
[0022] 2) Eliminate the time and place words in the modifying elements and replace them with parts of speech in the corresponding positions;
[0023] 3) Keep the pronouns, conjunctions, predicate verbs and gerunds in the single sentence.
[0024] Furthermore, the part expressing the object of the action includes the subject, the object and the object complement; the entity words include names of people, places, and names of institutions and organizations; and the modifying components include adverbials and attributives.
[0025] Furthermore, idiomatic sentence patterns are obtained by merging two lists of single sentences, a list of single sentences and a list of merged results, and two lists of merged results.
[0026] Furthermore, the two lists of single sentences are merged pairwise by the following steps:
[0027] 1) Remove adverbs and particles from the list;
[0028] 2) Merge the same words between two sentences;
[0029] 3) Different words with the same part of speech at the same position are added to the vocabulary candidate set at the corresponding position, and different words with different parts of speech at the same position are deleted.
[0030] A storage medium stores a computer program, wherein the computer program executes the above method.
[0031] An electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the above method.
[0032] Compared with the existing methods, the present invention has the following advantages:
[0033] 1) Based on the characteristics of long and difficult Chinese sentences, the redundant parts of the sentences are simplified instead of simply deleted. A method for simplifying long and difficult sentences without losing sentence information is proposed. According to the needs of sentence extraction, the non-sentence trunk parts of long and difficult Chinese sentences are processed to improve the accuracy of sentence extraction;
[0034] 2) Propose a sentence information representation structure that uses vocabulary, vocabulary candidate sets, and part-of-speech tags to represent sentence information and retain as much sentence information as possible. This sentence representation method is consistent with people's understanding of Chinese sentences and is easy to use in other Chinese natural language processing tasks.
[0035] 3) The present invention is based on some mature basic technologies in natural language processing technology, such as Chinese word segmentation, part-of-speech tagging, and parsing, as a preprocessing technology of the corpus, combined with the perceptron algorithm and the classic rule-based method to achieve sentence extraction with high extraction accuracy and strong interpretability, and can effectively process both simple and complex sentences.
[0036] 4) A method for merging sentences is proposed, which can be used to merge idiomatic sentences of multiple sentences with similar structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 Flowchart for extracting idiomatic sentence patterns from natural language text.
[0038] Figure 2 This is an example diagram of the results of part-of-speech tagging and dependency parsing of Chinese sentences.
[0039] Figure 3 This is an example of the results of simplifying long and difficult sentences.
[0040] Figure 4 This is an example of the results of Chinese sentence pattern extraction. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the following reference is made to the attached Figure 1 , the present invention is described in further detail.
[0042] The present invention provides a method for extracting idiomatic sentence patterns from natural language texts, comprising three aspects:
[0043] The first aspect is to simplify the text based on the characteristics of long and difficult Chinese sentences. In order to ensure the algorithm's processing effect on long and difficult sentences, this method makes improvements on long and difficult sentences. The following reasons often lead to long and complex sentences: (1) There are too many modifying words or clauses in the sentence, and there are multiple modifications, such as the attributive of the attributive. According to the results of grammatical analysis, the present invention recursively detects the attributive and adverbial components, reduces them, and effectively simplifies long and difficult sentences. (2) Due to parallel or transitional relationships, two sentences are combined into one sentence, such as "but", "at the same time", etc. The sentences are split according to punctuation marks and conjunctions. (3) There are too many parallel components. When the sentence needs to express enumeration, inclusion, etc., components of the same part of speech often appear repeatedly. These repeated components are merged.
[0044] The second aspect is to extract the main stem of the sentence based on the results of dependency syntax analysis and part-of-speech tagging, and then merge similar parts in multiple sentence patterns. This part is mainly based on rules. For the subject, object, object complement and other parts of the sentence that represent the object of the action, noun components such as names of people, places, and names of organizations are removed, but pronouns are retained. Among the modifying components such as adverbials and attributives, words that represent specific time, place, etc. are removed. While removing these specific words, their parts of speech are used as replacements to retain more information. For words that do not represent specific objects, such as conjunctions, predicate verbs, and gerunds, the original words are retained.
[0045] According to the third aspect of the present invention, after extracting sentences with similar structures, multiple sentence information is merged. According to the description of the first aspect, the modified part of the sentence has been simplified and the repeated part has been deleted. When merging two sentences, the same parts can be directly merged. For different parts, they need to be handled according to different situations. For adverbs and modal particles, since such words convey less information semantically and are not necessary components structurally, they can be skipped directly; for other words that represent actions, if their parts of speech are the same, these words are added to the vocabulary candidate set at that position, and if the parts of speech are different, they are deleted.
[0046] Figure 1 The following is a flowchart for extracting idiomatic sentences from natural language texts. According to the flowchart, the steps for extracting idiomatic sentences from Chinese corpus are as follows:
[0047] Step 01: Read a list of Chinese sentences with similar sentence structures
[0048] Step 02: Perform word segmentation, part-of-speech tagging, and dependency syntax analysis on each sentence
[0049] First, the Chinese sentences need to be preprocessed. HanLP-based Chinese word segmentation, part-of-speech tagging, dependency syntactic analysis, etc. are used as text preprocessing methods. HanLP is a high-precision Chinese processing toolkit. There are several algorithms to choose from for each task. The perceptron algorithm is selected in this method. The structured perceptron annotation framework is a complete online learning framework that uses perceptrons for sequence tagging tasks and is applied to the three problems of Chinese word segmentation, part-of-speech tagging, and named entity recognition. If different algorithms are used to handle word segmentation, part-of-speech tagging, and syntactic analysis tasks respectively, the processing results of the three tasks on sentences may be inconsistent, so a unified algorithm framework needs to be used. The algorithm has relatively high accuracy and takes efficiency into consideration.
[0050] Figure 2 The following is an example of Chinese sentence part-of-speech tagging and dependency parsing results. Figure 1 As shown in the example sentence "In April 2020, Mr. Li from the relevant department of China National Petroleum Corporation held a working meeting with the president, vice president, and manager of the Export-Import Bank of China to conduct in-depth exchanges on bank-enterprise cooperation." The sentence structure is quite complex, and HanLP accurately calculates the part of speech of each word and the syntactic relationship between words. It is worth noting that in complex sentences, there are often multiple modification relationships. For example, "China National Petroleum Corporation", "related", "department", and "of" are all modifying components, and the modified word "Mr. Li" is preceded by multiple attributives and additional words, but these complex modifications have no important impact on the main body of the sentence.
[0051] Step 03: Simplify long and difficult sentences;
[0052] like Figure 3As shown in FIG. 1 , an example of the simplification result of a long and difficult sentence of an embodiment "In April 2020, Mr. Li from the relevant department of China National Petroleum Corporation held a working meeting with the president, vice president and manager of the Export-Import Bank of China to conduct in-depth exchanges on bank-enterprise cooperation issues." The specific implementation method of the simplification of difficult sentences is: (1) Construct a vocabulary of conjunctions that express parallel or transitional relationships, including sentence conjunctions commonly used in Chinese sentences such as "but", "at the same time", "and", "and", "in addition to this", "and" and commas. Scan the sentence. If there are words or commas in the conjunction vocabulary, and check that the sentences before and after have predicates and can form independent sentences, the original sentence will be split from here. For example, in the example sentence, "carry out in-depth exchanges on bank-enterprise cooperation issues" contains the verb "expand" which forms a parallel relationship with the predicate verb "conduct" in the first half of the sentence, and can form an independent sentence, it can be split from the second comma. (2) Represent the sentence as a vocabulary list and set a sliding window to scan the sentence. If there are words with the same part of speech repeated three or more times in the window, keep the first one and delete the others. For example, in the example sentence, "bank president", "deputy bank president" and "manager" are consecutive nouns, so only "bank president" is kept. (3) Scan the dependency syntactic relationship table and recursively detect the attributive and adverbial components of the non-modified core word (i.e., predicate verb) to obtain the complete modified part. This modified part is marked as "de" (decorate) to avoid its influence on sentence extraction. For example, in the example sentence, "the relevant departments of China National Petroleum Corporation" is the modifying component of "Mr. Li" and is marked as "de" as a whole.
[0053] Step 04: Represent the sentence as a list of words and part-of-speech tags;
[0054] Figure 4 An example of Chinese sentence pattern extraction is given. The corresponding parts of speech are used to represent specific time, specific place, specific action (noun verb), name, organization, job title, etc. In the part-of-speech tagging task of HanLP, the division of parts of speech is very detailed. For example, for organizations, there are 'nt' (organization group name), 'ntc' (company name), 'ntcb' (bank), 'ntcf' (factory), 'ntch' (hotel), 'nth' (hospital), 'nto' (government agency), 'nts' (primary and secondary school), and 'ntu' (university). In this method, the overly detailed part-of-speech division will interfere with the similarity calculation. Here, a coarser-grained part-of-speech division is used. At this time, the sentence is represented as a list of vocabulary and part-of-speech tags, and this operation is performed on the input list of similar sentences.
[0055] Step 05: Merge the lists to get the common sentence patterns.
[0056] When extracting general sentence patterns, the sentence pattern information is merged pairwise. Two lists representing sentence patterns are compared starting from the beginning. If the elements (words or part-of-speech tags) at the corresponding positions are the same, they are retained; if the elements at the corresponding positions are different, they are handled in different cases: for adverbs and auxiliary words, such as "etc." and "le" in the first example sentence, in the sentence pattern ["t", "de", "n", "与", "de", "n", "举行", "de", "会谈"] extracted from the sentence "On May 17th, Secretary Zhang of the Provincial Party Committee of our province held a cooperation meeting with Director Huang of the Institute of Agricultural Genomics of the Chinese Academy of Agricultural Sciences.", since it does not exist, it is directly deleted from the list; for words representing actual meanings, such as verbs and gerunds, if the parts of speech of the words are the same, or the parts of speech belong to the same major category (for example, gerunds and nouns both belong to the noun part of speech), they are merged into a candidate word list. For example, "进行" and "举行" are both verbs and are merged into the candidate word list "进行 / 举行"; if the parts of speech are different, it is determined that the sentence has additional components compared to the other sentence, and a deletion operation is performed.
[0057] It should be noted and understood that various modifications and improvements can be made to the present invention described in detail above without departing from the spirit and scope of the present invention as claimed in the claims. Therefore, the scope of the claimed technical solution is not limited by any specific exemplary teachings given.
Claims
1. A method for extracting idiomatic sentence patterns from natural language text, comprising the steps of: 1) Perform word segmentation, part-of-speech tagging and dependency syntactic analysis on each collected sentence; 2) Convert each sentence into several single sentences, and extract the main stem of each single sentence based on the results of part-of-speech tagging and dependency syntactic analysis, and represent each single sentence as a list of vocabulary and part-of-speech tags; 3) merging the lists of the individual sentences to obtain the idiomatic sentence patterns of the individual sentences; wherein the merging the lists of the individual sentences to obtain the idiomatic sentence patterns of the individual sentences comprises: Remove adverbs and particles from the list; Merge the same words between two sentences; Different words with the same part of speech at the same position are added to the vocabulary candidate set at the corresponding position, and different words with different parts of speech at the same position are deleted.
2. The method according to claim 1, characterized in that The HanLP Chinese processing toolkit is used to perform word segmentation, part-of-speech tagging and dependency syntax analysis on each sentence.
3. The method according to claim 1, characterized in that Convert each sentence into several single sentences by following the steps below: 1) If the sentence contains a conjunction or a comma, find out whether the predicate is contained in the sentence before and after the conjunction or comma; 2) If both contain predicates, split them at the position of conjunctions or commas, delete the conjunctions or commas, and make the first and second sentences into single sentences; 3) Set the sentence that does not contain conjunctions or commas and does not contain a predicate in both the preceding sentence and the following sentence as a single sentence.
4. The method according to claim 1, characterized in that The obtained single sentence is processed by the following steps: 1) According to the word segmentation results, each sentence is represented as a vocabulary list; 2) Set a sliding window to scan each sentence. If a word with the same part of speech appears n times in the window, keep the first word with the same part of speech and delete the others, where n≥2; 3) Based on the results of dependency syntax analysis, the attributive and adverbial components of non-modifying core words in each sentence are reduced.
5. The method according to claim 1, characterized in that The main stem of each single sentence is extracted through the following steps: 1) Eliminate entity words that represent the object of action in a single sentence; 2) Eliminate the time and place words in the modifying elements and replace them with parts of speech in the corresponding positions; 3) Keep the pronouns, conjunctions, predicate verbs and gerunds in the single sentence.
6. The method according to claim 5, characterized in that The part that indicates the object of the action includes the subject, object and object complement; the entity words include names of people, places, institutions and organizations; the modifying components include adverbials and attributives.
7. The method according to claim 1, characterized in that Idiomatic sentence patterns are obtained by merging two lists of single sentences, a list of single sentences and a list of merged results, and two lists of merged results.
8. A storage medium storing a computer program, wherein: The computer program is configured to execute the method according to any one of claims 1 to 7 when executed.
9. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.
