A method, device, equipment and readable storage medium for cutting addresses
By using the address cutting model of the BERT and CRF algorithm layers, the problems of inaccurate and low efficiency of address cutting in the prior art are solved, and a more accurate and efficient address cutting effect is achieved, reducing the need for artificial modification.
Patent Information
- Application Number
- CN202111263277.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-10-28
AI Technical Summary
When processing complex address information about China, the existing address cutting technology is not accurate enough and is inefficient, making it difficult to automatically cut, and cutting errors are prone to occur.
The address cutting model consisting of the BERT algorithm layer and the CRF algorithm layer is used to automatically identify and cut address elements by labeling and calibrating the address text, reducing artificial modifications and improving cutting efficiency.
It achieves a more accurate and efficient address cutting effect, reduces labeling errors, and improves the automation of address cutting.
Smart Images

Figure CN114004232B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of semantic parsing technology, and in particular to a method, device, equipment and readable storage medium for cutting an address. Background Art
[0002] At present, address cutting technology is more and more widely used in various fields. For example, sending and receiving express delivery, household registration address management or letter mailing all require address information to be cut and processed. Irregular address cutting will bring many inconveniences to people.
[0003] Since address information in China is relatively complex, the existing method requires the use of address cutting templates to manually cut the address text, but the cutting effect is not accurate enough. It can only cut the four types of address elements specified by the address cutting template: province, city, district, and county. The subsequent address text of these four types of address elements cannot be further cut. At the same time, the address cutting template is also prone to cutting errors in the process of cutting address information, and the cutting results need to be manually modified, which reduces the efficiency of address cutting.
[0004] Therefore, how to automatically, accurately and efficiently perform address segmentation on address text has become a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0005] The purpose of the present invention is to provide a method, device, equipment and readable storage medium for cutting addresses, which solve the technical problems existing in the prior art and achieve a more accurate and efficient address cutting effect.
[0006] According to one aspect of the present invention, a method for cutting an address is provided, the method comprising the following steps:
[0007] Obtaining the address text to be processed and obtaining a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer;
[0008] Using the BERT algorithm layer, adding a corresponding annotation to each word in the address text; wherein the annotation is used to indicate whether the word in the address text belongs to an address element;
[0009] Calculate the labeling accuracy rate according to the labeling corresponding to each word in the address text by using the CRF algorithm layer;
[0010] When the annotation accuracy is greater than a preset threshold, the address elements in the address text are determined according to the annotation corresponding to each word in the address text, and a corresponding address element type label is added to each address element;
[0011] The address elements and address element type labels in the address text are displayed in pairs to complete the address cutting operation on the address text.
[0012] Optionally, the BERT algorithm layer adds a corresponding annotation to each word in the address text, specifically including:
[0013] The BERT algorithm layer is used to calculate the probability value of each word in the address text under various preset annotations; wherein the preset annotations include: address header annotation, address non-header annotation and non-address annotation;
[0014] According to the probability values of the target word in the address text under various preset annotations, the annotation corresponding to the maximum probability value is added to the target word.
[0015] Optionally, the CRF algorithm layer calculates the annotation accuracy rate according to the annotation corresponding to each word in the address text, specifically including:
[0016] Starting from the first word of the address text, determining in turn whether the marking of each word in the address text satisfies a preset marking rule, and counting the number of words that meet the marking rule;
[0017] The ratio of the number of words that meet the marking rule to the total number of words in the address text is used as the marking accuracy rate.
[0018] Optionally, when the annotation accuracy is greater than a preset threshold, determining the address element in the address text according to the annotation corresponding to each word in the address text specifically includes:
[0019] Determining address elements in the address text according to the words added with the address header mark and the words added with the address non-header mark in the address text;
[0020] The address element is N consecutive words in the address text, and the first word in the address element is added with an address header mark, and the other words in the address element except the first word are added with an address non-header mark.
[0021] Optionally, the adding of a corresponding address element type label to each address element respectively includes:
[0022] Determining whether the address element exists in a preset Chinese address tree;
[0023] If so, obtaining an address element type tag corresponding to the address element from the Chinese address tree;
[0024] If not, a non-address element tag is added to the address element.
[0025] Optionally, the method further includes:
[0026] Obtain the address element data of each province from the preset map database;
[0027] The address element data of the target province are divided according to the preset address element types to obtain the address element data of the target province under each address element type, and a corresponding address element type label is added to the address element data under each address element type to construct an address tree of the target province;
[0028] The Chinese address tree is constructed based on the address trees of all provinces.
[0029] Optionally, the method further includes:
[0030] If all the consecutive M characters in the address text are non-address tags, non-address element tags are added to the consecutive M characters.
[0031] In order to achieve the above object, the present invention also provides a device for cutting addresses, which specifically includes the following components:
[0032] An acquisition module is used to acquire the address text to be processed and acquire a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer;
[0033] A labeling module, used to add a corresponding label to each word in the address text using the BERT algorithm layer; wherein the label is used to indicate whether the word in the address text belongs to an address element;
[0034] A calibration module, used to calculate the annotation accuracy rate according to the annotation corresponding to each word in the address text by using the CRF algorithm layer;
[0035] A determination module, configured to determine the address elements in the address text according to the annotations corresponding to each word in the address text when the annotation accuracy is greater than a preset threshold, and to add a corresponding address element type label to each address element;
[0036] The display module is used to display the address elements and address element type labels in the address text in pairs to complete the address cutting operation on the address text.
[0037] In order to achieve the above objectives, the present invention also provides a computer device, which specifically includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above-mentioned method of cutting addresses when executing the computer program.
[0038] In order to achieve the above object, the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for cutting addresses introduced above are implemented.
[0039] The method, device, equipment and readable storage medium for cutting addresses provided by the present invention can input the address text into the BERT algorithm layer in the address cutting model to identify the address elements in the address text and mark the identified address elements, thereby achieving the effect of cutting the address text according to the address elements; then the marking results output by the BERT algorithm layer are input into the CRF algorithm layer and the marking results are calibrated according to the marking rules, thereby reducing the situation of marking errors occurring during the word segmentation or marking process, making the address cutting effect more accurate; finally, the address elements in the address text are displayed, achieving an automatic, accurate and efficient address cutting effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0041] Figure 1 An optional flow chart of the method for cutting addresses provided in Embodiment 1;
[0042] Figure 2 A schematic diagram of an optional program module of the device for cutting addresses provided in the second embodiment;
[0043] Figure 3 A schematic diagram of an optional hardware architecture of a computer device provided in Example 3. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0045] Embodiment 1
[0046] The embodiment of the present invention provides a method for cutting an address, such as Figure 1 As shown, the method specifically comprises the following steps:
[0047] Step S101: Obtain address text to be processed, and obtain a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer.
[0048] The address text contains several words representing address elements, and address elements are the constituent units that constitute the address. For example, xx province, xx city, xx district, xx street, etc. are all address elements.
[0049] The address segmentation model is a model trained based on a large amount of address sample data and can be used to identify address elements in text. The address segmentation model is composed of a BERT algorithm layer and a CRF algorithm layer.
[0050] The BERT (Bidirectional Encoder Representation from Transformers) algorithm layer is a bidirectional encoder representation algorithm based on Transformer, which can be pre-trained to understand the meaning of words in the text and the contextual relationship between sentences. In this embodiment, the BERT algorithm layer is used to understand the address elements contained in the text and annotate each address element.
[0051] The CRF (Conditional Random Field) algorithm layer is a conditional probability distribution algorithm for another set of output sequences under a given set of input sequences. It is used to determine whether the labeling results output by the BERT algorithm layer meet the constrained labeling rules, and calculate the labeling accuracy based on the labeling results.
[0052] In this implementation, an address segmentation model composed of a BERT algorithm layer and a CRF algorithm layer is used to replace the existing method of only segmenting address texts in a fixed format according to an address segmentation template, which can segment addresses more automatically, accurately, and efficiently.
[0053] Step S102: using the BERT algorithm layer to add a corresponding annotation to each word in the address text; wherein the annotation is used to indicate whether the word in the address text belongs to an address element.
[0054] Specifically, step S102 includes:
[0055] Step A1: using the BERT algorithm layer to calculate the probability value of each word in the address text under various preset annotations; wherein the preset annotations include: address header annotation, address non-header annotation and non-address annotation;
[0056] In this embodiment, each word in the address text is annotated by using the BIO (Beginning-Inside-Outside, named entity recognition) annotation method, that is, "B" represents the address header annotation, "I" represents the address non-header annotation, and "O" represents the non-address annotation; after a section of address text is input into the BERT algorithm layer, the address text is first divided into several words by the BERT algorithm layer word segmenter, and then the probability value of each word under "B", "I", and "O" is calculated. It should be noted that in this embodiment, the BERT algorithm layer word segmenter will treat continuous numbers or continuous English as one word.
[0057] For example, input "I am from Suzhou, Jiangsu Province" into the BERT algorithm layer, first segment the words to get "I", "come", "from", "Jiang", "Su", "province", "Su", "state", and "city", and then calculate the probability value of each word corresponding to the BIO annotation, that is, "I (B-0.2; I-0.1; O-0.7)", "Come (B-0.2; I-0.2; O-0.6)", "From (B-0.2; I-0.1; O-0.7)", "Jiang (B-0.6; I-0.1; O-0.3)", "Su (B-0.1; I-0.7; O-0.2)", "Province (B-0.1; I-0.6; O-0.3)", "Su (B-0.5; I-0.2; O-0.3)", "State (B-0.1; I-0.7; O-0.2)", and "City (B-0.1; I-0.8; O-0.1)".
[0058] Step A2: According to the probability values of the target word in the address text under various preset annotations, a annotation corresponding to the maximum probability value is added to the target word.
[0059] For example: According to the maximum probability value, the annotation result corresponding to the address text "I am from Suzhou City, Jiangsu Province" is "I (O) come (O) from (O) Jiangsu (B) Jiangsu (I) Province (I) Suzhou (B) State (I) City (I)".
[0060] In addition, the above step S102 further includes:
[0061] Step B1: using the BERT algorithm layer to perform word segmentation processing on the address text to obtain each word segment;
[0062] Step B2: determining in sequence whether each of the segmented words exists in a preset Chinese address tree;
[0063] Step B3: If yes, add an address header mark to the first word in the segmented word, and add address non-header marks to other words in the segmented word except the first word; if no, add non-address marks to each word in the segmented word.
[0064] This embodiment provides two ways to label each character in the address text. In practical applications, the labeling method can be improved based on the above two situations as needed, and this embodiment does not make specific limitations.
[0065] Step S103: Use the CRF algorithm layer to calculate the labeling accuracy rate according to the label corresponding to each character in the address text.
[0066] Among them, the labeling accuracy rate is used to represent the probability of whether the labeling result of each character in the address text by the BERT algorithm layer is correct.
[0067] Specifically, step S103 includes:
[0068] Step C1: Starting from the first character of the address text, sequentially determine whether the label of each character in the address text meets the preset labeling rules, and count the number of characters that meet the labeling rules;
[0069] Among them, the labeling rules include at least one of the following:
[0070] The label of the first character in the address text must be an address head label or a non-address label;
[0071] The label of the character after a character labeled with an address head label must be an address non-head label;
[0072] The label of the character after a character labeled with a non-address label cannot be an address non-head label.
[0073] Step C2: Use the ratio of the number of characters that meet the labeling rules to the total number of characters in the address text as the labeling accuracy rate.
[0074] Furthermore, step C1 further includes:
[0075] If a character that does not meet the labeling rules appears in the address text, correct the label of the character that does not meet the labeling rules according to the labeling rules.
[0076] In this embodiment, sequentially determine whether the label of each character in the address text meets the labeling rules. If there is a label that does not meet the labeling rules, for example: I (O) come (O) from (O) Jiang (B) Su (I) Province (I) Su (B) Zhou (B) City (I), among which, the label corresponding to the character "Zhou" does not meet the labeling rules, that is, the label of the character after a character labeled with an address head label must be an address non-head label. Therefore, modify the label B corresponding to the character "Zhou" to I according to the labeling rules. The modified address text is I (O) come (O) from (O) Jiang (B) Su (I) Province (I) Su (B) Zhou (I) City (I).
[0077] In this embodiment, the address segmentation model CRF algorithm layer is used to verify the annotation results of the BERT algorithm layer according to the annotation rules, which can reduce the occurrence of annotation errors in the word segmentation or annotation process and make the annotation results more accurate.
[0078] Step S104: when the annotation accuracy is greater than a preset threshold, the address elements in the address text are determined according to the annotation corresponding to each word in the address text, and a corresponding address element type label is added to each address element.
[0079] Among them, the address element type label is used to characterize the type of the address element. The address segmentation model can search for the corresponding address element type label according to the address element. In this embodiment, 21 available address element type labels are pre-designed for the address text, including: province (prov), city (city), county (district), district (devzone), town (town), village (community), group (village group), road (road), road number (roadno), point of interest (poi), sub-point of interest (subpoi), building number (houseno), unit number (cellno), floor number (floorno), household number (roomno), hierarchical relationship (detail), auxiliary positioning word (assist, such as nearby), distance positioning word (distance, such as meters), intersection (intersection), non-address element (redundant) and the above-mentioned uncovered area (others, address elements with word errors in the address text or that cannot be queried through the Chinese address tree).
[0080] Specifically, when the annotation accuracy is greater than a preset threshold, determining the address element in the address text according to the annotation corresponding to each word in the address text includes:
[0081] Determining address elements in the address text according to the words added with the address header mark and the words added with the address non-header mark in the address text;
[0082] The address element is N consecutive words in the address text, and the first word in the address element is added with an address header mark and the other words in the address element except the first word are added with address non-header marks; wherein N is a positive integer.
[0083] In this embodiment, starting from the first word, it is determined word by word whether the label of each word in the address text is an address header label; in the case of an address header label, it is determined whether there are one or more consecutive words with address non-header labels after the word with the address header label. If so, the word with the address header label and these consecutive words with address non-header labels are regarded as one address element.
[0084] Furthermore, the step of adding a corresponding address element type label to each address element specifically includes:
[0085] Step D1: Determine whether the address element exists in a preset Chinese address tree;
[0086] If so, obtaining an address element type tag corresponding to the address element from the Chinese address tree;
[0087] If not, a non-address element tag is added to the address element.
[0088] Furthermore, before step D1, the method further includes:
[0089] Step E1: Obtaining address element data of each province from a preset map database;
[0090] Among them, the map database crawls the address element data including China through the national official address website, and stores the address element data of each province according to the province.
[0091] Step E2: dividing the address element data of the target province according to the preset address element types, obtaining the address element data of the target province under each address element type, and adding a corresponding address element type label to the address element data under each address element type, so as to construct an address tree of the target province;
[0092] Step E3: Construct the Chinese address tree based on the address trees of all provinces.
[0093] Furthermore, step S104 further includes:
[0094] If all the consecutive M characters in the address text are non-address tags, non-address element tags are added to the consecutive M characters; wherein M is a positive integer.
[0095] Among them, in the address element type tag, the non-address element (redundant) tag is used to add a tag to the word with the non-address element mark.
[0096] Furthermore, step S104 further includes:
[0097] It is determined whether each word of the address text is added with an address element type tag or a non-address element tag. If not, a non-address element tag is added.
[0098] In this embodiment, the address element is determined from the address text according to the annotation, and then the preset Chinese address tree is used to determine whether the address element is in the Chinese address tree and the address element type label corresponding to the address element in the Chinese address tree. Finally, the corresponding address element type label is added to the address element in the address text that is determined to exist in the Chinese address tree, and the non-address element label is added to the word other than the address element in the address text. Since the address element identified by the address cutting model may have errors, in this embodiment, the Chinese address tree is added to verify the address element identified by the address cutting model, so as to ensure the accuracy of the identified address element.
[0099] Furthermore, the method further comprises:
[0100] If the annotation accuracy is less than the preset threshold, the address text is returned to the BERT algorithm layer and each word in the address text is re-annotated; the re-annotated address text is then input into the CRF algorithm layer to recalculate the annotation accuracy until the calculated annotation accuracy is greater than the preset threshold.
[0101] Step S105: displaying the address elements and address element type labels in the address text in pairs to complete the address cutting operation on the address text.
[0102] In this embodiment, the address cutting model is input with an address text of "6th Floor, Unit 2, Building 1, Yongyi Shanyu City, Rongjun Street, Yufeng District, Liuzhou City, Guangxi Zhuang Autonomous Region Note_The courier does not need to call, just drop it off at the property office, thank you, no need to call, I have too many phone calls, please understand", then the target address text output by the address cutting model is expressed as "prov=Guangxi Zhuang Autonomous Region city=Liuzhou City district=Yufeng District town=Rongjun Street poi=Yongyi Shanyu City houseno=Building 1 cellno=Unit 2 floorno=6th Floor O=Note_The courier does not need to call, just drop it off at the property office, thank you, no need to call, I have too many phone calls, please understand".
[0103] In this embodiment, the address text is input into the BERT algorithm layer in the address segmentation model to identify the address elements in the address text and annotate the identified address elements, thereby achieving the effect of segmenting the address text according to the address elements; the annotation results output by the BERT algorithm layer are then input into the CRF algorithm layer and the annotation results are calibrated according to the annotation rules, thereby reducing the occurrence of annotation errors during word segmentation or annotation, making the address segmentation effect more accurate; finally, the address elements in the address text are displayed, achieving a more automatic, accurate and efficient address segmentation effect.
[0104] Embodiment 2
[0105] The embodiment of the present invention provides a device for cutting addresses, such as Figure 2 As shown, the device specifically includes the following components:
[0106] The acquisition module 201 is used to acquire the address text to be processed and acquire a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer;
[0107] A labeling module 202, configured to add a corresponding label to each word in the address text using the BERT algorithm layer; wherein the label is used to indicate whether the word in the address text belongs to an address element;
[0108] A calibration module 203, configured to calculate a labeling accuracy rate according to the labeling corresponding to each word in the address text by using the CRF algorithm layer;
[0109] A determination module 204, configured to determine the address elements in the address text according to the annotations corresponding to each word in the address text when the annotation accuracy is greater than a preset threshold, and to add a corresponding address element type label to each address element;
[0110] The display module 205 is used to display the address elements and address element type labels in the address text in pairs to complete the address cutting operation on the address text.
[0111] Specifically, the marking module 202 is used to:
[0112] The BERT algorithm layer is used to calculate the probability value of each word in the address text under various preset annotations; wherein the preset annotations include: address header annotation, address non-header annotation and non-address annotation;
[0113] According to the probability values of the target word in the address text under various preset annotations, the annotation corresponding to the maximum probability value is added to the target word.
[0114] In addition, the marking module 202 is also used for:
[0115] Using the BERT algorithm layer to perform word segmentation on the address text to obtain each word segment;
[0116] Determine in sequence whether each of the segmented words exists in a preset Chinese address tree;
[0117] If yes, add an address header mark to the first word in the word segmentation, and add address non-header marks to other words in the word segmentation except the first word; if no, add non-address marks to each word in the word segmentation.
[0118] Specifically, the calibration module 203 includes:
[0119] A counting unit, used to determine, starting from the first word of the address text, whether the marking of each word in the address text satisfies a preset marking rule, and count the number of words that meet the marking rule;
[0120] The calculation unit is used to use the ratio of the number of words that meet the marking rule to the total number of words in the address text as the marking accuracy rate.
[0121] Furthermore, the statistical unit is specifically used for:
[0122] If a word that does not satisfy the marking rule appears in the address text, the marking of the word that does not satisfy the marking rule is corrected according to the marking rule.
[0123] Specifically, the determining module 204 is used to:
[0124] Determining address elements in the address text according to the words added with the address header mark and the words added with the address non-header mark in the address text;
[0125] The address element is N consecutive words in the address text, and the first word in the address element is added with an address header mark and the other words in the address element except the first word are added with address non-header marks; wherein N is a positive integer.
[0126] Furthermore, the determining module 204 is further configured to:
[0127] Determining whether the address element exists in a preset Chinese address tree;
[0128] If so, obtaining an address element type tag corresponding to the address element from the Chinese address tree;
[0129] If not, a non-address element tag is added to the address element.
[0130] Furthermore, the device also includes:
[0131] A component module is used to obtain the address element data of each province from a preset map database; divide the address element data of the target province according to the preset address element type, obtain the address element data of the target province under each address element type, and add a corresponding address element type label to the address element data under each address element type to construct the address tree of the target province; and construct the Chinese address tree based on the address trees of all provinces.
[0132] Furthermore, the determining module 204 is further configured to:
[0133] Determine whether each word of the address text is added with an address element type tag or a non-address element tag, and if not, add a non-address element tag;
[0134] If all the consecutive M characters in the address text are non-address tags, non-address element tags are added to the consecutive M characters.
[0135] Furthermore, the device also includes:
[0136] The return module is used to return the address text to the BERT algorithm layer and re-annotate each word in the address text if the annotation accuracy is less than a preset threshold; and then input the re-annotated address text into the CRF algorithm layer to recalculate the annotation accuracy until the calculated annotation accuracy is greater than the preset threshold.
[0137] In this embodiment, the address text is input into the BERT algorithm layer in the address segmentation model to identify the address elements in the address text and annotate the identified address elements, thereby achieving the effect of segmenting the address text according to the address elements; the annotation results output by the BERT algorithm layer are then input into the CRF algorithm layer and the annotation results are calibrated according to the annotation rules, thereby reducing the occurrence of annotation errors during word segmentation or annotation, making the address segmentation effect more accurate; finally, the address elements in the address text are displayed, achieving a more automatic, accurate and efficient address segmentation effect.
[0138] Embodiment 3
[0139] This embodiment also provides a computer device, such as a smart phone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server or cabinet server (including an independent server or a server cluster composed of multiple servers) that can execute programs. Figure 3As shown, the computer device 30 of this embodiment includes at least but not limited to: a memory 301 and a processor 302 that can communicate with each other via a system bus. It should be noted that Figure 3 Only computer device 30 is shown with components 301 - 302 , but it should be understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.
[0140] In this embodiment, the memory 301 (i.e., a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 301 may be an internal storage unit of the computer device 30, such as a hard disk or a memory of the computer device 30. In other embodiments, the memory 301 may also be an external storage device of the computer device 30, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. equipped on the computer device 30. Of course, the memory 301 may also include both the internal storage unit and the external storage device of the computer device 30. In this embodiment, the memory 301 is generally used to store the operating system and various application software installed on the computer device 30. In addition, the memory 301 may also be used to temporarily store various types of data that have been output or are to be output.
[0141] In some embodiments, the processor 302 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 302 is generally used to control the overall operation of the computer device 30 .
[0142] Specifically, in this embodiment, the processor 302 is used to execute the program of the method for cutting addresses stored in the memory 301, and the program of the method for cutting addresses is implemented as follows when being executed:
[0143] Obtaining the address text to be processed and obtaining a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer;
[0144] Using the BERT algorithm layer, adding a corresponding annotation to each word in the address text; wherein the annotation is used to indicate whether the word in the address text belongs to an address element;
[0145] Calculate the labeling accuracy rate according to the labeling corresponding to each word in the address text by using the CRF algorithm layer;
[0146] When the annotation accuracy is greater than a preset threshold, the address elements in the address text are determined according to the annotation corresponding to each word in the address text, and a corresponding address element type label is added to each address element;
[0147] The address elements and address element type labels in the address text are displayed in pairs to complete the address cutting operation on the address text.
[0148] The specific implementation process of the above method steps can be found in the first embodiment, and this embodiment will not be repeated here.
[0149] Embodiment 4
[0150] This embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, a server, an App application store, etc., on which a computer program is stored. When the computer program is executed by a processor, the following method steps are implemented:
[0151] Obtaining the address text to be processed and obtaining a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer;
[0152] Using the BERT algorithm layer, adding a corresponding annotation to each word in the address text; wherein the annotation is used to indicate whether the word in the address text belongs to an address element;
[0153] Calculate the labeling accuracy rate according to the labeling corresponding to each word in the address text by using the CRF algorithm layer;
[0154] When the annotation accuracy is greater than a preset threshold, the address elements in the address text are determined according to the annotation corresponding to each word in the address text, and a corresponding address element type label is added to each address element;
[0155] The address elements and address element type labels in the address text are displayed in pairs to complete the address cutting operation on the address text.
[0156] The specific implementation process of the above method steps can be found in the first embodiment, and this embodiment will not be repeated here.
[0157] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0158] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0159] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.
[0160] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for cutting addresses, It is characterized in that The method comprises: Obtaining the address text to be processed and obtaining a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer; Using the BERT algorithm layer, adding a corresponding annotation to each word in the address text; wherein the annotation is used to indicate whether the word in the address text belongs to an address element; Calculate the labeling accuracy rate according to the labeling corresponding to each word in the address text by using the CRF algorithm layer; When the annotation accuracy is greater than a preset threshold, the address elements in the address text are determined according to the annotation corresponding to each word in the address text, and a corresponding address element type label is added to each address element; The address elements and address element type labels in the address text are displayed in pairs to complete the address cutting operation on the address text; The step of adding a corresponding address element type label to each address element specifically includes: Determining whether the address element exists in a preset Chinese address tree; If so, obtaining an address element type tag corresponding to the address element from the Chinese address tree; If not, adding a non-address element tag to the address element; The method further comprises: Obtain the address element data of each province from the preset map database; The address element data of the target province are divided according to the preset address element types to obtain the address element data of the target province under each address element type, and a corresponding address element type label is added to the address element data under each address element type to construct an address tree of the target province; The Chinese address tree is constructed based on the address trees of all provinces.
2. The method for cutting addresses according to claim 1, It is characterized in that The BERT algorithm layer adds corresponding annotations to each word in the address text, specifically including: The BERT algorithm layer is used to calculate the probability value of each word in the address text under various preset annotations; wherein the preset annotations include: address header annotation, address non-header annotation and non-address annotation; According to the probability values of the target word in the address text under various preset annotations, the annotation corresponding to the maximum probability value is added to the target word.
3. The method for cutting addresses according to claim 1 or 2, It is characterized in that The CRF algorithm layer calculates the annotation accuracy according to the annotation corresponding to each word in the address text, specifically including: Starting from the first word of the address text, determining in turn whether the marking of each word in the address text satisfies a preset marking rule, and counting the number of words that meet the marking rule; The ratio of the number of words that meet the marking rule to the total number of words in the address text is used as the marking accuracy rate.
4. The method for cutting addresses according to claim 2, It is characterized in that When the annotation accuracy is greater than a preset threshold, determining the address element in the address text according to the annotation corresponding to each word in the address text specifically includes: Determining address elements in the address text according to the words added with the address header mark and the words added with the address non-header mark in the address text; The address element is N consecutive words in the address text, and the first word in the address element is added with an address header mark, and the other words in the address element except the first word are added with an address non-header mark.
5. The method for cutting addresses according to claim 2, It is characterized in that The method further comprises: If all the consecutive M characters in the address text are non-address tags, non-address element tags are added to the consecutive M characters.
6. A device for cutting addresses, It is characterized in that The device comprises: An acquisition module is used to acquire the address text to be processed and acquire a pre-trained address segmentation model; wherein the address segmentation model includes: a BERT algorithm layer and a CRF algorithm layer; A labeling module, used to add a corresponding label to each word in the address text using the BERT algorithm layer; wherein the label is used to indicate whether the word in the address text belongs to an address element; A calibration module, used to calculate the annotation accuracy rate according to the annotation corresponding to each word in the address text by using the CRF algorithm layer; A determination module, configured to determine the address elements in the address text according to the annotations corresponding to each word in the address text when the annotation accuracy is greater than a preset threshold, and to add a corresponding address element type label to each address element; A display module, used to display the address elements and address element type labels in the address text in pairs, so as to complete the address cutting operation on the address text; Wherein, the determination module is specifically used for: Determine whether the address element exists in a preset Chinese address tree; if so, obtain an address element type tag corresponding to the address element from the Chinese address tree; if not, add a non-address element tag to the address element; The device also includes: A construction module is used to obtain the address element data of each province from a preset map database; divide the address element data of the target province according to the preset address element type, obtain the address element data of the target province under each address element type, and add the corresponding address element type label to the address element data under each address element type to construct the address tree of the target province; and construct the Chinese address tree based on the address trees of all provinces.
7. A computer device, wherein the computer device include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
