Method for extracting entities from text, electronic device and storage medium

By comprehensively analyzing the entity keyword characteristics in the case text and matching with the expert database, the accuracy of entity extraction in the case text is solved, achieving faster and more accurate information acquisition.

CN120163151BActive Publication Date: 2025-08-15奇点智保(上海)科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510646887.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-08-15
Estimated Expiration
2045-05-20

AI Technical Summary

Technical Problem

The accuracy of the prior art in case text is low, which makes it time-consuming to view information and is prone to omissions or incorrect extraction, affecting the management of medical records and medical expense accounting.

Method used

By calculating the word frequency, word attributes, character length and position information of entity keywords, the entity score is calculated, and when the score does not meet the threshold, it further matches with the preset expert entity library or generates recombinant entity words through character disassembly and combination to ensure accuracy.

Benefits of technology

A more comprehensive and accurate physical word extraction is achieved, preventing omissions, and improving the speed and accuracy of case text information acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120163151B_ABST
    Figure CN120163151B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of text processing technology, and in particular to a method, electronic device and storage medium for extracting entities from text. The method comprises: for any entity keyword extracted from a given case text, calculating an entity score corresponding to the entity keyword; when the entity score is less than an entity score threshold, first matching the entity keyword with a preset entity word in a preset expert entity library; a successfully matched entity word is used as a target entity word; when the match is unsuccessful, searching for a target sentence containing the entity keyword, performing character decomposition and character combination on the target sentence to generate a plurality of recombined entity words; and then determining a final target entity word based on the matching situation between the recombined entity word and the preset entity word. The present invention can extract more comprehensive and accurate target entity words, and is conducive to quickly and accurately obtaining key information in the case text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text processing, and in particular to a method for extracting entities from text, an electronic device, and a storage medium. Background Art

[0002] Medical records are text documents that provide detailed records of a patient's condition and treatment process during the medical process. They typically include basic patient information, diagnosis results, test results, and treatment methods. However, due to their extensive content, reviewing medical records is time-consuming and prone to omissions and incorrect information. This impacts medical record management, medical expense calculation, and medical insurance reimbursement coverage.

[0003] In recent years, with the development of computer technology in the medical field, the method of using computer systems to extract entities from case texts instead of humans has gradually been implemented. However, due to the complexity of case texts and professional vocabulary, the accuracy of computer-extracted entities still needs to be improved. Summary of the Invention

[0004] In response to the above technical problems, the present invention provides a method, electronic device and storage medium for extracting entities from text, which can extract more comprehensive and accurate target entity words, and is conducive to quickly and accurately obtaining key information in case texts.

[0005] According to a first aspect of the present invention, a method for extracting entities from text is provided, comprising the following steps:

[0006] S100, for any entity keyword among several entity keywords extracted from a given case text, calculate the entity score corresponding to the entity keyword based on the word frequency, word attributes, character length and position information of the entity keyword in the given case text.

[0007] S200, when the entity score corresponding to the entity keyword is not less than the preset entity score threshold, the entity keyword is used as the target entity word to be extracted; otherwise, the preset entity words in the preset expert entity library are traversed, and when there is a preset entity word that is the same as the entity keyword, the entity keyword is used as the target entity word to be extracted.

[0008] S300, when there is no preset entity word identical to the entity keyword, a target sentence containing the entity keyword is found from a given case text, and the target sentence is decomposed and combined to generate a number of recombined entity words.

[0009] S400, traverse the preset entity words in the preset expert entity library again, and when there is no preset entity word that is the same as any recombined entity word, delete the entity keyword. Conversely, determine the final extracted target entity word based on the recombined entity word corresponding to the same preset entity word.

[0010] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, in which at least one instruction or at least one program is stored. The at least one instruction or the at least one program is loaded and executed by a processor to implement the above-mentioned method for extracting entities from text.

[0011] According to a third aspect of the present invention, there is provided an electronic device comprising a processor and the above-mentioned non-transitory computer-readable storage medium.

[0012] The present invention has at least the following beneficial effects:

[0013] The present invention provides a method for extracting entities in a text. For any entity keyword extracted from a given case text, four indicators, namely, word frequency, word attribute, character length and position information of the entity keyword, are introduced to perform a comprehensive analysis on the entity keyword, and an entity score is quantified to facilitate the judgment of the accuracy of the entity keyword extraction. When the entity score is not less than the entity score threshold, it is considered that the extraction of the entity keyword is accurate. Otherwise, the accuracy of the entity keyword needs to be further judged. The entity keyword is matched with a preset entity word in a preset expert entity library. The successfully matched entity word is used as the target entity word. When the match is unsuccessful, the target sentence where the entity keyword is located is searched, and the target sentence is character-decomposed and character-combined to generate a number of recombined entity words. Then, the final target entity word is determined based on the matching situation between the recombined entity word and the preset entity word. The above process realizes the final determination of the accuracy of the entity keyword and the recombined entity word, making the screened entity word more accurate. At the same time, by recombining the characters, the omission of the entity word can be prevented. Therefore, the present invention makes the target entity word finally extracted more comprehensive and accurate, which is conducive to quickly and accurately obtaining key information in the case text. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0015] Figure 1 A flowchart of a method for extracting entities from text provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0016] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only 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 those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.

[0017] The embodiment of the present invention provides a method for extracting entities from text, such as Figure 1 As shown, the method includes the following steps:

[0018] S100, for any entity keyword among several entity keywords extracted from a given case text, calculate the entity score corresponding to the entity keyword based on the word frequency, word attributes, character length and position information of the entity keyword in the given case text.

[0019] Furthermore, a number of entity keywords are extracted from the given case text using a named entity model, for example, the NER model.

[0020] Specifically, in step S100, the entity score corresponding to the entity keyword is calculated through the following steps:

[0021] S101, based on a number of historical case texts, obtain indicator-confidence fitting curves corresponding to word frequency and character length respectively.

[0022] Furthermore, both word frequency and character length are positively correlated with the entity scores corresponding to entity keywords.

[0023] Specifically, the index-confidence fitting curve corresponding to the word frequency is obtained through the following steps:

[0024] S1011: Based on the frequency of each entity keyword in the corresponding historical case text, the entity confidence corresponding to the entity keyword with different frequency is obtained. For example, if several entity keywords appear twice in the same historical case text, they are matched with known entity keywords. The matching entity keywords are considered to be accurate keywords, and the entity confidence corresponding to the entity keyword at each frequency is calculated.

[0025] S1012: Perform curve fitting on the word frequency and the entity confidence corresponding to the word frequency to obtain an indicator-confidence fitting curve.

[0026] Furthermore, the index-confidence fitting curve corresponding to character length and the index-confidence fitting curve corresponding to word frequency are obtained in the same manner, which will not be repeated here.

[0027] S102: Find out the word frequency confidence and character length confidence corresponding to the entity keyword according to the word frequency and character length of the entity keyword in the given case text.

[0028] S103, based on the word frequency confidence, character length confidence, pre-acquired word attribute confidence and position confidence corresponding to the entity keyword, and the preset indicator weights corresponding to the word frequency confidence, character length confidence, word attribute confidence and position confidence, a weighted sum is calculated to obtain the entity score corresponding to the entity keyword.

[0029] Specifically, the word attribute confidence and position confidence are set based on actual needs. For example, in actual operations, since conclusive entities are mostly nouns, a higher confidence should be set for nouns, a lower confidence for adjectives, and a lower confidence for verbs. Furthermore, since the conclusion usually ends at the end of a case text, a higher confidence should be set for entity keywords positioned later in the text.

[0030] As mentioned above, when extracting entities such as diagnosis, examination, surgery, and treatment methods from case texts, it is necessary to judge the accuracy of the extracted entities. Therefore, this application introduces the above four dimensions to conduct a comprehensive analysis of the extracted entity keywords and quantify them into numerical forms, providing a clear and definite judgment basis for whether the extraction of entity keywords is accurate.

[0031] Furthermore, the entity score corresponding to the entity keyword is calculated through the following steps:

[0032] S110: Based on the obtained case text samples, the case text samples are divided into corresponding character quantity intervals according to a plurality of preset character quantity intervals. For example, the character quantity intervals may be set to 50-100, 100-150, etc.

[0033] S120 , for a number of case text samples corresponding to any character number interval, take each case text sample as a given case text and execute steps S100 to S500 to obtain a number of target entity words corresponding to each case text sample.

[0034] S130, based on the target entity words corresponding to any case text sample and the corresponding preset entity word samples, calculate the initial extraction accuracy corresponding to the target entity words with different character lengths within any character length range. For example, for any case text sample in the range of 50-100, obtain target entity words with 2 and 3 characters respectively, and match them with the preset entity word samples to obtain the initial extraction accuracy corresponding to the target entity words with 2 and 3 characters respectively.

[0035] S140 , based on a plurality of character number intervals, determining an average of a plurality of initial extraction accuracy rates corresponding to a target entity word of any character number as a final extraction accuracy rate corresponding to the target entity word of any character number.

[0036] S150, calculating a new entity score corresponding to the entity keyword based on the entity score corresponding to the entity keyword and the final extraction accuracy corresponding to the number of characters of the entity keyword; this can be understood as: using the final extraction accuracy as a confidence factor of the entity score.

[0037] As mentioned above, on the basis of obtaining the entity score, case texts in different character ranges are further considered. Since the case text has more characters, it is likely that the entity keywords have more characters, and the number of entity keywords extracted in the actual extraction process is not necessarily accurate. Therefore, a large number of case text samples in different character number ranges are analyzed to obtain the extraction accuracy of entity words with different character numbers, and use it as a reference factor to make the obtained entity score more reliable.

[0038] S200, when the entity score corresponding to the entity keyword is not less than the preset entity score threshold, the entity keyword is used as the target entity word to be extracted; otherwise, the preset entity words in the preset expert entity library are traversed, and when there is a preset entity word that is the same as the entity keyword, the entity keyword is used as the target entity word to be extracted; it can be understood that: the preset expert entity library refers to an entity library that stores several entity words in this field added by experts in this field; technical personnel in this field set the entity score threshold according to actual needs or experience, which will not be repeated here.

[0039] As mentioned above, when the entity score corresponding to the entity keyword is low, it indicates that the accuracy of the entity keyword is unreliable. In order to further determine its accuracy, it is compared with the preset entity words in the expert entity library to achieve secondary confirmation of the entity keyword, making the screened entity keyword more accurate.

[0040] S300, when there is no preset entity word identical to the entity keyword, a target sentence containing the entity keyword is found from a given case text, and the target sentence is decomposed and combined to generate a number of recombined entity words.

[0041] Specifically, the character decomposition and character combination of the target sentence to generate a plurality of recombined entity words includes the following steps:

[0042] S301, obtaining the total number of characters K of the target sentence.

[0043] S302, in the order of the number of characters from 1 to K, respectively use the character-level N-gram model to decompose and combine the target sentence into characters, and generate a number of recombined entity words corresponding to each number of characters; it can be understood as: N is taken as 1 to K in sequence.

[0044] As mentioned above, when there is no preset entity word that is the same as the entity keyword, considering that the entity keyword extracted by the NER model may be incorrect, the sentence where the entity keyword is located is found, and several reorganized entity words are regenerated through the N-gram model to judge the accuracy of the reorganized entity word again to prevent the omission of the extraction of entity keywords.

[0045] S400, traverse the preset entity words in the preset expert entity library again, and when there is no preset entity word that is the same as any recombined entity word, delete the entity keyword. Conversely, determine the final extracted target entity word based on the recombined entity word corresponding to the same preset entity word.

[0046] Specifically, the method of determining the target entity word to be finally extracted based on the recombined entity words corresponding to the same preset entity word includes the following steps:

[0047] S401: When the number of recombined entity words corresponding to the same preset entity word is 1, the recombined entity words corresponding to the same preset entity word are used as the target entity words finally extracted, and the entity keywords are deleted.

[0048] S402, when the number of recombined entity words corresponding to the same preset entity word is greater than 1, obtain the position information of each recombined entity word corresponding to the same preset entity word in the target sentence; it can be understood that: the position information refers to the character order corresponding to each character of the recombined entity word in the target sentence.

[0049] S403, based on the position information of each recombined entity word in the target sentence, determine whether there is character overlap between the recombined entity words. When there is no character overlap, all the recombined entity words corresponding to the same preset entity words are used as the final extracted target entity words, and the entity keywords are deleted.

[0050] S404, when there is character overlap between reorganized entity words, the reorganized entity word with a larger number of corresponding characters or the reorganized entity word at a higher position is used as the target entity word finally extracted, and the entity keyword is deleted; it can be understood as: when the number of characters is different, the reorganized entity word with a larger number of corresponding characters is used as the target entity word finally extracted, and when the number of characters is the same, the reorganized entity word at a higher position is used as the target entity word finally extracted, for example, XX resection, where "XX" represents a body part and is an important entity. XX resection and XX resection have roughly the same meaning. It can be seen that the entity word at a higher position has higher accuracy.

[0051] As mentioned above, since there is character overlap in the reorganized entity words, it indicates that only one of the overlapping reorganized entity words is accurate. Therefore, this application introduces the character overlap of the reorganized entity words to further judge the entity words, and in the judgment process, the target entity words are screened out taking into account the actual situation, so that the target entity words finally extracted are more comprehensive and accurate.

[0052] In summary, the present invention provides a method for extracting entities in a text. For any entity keyword extracted from a given case text, the four indicators of entity keyword frequency, word attributes, character length and position information are introduced to conduct a comprehensive analysis of the entity keyword, and the entity score is quantified, which is conducive to the judgment of the accuracy of entity keyword extraction. When the entity score is not less than the entity score threshold, it is considered that the extraction of the entity keyword is accurate. Otherwise, the accuracy of the entity keyword needs to be further judged. The entity keyword is matched with the preset entity word in the preset expert entity library. The successful match is used as the target entity word. When the match is unsuccessful, the target sentence where the entity keyword is located is searched, and the target sentence is character-decomposed and character-combined to generate several recombined entity words. Then, the final target entity word is determined based on the matching situation between the recombined entity word and the preset entity word. The above process realizes the final determination of the accuracy of the entity keyword and the recombined entity word, making the screened entity word more accurate. At the same time, by adopting the N-gram model to reorganize adjacent characters, the omission of entity words can also be prevented. Therefore, the present invention makes the target entity word finally extracted more comprehensive and accurate, which is conducive to quickly and accurately obtaining key information in the case text.

[0053] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to implementing a method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the method for extracting entities from text provided in the above embodiment.

[0054] An embodiment of the present invention further provides an electronic device including a processor and the aforementioned non-transitory computer-readable storage medium.

[0055] Although some specific embodiments of the present invention have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It should also be understood by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A method for extracting entities from text, characterized in that: The method comprises the following steps: S100, for any entity keyword among several entity keywords extracted from a given case text, calculating an entity score corresponding to the entity keyword based on word frequency, word attributes, character length, and position information of the entity keyword in the given case text; The entity score corresponding to the entity keyword is calculated through the following steps: S101, based on a number of historical case texts, obtaining an indicator-confidence fitting curve corresponding to word frequency and character length respectively; S102, according to the word frequency and character length of the entity keyword in the given case text, respectively finding the word frequency confidence and character length confidence corresponding to the entity keyword; S103, calculating an entity score corresponding to the entity keyword by performing a weighted sum calculation based on the word frequency confidence, character length confidence, pre-acquired word attribute confidence, and position confidence corresponding to the entity keyword, as well as preset indicator weights corresponding to the word frequency confidence, character length confidence, word attribute confidence, and position confidence, respectively; S200: When the entity score corresponding to the entity keyword is not less than a preset entity score threshold, the entity keyword is used as the target entity word to be extracted; otherwise, the preset entity words in the preset expert entity library are traversed, and when a preset entity word identical to the entity keyword exists, the entity keyword is used as the target entity word to be extracted; S300, when there is no preset entity word identical to the entity keyword, searching for a target sentence containing the entity keyword from a given case text, and performing character decomposition and character combination on the target sentence to generate a plurality of recombined entity words; S400, traverse the preset entity words in the preset expert entity library again, and when there is no preset entity word that is the same as any recombined entity word, delete the entity keyword. Conversely, determine the final extracted target entity word based on the recombined entity word corresponding to the same preset entity word.

2. The method for extracting entities from text according to claim 1, characterized in that: In step S100, the entity score corresponding to the entity keyword is calculated through the following steps: S110, based on the obtained case text samples, dividing the case text samples into corresponding character quantity intervals according to the preset character quantity intervals; S120, for a number of case text samples corresponding to any character number interval, take each case text sample as a given case text and execute steps S100-S500 to obtain a number of target entity words corresponding to each case text sample; S130, calculating the initial extraction accuracy corresponding to target entity words with different character numbers in any character length interval based on the target entity words corresponding to any case text sample and the corresponding preset entity word samples; S140, based on a plurality of character number intervals, determining an average of a plurality of initial extraction accuracy rates corresponding to a target entity word of any character number as a final extraction accuracy rate corresponding to the target entity word of any character number; S150 , calculating a new entity score corresponding to the entity keyword based on the entity score corresponding to the entity keyword and the final extraction accuracy corresponding to the number of characters in the entity keyword.

3. The method for extracting entities from text according to claim 1, wherein: The step of decomposing and combining the target sentence into a plurality of recombined entity words includes the following steps: S301, obtaining the total number of characters K of the target sentence; S302 , in the order of the number of characters from 1 to K, respectively use a character-level N-gram model to perform character decomposition and character combination on the target sentence, and generate a number of recombined entity words corresponding to each number of characters.

4. The method for extracting entities from text according to claim 1, wherein: The step of determining the target entity word finally extracted based on the recombined entity words corresponding to the same preset entity word comprises the following steps: S401, when the number of recombined entity words corresponding to the same preset entity word is 1, the recombined entity words corresponding to the same preset entity word are used as the target entity words finally extracted, and the entity keywords are deleted; S402, when the number of recombined entity words corresponding to the same preset entity word is greater than 1, obtaining position information of each recombined entity word corresponding to the same preset entity word in the target sentence; S403, based on the acquired position information of each recombined entity word in the target sentence, determining whether there is character overlap between the recombined entity words. If there is no character overlap, all recombined entity words corresponding to the same preset entity word are used as the final extracted target entity words, and the entity keyword is deleted; S404: When characters overlap between reorganized entity words, the reorganized entity word with more corresponding characters or the reorganized entity word at the front is used as the target entity word to be finally extracted, and the entity keyword is deleted.

5. The method for extracting entities from text according to claim 1, wherein: Several entity keywords are extracted from the given case text through the named entity model.

6. A non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, characterized in that: The at least one instruction or the at least one program segment is loaded and executed by a processor to implement the method for extracting entities from text as described in any one of claims 1-5.

7. An electronic device, characterized in that: The device comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 6.

Citation Information

Patent Citations

  • Data mining-oriented text processing system and method

    CN105243130A

  • Knowledge graph-based entity description extraction method and apparatus, and computing device

    CN111984794A