Text element extraction method, device, electronic device and storage medium

By classifying word granularity and sentence granularity for each clause in the recognized text, combining the processing methods of word granularity and sentence granularity, the text is extracted in discontinuous elements, which solves the problem of low extraction accuracy and timeliness in the prior art. , achieving more efficient factor extraction.

CN114266238BActive Publication Date: 2025-02-25IFLYTEK (SUZHOU) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111530417.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-14
Publication Date
2025-02-25
Estimated Expiration
2041-12-14

AI Technical Summary

Technical Problem

In the prior art, when extracting discontinuous factors, the accuracy of sentence-level extraction is low, while the timeliness of word-level extraction is low.

Method used

By classifying word granularity and sentence granularity for each clause in the identification text, each clause extracts elements according to its granularity type, combining the processing methods of word granularity and sentence granularity, the element sequence is divided and feature extraction is performed.

Benefits of technology

While ensuring the accuracy of identification, the timeliness of identification is improved, and thus the accuracy and timeliness of factor extraction are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114266238B_ABST
    Figure CN114266238B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, electronic device and storage medium for extracting text elements, wherein the method comprises: determining a text to be recognized; classifying the element granularity of each clause in the text to be recognized to obtain the element granularity type of each clause, wherein the element granularity type is sentence granularity or word granularity; based on the element granularity type of each clause, extracting elements from the text to be recognized to obtain a target element text. The method, device, electronic device and storage medium provided by the present invention can classify each clause in the text to be recognized into word granularity and sentence granularity, extract elements from each clause according to its corresponding granularity type, and obtain a target element text, thereby realizing non-continuous element extraction of text based on the use of word granularity combined with sentence granularity, while ensuring the recognition accuracy, it also improves the timeliness of recognition, thereby improving the accuracy and timeliness of element extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a text element extraction method, device, electronic device and storage medium. Background Art

[0002] With the iterative upgrade of artificial intelligence technology, extracting key information from large paragraphs of text through artificial intelligence technology can reduce the pressure on users to read large paragraphs of text, allowing users to understand the main meaning of the text paragraph more quickly, saving labor costs, and improving the timeliness and accuracy of user text processing.

[0003] Existing non-continuous feature extraction models mainly perform recognition at the word level or sentence level. However, recognizing non-continuous features in text at the sentence level will make the recognition results ambiguous, resulting in low recognition accuracy, and then low feature extraction accuracy. Although recognizing non-continuous features in text at the word level has a high recognition accuracy, when processing large amounts of text, post-processing of the text for word segmentation will produce a high delay, resulting in low timeliness. Summary of the invention

[0004] The present invention provides a text element extraction method, device, electronic device and storage medium, which are used to solve the defects of low accuracy of sentence-level element extraction and low timeliness of word-level element extraction in the prior art when extracting non-continuous elements.

[0005] The present invention provides a text element extraction method, comprising:

[0006] Determine the text to be recognized;

[0007] Performing element granularity classification on each clause in the to-be-recognized text to obtain an element granularity type of each clause, wherein the element granularity type is sentence granularity or word granularity;

[0008] Based on the element granularity type of each clause, elements are extracted from the text to be recognized to obtain a target element text.

[0009] According to a text element extraction method provided by the present invention, the element extraction of the to-be-recognized text based on the element granularity type of each clause to obtain the target element text includes:

[0010] Based on the element granularity type of each clause, the text to be recognized is segmented to obtain an element sequence;

[0011] Perform element extraction on the element sequence to obtain target element text.

[0012] According to a text element extraction method provided by the present invention, the text to be recognized is segmented based on the element granularity type of each clause to obtain an element sequence, including:

[0013] If the element granularity type of the current clause in the to-be-recognized text is word granularity, the word segmentation sequence of the current clause is stored in the element sequence; otherwise, the current clause is stored in the element sequence;

[0014] The next clause of the current clause in the to-be-recognized text is updated as the current clause.

[0015] According to a text element extraction method provided by the present invention, the determining of the text to be recognized includes:

[0016] Identify the original text;

[0017] Performing element category detection on the original text, and if any element category exists in the original text, locating a candidate start index and a candidate end index of any element category in the original text;

[0018] Based on the positions of the candidate start index and the candidate end index of any element category in the original text, the to-be-recognized text corresponding to any element category is determined from the original text.

[0019] According to a text element extraction method provided by the present invention, the element category detection is performed on the original text, and when any element category exists in the original text, the candidate start index and the candidate end index of any element category in the original text are located, including:

[0020] Performing semantic extraction on the original text to obtain text semantics of the original text and context semantics of each word in the original text;

[0021] Based on the text semantics of the original text, element category detection is performed on the original text, and if any element category exists in the original text, the candidate start index and the candidate end index of any element category in the original text are located based on the context semantics of each word in the original text.

[0022] According to a text element extraction method provided by the present invention, the method of determining the text to be recognized corresponding to any element category from the original text based on the positions of the candidate start index and the candidate end index of any element category in the original text includes:

[0023] With the restriction that the position of the candidate start index is before the position of the candidate end index and the distance between the candidate start index and the candidate end index is the shortest, the candidate start index and the candidate end index of any element category in the original text are combined to obtain a candidate index pair of any element category;

[0024] Selecting a start and end index pair from each candidate index pair of any element category based on the confidence of the candidate start index and the confidence of the candidate end index in each candidate index pair of any element category;

[0025] Based on the start-end index pair, the text to be identified corresponding to any element category is determined from the original text.

[0026] According to a text element extraction method provided by the present invention, the method of determining the text to be identified corresponding to any element category from the original text based on the start-end index pair includes:

[0027] Determine the index text of each start-end index pair from the original text;

[0028] Based on the semantic similarity and syntactic repetition between the index texts of each pair of start and end indexes, all index texts are deduplicated. The syntactic repetition is determined based on the intersection of the two index texts.

[0029] Based on the deduplicated index text, the text to be recognized is determined.

[0030] According to a text element extraction method provided by the present invention, based on the positions of the candidate start index and the candidate end index of the any element category in the original text, determining the to-be-recognized text corresponding to the any element category from the original text, and then further comprising:

[0031] Based on the original text, completing the text to be recognized corresponding to any one of the element categories to obtain a completed text;

[0032] Based on the completed text, the text to be recognized is updated.

[0033] The present invention also provides a text element extraction device, comprising:

[0034] A determination module, used for determining the text to be recognized;

[0035] A classification module, used for classifying each clause in the to-be-recognized text into element granularity, and obtaining an element granularity type of each clause, wherein the element granularity type is sentence granularity or word granularity;

[0036] The extraction module is used to extract elements from the text to be recognized based on the element granularity type of each clause to obtain a target element text.

[0037] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned text element extraction methods are implemented.

[0038] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned text element extraction methods are implemented.

[0039] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned text element extraction methods are implemented.

[0040] The present invention provides a text element extraction method, device, electronic device and storage medium. By classifying each clause in the text to be recognized into word granularity and sentence granularity, each clause is subjected to element extraction according to its corresponding granularity type to obtain a target element text, thereby realizing non-continuous element extraction of the text based on the use of word granularity combined with sentence granularity. While ensuring the recognition accuracy, the timeliness of the recognition is also improved, thereby improving the accuracy and timeliness of the element extraction. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0042] Figure 1 It is a flowchart of the text element extraction method provided by the present invention;

[0043] Figure 2 It is a flow chart of the element extraction method based on text element sequence provided by the present invention;

[0044] Figure 3 It is a flowchart of the method for segmenting text to be recognized provided by the present invention;

[0045] Figure 4 This is one of the flow charts of the method for obtaining text to be recognized provided by the present invention;

[0046] Figure 5 It is a flow chart of the original text semantic extraction method provided by the present invention;

[0047] Figure 6 It is a schematic diagram of the model structure for extracting the text semantics of the original text and the context semantics of each word in the original text provided by the present invention;

[0048] Figure 7 This is the second flow chart of the method for obtaining text to be recognized provided by the present invention;

[0049] Figure 8 It is a flowchart of the index text deduplication method provided by the present invention;

[0050] Fig. 9 It is a flowchart of the method for extracting text elements in field A provided by the present invention;

[0051] Fig.10 It is a flowchart of the text element extraction operation method provided by the present invention;

[0052] Fig.11 It is a structural schematic diagram of the text element extraction device provided by the present invention;

[0053] Fig.12 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] There are four main processing methods for the existing non-continuous feature extraction models, including:

[0056] Method 1 is to extend the BIO tag set, give a corresponding tag prediction for each token position, and then decode the predicted tag sequence to get the final result;

[0057] Method 2 is based on the hypergraph, building a subgraph to represent the combination of multiple Mentions in the predicted sentence, and then decoding to get the final result;

[0058] Method 3 is to extract spans related to multiple elements through fragments, filter out inappropriate spans based on the trained classifier, and concatenate the remaining spans to obtain the final result;

[0059] Method 4 is based on a word-level transfer model. It defines a series of behaviors, learns the model of related states, and obtains the final result by decoding the states predicted by the model.

[0060] Both Method 1 and Method 2 predict the intermediate state, such as predicting the label in Method 1 and predicting the combination of Mentions in Method 2, and then decoding the predicted latent features. This will cause ambiguity when decoding the intermediate latent features, resulting in low recognition accuracy; Method 3 has a very high model complexity, resulting in increased latency; Although Method 4 solves the ambiguity problem of Methods 1 and 2, it is time-consuming in the case of a large amount of text, resulting in low timeliness.

[0061] Therefore, how to ensure accuracy while improving timeliness when extracting non-continuous elements is an urgent problem to be solved in this field.

[0062] Figure 1 Schematic diagram of the text element extraction method provided by the present invention. Figure 1 As shown, an embodiment of the present invention provides a text element extraction method, comprising:

[0063] Step 110, determining the text to be recognized;

[0064] Specifically, the text to be recognized is the text that needs to be extracted. The text to be recognized can be directly input by the user, or obtained by transcribing the collected audio, or by acquiring an image through an image acquisition device such as a scanner, mobile phone, camera, etc., and performing OCR (Optical Character Recognition) on the image. The text to be recognized can also be obtained by pre-processing the text obtained based on the above-mentioned text acquisition method, such as deletion, deduplication and splicing. The embodiment of the present invention is not limited to this.

[0065] Step 120, classifying each clause in the text to be recognized into element granularity, and obtaining the element granularity type of each clause, where the element granularity type is sentence granularity or word granularity;

[0066] Considering the extraction of text elements, word-level recognition improves the accuracy of recognition, but is time-consuming, resulting in poor timeliness. Therefore, the embodiment of the present invention combines the word-level recognition method with the sentence-level recognition method to extract text elements.

[0067] Specifically, each clause in the text to be recognized is classified into word granularity and sentence granularity elements to obtain the element granularity type to which each clause belongs, wherein the clauses in the text to be recognized are sentences separated by commas and periods in the text to be recognized. For example: the text to be recognized is "A, B. C, D and E, F.", then the clauses of the text to be recognized are "A", "B", "C, D and E" and "F".

[0068] It should be noted that the element granularity classification of each clause in the text to be recognized is based on whether the clause contains multiple element categories or multiple keywords. If it contains multiple element categories or multiple keywords, the element granularity type of the clause is considered to be word granularity. When extracting elements from the clause, it is necessary to extract elements one by one. Otherwise, the element granularity type of the clause is considered to be sentence granularity. When extracting elements from the clause, the clause can be regarded as a whole for element extraction, instead of extracting elements from the words one by one.

[0069] Step 130 , based on the element granularity type of each clause, extract elements from the text to be recognized to obtain a target element text.

[0070] It should be noted that, through the element granularity type of each clause, the element extraction of the recognized text is processed in different processing methods according to different element granularity types. When the element granularity type of the clause is sentence granularity, the clause can be directly judged whether there are elements or keywords to determine whether to extract the clause. The corresponding operation action of the clause in the element extraction can also be predicted, and related operations can be performed based on the predicted operation action. For example, if the operation action of the clause is to retain, the clause is extracted, or the clause is discarded, etc. The embodiment of the present invention does not limit this. When the element granularity type of the clause is word granularity, each participle in the clause can be judged whether there are elements or keywords to determine whether to extract the participle. The corresponding operation action of each participle in the clause in the element extraction can also be predicted, and related operations can be performed based on the predicted operation action. The embodiment of the present invention does not limit this.

[0071] In addition, the text to be recognized can be segmented according to the element granularity type of each clause in the text to be recognized to obtain a segmented element sequence. The elements contained in the element sequence obtained by segmentation can be a whole clause or a single word segment. In subsequent operations, whether the element is a clause or a word segment, it is treated the same. Then, a judgment is made on whether each element in the element sequence is to be extracted, and corresponding operations are performed based on the judgment result to obtain the final target element text, which is not specifically limited in the embodiment of the present invention.

[0072] A text element extraction method provided by an embodiment of the present invention classifies each clause in a text to be recognized into word granularity and sentence granularity, extracts elements from each clause according to its corresponding granularity type, and obtains a target element text, thereby realizing non-continuous element extraction of text based on the use of word granularity combined with sentence granularity. While ensuring the recognition accuracy, it also improves the timeliness of recognition, thereby improving the accuracy and timeliness of element extraction.

[0073] Based on the above embodiments, Figure 2 FIG. 1 is a flow chart of the method for extracting elements based on text element sequences provided by the present invention. Figure 2 As shown, step 130 includes:

[0074] Step 131, based on the element granularity type of each clause, the text to be recognized is segmented to obtain an element sequence;

[0075] Step 132, extracting elements from the element sequence to obtain target element text.

[0076] Considering that if element extraction is performed directly in the text to be recognized, the clauses or participles to be extracted need to be marked by indexes, so the current index position needs to be recorded at all times, which makes the logic complex, thus affecting the efficiency of extraction and making it easy to make mistakes. Therefore, the embodiment of the present invention segments the text to be recognized and extracts elements based on the segmented elements.

[0077] Specifically, the text to be recognized is segmented into elements according to the element granularity type of each clause, and the elements obtained after the segmentation of each clause element are placed in an element sequence. After the segmentation of each clause of the text to be recognized is completed, the element sequence of the text to be recognized is obtained, and elements are extracted from the element sequence to obtain the target element text, wherein the segmentation methods of the word granularity element granularity type and the sentence granularity element granularity type are different.

[0078] It should be noted that the element segmentation of the text to be recognized according to the word granularity element granularity type can be performed by segmenting the current clause with the word segmentation result of the current clause, or by segmenting the current clause with keywords, and the embodiment of the present invention does not limit this; the element segmentation of the text to be recognized according to the sentence granularity element granularity type can be performed by directly segmenting the current clause as a separate element. In the element sequence thus obtained, the elements corresponding to each clause in the text to be recognized are arranged in order, and the element corresponding to a single clause here can be the word segmentation result of a single clause, or it can be a single clause itself.

[0079] On this basis, elements can be extracted from the element sequence. Specifically, it can be determined whether elements or keywords exist for each element in the element sequence to determine whether to extract the element. The operation action of each element in the element sequence can also be predicted, and related operations can be performed based on the predicted operation action. The embodiments of the present invention are not limited to this.

[0080] Based on the above embodiments, Figure 3 Schematic diagram of the flow of the text segmentation method provided by the present invention. Figure 3 As shown, step 131 includes:

[0081] Step 131-1, if the element granularity type of the current clause in the text to be recognized is word granularity, then the word segmentation sequence of the current clause is stored in the element sequence, otherwise the current clause is stored in the element sequence;

[0082] Step 131 - 2 , updating the next clause of the current clause in the text to be recognized as the current clause.

[0083] Specifically, each clause of the text to be recognized is traversed from the beginning to the end of the sentence. If the element granularity type of the current clause is word granularity, the word segmentation sequence of the current clause is stored in the element sequence. If the element granularity type of the current clause is sentence granularity, the current clause is stored in the element sequence. Then the next clause of the current clause is updated to the current clause to perform the above operation until the traversal is completed and the element sequence of the text to be recognized is obtained.

[0084] Based on the above embodiments, Figure 4 FIG. 1 is one of the flow charts of the method for obtaining text to be recognized provided by the present invention. Figure 4 As shown, step 110 includes:

[0085] Step 111, determining the original text;

[0086] Specifically, the original text is the text that needs to be extracted. The text to be recognized can be directly input by the user, or obtained by transcribing the collected audio, or by collecting images through image acquisition devices such as scanners, mobile phones, cameras, etc., and performing OCR (Optical Character Recognition) on the images.

[0087] Step 112, performing element category detection on the original text, and locating a candidate start index and a candidate end index of the element category in the original text if any element category exists in the original text;

[0088] Considering that if the original text is directly used as the text to be recognized, a large amount of useless or repeated information will be processed, and even the original text does not contain the element information to be extracted, resulting in reduced efficiency of element extraction. Therefore, the embodiment of the present invention adds an implementation method of preprocessing the original text to obtain the text to be recognized and then applying the text to be recognized to element extraction.

[0089] Specifically, the element category of the original text is first detected to determine whether the original text contains the element category to be extracted. When the original text contains the element category to be extracted, the candidate start index and candidate end index of the element category are located in the original text according to each element category existing in the original text.

[0090] It should be noted that the candidate start index can be a single index or a list of multiple indexes, and the candidate end index can be a single index or a list of multiple indexes, which is not limited in the embodiment of the present invention. The candidate start index and the candidate end index can be obtained by contextual semantic positioning of each word in the original text.

[0091] Step 113: Based on the positions of the candidate start index and the candidate end index of the element category in the original text, determine the text to be recognized corresponding to the element category from the original text.

[0092] Specifically, according to the positions of the candidate start index and the candidate end index of the element category in the original text, the original text is intercepted to obtain the text to be recognized corresponding to the element category.

[0093] It should be noted that the candidate starting index and the candidate ending index can be one or more, that is, the index pair composed of the candidate starting index and the candidate ending index can be one or more. When the index pair is one, the text to be recognized corresponding to the element category can be intercepted according to the positions of the candidate starting index and the candidate ending index in the index pair; when the index pair is multiple, the text to be recognized can be intercepted according to the positions of the candidate starting index and the candidate ending index in each index pair, and then the intercepted texts can be directly spliced, or the intercepted texts can be deduplicated and then spliced ​​to obtain the text to be recognized corresponding to the element category. The embodiment of the present invention does not limit this.

[0094] A text element extraction method provided by an embodiment of the present invention detects the element category of the original text, locates the starting index position and the ending index position of the element category, realizes the positioning and screening of the original text based on the element category, and obtains the text to be identified corresponding to the element category, so that the text to be identified corresponds to the element category, removes the information in the original text that is not related to the element category, and further improves the accuracy and timeliness of text element extraction.

[0095] Based on the above embodiments, Figure 5 FIG. 1 is a flow chart of the original text semantic extraction method provided by the present invention. Figure 5 As shown, step 112 includes:

[0096] Step 112-1, performing semantic extraction on the original text to obtain the text semantics of the original text and the context semantics of each word in the original text;

[0097] Considering that if two sets of encoders are used to extract the text semantics of the original text and the context semantics of each word in the original text respectively, the semantic extraction needs to be performed twice, resulting in reduced efficiency. Therefore, the embodiment of the present invention uses the same set of encoders to extract the text semantics of the original text and the context semantics of each word in the original text once.

[0098] Specifically, the original text is input into the encoder, and the encoder performs feature extraction based on the original text and each word in the original text to obtain the text semantics of the original text and the context semantics of each word in the original text.

[0099] Step 112-2, based on the text semantics of the original text, perform feature category detection on the original text, and if any feature category exists in the original text, locate the candidate start index and candidate end index of the feature category in the original text based on the context semantics of each word in the original text.

[0100] Specifically, based on the text semantics of the original text obtained in step 112-1, it is determined whether the original text contains element categories to complete the element category detection of the original text. When it is determined that the original text contains any element category in the element categories, the confidence of each character as the starting index and the key index is predicted based on the semantics of the context of each character in the original text, and based on the confidence of the starting index and the key index of each character, the candidate starting index and the candidate ending index of the element category in the original text are located.

[0101] It should be noted that based on the confidence of each character's starting index and key index, locating the candidate starting index and candidate ending index of the element category in the original text is based on a preset confidence threshold, filtering out the index positions of characters that do not match the confidence, and obtaining the candidate starting index and candidate ending index of the element category in the original text. Figure 6 Schematic diagram of the model structure for extracting the text semantics of the original text and the context semantics of each word in the original text provided by the present invention. Figure 6 As shown, only one BERT model Encoder is needed to simultaneously realize the extraction of the text semantics of the original text and the context semantics of each word in the original text. After predicting the text semantics after the CLS position of the original text, the element category of the original text can be determined on this basis. The element categories here include why, what happened and what result, among which why and what happened are the element categories existing in the original text. The figure takes the why element category as an example, and calculates the confidence rate of the starting index and the ending index of the why element category of each word in the original text based on the context semantics of each word in the original text, so as to obtain the candidate starting index and candidate ending index of the why element category. Here, the candidate starting index of the why element category is in the word "cause", and the candidate ending index is in the word "F". It should be noted that Figure 6 The letters A, B, C, D, E, F, G, and J are only used as examples of each word in the original text and have no actual meaning.

[0102] A text element extraction method provided by an embodiment of the present invention simultaneously extracts the text semantics of the original text and the context semantics of each word in the original text through an encoder, thereby reducing the encoder's re-extraction process of features and further improving the timeliness of text element extraction.

[0103] Based on the above embodiments, Figure 7 FIG. 2 is a flow chart of the method for obtaining text to be recognized provided by the present invention. Figure 7 As shown, step 113 includes:

[0104] Step 113-1, with the restriction that the position of the candidate start index is before the position of the candidate end index and the distance between the candidate start index and the candidate end index is the shortest, the candidate start index and the candidate end index of any element category in the original text are combined to obtain a candidate index pair of the element category;

[0105] It should be noted that when the candidate start index and candidate end index of any element category in the original text are combined into a candidate index pair, the position of the candidate start index of each candidate index pair needs to be before the position of the candidate end index, and under this condition, each revelation index in the candidate start index needs to find an end index closest to it in the candidate end index. For example: the candidate start index is [2,15,18], and the candidate end index is [8,20], then the index pairs composed of the candidate start index and the candidate end index are (2,8), (15,20), (18,20).

[0106] Step 113-2, based on the confidence of the candidate start index and the confidence of the candidate end index in each candidate index pair of the element category, select a start and end index pair from each candidate index pair of the element category;

[0107] Specifically, the confidence of each candidate index pair is calculated based on the confidence of the candidate start index and the confidence of the candidate end index in each candidate index pair of the element category, and then one or more candidates that meet the preset conditions are selected from the confidence of each candidate index pair as the start and end index pairs.

[0108] It should be noted that, according to the confidence of the candidate start index and the confidence of the candidate end index in each candidate index pair, the confidence of each candidate index pair can be calculated by weighted summing the confidence of the candidate start index and the confidence of the candidate end index in the candidate index pair, or by multiplying the confidence of the candidate start index and the confidence of the candidate end index in the candidate index pair, which is not limited in the embodiment of the present invention. Selecting one or more candidate index pairs that meet the preset conditions from the confidence of each candidate index pair can be obtained by pre-setting the confidence threshold, or by selecting a specified number of the confidences of each candidate index pair from high to low, which is not limited in the embodiment of the present invention.

[0109] Step 113 - 3 , based on the start-end index pair, determine the text to be identified corresponding to the element category from the original text.

[0110] Specifically, according to the start index and the end index in each index pair in the start-end index pair, the index text is extracted from the original text, and then the to-be-recognized text corresponding to the element category is determined through the extracted index text.

[0111] It should be noted that when the number of index texts is one, the index text is used as the text to be recognized corresponding to the element category. When the number of index texts is greater than 1, multiple index texts can be spliced ​​to obtain the text to be recognized corresponding to the element category, and multiple index texts can also be spliced ​​after removing duplicate content to obtain the text to be recognized corresponding to the element category, which is not limited in the embodiment of the present invention.

[0112] Based on the above embodiments, Figure 8 Schematic diagram of the process of deduplication of indexed text provided by the present invention. Figure 8 As shown, step 113-3 includes:

[0113] Step 810, determining the index text of each start-end index pair from the original text;

[0114] Step 820, deduplication of all index texts based on the semantic similarity and syntactic repetition between the index texts of each two start-end index pairs, where the syntactic repetition is determined based on the intersection of the two index texts;

[0115] Step 830: Determine the text to be recognized based on the index text after deduplication.

[0116] Considering that when there are multiple index pairs in the start-end index pair, after extracting index texts from the original text according to these indexes, texts with similar or repeated contents may appear. If they are not removed, the efficiency of text element extraction will be reduced, and repeated contents will also exist in the result of text element extraction. Therefore, the embodiment of the present invention performs a deduplication operation when there are multiple index pairs in the start-end index pair.

[0117] Specifically, when there are multiple index pairs in the start-end index pair, the index text corresponding to each index pair is extracted from the original text according to the start index and end index of each index pair in the start-end index pair, and based on the index text corresponding to each extracted index pair, all index texts are deduplicated by semantic similarity and syntactic repetition between every two index texts, and the index texts retained after deduplication are spliced ​​to obtain the text to be recognized, wherein the syntactic repetition is determined based on the intersection of the two index texts. In addition, if only one index text of the start-end index pair is determined in the original text, steps 820 and 830 are no longer executed, and the index text is directly used as the text to be recognized.

[0118] It should be noted that all index texts are deduplicated by semantic similarity and syntactic repetition between every two index texts. For example, if there are four index texts A, B, C, and D, semantic similarity and syntactic repetition deduplication are performed between A and B, A and C, A and D, B and C, B and D, and C and D. Semantic similarity deduplication can be performed by semantic extraction using a BERT pre-trained model or an Electra pre-trained model, and deduplication is performed based on the semantic features extracted from the two index texts; syntactic repetition deduplication can be performed based on the length of the intersection of the two index texts, for example: if the ratio of the length of the intersection of the two index texts to the length of the longer text of the two index texts is greater than a preset value, the index text corresponding to the deduplication is removed. Therefore, deduplication is performed on the index text with a lower confidence level, and the embodiment of the present invention does not limit this.

[0119] A text element extraction method provided by an embodiment of the present invention reduces repeated content in the text to be identified by deduplicating multiple index texts during the preprocessing of the original text, thereby further improving the accuracy and timeliness of text element extraction.

[0120] Based on the above embodiment, step 113 further includes:

[0121] Step 114, based on the original text, completing the text to be recognized corresponding to any element category to obtain a completed text;

[0122] Step 115: Update the text to be recognized based on the completed text.

[0123] Considering that the index text extracted based on the positions of the candidate start index and the candidate end index in the original text is not necessarily continuous, resulting in discontinuity of the text to be recognized corresponding to the element category, the embodiment of the present invention completes the text to be recognized.

[0124] Specifically, based on one or more index pairs consisting of candidate starting indexes and candidate ending indexes, the index position with the smallest index position of the starting index in each index pair is used as the starting index position of the completed text, and the index position with the largest index position of the ending index in each index pair is used as the ending index position of the completed text. Based on the initial index position and the ending index position of the completed text, the completed text is extracted from the original text, and then the text to be recognized is updated based on the completed text.

[0125] It should be noted that one or more index pairs consisting of a candidate start index and a candidate end index may be obtained by combining the restriction that the position of the candidate start index is before the position of the candidate end index and the distance between the candidate start index and the candidate end index is the shortest, or the index texts corresponding to each index pair may be deduplicated based on semantic similarity and syntactic repetition, which is not limited in the embodiment of the present invention. Before the supplementary text updates the text to be recognized, the supplementary text may be syntactically adjusted, and the adjusted supplementary text may be updated with the text to be recognized, which is not limited in the embodiment of the present invention.

[0126] Based on the above embodiments, Fig. 9 It is a flow chart of the method for extracting text elements in field A provided by the present invention. Fig. 9 As shown, the field A here can be any field, such as the medical field, the educational field, etc. This embodiment takes the extraction of text elements in the field A as an example. The method includes:

[0127] Step 910, the original text of domain A is passed into the model based on domain A, and after multiple layers of Transformers, the original text features of domain A are finally obtained after the CLS (marking the beginning of the text segment in the BERT pre-training model), and the probability of existence of each element category is normalized by the Sigmoid function, and the threshold is set by heuristics to obtain the final result of whether the original text of domain A exists in different element categories. Among them, the model of domain A is a BERT model pre-trained based on the pre-training vocabulary dataset and training dataset of domain A.

[0128] Step 920, according to the result of whether the original text of the field A exists in different element categories in step 910, for the category where the element category exists, the MRC (Machine Reading Comprehension) model based on the Token level (each word) binary classification is selected, and the position index of the start and end of each element category is judged by 0 / 1 (binary classification) token by token, and the index position and its corresponding confidence rate with a confidence rate greater than the threshold are stored. For one of the element categories, multiple pairs of start and end index pairs can be obtained by rule-based combination (in the index pair, the index value of the start position is always less than the index value of the end position, and the index value of each start position only combines the index value of the end position closest to itself), and the confidence rate corresponding to each pair of start and end positions is multiplied to obtain the score corresponding to this start and end index pair, and the score is arranged in descending order according to the score size, and the Top5 (the top 5) candidate index pairs are selected as the final start and end index pairs. Among them, the MRC model and the model of the field A in step 910 use the same encoder, and in order to be not easily affected by false negative examples, the training data of the MRC model all uses positive examples, and no negative examples are introduced.

[0129] Step 930, based on the final start-end index pair obtained in step 920, determine the index text of the start-end index pair from the original text of field A, and perform deduplication on each index text by semantic similarity and syntactic repetition, wherein semantic similarity deduplication is to select a static BERT pre-trained model as an encoder, traverse each index pair in the start-end index pair in order, so that the index texts corresponding to the index pairs are all converted into vector expressions, and then calculate the distance between the index texts corresponding to the index pairs by the Euclidean distance formula, and delete the index pairs with a distance less than a threshold and a lower ranking from the start-end index pair; syntactic repetition deduplication is to select the IOU (Intersection Over Union) evaluation index based on NLP (Natural Language Process, natural language processing), and also calculate the value of the index between the index texts corresponding to the index pairs by two by two, and delete the index pairs with a value greater than a given threshold and a lower ranking from the start-end index pair, wherein the calculation formula of IOU is as follows:

[0130]

[0131] In the formula, segments A and B have the same text, and Max indicates the length of the segment with the longer length between segments A and B.

[0132] Step 940: The smallest index position of the start index in each of the deduplicated start and end index pairs obtained in step 930 is used as the start index position of the completed text, and the largest index position of the end index in each of the start and end index pairs is used as the end index position of the completed text. The formula is as follows:

[0133] (S1, E1), (S2, E2)-> (Min (S1, S2), Max (E1, E2)) = (Snew, Enew)

[0134] Where (S1, E1) and (S2, E2) are the deduplicated start and end index pairs, where S1 and S2 represent the start index positions, E1 and E2 represent the end index positions, Min represents the smaller value of S1 and S2, and is represented by Snew, and Max represents the larger value of E1 and E2, and is represented by Enew.

[0135] According to (Snew, Enew), the completed text is extracted from the original text in the original domain A, and the completed text is input into a syntax tree model for adjusting the syntax of text sentences to obtain the text to be recognized with adjusted syntax.

[0136] Input each clause in the text to be recognized into the classification model to obtain the element granularity type of each clause, wherein the classification model is trained based on the sample text and the element granularity classification label of the sample text. Since the element granularity type of each clause is word granularity, the clause is segmented based on the precise mode of JIEBA (Chinese word segmentation library) and the segmentation result is stored in the element sequence, otherwise the clause is directly placed in the element sequence until each clause in the text to be recognized is classified and the element sequence is obtained. Each element of the element sequence is input into the action model, and the elements are extracted according to the action of each element to obtain the final element extraction text. The action model is trained based on the sample element sequence and the action label of each element in the sample element sequence. In addition, the elements are extracted according to the action of the element, Fig.10 Schematic diagram of the process of extracting text elements provided by the present invention. Fig.10 As shown in the figure, the stack frame is used to represent the extraction result, the queue frame is used to identify the change of the element sequence, the numbers in the stack frame and the queue frame represent the elements, the step frame is used to represent each step, and the next action frame identifies the operation action of each step, wherein the operation action ADD represents moving the element (word / sentence) in the queue to the stack, indicating that the element contains the element granularity category and is the element extraction part; POP represents directly deleting the element (word / sentence) in the queue, and the element does not contain the element granularity category; UNION represents sequentially splicing multiple elements in the stack, indicating that there are multiple elements in the stack belonging to the same element granularity category; DONE represents the end of the operation, and there is no subsequent action.

[0137] The text element extraction device provided by the present invention is described below. The text element extraction device described below and the text element extraction method described above can be referenced to each other.

[0138] Fig.11 Schematic diagram of the structure of the text element extraction device provided by the present invention. Fig.11 As shown, the device includes: a determination module 1110, a classification module 1120 and an extraction module 1130;

[0139] in,

[0140] A determination module 1110, used to determine the text to be recognized;

[0141] A classification module 1120 is used to classify the element granularity of each clause in the text to be recognized, and obtain the element granularity type of each clause, where the element granularity type is sentence granularity or word granularity;

[0142] The extraction module 1130 is used to extract elements from the text to be recognized based on the element granularity type of each clause to obtain a target element text.

[0143] In an embodiment of the present invention, a determination module 1110 is used to determine a text to be recognized; a classification module 1120 is used to perform element granularity classification on each clause in the text to be recognized to obtain the element granularity type of each clause, and the element granularity type is sentence granularity or word granularity; an extraction module 1130 is used to perform element extraction on the text to be recognized based on the element granularity type of each clause to obtain a target element text, thereby realizing non-continuous element extraction of the text based on the use of word granularity combined with sentence granularity, while ensuring the recognition accuracy, it also improves the timeliness of the recognition, thereby improving the accuracy and timeliness of the element extraction.

[0144] Based on any of the above embodiments, the classification module 1120 includes:

[0145] The segmentation submodule is used to segment the text to be recognized based on the element granularity type of each clause to obtain an element sequence;

[0146] The extraction submodule is used to extract elements from the element sequence to obtain the target element text.

[0147] Based on any of the above embodiments, the segmentation submodule includes:

[0148] A judgment submodule, for storing the word segmentation sequence of the current clause into the element sequence if the element granularity type of the current clause in the text to be recognized is word granularity, otherwise storing the current clause into the element sequence;

[0149] The updating submodule is used to update the next clause of the current clause in the text to be recognized to the current clause.

[0150] Based on any of the above embodiments, the determining module 1110 includes:

[0151] An original text determination submodule, used for determining the original text;

[0152] The start-end index prediction submodule is used to detect the element category of the original text, and locate the candidate start index and candidate end index of any element category in the original text if any element category exists in the original text;

[0153] The recognition text determination submodule is used to determine the text to be recognized corresponding to any element category from the original text based on the positions of the candidate start index and the candidate end index of any element category in the original text.

[0154] Based on any of the above embodiments, the start-end index prediction submodule includes:

[0155] The semantic determination submodule is used to extract the semantics of the original text to obtain the text semantics of the original text and the context semantics of each word in the original text;

[0156] The start-end index determination submodule is used to detect element categories of the original text based on the text semantics of the original text, and locate the candidate start index and candidate end index of any element category in the original text based on the context semantics of each word in the original text if any element category exists in the original text.

[0157] Based on any of the above embodiments, the recognition text determination submodule includes:

[0158] A candidate index pair determination submodule is used to combine the candidate start index and the candidate end index of the feature category in the original text with the restriction that the position of the candidate start index is before the position of the candidate end index and the distance between the candidate start index and the candidate end index is the shortest, so as to obtain a candidate index pair of the feature category;

[0159] A start-end index pair determination submodule, for selecting a start-end index pair from each candidate index pair of any element category based on the confidence of the candidate start index and the confidence of the candidate end index in each candidate index pair of any element category;

[0160] The to-be-recognized text determination submodule determines the to-be-recognized text corresponding to any element category from the original text based on the start-end index pair.

[0161] Based on any of the above embodiments, the to-be-recognized text determination submodule includes:

[0162] An index text determination submodule, used to determine the index text of the start and end index pairs from the original text;

[0163] A deduplication submodule is used to deduplicate all index texts based on the semantic similarity and syntactic repetition between the index texts of each pair of start and end indexes. The syntactic repetition is determined based on the intersection of the two index texts.

[0164] The submodule for determining the text to be recognized is used to determine the text to be recognized based on the index text after deduplication.

[0165] Based on any of the above embodiments, the determining module 1110 further includes:

[0166] The completion submodule is used to complete the text to be recognized corresponding to any element category based on the original text to obtain the completed text;

[0167] The submodule for updating the text to be recognized is used to update the text to be recognized based on the completed text.

[0168] Fig.12 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.12As shown, the electronic device may include: a processor 1210, a communication interface 1220, a memory 1230 and a communication bus 1240, wherein the processor 1210, the communication interface 1220 and the memory 1230 communicate with each other through the communication bus 1240. The processor 1210 may call the logic instructions in the memory 1230 to execute the text element extraction method, which includes: determining the text to be recognized; performing element granularity classification on each clause in the text to be recognized to obtain the element granularity type of each clause, the element granularity type being sentence granularity or word granularity; performing element extraction on the text to be recognized based on the element granularity type of each clause to obtain the target element text.

[0169] In addition, the logic instructions in the above-mentioned memory 1230 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0170] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the text element extraction method provided by the above methods, which includes: determining the text to be recognized; performing element granularity classification on each clause in the text to be recognized to obtain the element granularity type of each clause, and the element granularity type is sentence granularity or word granularity; based on the element granularity type of each clause, extracting elements from the text to be recognized to obtain the target element text.

[0171] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the text element extraction method provided by the above-mentioned methods, the method comprising: determining the text to be recognized; performing element granularity classification on each clause in the text to be recognized to obtain the element granularity type of each clause, the element granularity type being sentence granularity or word granularity; performing element extraction on the text to be recognized based on the element granularity type of each clause to obtain the target element text.

[0172] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0173] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0174] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A text element extraction method, characterized in that: include: Determine the text to be recognized; Performing element granularity classification on each clause in the to-be-recognized text to obtain an element granularity type of each clause, wherein the element granularity type is sentence granularity or word granularity; Based on the element granularity type of each clause, extract elements from the text to be recognized to obtain a target element text; The step of classifying each clause in the to-be-recognized text into element granularity types to obtain the element granularity types of each clause includes: If the clause contains multiple element categories or multiple keywords, the element granularity type of the clause is determined to be word granularity, otherwise the element granularity type of the clause is determined to be sentence granularity; the clause with the element granularity type of word granularity is segmented one by one for element extraction, and the clause with the element granularity type of sentence granularity is extracted as a whole; The extracting elements of the text to be recognized based on the element granularity type of each clause to obtain a target element text includes: Based on the element granularity type of each clause, the text to be recognized is segmented to obtain an element sequence; Perform element extraction on the element sequence to obtain target element text.

2. The text element extraction method according to claim 1, characterized in that: The step of segmenting the text to be recognized based on the element granularity type of each clause to obtain an element sequence includes: If the element granularity type of the current clause in the to-be-recognized text is word granularity, the word segmentation sequence of the current clause is stored in the element sequence; otherwise, the current clause is stored in the element sequence; The next clause of the current clause in the to-be-recognized text is updated as the current clause.

3. The text element extraction method according to claim 1, characterized in that: Determining the text to be recognized includes: Identify the original text; Performing element category detection on the original text, and if any element category exists in the original text, locating a candidate start index and a candidate end index of any element category in the original text; Based on the positions of the candidate start index and the candidate end index of any element category in the original text, the to-be-recognized text corresponding to any element category is determined from the original text.

4. The text element extraction method according to claim 3, characterized in that: The performing element category detection on the original text, and locating a candidate start index and a candidate end index of any element category in the original text when any element category exists in the original text, comprises: Performing semantic extraction on the original text to obtain text semantics of the original text and context semantics of each word in the original text; Based on the text semantics of the original text, element category detection is performed on the original text, and if any element category exists in the original text, the candidate start index and the candidate end index of any element category in the original text are located based on the context semantics of each word in the original text.

5. The text element extraction method according to claim 3, characterized in that: The determining, from the original text, a text to be recognized corresponding to any element category based on the positions of the candidate start index and the candidate end index of any element category in the original text includes: With the restriction that the position of the candidate start index is before the position of the candidate end index and the distance between the candidate start index and the candidate end index is the shortest, the candidate start index and the candidate end index of any element category in the original text are combined to obtain a candidate index pair of any element category; Selecting a start and end index pair from each candidate index pair of any element category based on the confidence of the candidate start index and the confidence of the candidate end index in each candidate index pair of any element category; Based on the start-end index pair, the text to be identified corresponding to any element category is determined from the original text.

6. The text element extraction method according to claim 5, characterized in that: The step of determining the text to be identified corresponding to any element category from the original text based on the start-end index pair includes: Determine the index text of each start-end index pair from the original text; Based on the semantic similarity and syntactic repetition between the index texts of each pair of start and end indexes, all index texts are deduplicated. The syntactic repetition is determined based on the intersection of the two index texts. Based on the deduplicated index text, the text to be recognized is determined.

7. The text element extraction method according to claim 3, characterized in that: The method further comprises: determining the text to be recognized corresponding to any element category from the original text based on the positions of the candidate start index and the candidate end index of any element category in the original text, and then: Based on the original text, completing the text to be recognized corresponding to any one of the element categories to obtain a completed text; Based on the completed text, the text to be recognized is updated.

8. A text element extraction device, characterized in that: include: A determination module, used for determining the text to be recognized; A classification module, used for classifying each clause in the to-be-recognized text into element granularity, and obtaining an element granularity type of each clause, wherein the element granularity type is sentence granularity or word granularity; An extraction module, used for extracting elements from the text to be recognized based on the element granularity type of each clause to obtain a target element text; The classification module is specifically used for: If the clause contains multiple element categories or multiple keywords, the element granularity type of the clause is determined to be word granularity, otherwise the element granularity type of the clause is determined to be sentence granularity; the clause with the element granularity type of word granularity is segmented one by one for element extraction, and the clause with the element granularity type of sentence granularity is extracted as a whole; The extraction module is specifically used for: Based on the element granularity type of each clause, the text to be recognized is segmented to obtain an element sequence; Perform element extraction on the element sequence to obtain target element text.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the text element extraction method according to any one of claims 1 to 7 are implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the text element extraction method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • A text implication relation recognition method based on multi-granularity information fusion

    CN109299262A

  • Text implication recognition method and device

    CN110390397A