A method and apparatus for creating a state transition trie oriented for address recognition
By using a state transition trie creation method, the problems of large storage space and low retrieval efficiency in address identification are solved, achieving efficient address identification and information access.
Patent Information
- Application Number
- CN202310094247.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-07
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2043-02-07
AI Technical Summary
Existing address recognition methods require large address dictionary storage space and low retrieval efficiency. Address trees need to store the hierarchical and jump relationships of adjacent address objects, resulting in even larger storage space and longer retrieval time. Furthermore, they cannot effectively handle address objects with the same name or overlapping prefixes.
A state transition trie creation method is adopted. By creating an address dictionary and generating a state transition trie, address names are arranged in lexicographical order, the parent-child relationship between adjacent characters in the address names is recorded, and arrays base and check are used to record the state transition of nodes. The state value of the leaf nodes records the address name number, which reduces storage space and establishes the association between the matching results and the address dictionary.
It significantly reduces storage space, improves the retrieval speed and accuracy of address recognition, can handle address objects with the same name or overlapping prefixes, and facilitates access to the corresponding address information after matching.
Smart Images

Figure CN116303849B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing and address recognition technology, specifically to a method and apparatus for creating a state transition trie for address recognition. Background Technology
[0002] Address information is widely present in various text formats, such as work orders, insurance policies, express delivery slips, invoices, and contracts, and is an important processing object in the field of entity recognition. To improve the processing efficiency of address recognition, it is necessary to collect and manage large amounts of address information for the training and inference of address recognition models.
[0003] Currently, the commonly used methods for address information management are as follows:
[0004] 1. Address dictionary database
[0005] This method stores all addresses at different levels in a database, retrieving address information through text matching. Due to the vast number of addresses in my country, coupled with the prevalence of aliases and abbreviations, the address dictionary database requires an exceptionally large storage space, severely impacting retrieval speed. Establishing address dictionary databases at different levels (province, city, county, township, etc.) can reduce storage space and improve retrieval speed to some extent. However, the data volume of address dictionary databases at the same level is still substantial, especially for smaller areas such as communities and streets, and widely distributed POIs (Points of Interest), resulting in large space consumption and long retrieval times. Furthermore, without prior specification, the address level of the target object cannot be determined, requiring matching from different levels of address dictionary databases one by one, further increasing time overhead.
[0006] 2. Address tree
[0007] This method stores address objects at different levels in a tree structure, with the root node representing address objects at different levels such as country, province, city, county, township, and village, respectively. When used, it matches text strings and address objects at different levels in the address tree one by one from left to right. This method assigns all address objects to different subtrees according to their spatial location and address level. Based on the hierarchical relationship between adjacent address names in the Chinese address string, after the current address name is matched, the subsequent address name is only compared with a small number of address objects in the subtree that meet the conditions; thus significantly reducing the number of matching operations and improving retrieval speed. However, for different address objects with the same name, such as Zhangjia Village and Wangjiazhai, which are widespread throughout the country, and popular names like Chaoyang District and Shengli Road, the address tree needs to be stored separately, and the characteristic of their identical names cannot be used to reduce storage volume. For different address objects with overlapping name prefixes, such as Jilin Province and Jilin City, or Zhongshan City and Zhongshan Village, their common prefixes cannot be used to reduce storage volume. In addition to the name, the address tree also needs to record hierarchical relationships, so the storage volume is quite large. Furthermore, the retrieval performance of the address tree is limited by its stored content. For new addresses or less commonly used aliases or abbreviations, if they do not exist in the address tree, the retrieval will fail. In addition, for address jump phenomena in text strings, such as "Jinan City Langchao Road", where "High-tech Zone" is missing between "Jinan City" and "Langchao Road", if the jump relationship is not recorded in the address tree, even if the address objects with jump phenomena are all in the address tree, the retrieval will fail due to the lack of connection relationship.
[0008] In summary, address dictionaries suffer from large storage space requirements and low retrieval efficiency. In addition to the aforementioned problems, address trees also need to store the hierarchical and jump relationships between adjacent address objects, requiring even more storage space. Summary of the Invention
[0009] The technical objective of this invention is to address the above-mentioned shortcomings by providing a method and apparatus for creating a state transition dictionary tree for address recognition. This method can improve address recognition speed, reduce storage space, and establish a connection between the address dictionary and the state transition dictionary tree. By determining the corresponding address information through matching results, it can facilitate subsequent processing and analysis.
[0010] The technical solution adopted by this invention to solve its technical problem is:
[0011] A method for creating a state transition trie based on address recognition is described below:
[0012] S1. Create an address dictionary database and store all address information in the database;
[0013] S2. Generate a state transition trie based on the address dictionary, ensuring the generated trie corresponds to the address dictionary; the generation method is as follows:
[0014] S21: The trie is initialized to empty;
[0015] S22: Sort the list of address names lexicographically;
[0016] S23: Generate a trie layer by layer based on the sorting results: Generate a trie layer by layer based on the parent-child relationship between adjacent characters in the address name;
[0017] S24: Modify the status value corresponding to the address name: Modify the status value of the node corresponding to the address name in the trie, which is used to retrieve its address information in the address dictionary;
[0018] S25: Returns the generated trie;
[0019] S3. Look up address information based on the state transition dictionary: Obtain the address information in the address dictionary based on the state value of the matched address name.
[0020] Preferably, the address dictionary includes:
[0021] Address Name Mapping Table: Used to establish a mapping relationship from address names to address information sets. Since different address names may have the same name, the address information set corresponding to a single address name can contain multiple address information entries.
[0022] Address Name List: A list consisting of all address names;
[0023] Address code mapping table: used to establish the mapping relationship from address code to address information. Since the address code is unique, the address code and address information are mapped one-to-one.
[0024] Preferably, the address dictionary stores address information, and each address information contains the following entries:
[0025] name: Address name;
[0026] code: address encoding;
[0027] abbreviation: address abbreviation;
[0028] alias: alternative name;
[0029] parentCode: Parent address code;
[0030] level: hierarchy.
[0031] Preferably, the process of generating a trie layer by layer based on the sorting results is described by locWords, where locWords represents the list of address names arranged lexicographically, I is the number of address names in the list, L is the maximum length of the address names, locWords[i] represents the i-th address name (1≤i≤I), locWords[i][j] represents the j-th character of the address name, locWords[i][1..j] represents the substring formed by the first j characters of the address name, and locWords[i][0]=locWords[i][1..0]="". If the root node of the trie is 0, then the maximum number of levels (depth) of the trie is the maximum length L of the address names. The prefix substring of the address names is considered as a state, and the characters in the address names are considered as variables. state represents the state array, s and t represent the indices of the states in state, c represents the variable number, base[s] represents the state corresponding to index s, and check[t] represents the predecessor state corresponding to state base[t], satisfying: base[s]+c=t, check[t]=s.
[0032] Step S23 specifically includes:
[0033] S231: Initialize the elements of arrays base and check to be 0, and set the level j = 1;
[0034] S232: Visit the prefix substrings locWords[i][1..1] one by one in order of i increasing from 1. After merging the duplicate prefix substrings, obtain the child state of the root node in the trie, that is, the state of the first level of the trie, and store them in the state array state in order.
[0035] S233: If j+1≤L, then go to step S234; otherwise, go to step S23B.
[0036] S234: i = 1;
[0037] S235: Obtain the number of prefix substrings p to be processed when calculating parent-child relationships: locWords[i-1][1..j]! = locWords[i][1..j], locWords[i][1..j] = locWords[i+p-1][1..j], locWords[i][1..j]! = locWords[i+p][1..j];
[0038] S236: Merge the duplicates of p prefix substrings locWords[k][1..j+1] to obtain q prefix substrings, which are the child states of the corresponding nodes of locWords[i][1..j] in the trie, i≤k≤i+p-1, q≤p;
[0039] S237: Update arrays base, check, and state based on parent-child relationships: Update arrays base, check, and state based on the parent-child relationships of the corresponding nodes of locWords[k][1..j] and locWords[k][1..j+1] in the trie, i≤k≤i+p-1;
[0040] S238: Update the address name sequence number i = i + p;
[0041] S239: If i≤I, then go to step S235; otherwise, go to step S23A.
[0042] S23A: Update the layer number j = j + 1, then proceed to step S233;
[0043] S23B: Returns the generated arrays base, check, and state.
[0044] Furthermore, the arrays base, check, and state are updated according to the parent-child relationship; using s k,j The indices of the states corresponding to locWords[k][1..j] are represented by t1, t2, ..., tj. q The indices representing the states of q children are c1, c2, ..., cq. q This represents the variable numbers from locWords[k][1..j] to the q child states;
[0045] Step S237 specifically includes:
[0046] S2371: Initialize a positive integer r = 1;
[0047] S2372: If the following conditions are met: base[r+c1]=base[r+c2]=L=base[r+c q ]=0,check[r+c1]=check[r+c2]=L=check[r+c q If ] = 0, then proceed to step S2374; otherwise, proceed to step S2373.
[0048] S2373: r = r + 1, proceed to step S2372;
[0049] S2374: Update state base[s] k,j ] = r;
[0050] S2375: Update the indices of q children in the state array state: t1 = r + c1, t2 = r + c2, ..., t q =r+c q ;
[0051] S2376: Update the predecessor status of q children. check[r+c1]=check[r+c2]=L=check[r+c q ] = s k,j ;
[0052] S2377: Returns the updated arrays base, check, and state.
[0053] Preferably, the modified address name's corresponding status value is represented by locWords, which represents the list of address names arranged lexicographically, where I is the number of address names in the list, locWords[i] represents the i-th address name, and s... i Let locWords[i] be the index of the state corresponding to the state in state, satisfying: 1≤i≤I;
[0054] Step S24 specifically includes:
[0055] S241: Initialize i = 1;
[0056] S242: Get the index s of the state corresponding to locWords[i] in state. i ;
[0057] S243: Modify the status value base[s] i ] = -i;
[0058] S244: i = i + 1;
[0059] S245: If i≤I, then go to step S242; otherwise, go to step S246.
[0060] S246: Returns the modified array base.
[0061] Preferably, in the step of searching for address information based on the state transition trie, addrName represents the matched address name, and s represents the address name. a This represents the index of the state corresponding to it in the state, with addrNameNum representing its address name number, addrInfoSet representing its corresponding set of address information, and the elements in this set represented as addrInfo, LocWords representing the list of address names arranged in lexicographical order, and locationWordMap representing the address name mapping table;
[0062] Step S3 specifically includes:
[0063] S31: Get the index s of the state corresponding to addrName in the state. a ;
[0064] S32: Calculate the address name number addrNameNum = base[s a ]*(-1);
[0065] S33: Get the address information set addrInfoSet = locationWordMap[locWords[addrNameNum]];
[0066] S34: Access the address information addrInfo in addrInfoSet.
[0067] The theoretical basis of this method is to use an array to represent the state transitions between nodes in the trie, which can accurately record the positional relationships of adjacent characters in address names. Address recognition is performed using node matching, with the number of matches not exceeding the maximum length of the address name, making it suitable for address identification. Based on the hierarchical relationship of adjacent characters in the trie, the common prefix of the address name only needs to be stored once, significantly reducing storage space. Leaf node state values are used to record the address name number, establishing a connection between the matching results and the address dictionary, which facilitates subsequent processing and analysis.
[0068] This invention also claims a state transition trie creation apparatus for address recognition, comprising:
[0069] The address dictionary database creation component M1 is used to store all address information in the dictionary database;
[0070] The state transition trie generation component M2 is used to generate a state transition trie corresponding to the address dictionary.
[0071] Address information lookup component M3 is used to retrieve the address information of the address name in the address dictionary based on the state value matched in the state transition dictionary.
[0072] This device can implement the above-described address-oriented state transition dictionary tree creation method.
[0073] Furthermore, the state transition trie generation component M2 includes:
[0074] The state transition trie initialization component M21 is used to initialize the state transition trie.
[0075] Address name list sorting component M22 is used to sort the address name list in lexicographical order;
[0076] The state transition trie generation component M23 is used to generate the state transition trie layer by layer based on the parent-child relationship between adjacent characters in the address name;
[0077] The address name state value modification component M24 is used to modify the state value of the corresponding node of the address name in the state transition dictionary tree to its index in the address name dictionary sequence table.
[0078] The present invention also claims a computer-readable medium storing computer instructions that, when executed by a processor, enable the processor to perform the above-described address-oriented state transition trie creation method.
[0079] The state transition trie creation method and apparatus for address recognition of the present invention have the following advantages compared with the prior art:
[0080] This method uses a tree structure to store address name information. The path starting from the root node represents the complete address name, and each node on the path represents a single character of the address name. Address identification is performed by matching nodes, and the maximum number of matches does not exceed the maximum length of the address name. This is a storage structure suitable for address identification.
[0081] Three arrays, base, check, and state, are used to record the state transition information between trie nodes. Path nodes can be accessed through a simple and intuitive state transition method, avoiding the use of complex and difficult-to-understand multi-branch trees to record and match the hierarchical and jump relationships between trie nodes. Based on the hierarchical relationship of adjacent characters in the address name in the trie, the common prefix of the address name only needs to be stored once. The above measures can significantly reduce storage space.
[0082] Furthermore, this method uses the state values of the tree nodes in the address database to record the address name number, thereby establishing a connection between the matching results and the address dictionary. This allows access to the corresponding address information after matching, improving the understanding of the matching results and facilitating subsequent processing and analysis. Attached Figure Description
[0083] Figure 1 This is a flowchart of the steps in the address-oriented state transition trie creation method provided in this embodiment of the invention;
[0084] Figure 2 This is a flowchart illustrating the specific steps of step S2 provided in this embodiment of the invention;
[0085] Figure 3 This is a flowchart illustrating the specific steps of step S23 provided in this embodiment of the invention;
[0086] Figure 4 This is an example diagram of the first level of the state transition trie provided in this embodiment of the invention;
[0087] Figure 5 This is an example diagram of the second level of the state transition trie provided in this embodiment of the invention;
[0088] Figure 6 This is an example diagram of the third level of the state transition trie provided in this embodiment of the invention;
[0089] Figure 7 This is an example diagram of the fourth level of the state transition trie provided in this embodiment of the invention;
[0090] Figure 8 This is a structural block diagram of the address-oriented state transition dictionary tree creation device provided in an embodiment of the present invention. Detailed Implementation
[0091] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0092] Regarding the problems raised in the background technology, both address dictionaries and address trees have the problem of large storage space consumption in terms of storage. Since address trees also need to store the hierarchical relationships and jump relationships of adjacent address objects, they require more storage space. In terms of retrieval, address dictionaries cannot predict the address level of the object to be retrieved, and need to use the entire dictionary for matching, which has a large time overhead. If the hierarchical relationships and jump relationships recorded by the address tree are incorrect or omitted, it will lead to retrieval errors or failures. The above phenomena will reduce the retrieval efficiency of both.
[0093] This invention provides a method for creating a state transition trie based on address recognition, such as... Figure 1 As shown, the implementation of this method includes the following steps:
[0094] S1. Create an address dictionary:
[0095] This step stores all address information in a dictionary, using addrInfo to represent address information. Each address entry contains the following entries:
[0096] A. name: Address name;
[0097] B. code: address encoding;
[0098] C. Abbreviation: Address abbreviation;
[0099] D. alias: alternative name;
[0100] E. parentCode: Parent address code;
[0101] F, level: level.
[0102] The address dictionary consists of the following three parts:
[0103] A. Location WordMap: Used to establish a mapping relationship from address names to address information sets. Since different address names may have the same name, the address information set corresponding to a single address name can contain multiple address information sets.
[0104] B. Location Words: A list consisting of all address names;
[0105] C. Location Map: Used to establish a mapping relationship from address codes to address information. Since address codes are unique, there is a one-to-one mapping relationship between address codes and address information.
[0106] S2. Generate a state transition trie based on the address dictionary:
[0107] This step generates a trie corresponding to the address dictionary. For example... Figure 2 As shown, the generation method is as follows:
[0108] S21: The trie is initialized to empty;
[0109] S22: Sort the list of address names lexicographically;
[0110] S23: Generate a trie level by level based on the sorting results:
[0111] This step generates a trie layer by layer based on the parent-child relationships between adjacent characters in the address names. Let `locWords` represent the list of address names arranged lexicographically, where `I` is the number of address names in the list, `L` is the maximum length of the address names, `locWords[i]` represents the i-th address name (1 ≤ i ≤ I), `locWords[i][j]` represents the j-th character of the address name, and `locWords[i][1..j]` represents the substring formed by the first j characters of the address name. `locWords[i][0] = locWords[i][j]`. ds[i][1..0] = ""; Let the root node of the trie be 0, then the maximum level (depth) of the trie is the maximum length L of the address name; Consider the prefix substring of the address name as a state, and the characters in the address name as variables. Let state represent the state array, s and t represent the index of the state in state, c represent the variable number, base[s] represent the state corresponding to index s, and check[t] represent the predecessor state corresponding to state base[t], satisfying: base[s] + c = t, check[t] = s;
[0112] Then as Figure 3 As shown, step S23 specifically includes:
[0113] S231: Initialize the elements of arrays base and check to be 0, and set the level j = 1;
[0114] S232: Visit the prefix substrings locWords[i][1..1] one by one in order of i increasing from 1. After merging the duplicate prefix substrings, obtain the child state of the root node in the trie, that is, the state of the first level of the trie, and store them in the state array state in order.
[0115] S233: If j+1≤L, then go to step S234; otherwise, go to step S23B.
[0116] S234: i = 1;
[0117] S235: Obtain the number of prefix substrings p to be processed when calculating parent-child relationships: locWords[i-1][1..j]! = locWords[i][1..j], locWords[i][1..j] = locWords[i+p-1][1..j], locWords[i][1..j]! = locWords[i+p][1..j];
[0118] S236: Merge the duplicates of p prefix substrings locWords[k][1..j+1] to obtain q prefix substrings, which are the child states of the corresponding nodes of locWords[i][1..j] in the trie, i≤k≤i+p-1, q≤p;
[0119] S237: Update arrays base, check, and state based on parent-child relationships:
[0120] This step updates the arrays `base`, `check`, and `state` based on the parent-child relationships of the corresponding nodes in the trie using `locWords[k][1..j]` and `locWords[k][1..j+1]`, where `i` ≤ `k` ≤ `i+p`; using s k,j The indices of the states corresponding to locWords[k][1..j] are represented by t1, t2, ..., tj. q The indices representing the states of q children are c1, c2, ..., cq. q Let locWords[k][1..j] represent the variable numbers of the q child states; then step S237 specifically includes:
[0121] S2371: Initialize a positive integer r = 1;
[0122] S2372: If the following conditions are met: base[r+c1]=base[r+c2]=L=base[r+c q ] = 0,
[0123] check[r+c1]=check[r+c2]=L=check[r+c q If ] = 0, then proceed to step S2374; otherwise, proceed to step S2373.
[0124] S2373: r = r + 1, proceed to step S2372;
[0125] S2374: Update state base[s] k,j ] = r;
[0126] S2375: Update the indices of q children in the state array state: t1 = r + c1, t2 = r + c2, ..., t q =r+c q ;
[0127] S2376: Update the predecessor status of q children. check[r+c1]=check[r+c2]=L=check[r+c q ] = s k,j ;
[0128] S2377: Returns the updated arrays base, check, and state.
[0129] S238: Update the address name sequence number i = i + p + 1;
[0130] S239: If i≤I, then go to step S235; otherwise, go to step S23A.
[0131] S23A: Update the layer number j = j + 1, then proceed to step S233;
[0132] S23B: Returns the generated arrays base, check, and state.
[0133] S24: Modify the status value corresponding to the address name:
[0134] This step modifies the state value of the corresponding node in the trie for each address name, used to retrieve its address information in the address dictionary. Let locWords represent the list of address names arranged lexicographically, I is the number of address names in the list, locWords[i] represents the i-th address name, and s... i Let locWords[i] be the index of the state corresponding to the state in state, satisfying: 1≤i≤I;
[0135] Step S24 specifically includes:
[0136] S241: Initialize i = 1;
[0137] S242: Get the index s of the state corresponding to locWords[i] in state. i ;
[0138] S243: Modify the status value base[s] i ] = -i;
[0139] S244: i = i + 1;
[0140] S245: If i≤I, then go to step S242; otherwise, go to step S246.
[0141] S246: Returns the modified array base.
[0142] S25: Returns the generated trie.
[0143] S3. Look up the address information based on the state transition trie:
[0144] This step retrieves the address information from the address dictionary based on the status value of the matched address name. `addrName` represents the matched address name, and `s` represents the status value. a This represents the index of the state corresponding to it in the state, with addrNameNum representing its address name number, addrInfoSet representing its corresponding set of address information, and the elements in this set represented as addrInfo, LocWords representing the list of address names arranged in lexicographical order, and locationWordMap representing the address name mapping table;
[0145] Step S3 specifically includes:
[0146] S31: Get the index s of the state corresponding to addrName in the state. a ;
[0147] S32: Calculate the address name number addrNameNum = base[s a ]*(-1);
[0148] S33: Get the address information set addrInfoSet = locationWordMap[locWords[addrNameNum]];
[0149] S34: Access the address information addrInfo in addrInfoSet.
[0150] The following uses an address dictionary containing 10 address entries as a specific example to further illustrate this method and demonstrate its execution process.
[0151] Execute S1: First, create an address dictionary containing 10 address entries. The names of the address entries are: Shanhou Village, Shanhouwan Village, Shanzhou Village, Shanzuiqian Village, Shanzuizi Town, Shanzui Community, Shancheng Town, Shancheng District, Shancheng Village, and Shancheng West Alley. Each address entry contains the following entries: address name, address code, address abbreviation, alias, parent address code, and level. Then, create an address name mapping table, an address name list, and an address code list for accessing the address information.
[0152] Execute S21: Initialize the state transition trie to be empty.
[0153] Execute S22: Sort the list of address names lexicographically, the result is as follows:
[0154] Shanhou Village
[0155] Shanhouwan Village
[0156] Shanzhou Village
[0157] Shanzuiqian Village
[0158] Shanzuizi Town
[0159] Shanzui Community
[0160] Shancheng Town
[0161] Shancheng District
[0162] Shancheng Village
[0163] Shancheng West Alley
[0164] Execution S23: Generate a state transition trie layer by layer based on the parent-child relationship between adjacent characters in the address name, and synchronously update the arrays base, check, and state. The processing at different levels is as follows:
[0165] A. Level 0: Generate the root node, array base, and initialize check and state to empty.
[0166] B. Level 1: Add node "mountain", the state transition trie and array are as follows: Figure 4 As shown in Table 1, the “mountain1” on the side indicates that the variable number of the character “mountain” is 1, and the same applies below.
[0167] Table 1 shows the array states after generating the first-level state transition trie.
[0168]
[0169]
[0170] C, Layer 2: Add nodes "Hou", "Zhou", "Zui", "Cheng" from left to right in sequence. The state transition trie and array are as shown in Figure 5 and Table 2 respectively. Here, the state of the array state is the string from the root node to the current node. The same applies hereinafter.
[0171] Table 2 Array state after generating the state transition trie of Layer 2
[0172] Subscript 1 2 3 4 5 6 base 1 0 0 0 0 0 check 0 0 1 1 1 1 state Mountain Behind the mountain Yamazu Mountain beak mountain city
[0173] D, Layer 3: Add nodes "Cun", "Wan", "Cun", "Qian", "Zi", "She", "Zhen", "Qu", "Cun", "Xi" from left to right in sequence. The state transition trie and array are as shown in Figure 6 and Table 3 respectively.
[0174] Table 3 Array state after generating the state transition trie of Layer 3
[0175]
[0176] E, Layer 4: Add nodes "Cun", "Cun", "Zhen", "Qu", "Xiang" from left to right in sequence. The state transition trie and array are as shown in Figure 7 and Table 4 respectively.
[0177] Table 4 Array state after generating the state transition trie of Layer 4
[0178]
[0179]
[0180] Execute S24: Modify the state value of the node corresponding to the address name in the state transition trie, that is, the value of the leaf node in the array base. The result is shown in Table 5.
[0181] Table 5 Array state after modifying the state value of the address name
[0182]
[0183] Execute S31: Set addrName = "Shanzuizi Town", and its corresponding state index s in state a = 16;
[0184] Execute S32: Calculate the address name number addrNameNum = base[s a *(-1) = base
[16] *(-1) = 5;
[0185] Execute S33: Retrieve the address name from locWords, and then retrieve the address information set addrInfoSet from locationWordMap;
[0186] Execute S34: Obtain the required address information by accessing the addrInfo element in addrInfoSet.
[0187] This invention also provides an address-based state transition dictionary tree creation apparatus, such as... Figure 8 As shown, it includes:
[0188] The address dictionary database creation component M1 is used to store all address information in the dictionary database;
[0189] A state transition trie generation component M2 is used to generate a state transition trie corresponding to the address dictionary; the state transition trie generation component M2 includes:
[0190] The state transition trie initialization component M21 is used to initialize the state transition trie.
[0191] Address name list sorting component M22 is used to sort the address name list in lexicographical order;
[0192] The state transition trie generation component M23 is used to generate the state transition trie layer by layer based on the parent-child relationship between adjacent characters in the address name;
[0193] The address name state value modification component M24 is used to modify the state value of the corresponding node of the address name in the state transition dictionary tree to its index in the address name dictionary sequence table.
[0194] Address information lookup component M3 is used to retrieve the address information of the address name in the address dictionary based on the state value matched in the state transition dictionary.
[0195] This device can implement the address-oriented state transition trie creation method described in the above embodiments, and its implementation process is the specific implementation process described in the above embodiments of the address-oriented state transition trie creation method.
[0196] This invention also provides a computer-readable medium storing computer instructions. When executed by a processor, the computer instructions cause the processor to perform the address-oriented state transition dictionary tree creation method described in the above embodiments. Specifically, a system or apparatus equipped with a storage medium storing software program code that implements the functions of any of the above embodiments can be provided, and the computer (or CPU or MPU) of the system or apparatus can read and execute the program code stored in the storage medium.
[0197] In this case, the program code read from the storage medium can itself implement the function of any of the above embodiments, and therefore the program code and the storage medium storing the program code constitute part of the present invention.
[0198] Examples of storage media used to provide program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer via a communication network.
[0199] Furthermore, it should be clear that not only can the program code read by the computer be executed, but also the operating system or other components operating on the computer can be instructed based on the program code to perform some or all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0200] Furthermore, it is understood that the program code read from the storage medium is written to the memory set in the expansion board inserted into the computer or to the memory set in the expansion unit connected to the computer. Then, based on the instructions of the program code, the CPU or other components installed on the expansion board or expansion unit execute some and all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0201] The present invention has been shown and described in detail above with reference to the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above embodiments, those skilled in the art will know that more embodiments of the present invention can be obtained by combining the code review methods in the different embodiments. These embodiments are also within the protection scope of the present invention.
Claims
1. A method for creating a state transition trie based on address recognition, characterized in that, The method is implemented as follows: S1. Create an address dictionary database and store all address information in the database; S2. Generate a state transition trie based on the address dictionary, ensuring the generated trie corresponds to the address dictionary; the generation method is as follows: S21: The trie is initialized to empty; S22: Sort the list of address names lexicographically; S23: Generate a trie layer by layer based on the sorting results: Generate a trie layer by layer based on the parent-child relationship between adjacent characters in the address name; S24: Modify the status value corresponding to the address name: Modify the status value of the node corresponding to the address name in the trie, which is used to retrieve its address information in the address dictionary; S25: Returns the generated trie; S3. Look up address information based on the state transition trie: Obtain the address information in the address dictionary based on the state value of the matched address name; The address dictionary includes: Address Name Mapping Table: Used to establish a mapping relationship from address names to address information sets. Since different address names may have the same name, the address information set corresponding to a single address name can contain multiple address information entries. Address Name List: A list consisting of all address names; Address code mapping table: used to establish the mapping relationship from address code to address information. Since the address code is unique, the address code and address information are mapped one-to-one. The process involves generating a trie layer by layer based on the sorting results. `locWords` represents the list of address names arranged lexicographically, `I` is the number of address names in the list, `L` is the maximum length of the address names, `locWords[i]` represents the i-th address name (1 ≤ i ≤ I), `locWords[i][j]` represents the j-th character of the address name, and `locWords[i][1..j]` represents the substring formed by the first j characters of the address name. `locWords[i][0] = locWords[i][1..0] = ""`. If the root node of the trie is at level 0, then the maximum level of the trie is the maximum length of the address names, `L`. The prefix substring of the address names is considered as a state, and the characters in the address names are considered as variables. `state` represents the state array, `s` and `t` represent the indices of the states in `state`, `c` represents the variable number, `base[s]` represents the state corresponding to index `s`, and `check[t]` represents the predecessor state corresponding to state `base[t]`, satisfying: `base[s] + c = t` and `check[t] = s`. Step S23 specifically includes: S231: Initialize the elements of arrays base and check to be 0, and set the level j = 1; S232: Visit the prefix substrings locWords[i][1..1] one by one in order of i increasing from 1. After merging the duplicate prefix substrings, obtain the child state of the root node in the trie, that is, the state of the first level of the trie, and store them in the state array state in order. S233: If j+1≤L, then go to step S234; otherwise, go to step S23B. S234: i = 1; S235: Obtain the number of prefix substrings p to be processed when calculating parent-child relationships: locWords[i-1][1..j]! = locWords[i][1..j], locWords[i][1..j] = locWords[i+p-1][1..j], locWords[i][1..j]! = locWords[i+p][1..j]; S236: Merge the duplicates of p prefix substrings locWords[k][1..j+1] to obtain q prefix substrings, which are the child states of the corresponding nodes of locWords[i][1..j] in the trie, i≤k≤i+p-1, q≤p; S237: Update arrays base, check, and state based on parent-child relationships: Update arrays base, check, and state based on the parent-child relationships of the corresponding nodes of locWords[k][1..j] and locWords[k][1..j+1] in the trie, i≤k≤i+p-1; S238: Update the address name sequence number i = i + p; S239: If i≤I, then go to step S235; otherwise, go to step S23A. S23A: Update the layer number j = j + 1, then proceed to step S233; S23B: Returns the generated arrays base, check, and state; The modified address name's corresponding status value is represented by locWords, which represents the list of address names arranged lexicographically. I is the number of address names in this list, locWords[i] represents the i-th address name, and s... i Let locWords[i] be the index of the state corresponding to the state in state, satisfying: 1≤i≤I; Step S24 specifically includes: S241: Initialize i = 1; S242: Get the index s of the state corresponding to locWords[i] in state. i ; S243: Modify the status value base[s] i ] = -i; S244: i = i + 1; S245: If i≤I, then go to step S242; otherwise, go to step S246. S246: Returns the modified array base; The process of searching for address information based on the state transition trie uses addrName to represent the matched address name, and s... a This represents the index of the state corresponding to it in the state, with addrNameNum representing its address name number, addrInfoSet representing its corresponding set of address information, and the elements in this set represented as addrInfo, LocWords representing the list of address names arranged in lexicographical order, and locationWordMap representing the address name mapping table; Step S3 specifically includes: S31: Get the index s of the state corresponding to addrName in the state. a ; S32: Calculate the address name number addrNameNum = base[s a ]*(-1); S33: Get the address information set addrInfoSet = locationWordMap[locWords[addrNameNum]]; S34: Access the address information addrInfo in addrInfoSet.
2. The method for creating a state transition trie based on address recognition according to claim 1, characterized in that, The address dictionary stores address information, and each address entry contains the following entries: name: Address name; code: address encoding; abbreviation: address abbreviation; alias: alternative name; parentCode: Parent address code; level: hierarchy.
3. The method for creating a state transition trie based on address recognition according to claim 1, characterized in that, The statement describes updating the arrays base, check, and state based on parent-child relationships; using s k,j The indices of the states corresponding to locWords[k][1..j] are represented by t1, t2, ..., tj. q The indices representing the states of q children are c1, c2, ..., cq. q This represents the variable numbers from locWords[k][1..j] to q child states; Step S237 specifically includes: S2371: Initialize a positive integer r = 1; S2372: If the following conditions are met: base[r+c1]=base[r+c2]=L=base[r+c q ]=0,check[r+c1]=check[r+c2]=L=check[r+c q If ] = 0, then proceed to step S2374; otherwise, proceed to step S2373. S2373: r=r+1 Proceed to step S2372; S2374: Update state base[s] k,j ] = r; S2375: Update the indices of q children in the state array state: t1 = r + c1, t2 = r + c2, ..., t q =r+c q ; S2376: Update the predecessor status of q children. check[r+c1]=check[r+c2]=L=check[r+c q ] = s k,j ; S2377: Returns the updated arrays base, check, and state.
4. A state transition trie creation device for address recognition, characterized in that, The device is used to implement the method according to any one of claims 1 to 3, comprising: The address dictionary database creation component M1 is used to store all address information in the dictionary database; The state transition trie generation component M2 is used to generate a state transition trie corresponding to the address dictionary. Address information lookup component M3 is used to retrieve the address information of the address name in the address dictionary based on the state value matched in the state transition dictionary.
5. The state transition dictionary tree creation device for address recognition according to claim 4, characterized in that, The state transition trie generation component M2 includes: The state transition trie initialization component M21 is used to initialize the state transition trie. Address name list sorting component M22 is used to sort the address name list in lexicographical order; The state transition trie generation component M23 is used to generate the state transition trie layer by layer based on the parent-child relationship between adjacent characters in the address name. The address name state value modification component M24 is used to modify the state value of the corresponding node of the address name in the state transition dictionary tree to its index in the address name dictionary sequence table.
6. A computer-readable medium, characterized in that, The computer-readable medium stores computer instructions that, when executed by a processor, enable the processor to perform the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Method for quickly matching Chinese addresses in multi-level manner on basis of address feature words
CN103914544A
A Chinese geo-coding method based on dictionary tree
CN109344213A
Address query method and system, equipment, and storage medium
CN113886650A