A method, system, electronic device and computer storage medium for region matching
Through the combination of AC automata and the regional hierarchical relationship structure tree, the accuracy and efficiency of regional matching in the existing technology are solved, and efficient and accurate regional identification and completion are achieved.
Patent Information
- Application Number
- CN202510255087.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-03-05
AI Technical Summary
In the prior art, when matching the region in the processing organization name, there are insufficient accuracy and performance bottlenecks, which are difficult to adapt to the diversity and variation of the region name.
The AC automata and the regional hierarchical relationship structure tree are used to preprocess the regional pattern string, and the candidate region list is constructed and hierarchical verification is performed. The region coding rules are used to select the region coding with the smallest hierarchy as the matching result, and the region hierarchical relationship structure tree is completed.
It significantly improves the efficiency and accuracy of regional matching, can adapt to the updates and changes of regional names, and provides good scalability and stability.
Smart Images

Figure CN119739806B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the technical field of computer information processing, and particularly relates to a region matching method and system, an electronic device, and a computer storage medium. Background Art
[0002] Matching the region in the organization name is crucial for precise positioning, regional management, market analysis, resource allocation, and business collaboration, improving data processing efficiency and accuracy, optimizing the customer service experience, and enhancing operational effectiveness.
[0003] In the prior art, the region in the organization name generally adopts a simple string matching technique or a regular expression matching method. These methods perform poorly in dealing with the complexity and diversity of region names. Due to the diversity and variability of region names, the limitations of the prior art lead to insufficient accuracy of the matching results and performance bottlenecks in large-scale data processing. Therefore, it is of great significance to study an efficient and accurate region matching method. Summary of the Invention
[0004] To solve the above problems, the present disclosure provides a region matching method and system, an electronic device, and a computer storage medium, which adopt an AC automaton and a region hierarchical relationship structure tree, and can quickly realize the high-speed processing of region matching in a large number of organization names, significantly improving the efficiency.
[0005] The present disclosure proposes a region matching method, which includes:
[0006] Obtain a query region text containing region information;
[0007] Use a pre-generated AC region automaton to search for matching region pattern strings in the query region text, and create a candidate region list using the searched region pattern strings;
[0008] Use a pre-constructed region hierarchical relationship structure tree to obtain a candidate region code list corresponding to the candidate region list, where the region hierarchical relationship structure tree contains the mapping relationship between region names and identification codes;
[0009] Based on the region coding rules, perform province-city-county level verification on the candidate region code list to obtain region codes that pass the level verification;
[0010] Select a region code with the smallest level from the region codes that pass the level verification, and use the region represented by the selected region code with the smallest level as the region matching the query region text.
[0011] Further, performing province-city-county level verification on the candidate region code list based on the region coding rules to obtain region codes that pass the level verification includes:
[0012] Based on the regional coding rules, perform county-level verification on the candidate regional coding list;
[0013] If the county-level verification is passed, terminate the verification and obtain the regional coding that passes the county-level verification;
[0014] If the county-level verification fails, perform city-level verification on the candidate regional coding list;
[0015] If the city-level verification is passed, terminate the verification and obtain the regional coding that passes the city-level verification;
[0016] If the city-level verification fails, perform provincial-level verification on the candidate regional coding list;
[0017] If the provincial-level verification is passed, obtain the regional coding that passes the provincial-level verification.
[0018] Furthermore, performing county-level verification on the candidate regional coding list includes:
[0019] Based on the regional coding rules, extract the regional coding containing the county-level coding from the regional coding corresponding to each candidate region to obtain a list of candidate regions at the county level;
[0020] Judge whether the number of regions in the list of candidate regions at the county level is greater than half of the number of regions in the candidate regional coding list, and judge whether there is a regional coding corresponding to one candidate region in the list of candidate regions at the county level that is the same as the regional coding corresponding to another candidate region;
[0021] If both are yes, judge that the county-level verification is passed, and use the identical regional coding as the regional coding that passes the county-level verification; if not both are yes, the county-level verification fails;
[0022] Performing city-level verification on the candidate regional coding list includes:
[0023] Based on the regional coding rules, truncate the number of digits of the coding in the candidate regional coding list to the city level to obtain a list of candidate regional codings at the city level;
[0024] Judge whether the number of regions corresponding to a regional coding in the list of candidate regional codings at the city level is greater than half of the total number of regions in the candidate regional coding list;
[0025] If so, the city-level verification is passed, determine the regional coding of the region whose number of corresponding regions is greater than half of the total number of regions in the candidate regional coding list, and use the coding before truncation corresponding to the determined regional coding as the regional coding that passes the city-level verification; if not, the city-level verification fails;
[0026] Performing provincial-level verification on the candidate regional coding list includes:
[0027] Based on the regional coding rules, truncate the coding digits in the candidate regional coding list to the provincial level to obtain a provincial candidate regional coding list;
[0028] Judge whether the number of regions corresponding to a regional coding in the provincial candidate regional coding list is greater than half of the total number of regions in the candidate region list;
[0029] If so, pass the provincial-level verification, determine the regional coding corresponding to the region where the number of regions is greater than half of the total number of regions in the candidate region list, and use the coding before truncation corresponding to the determined regional coding as the regional coding passing the verification; if not, fail the provincial-level verification.
[0030] Further, the method further includes:
[0031] According to the regional hierarchy relationship structure tree, complete the regional coding of the region that matches the query regional text; output the address represented by the completed regional coding.
[0032] Further, the AC regional automaton is constructed using a regional thesaurus, and the regional thesaurus includes: a standard regional name library and an abbreviation and alias library, where the abbreviation and alias library contains the mapping relationship between abbreviations, alternative names, and standard regional names.
[0033] Further, the AC regional automaton is generated in the following manner:
[0034] Use the regional name as the regional pattern string of the AC regional automaton;
[0035] Preprocess the regional pattern string;
[0036] Use the preprocessed regional pattern string to construct the initial state diagram of the AC regional automaton, where each state corresponds to a position in the preprocessed regional pattern string, the transfer edges between states correspond to the recognized characters, each state has a state marker code, and the state marker code uses different numerical values to represent the validity and invalidity of the state.
[0037] Further, the state marker code being 0 indicates that the state is invalid, and being 1 indicates that the state is valid;
[0038] The generated AC regional automaton is updated by the following method:
[0039] When adding a new regional name, perform the addition operation: add the new regional pattern string to the AC regional automaton and set the state marker codes of the corresponding states to 1;
[0040] When deleting a regional name, perform the deletion operation: modify the state marker code of the last state of the original regional name pattern string in the AC regional automaton to 0;
[0041] When modifying the region name, first perform the above deletion operation using the region name before modification as the original region name, and then perform the above addition operation using the modified region name as the newly added region name.
[0042] Further, preprocess the region pattern strings, specifically including:
[0043] Split each region pattern string character by character and count the word frequencies by character;
[0044] Set up a region name scoring mechanism, where the higher the descending rank of the word frequency statistics result, the lower the assigned score;
[0045] Calculate the scores for all region pattern strings using the set region name scoring mechanism, sort them in descending order according to the score results, and generate an ordered set of region pattern strings from high frequency to low frequency.
[0046] Further, construct a region hierarchy relationship structure tree in the following way:
[0047] Based on the region thesaurus, establish the hierarchical relationship between different administrative levels of provinces, cities, and counties;
[0048] Define a region coding rule, assign a unique identification code to each region, and at the same time establish a mapping relationship between the region name and the identification code to obtain the region hierarchy relationship structure tree.
[0049] The present disclosure also provides a region matching system, which includes: an acquisition unit, a candidate region list determination unit, a candidate region code list determination unit, a verification unit, and a matching region determination unit; where:
[0050] The acquisition unit is used to acquire a query region text containing region information;
[0051] The candidate region list determination unit is used to search for matching region pattern strings in the query region text using the pre-generated AC region automaton and create a candidate region list using the searched region pattern strings;
[0052] The candidate region code list determination unit is used to obtain a candidate region code list corresponding to the candidate region list using the pre-constructed region hierarchy relationship structure tree, and the region hierarchy relationship structure tree contains the mapping relationship between the region name and the identification code;
[0053] The verification unit is used to perform province-city-county level verification on the candidate region code list based on the region coding rule to obtain the region codes that pass the level verification;
[0054] A matching area determination unit, configured to select, from the area codes that pass the hierarchical verification, an area code with the smallest level, and use the area represented by the selected area code with the smallest level as the area that matches the query area text.
[0055] The present disclosure also provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;
[0056] The memory is used to store computer programs;
[0057] The processor is configured to implement the above method steps when executing the programs stored on the memory.
[0058] The present disclosure also provides a computer storage medium. The computer storage medium is a readable storage medium, and a computer program is stored therein. When the computer program is executed by a processor, the above method steps are implemented.
[0059] Compared with the prior art, the present disclosure has the following advantages:
[0060] 1. Based on the design of the AC automaton, it can quickly realize the high-speed processing of area matching in a large number of institutional names, significantly improving the efficiency;
[0061] 2. The improved AC automaton has good scalability, can adapt to the update and change of area names, and ensure the applicability and stability of the algorithm during long-term operation;
[0062] 3. The present invention constructs a regional hierarchical relationship structure tree by using a custom coding method, which can more accurately identify and match the regions in institutional names and complete the regional information supplementation for missing regions.
[0063] Other features and advantages of the present disclosure will be described in the subsequent specification, and part of them will become obvious from the specification, or be understood by implementing the present disclosure. The objectives and other advantages of the present disclosure can be achieved and obtained through the structures pointed out in the specification, claims, and drawings. Description of the Drawings
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0065] Figure 1 Shows one of the flowcharts of the area matching method according to the embodiments of the present disclosure;
[0066] Figure 2 Shows the second flowchart of the region matching method according to an embodiment of the present disclosure;
[0067] Figure 3 Shows the preprocessing flowchart of the region pattern string according to an embodiment of the present disclosure;
[0068] Figure 4 Shows the schematic diagram of the status flag code assignment process according to an embodiment of the present disclosure;
[0069] Figure 5 Shows a partial state diagram of the AC region automaton according to an embodiment of the present disclosure;
[0070] Figure 6 Shows a schematic diagram of a partial region hierarchy relationship according to an embodiment of the present disclosure;
[0071] Figure 7 Shows the flowchart of the region name matching according to an embodiment of the present disclosure;
[0072] Figure 8 Shows the flowchart of the region hierarchy verification and completion according to an embodiment of the present disclosure. Detailed implementation manners
[0073] The present disclosure proposes a region matching method, as Figure 1 shown, including the following steps:
[0074] Step 101: Obtain a query region text containing region information;
[0075] Step 102: Use the pre-generated AC region automaton to search for matching region pattern strings in the query region text, and use all the searched region pattern strings as the candidate region list;
[0076] Step 103: Use the pre-constructed region hierarchy relationship structure tree to obtain a candidate region code list corresponding to the candidate region list, and the region hierarchy relationship structure tree contains the mapping relationship between the region name and the identification code;
[0077] Step 104: Based on the region coding rule, perform province-city-county level verification on the candidate region code list to obtain the region codes that pass the level verification;
[0078] Step 105: Select a region code with the smallest level from the region codes that pass the level verification, and use the region represented by the selected region code with the smallest level as the region matching the query region text.
[0079] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0080] Figure 2 A schematic diagram of a regional matching method according to an embodiment of the present disclosure is shown. The matching method is implemented based on an AC (Aho-Corasick automaton). The embodiment of the present disclosure takes an institution name text as an example of a query regional text containing regional information. However, the query regional text of the present disclosure is not limited to the institution name text. The method of the embodiment of the present disclosure is as follows: Figure 2 As shown, it includes the following steps:
[0081] Step 1: Build a regional vocabulary
[0082] Step 1.1. Collect regional data
[0083] Collect regional names and previously used regional names from authoritative geographic databases and official data, including provinces, cities, districts and counties, which are the basic units that constitute the regional vocabulary. In actual application scenarios, the expressions of regional names are often diverse, and it is necessary to conduct in-depth research and integrate the abbreviations and nicknames of various regions. For example, "Guangdong Province" is often referred to as "Yue", "Shanghai" is sometimes abbreviated as "Hu", and "Chongqing City" has the abbreviation "Yu". In addition, some regions have well-known nicknames, such as "Yangcheng" refers to Guangzhou, and "Rongcheng" represents Chengdu, which all need to be included in the regional vocabulary.
[0084] Step 1.2: Obtain the standard region name library and abbreviation alias library
[0085] The collected data may have multiple writing methods, spelling errors, homophones, and other problems. Therefore, data cleaning is crucial, including removing duplicates, correcting errors, and unifying naming rules. At the same time, strict screening and verification are carried out to eliminate inaccurate regional names. Create a mapping relationship between abbreviations and aliases and standard regional names to generate an abbreviation alias library. Integrate the obtained standard regional name library with the abbreviation alias library to eventually form a comprehensive regional vocabulary.
[0086] Step 2: Generate AC region automaton
[0087] Step 2.1: Regional pattern string preprocessing
[0088] Use the region names collected in Step 1 as the pattern strings of the AC region automaton, and preprocess the region pattern strings to reduce the size and complexity of the automaton. The specific preprocessing process of the region pattern strings is as Figure 3 shown:
[0089] Step 2.1.1, Word frequency statistics
[0090] For each region pattern string, perform a character-by-character split and count the word frequencies character by character to obtain the word frequency statistics results.
[0091] Step 2.1.2, Set the scoring criteria
[0092] Set the region name scoring mechanism in descending order according to the word frequency statistics results in Step 2.1.1. The higher the descending ranking of the word frequency statistics results, the lower the assigned score.
[0093] Specifically, words ranked in the top 10% can be assigned 3 points, words ranked between 10% - 30% can be assigned 2 points, and the rest can be assigned 1 point.
[0094] Step 2.1.3, Sort the region pattern strings
[0095] For all region pattern strings, adopt the scoring mechanism in Step 2.1.2, add up the scores of each character in each region pattern string to obtain the score of the region pattern string;
[0096] Sort the score results of all region pattern strings in descending order to generate an ordered set of region pattern strings from high frequency to low frequency.
[0097] After the above preprocessing of the region pattern strings, the size of the generated AC region automaton can be reduced, and the subsequent region matching efficiency can be improved.
[0098] Step 2.2, Design the AC region automaton
[0099] Step 2.2.1, Add the status flag code F
[0100] In order to adapt to situations such as region name updates and changes, the AC automaton needs to be improved. Add the status flag code F to each state in the original AC automaton. Specifically, 0 represents the failure state, and 1 represents the valid state.
[0101] The process of assigning the status flag code is specifically as Figure 4 shown.
[0102] For newly added region names, perform the addition operation: add the newly added region pattern string in the AC region automaton, and set the status flag code F of the corresponding state to 1;
[0103] When deleting the region name, perform the deletion operation: in the AC region automaton, modify the state flag code F of the last state of the original region name pattern string to 0;
[0104] When modifying the region name, first perform the above deletion operation with the region name before modification as the original region name, and then perform the above addition operation with the region name after modification as the newly added region name.
[0105] It should be noted that when updating the AC region automaton, the region thesaurus also needs to be updated. Specifically: when adding, when modifying, find the original region name in the region thesaurus, that is, the region name before modification, delete the mapping relationship between the original region name and the standard region name, and create a mapping relationship between the region name after modification and the standard region name. When deleting, find the original region name in the region thesaurus, that is, the region name to be deleted, and delete the mapping relationship between the original region name and the standard region name.
[0106] Step 2.2.2, Generate the AC region automaton
[0107] Using the ordered set of region pattern strings from high frequency to low frequency obtained by preprocessing, construct the initial state diagram of the AC region automaton. Among them, each state corresponds to a position in the region pattern string, the transition edge between states corresponds to the recognized character, each state has a state flag code, and different numerical values are used for the state flag code to represent the validity and invalidity of the state. Specifically, as Figure 5 is the partial state diagram of the AC region automaton, showing the state diagrams of partial region pattern strings "Shanghai", "Shangrao", "Hainan Province", and "Hainan District".
[0108] In the embodiment of the present invention, introducing the AC region automaton can greatly improve its matching efficiency when dealing with large-scale data processing, and improve it. When dealing with the update and change of region names, it has good scalability.
[0109] Step 3, Establish the regional hierarchical relationship structure tree
[0110] Step 3.1, Construct the regional hierarchical relationship structure tree
[0111] An important feature of geographical information is that there is a clear inclusion relationship between regions. For example, "Beijing City" includes "Dongcheng District". According to the data in the region thesaurus, establish the hierarchical relationship between different administrative levels such as provinces, cities, and counties. Usually, a tree structure is established to realize the hierarchical relationship between regions, where each node represents a region, and the parent node represents the region at the previous level. Specifically, as Figure 6 shown, it shows the hierarchical relationship between some regions in Hainan Province, a city.
[0112] Step 3.2, Formulate the regional coding rule
[0113] According to the regional hierarchical relationship structure tree which includes three levels of hierarchical relationships: provinces, cities, and counties, a set of regional name coding rules is formulated. Fixed-length coding can be adopted, and each node is coded with two decimal digits. This custom coding method can conveniently reflect its superior region. Each region is assigned a unique identification code, and at the same time, a mapping relationship is established between the regional name and the identification code. Figure 6 The complete regional code totals 6 digits. Among them, the first two digits represent the provincial mark, the middle two digits represent the municipal mark, and the last two digits represent the district / county mark. For example, Figure 6 The code for Meilan District in Hainan Province is 460108. Among them, 46 represents Hainan Province at the provincial level, 01 represents Haikou City at the municipal level, and 08 represents Meilan District at the district / county level. Figure 6 The regional code for Hainan Province is 460000, the regional code for Haikou City is 460100, the regional code for Meilan District is 460108, the regional code for Sanya District is 460200, the regional code for Haitang District is 460202, the regional code for Anhui Province is 340000, the regional code for Huangshan City is 341000, and the regional code for Huangshan District is 341003; the regional code for Jilin Province is 220000, the regional code for Changchun City is 220100, and the regional code for Chaoyang District is 220104 are given.
[0114] For China, here it can be coded according to the China Administrative Division Code Lookup Table, and the coding rules stipulate the code format.
[0115] Step 4: Regional Name Matching
[0116] Regional name matching is a process of using the generated AC regional automaton to identify and match the regional part in the input organization name, and verifying and complementing the matching results according to the regional hierarchical relationship. The regional name matching flowchart is as Figure 7 shown.
[0117] Step 4.1: Text Preprocessing
[0118] In the text preprocessing stage of regional name matching, the input organization name text is standardized, including converting full-width to half-width, removing special characters and spaces, etc. Then, the stop word list is used to remove common irrelevant words, such as "company", "group", etc., to improve the accuracy and speed of matching.
[0119] For example: Suppose the input organization name text is "Meiya Qiongguang Technology Co., Ltd. (Limited Partnership) in Hainan District".
[0120] The input organization name text is standardized, and irrelevant words such as "company" and "(Limited Partnership)" are removed to obtain "Meiya Qiongguang Technology in Hainan District".
[0121] Step 4.2: AC Regional Automaton Search
[0122] Use the AC regional automaton to search for all possible regional names in the preprocessed institutional name text, collect all matching regional pattern strings, and eliminate the regional pattern strings where the value of the status flag code F is 0 to form a list of candidate regions.
[0123] Continuing with the example in step 4.1, use the Figure 5 AC regional automaton in to search for all possible regional names in "Hainan District Meiya Qiongguang Technology" obtained in step 4.1. According to Figure 5 The obtained regional pattern strings are: Hainan, Hainan District, Meiya. Eliminate the regional pattern string Hainan District where the value of the status flag code F is 0. The formed list of candidate regions is Hainan, Meiya.
[0124] Step 4.3, Regional Hierarchy Verification and Completion
[0125] Obtain the regional codes corresponding to each candidate region in the list of candidate regions to get a list of candidate regional codes; according to the regional code rules, perform a hierarchy relationship verification to check whether the regions in the list of candidate regions are hierarchically included in each other; preferentially select more specific regions and complete the regions with partially disclosed regions according to the regional hierarchy relationship structure tree. The flow chart of regional hierarchy verification and completion is as Figure 8 shown, Figure 8 The regional hierarchy structure tree in is the regional hierarchy relationship structure tree, and the set of regional codes is the list of regional codes.
[0126] Step 4.3.1, Obtain the List of Regional Codes
[0127] Utilize the regional hierarchy relationship structure tree, the standard regional name library, and the abbreviation and alias library to obtain the list of regional codes corresponding to the list of candidate regions, providing a basis for subsequent verification between regional hierarchies.
[0128] Suppose the input query regional text is "No. 1, Hongqi Street, Huangshan Road, Chaoyang District, Changchun". Then, according to Figure 6 The obtained list of candidate regions is "Changchun", "Chaoyang District", and "Huangshan". At this time, the corresponding regional code for "Changchun" is "220100", there are two regional codes for "Chaoyang District", namely "110105" and "220104", and there are two regional codes for "Huangshan", namely "341000" and "341003"; since there is also a Chaoyang District in other cities, although Figure 6 the Chaoyang District of Beijing is not shown in, here for the purpose of illustration, another regional code 110105 is also assigned to the Chaoyang District of other cities.
[0129] The list of regional codes obtained here is: 220100, 110105, 220104, 341000, 341003.
[0130] Step 4.3.2: Perform province / city / county level verification
[0131] In this step 4.3.2, based on the area coding rule, the province / city / county level verification is performed on the candidate area coding list to obtain the area coding that passes the level verification; then, from the area coding that passes the level verification, an area coding with the smallest level is selected, and the area represented by the selected area coding with the smallest level is used as the area that matches the query area text.
[0132] Preferably, based on the area coding rule, the province / city / county level verification can be performed on the candidate area coding list in the order from the lowest level to the highest level; when the current level verification fails, the previous level verification is performed; when the current level verification passes, the verification is terminated.
[0133] Specifically, it includes the following first to fourth steps:
[0134] First step: According to the area coding rule in step 3.2, first perform county level verification on the candidate area coding list to determine whether the county level verification is passed. If so, execute the fourth step; if not, execute the second step;
[0135] Method for county level verification: Extract the area coding containing the county level coding. According to the example in 3.2, here the area coding with the county level area coding is the area coding whose last two digits are not 00. Create a county level candidate area list using the area that can extract the county level coding;
[0136] Judge whether the number of areas in the county level candidate area list is greater than half of the number of areas in the candidate area list, and judge whether there is a situation where the area coding corresponding to one candidate area in the county level candidate area list is the same as the area coding corresponding to another candidate area;
[0137] If both are yes, it is judged that the county level verification is passed, and the same area coding is used as the area coding that passes the county level verification; if not both are yes, the county level verification fails.
[0138] The county level verification is completed in two steps. 1): Judge whether the county level verification condition is met. If it is met, obtain the county level candidate area list; 2): Judge whether there is a situation where the area codings of two areas in the county level candidate area list are exactly the same. Here, the county level verification condition: The areas with the last two digits of the coding not being 00 account for more than half of the total number of areas in the candidate area list before the county level verification can be performed. If there is no area coding with the last two digits not being 00, directly perform the city level verification.
[0139] For example: "Changchun": "220100", "Chaoyang District": "110105" and "220104", "Huangshan": "341000" and "341003"
[0140] Extract the area codes of the last two digits that are not 00 for each region:
[0141] "Changchun": None
[0142] "Chaoyang District": "110105" and "220104"
[0143] "Huangshan": "341003"
[0144] Therefore, among the 3 regions in the candidate region list, 2 regions ("Chaoyang District" and "Huangshan") can perform county-level verification. The list composed of "Chaoyang District" and "Huangshan" is called the "county-level candidate region list".
[0145] Next, judge these 2 regions, "Chaoyang District" and "Huangshan", to determine whether the area codes are exactly the same.
[0146] Specifically as follows: Take "110105" in the area code corresponding to "Chaoyang District" and compare it with the code "341003" corresponding to "Huangshan". The area codes are not the same; then compare "220104" in the area code corresponding to "Chaoyang District" with the area code "341003" corresponding to "Huangshan". The area codes are also not the same.
[0147] The area codes in the above region list have all been compared. There is no area code that meets all the county-level candidate region lists, so the verification fails.
[0148] If there is an area code that meets all the county-level candidate region lists here, then the county-level verification passes.
[0149] Second step: Perform city-level verification on the candidate area code list to determine whether the city-level verification passes. If so, execute step four; if not, execute step three;
[0150] City-level verification method:
[0151] Based on the area code rule, truncate the number of digits of the codes in the candidate area code list to the city level to obtain the city-level candidate area code list;
[0152] Judge whether there is an area code in the city-level candidate area code list corresponding to an area where the number of regions is greater than half of the total number of regions in the candidate region list;
[0153] If so, the city-level verification passes. Determine the area code corresponding to the area where the number of regions is greater than half of the total number of regions in the candidate region list, and use the code before truncation corresponding to the determined area code as the area code passing the city-level verification; if not, the city-level verification fails.
[0154] According to the regional coding rule in step 3.2, the municipal-level verification is carried out in two steps: The first step: Extract or truncate the first 4 digits of the regional code; The second step: Judge whether there is a regional code in the extracted regional codes where the number of corresponding regions is greater than half of the total number of regions in the candidate region list.
[0155] 1) Extract the first 4 digits of the regional code for municipal-level regional verification. For example:
[0156] "Changchun": "220100"
[0157] "Chaoyang District": "110105" and "220104"
[0158] "Huangshan": "341000" and "341003"
[0159] Extract the first 4 digits of the regional code for each region to obtain the municipal-level candidate region code list:
[0160] "Changchun": 2201
[0161] "Chaoyang District": 1101 and 2201
[0162] "Huangshan": 3410
[0163] Traverse the municipal-level candidate region code list. As long as there is one region where the number of regions corresponding to the first 4-digit code is greater than half of the total number of regions in the candidate region list, the municipal-level verification passes.
[0164] For example: The regions corresponding to the first 4-digit region code 2201 are Changchun and Chaoyang District;
[0165] The region corresponding to the first 4-digit region code 1101 is Chaoyang District;
[0166] The region corresponding to the first 4-digit region code 3410 is Huangshan;
[0167] The total number of regions in the candidate region list is 3. Currently, the number of regions corresponding to the first 4-digit code 2201 is 2, which exceeds half of the total number of regions in the candidate region list. Therefore, the municipal-level verification passes, and the two region codes 220100 and 220104 are the region codes that pass the municipal-level verification.
[0168] If the number of regions corresponding to all the first 4-digit region codes does not exceed the total number of regions in the candidate region list, the municipal-level verification fails.
[0169] The third step: Conduct provincial-level verification on the candidate region code list to judge whether it passes the provincial-level verification. If so, execute the fourth step; if not, execute the fifth step;
[0170] Provincial verification method: Based on the regional coding rules, truncate the number of digits in the candidate regional coding list to the provincial level to obtain a provincial candidate regional coding list;
[0171] Determine whether the number of regions corresponding to a regional coding in the provincial candidate regional coding list is greater than half of the total number of regions in the candidate region list;
[0172] If so, pass the provincial verification, determine the regional coding corresponding to the region where the number of regions is greater than half of the total number of regions in the candidate region list, and use the coding before truncation corresponding to the determined regional coding as the regional coding passing the verification; if not, fail the provincial verification.
[0173] At this time, the provincial verification is divided into two steps: The first step: According to the regional coding rules in step 3.2, take the first 2 digits of the regional coding; The second step: Determine whether there is a regional coding among the taken regional codings where the number of corresponding regions is greater than half of the total number of regions in the candidate region list.
[0174] 1) Take the first 2 digits of the regional coding for provincial regional verification. For example:
[0175] "Changchun": "220100"
[0176] "Chaoyang District": "110105" and "220104"
[0177] "Huangshan": "341000" and "341003"
[0178] Extract the first 2 digits of the regional coding for each region to obtain a provincial candidate regional coding list:
[0179] "Changchun": 22
[0180] "Chaoyang District": 11 and 22
[0181] "Huangshan": 34
[0182] Traverse the provincial candidate regional coding list. As long as there is a region where the number of regions corresponding to the first 2 - digit coding is greater than half of the total number of regions in the candidate region list, the provincial verification passes.
[0183] For example: The regions corresponding to the first 2 - digit regional coding 22 are Changchun and Chaoyang District;
[0184] The regions corresponding to the first 2 - digit regional coding 11 are Chaoyang District;
[0185] The regions corresponding to the first 2 - digit regional coding 34 are Huangshan;
[0186] The total number of regions in the candidate region list is 3. The number of regions corresponding to the current first two digits of the code, 22, is 2, which exceeds half of the total number of regions in the candidate region list. Therefore, the provincial-level verification is passed. 220104 and 220100 are the region codes that have passed the provincial-level verification.
[0187] If the number of regions corresponding to all the first two-digit region codes does not exceed the total number of regions in the candidate address list, the provincial-level verification fails.
[0188] Step 4: From the region codes that have passed the hierarchical verification, select a region code with the smallest hierarchy, and use the region represented by the selected region code with the smallest hierarchy as the region that matches the query region text.
[0189] Taking the example of "No. 1, Hongqi Street, Huangshan Road, Chaoyang District, Changchun" passing the municipal-level verification:
[0190] "Changchun": "220100"
[0191] "Chaoyang District": "110105" and "220104"
[0192] "Huangshan": "341000", "341003"
[0193] The first four digits of the region code, 2201, represent Changchun and Chaoyang District and have passed the municipal-level verification. Next, from the list of region codes 220100 and 220104 that have passed the municipal-level verification, output the region represented by the region code 220104 with the smallest hierarchy in the list of region codes.
[0194] The selection rule is mainly to first look at the last two digits of the code. Priority is given to selecting those with the last two digits not being 00. If they are all 00, then priority is given to selecting those with the middle two digits not being 00. Otherwise, any region code can be selected. According to this rule, the region code with the smallest hierarchy in Changchun and Chaoyang District is 220104. Therefore, "Changchun Chaoyang District" is output.
[0195] Step 5: The output result is empty.
[0196] Step 4.3.3. Complete the address
[0197] When passing the provincial, municipal, and county-level hierarchical verification, supplement the previous hierarchical address according to the regional hierarchy relationship structure tree. For example, for the sample "No. 1, Hongqi Street, Huangshan Road, Chaoyang District, Changchun", the output address is "Changchun Chaoyang City". According to the regional hierarchy relationship structure tree, it lacks the provincial level. According to the completion rule, take the first two digits of the region code upward, and the generated region code is "34220104", and the address represented by it is "Changchun City, Jilin Province, Chaoyang City". Therefore, the address represented by the completed region code is specifically "Changchun City, Jilin Province, Chaoyang City".
[0198] Step 4.4. Output the matching result
[0199] After the above - mentioned step - by - step analysis, the address represented by the completed regional code is output, and the result is relatively accurate and context - relevant regional information.
[0200] The embodiments of the present invention make full use of the hierarchical relationship between regions. Especially in the face of situations such as regional abbreviations and aliases, it can complete regional supplementation and improve the accuracy of matching.
[0201] Based on the same inventive concept as the above - disclosed content, correspondingly, the present disclosure also provides a regional matching system. The system includes: an acquisition unit, a candidate region list determination unit, a candidate region code list determination unit, a verification unit, and a matching region determination unit; wherein:
[0202] The acquisition unit is used to acquire a query region text containing regional information.
[0203] The candidate region list determination unit is used to search for matching regional pattern strings in the query region text by using a pre - generated AC regional automaton, and create a candidate region list by using the searched regional pattern strings.
[0204] The candidate region code list determination unit is used to obtain a candidate region code list corresponding to the candidate region list by using a pre - constructed regional hierarchical relationship structure tree, and the regional hierarchical relationship structure tree contains the mapping relationship between region names and identification codes.
[0205] The verification unit is used to perform province - city - county level verification on the candidate region code list based on the regional code rules to obtain region codes that pass the level verification.
[0206] The matching region determination unit is used to select a region code with the smallest level from the region codes that pass the level verification, and use the region represented by the selected region code with the smallest level as the region matching the query region text.
[0207] Based on the same inventive concept as the above - disclosed content, correspondingly, the present disclosure also provides an electronic device. The electronic device in the embodiments of the present disclosure includes at least one processor and at least one memory that are electrically connected. The memory is electrically connected to the processor. Among them, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.
[0208] It should be noted that the electrical connections between the above - mentioned various units do not necessarily mean direct wire - to - wire connections. Indirect connection methods, as long as they can achieve the purpose of the present disclosure, are applicable to the embodiments of the present disclosure.
[0209] Based on the same inventive concept, the present invention also provides a computer storage medium, which is a readable storage medium and stores instructions executable by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to execute the method as described above.
[0210] Although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A region matching method, characterized in that: The method comprises: Get the query region text containing region information; Using the pre-generated AC region automaton to search for matching region pattern strings in the query region text, and using the searched region pattern strings to create a candidate region list; Using a pre-constructed region hierarchical relationship structure tree, a candidate region code list corresponding to the candidate region list is obtained, wherein the region hierarchical relationship structure tree includes a mapping relationship between region names and identification codes; Based on the regional coding rules, the candidate regional code list is verified at the provincial, municipal and county levels to obtain the regional codes that pass the level verification; From the region codes that pass the level check, a region code with the smallest level is selected, and the region represented by the selected region code with the smallest level is used as the region that matches the query region text; Generate AC region automata by: Use the region name as the region pattern string of the AC region automaton; Preprocess the regional pattern string; Using the preprocessed regional pattern string, construct the initial state graph of the AC regional automaton, wherein each state corresponds to a position in the preprocessed regional pattern string, the transition edges between states correspond to the recognized characters, each state has a state marking code, and the state marking code uses different values to indicate the validity and invalidity of the state; when the state marking code is the first value, it indicates that the state is invalid, and when it is the second value, it indicates that the state is valid; Update the generated AC region automaton by the following method: When adding a new region name, perform the adding operation: add the new region pattern string in the AC region automaton, and set the state marking codes of the corresponding states to the second value; When deleting a region name, a deletion operation is performed: in the AC region automaton, the state marking code of the last state of the original region name pattern string is modified to the first value; When modifying a region name, firstly perform the above-mentioned deletion operation on the region name before modification as the original region name, and then perform the above-mentioned addition operation on the region name after modification as the newly added region name.
2. The method according to claim 1, characterized in that Based on the regional coding rules, the candidate regional code list is verified at the provincial, municipal and county levels to obtain the regional codes that pass the level verification, including: Based on the regional coding rules, the candidate regional code list is verified at the county level; If the county-level verification is passed, the verification is terminated and the area code that has passed the county-level verification is obtained; If the county-level verification fails, the candidate area code list is verified at the city level; If the city-level verification is passed, the verification is terminated and the area code that has passed the city-level verification is obtained; If the city-level verification fails, the candidate area code list is verified at the provincial level; If it passes the provincial verification, the regional code that passes the provincial verification will be obtained.
3. The method according to claim 2, characterized in that Perform county-level verification on the candidate area code list, including: Based on the regional coding rules, the regional codes containing the county codes are extracted from the regional codes corresponding to each candidate region to obtain a list of county-level candidate regions; Determine whether the number of regions in the county-level candidate region list is greater than half of the number of regions in the candidate region list, and determine whether the region code corresponding to a candidate region in the county-level candidate region list is the same as the region code corresponding to another candidate region; If both are yes, it is judged that the county-level verification has been passed, and the consistent area code is regarded as the area code that has passed the county-level verification; if both are not yes, it is judged that the county-level verification has not been passed; Perform city-level verification on the candidate area code list, including: Based on the regional coding rules, the number of code digits in the candidate regional code list is truncated to the city level to obtain a city-level candidate regional code list; Determine whether there is a region code in the city-level candidate region code list whose number of regions is greater than half of the total number of regions in the candidate region code list; If yes, then through the city-level verification, determine the area code whose number of corresponding areas is greater than half of the total number of areas in the candidate area list, and use the code before truncation corresponding to the determined area code as the area code that has passed the city-level verification; if no, then it has failed the city-level verification; Provincial verification of candidate area code lists, including: Based on the regional coding rules, the number of code digits in the candidate regional code list is truncated to the provincial level to obtain a provincial candidate regional code list; Determine whether there is a region code in the provincial candidate region code list whose number of regions is greater than half of the total number of regions in the candidate region code list; If so, the provincial level verification is performed to determine the region code whose corresponding number of regions is greater than half of the total number of regions in the candidate region list, and the code before truncation corresponding to the determined region code is used as the region code that has passed the verification; if not, the provincial level verification is not performed.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: According to the regional hierarchical relationship structure tree, the regional code of the region matching the query regional text is completed; and the address represented by the completed regional code is output.
5. The method according to claim 1, characterized in that: The AC regional automaton is constructed using a regional vocabulary, which includes a standard regional name library and an abbreviation alias library, wherein the abbreviation alias library contains a mapping relationship between abbreviations and aliases and standard regional names.
6. The method according to claim 1, characterized in that A status mark code of 0 indicates that the status is invalid, and a status mark of 1 indicates that the status is valid.
7. The method according to claim 1, characterized in that Preprocess the regional pattern string, including: Split each regional pattern string word by word, and count the word frequencies by word; Set up a scoring mechanism for region names, where the higher the ranking of the word frequency statistics in descending order, the lower the score assigned; All regional pattern strings are scored using the set regional name scoring mechanism, and the scores are sorted in descending order to generate an ordered set of regional pattern strings from high frequency to low frequency.
8. The method according to claim 1, characterized in that The regional hierarchical relationship structure tree is constructed in the following ways: Based on the regional vocabulary, establish the hierarchical relationship between different administrative levels of provinces, cities and counties; Define the regional coding rules, assign a unique identification code to each region, and establish a mapping relationship between the region name and the identification code to obtain a regional hierarchical relationship structure tree.
9. A regional matching system, characterized in that: For implementing the method of claim 1, the system comprises: an acquisition unit, a candidate region list determination unit, a candidate region code list determination unit, a verification unit and a matching region determination unit; wherein: An acquisition unit, used for acquiring a query region text containing region information; A candidate region list determination unit, configured to search for a matching region pattern string in the query region text using a pre-generated AC region automaton, and create a candidate region list using the searched region pattern string; A candidate region code list determination unit is used to obtain a candidate region code list corresponding to the candidate region list by using a pre-constructed region hierarchical relationship structure tree, wherein the region hierarchical relationship structure tree includes a mapping relationship between region names and identification codes; A verification unit, used to verify the candidate area code list at the province, city and county levels based on the area code rule, and obtain the area code that passes the level verification; The matching region determination unit is used to select a region code with the smallest level from the region codes that have passed the level check, and use the region represented by the selected region code with the smallest level as the region that matches the query region text.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the steps of any method described in claims 1-8 when executing a program stored in a memory.
11. A computer storage medium, characterized in that: The computer storage medium is a readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of any method described in claims 1-8 are implemented.
Citation Information
Patent Citations
Administrative division information identification and standardization processing method and device and storage medium
CN116414824A
Address component identification method and device, computer equipment and storage medium
CN117454887A