Chinese address matching method based on vector similarity
The vector similarity calculation method solves the problems of high complexity and high resource consumption of existing Chinese address matching methods, realizes efficient and accurate address matching, and simplifies the address matching process.
Patent Information
- Application Number
- CN202411141015.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing Chinese address matching methods suffer from problems such as high computational complexity, the need for a large amount of manual annotation and training data, high computational cost, and lack of interpretability of matching results.
By employing a vector similarity calculation method, address matching is achieved by converting address text into vector format, constructing a reference address database, and calculating the similarity of address vectors.
The address matching algorithm is simplified, the accuracy and efficiency of matching are improved, the demand for computing resources is reduced, and the matching results are interpretable.
Smart Images

Figure CN119005164A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of logistics management and spatial big data processing, and in particular relates to a Chinese address matching method based on vector similarity. Background Art
[0002] Address matching is the process of searching for the address that is most similar to the address text to be matched from the reference address library. It plays an important role in the logistics business field of automated sorting of delivery objects and spatial data processing fields such as geocoding. Over the years, address matching methods have attracted the attention and research of many scholars and engineering technicians, have made great progress, and have been deeply integrated with logistics business. At present, Chinese address matching methods are roughly divided into:
[0003] (1) Address matching methods based on text similarity. This type of method directly queries the address that is most similar to the address text to be matched from the reference address database based on the address text similarity index. The text similarity index is usually measured by text distance. Commonly used text distances include Euclidean distance, edit distance (also known as Levenshtein distance), cosine distance, Jaro distance, Jaccard distance, etc. Although this type of address matching method is simple to operate, it only compares the similarity of the full text of the address, which not only ignores the weight of the address text in the address definition, but also sometimes has a high calculation complexity. For example, the most commonly used edit distance algorithm complexity is O(n 3 ), when the address text is long, it seriously affects the matching rate.
[0004] (2) Address matching methods based on address element similarity rules. This type of method first divides all addresses in the reference address library into multiple address elements, and establishes hierarchical or tree-based matching rules based on address elements. Then, the address to be matched is divided into multiple address elements, and the most similar address is queried from the reference address library using the established similarity matching rules. In order to divide the address into multiple address elements, this type of matching method usually requires the support of a natural language intelligent word segmentation (or word segmentation) algorithm, which not only requires a large amount of corpus for training, but also has a complex algorithm. In order to establish similarity matching rules, this type of method also requires manual setting of constraints and matching rules, which requires a lot of manual operations.
[0005] (3) Address matching methods based on deep learning. This type of method is an extension and application of deep learning methods in the field of address matching in recent years. Although this type of method has obvious advantages in terms of address matching accuracy, it has many defects: on the one hand, deep learning requires a large amount of address corpus and text annotation work, and the quality and completeness of training data directly affect the matching results; on the other hand, deep learning algorithms require more computing power. When the corpus is modified, re-training will cost a lot of computing resources and take a long time; on the other hand, this type of method still requires address segmentation and encoding, and constructs high-dimensional address vectors, and the prediction results are not interpretable; on the other hand, when the matching results are not ideal, it is usually necessary to modify many parameters and retrain. Therefore, there is an urgent need for a Chinese address matching method based on vector similarity. Summary of the invention
[0006] In order to solve the above technical problems, the present invention proposes a Chinese address matching method based on vector similarity to solve the above problems existing in the prior art.
[0007] To achieve the above object, the present invention provides a Chinese address matching method based on vector similarity, comprising:
[0008] Create a reference Chinese address library and vectorize the reference Chinese address to obtain a reference address vector;
[0009] Extract the address to be matched and construct the address vector to be matched;
[0010] Reading a reference address vector from a reference Chinese address library, and calculating the similarity between the reference address vector and the matching address vector;
[0011] Address matching is completed when the similarity is maximum.
[0012] Optionally, the process of creating a reference Chinese address library and vectorizing the reference Chinese address includes:
[0013] Extract several address terms based on Chinese addresses;
[0014] A reference address vector is constructed based on the plurality of address entries.
[0015] Optionally, the process of extracting a plurality of address terms based on the Chinese address includes:
[0016] Extract each Chinese character, English word and number combination of the Chinese address from left to right to obtain a Chinese character entry, an English word entry and a number combination entry; wherein punctuation marks in the Chinese address are ignored.
[0017] Optionally, the process of constructing the reference address vector includes:
[0018] Record each term of the same Chinese address and the order in which each term appears in the Chinese address in a vector format;
[0019] The reference address vector includes a plurality of vector tuples, and adjacent vector tuples are separated by spaces; each vector tuple includes an address entry and a plurality of position numbers.
[0020] Optionally, the process of calculating the similarity between the reference address vector and the matching address vector includes:
[0021] Calculating the term similarity of the reference address vector with respect to the matching address vector to obtain a first similarity;
[0022] Calculating the term similarity of the matching address vector with respect to the reference address vector to obtain a second similarity;
[0023] The similarity between the reference address vector and the matching address vector is obtained based on the first similarity and the second similarity.
[0024] Optionally, the expression for calculating the similarity between the reference address vector and the matching address vector is:
[0025] s 1,2 =t 1,2 ×t 2,1
[0026] In the formula, s 1,2 v 1 and v 2 The similarity of t 1,2 v 1 About v 2 The similarity of the terms, n is v 1 The number of entries, p i v 1 The i-th entry number, η i is the first existence factor, t 2,1 v 2 About v 1 The similarity of the terms, m is v 2 The number of entries, p j v 2 The jth entry number, η j is the second existence factor.
[0027] The present invention also provides a computer terminal device, comprising:
[0028] one or more processors;
[0029] A memory, coupled to the processor, for storing one or more programs;
[0030] When the one or more programs are executed by the one or more processors, the one or more processors implement a Chinese address matching method based on vector similarity.
[0031] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, a Chinese address matching method based on vector similarity is implemented.
[0032] Compared with the prior art, the present invention has the following advantages and technical effects:
[0033] The present invention adopts a vector similarity calculation method to take into account the importance of each character in the address text in the address definition, and defines the calculation weight of the vector similarity based on this. Therefore, the present invention not only has a simple algorithm, but also reflects the role of the address text in the address definition. Compared with the matching method of full text similarity, the matching is more accurate. In addition, compared with the address matching method of deep learning, the present invention does not require an address corpus, does not require a large amount of manual annotation, avoids a large amount of corpus training and massive computing power expenditure, and the implementation method is simple and efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0035] Figure 1 The figure is a flow chart of a Chinese address matching method based on vector similarity according to an embodiment of the present invention. DETAILED DESCRIPTION
[0036] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0037] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0038] Embodiment 1
[0039] Aiming at the shortcomings of the current Chinese address matching method, the present invention discloses a Chinese address matching method based on vector similarity. The present invention first establishes a method for calculating the similarity of address vectors, then vectorizes all addresses of the reference address library and stores them in the reference address library. When performing address matching, first create a vector of the address to be matched, then query the address with the highest vector similarity in the address library, and the address matching is completed.
[0040] like Figure 1 As shown, this embodiment provides a Chinese address matching method based on vector similarity. The present invention first creates an address vector of a reference address library, inputs a Chinese address to be matched, calculates the vector of the address to be matched, searches the reference address library for a Chinese address with the greatest similarity to the address vector to be matched, and completes the address matching. The following steps are included: creating a reference Chinese address library and vectorizing the reference Chinese address to obtain a reference address vector; extracting the address to be matched and constructing the address vector to be matched; reading the reference address vector from the reference Chinese address library, calculating the similarity between the reference address vector and the matching address vector; and completing the address matching when the similarity is the largest. The specific implementation process is:
[0041] Step 1 creates an address vector of the reference address library. The reference address library is an address database that has been collected and organized according to address specifications. The address is a structured text that defines the location of social production, people's lives, etc. It is composed of several address components, including administrative division names at all levels, road names, house numbers, courtyard names, buildings, units, room numbers, mailbox numbers, etc. Including:
[0042] (1) Extract address entries: Extract each Chinese character, English word, and number combination in the Chinese address from left to right, ignoring the punctuation marks in the address, where each Chinese character, English word, and number combination is an entry. For example, "932 Lushan South Road, Yuelu District, Changsha City, Hunan Province, Central South University", the segmented entries include: Hunan Province, Changsha City, Yuelu District, Lushan South Road, No. 932, Central South University, that is, each Chinese character is an entry, and the number combination "932" is an entry.
[0043] (2) Construct an address vector, which is composed of a series of vector tuples. The vector tuples include address terms and their sequence numbers in the address text. The address terms are extracted from left to right, in sequence, from each Chinese character, English word, and number combination in the Chinese address, ignoring punctuation marks in the address, wherein each Chinese character, English word, and number combination is an address term. The specific implementation process includes: recording each term of a Chinese address and the order in which it appears in the address in a vector format. The vector is composed of several vector tuples, and the tuples are separated by "spaces". Each tuple consists of a term and its sequence number, separated by ":". When a term has multiple sequence numbers, the sequence numbers are separated by ",". For example, the address vector in the above example is "{'932':14'Zhong':16'District':9'South':2,12,17'No.':15'University':18'School':19'Mountain':11'Yue':7'City':6'Sand':5'Lake':1'Province':3'Road':13'Chang':4'Footpath':8,10}", where "932", "Zhong", "District", "South", "No.", "University", "School", "Mountain", "Yue", "City", "Sand", "Lake", "Province", "Road", "Chang", and "Footpath" are the entries of the vector elements, and the numbers following them are the sequence numbers of the entries in the address.
[0044] Step 2 Calculate the address vector v 1 and v 2 Similarity, including:
[0045] (1) Calculate v 1 About v 2 The first similarity of the term is calculated as follows:
[0046]
[0047] Among them, t 1,2 v 1 About v 2 Term similarity, n is v 1 The number of entries, p i v 1 The i-th entry number, η i is the first existential factor, when v 1 The i-th term exists in v 2 When η i =1, otherwise η i =0.
[0048] (2) Calculate v 2 About v 1 The second similarity of the term is calculated as follows:
[0049]
[0050] Among them, t 2,1 is v 2 Regarding v 1 entry similarity, m is the number of entries of v 2 , p j is the j-th entry serial number of v 2 , η j is the second existence factor. When the j-th entry of v 2 exists in v 1 , η j = 1; otherwise, η j = 0.
[0051] (3) The similarity between address vectors v 1 and v 2 is calculated as follows:
[0052] s 1,2 = t 1,2 × t 2,1
[0053] Among them, s 1,2 is the similarity between v 1 and v 2 .
[0054] For example, when calculating the similarity between the two address vectors of "No. 932, South Lushan Road, Yuelu District, Changsha City, Hunan Province, Central South University" and "No. 605, South Lushan Road, Yuelu District, Changsha City, Hunan Province, Central South University (South Campus)", first convert the two addresses into address vectors: v 1 = "{ '932': 14, '中': 16, '区': 9, '南': 2, 12, 17, '号': 15, '大': 18, '学': 19, '山': 11, '岳': 7, '市': 6, '沙': 5, '湖': 1, '省': 3, '路': 13, '长': 4, '麓': 8, 10}" and v 2 = "{ '605': 14, '中': 16, '区': 9, 22, '南': 2, 12, 17, 20, '号': 15, '大': 18, '学': 19, '山': 11, '岳': 7, '市': 6, '校': 21, '沙': 5, '湖': 1, '省': 3, '路': 13, '长': 4, '麓': 8, 10}", then calculate t 1,2 = 0.926 and t 2,1 = 0.862, and finally calculate the similarity s of the two vectors 1,2 = t 1,2 × t 2,1 = 0.926 × 0.862 = 0.798.
[0055] Step 3: Search for the address with the maximum vector similarity from the reference address library, including: (1) Calculate the vector v of the address to be matched 0; (2) Calculate all address vectors of the reference address library and v 0 The similarity is obtained, and the address with the greatest similarity is taken out to complete the matching. The specific implementation process includes:
[0056] 1) Enter the address to be matched a 0 , use step 1 to construct address a 0 The vector v 0 .
[0057] 2) Initialization vector similarity s max =0, target address a t =null, where null means empty.
[0058] 3) Read an uncompared address a from the reference address library i The vector v i .
[0059] 4) Use the similarity calculation method in step 2 to calculate the vector v 0 With v i The similarity of 0,i .
[0060] 5) If s 0,i Greater than s max , then s max =s 0,i , and a t =a i .
[0061] 6) If all addresses in the reference library have been compared, the calculation ends and the target address a with the maximum similarity is obtained t ; Otherwise, go to 3).
[0062] In order to verify the address matching effect of the present invention, the inventors conducted a verification experiment using 50,000 Chinese address data in Changsha. Experimental process:
[0063] (1) Using the experimental address data as a reference address library, construct an address vector for each address and store it in the reference address library.
[0064] (2) 2000 addresses are randomly selected from the experimental addresses as verification data. In order to further verify the usability and noise resistance of the present invention, this experiment randomly adds 5% noise to the verification address, that is, based on the number of address entries, a certain number of Chinese characters are randomly inserted, modified or deleted at a ratio of 5%.
[0065] The method of the present invention is used for address matching, and the matching accuracy rate is 99.8%.
[0066] Embodiment 2
[0067] This embodiment also provides a computer terminal device, including:
[0068] one or more processors;
[0069] A memory, coupled to the processor, for storing one or more programs;
[0070] When the one or more programs are executed by the one or more processors, the one or more processors implement a Chinese address matching method based on vector similarity.
[0071] Embodiment 3
[0072] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, a Chinese address matching method based on vector similarity is implemented.
[0073] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A Chinese address matching method based on vector similarity, characterized in that: The following steps are involved: Create a reference Chinese address library and vectorize the reference Chinese address to obtain a reference address vector; Extract the address to be matched and construct the address vector to be matched; Reading a reference address vector from a reference Chinese address library, and calculating the similarity between the reference address vector and the matching address vector; Address matching is completed when the similarity is maximum.
2. The Chinese address matching method based on vector similarity according to claim 1 is characterized in that: The process of creating a reference Chinese address library and vectorizing the reference Chinese addresses includes: Extract several address terms based on Chinese addresses; A reference address vector is constructed based on the plurality of address entries.
3. The Chinese address matching method based on vector similarity according to claim 2 is characterized in that: The process of extracting several address terms based on Chinese addresses includes: Extract each Chinese character, English word and number combination of the Chinese address from left to right to obtain a Chinese character entry, an English word entry and a number combination entry; wherein punctuation marks in the Chinese address are ignored.
4. The Chinese address matching method based on vector similarity according to claim 3 is characterized in that: The process of constructing a reference address vector includes: Record each term of the same Chinese address and the order in which each term appears in the Chinese address in a vector format; The reference address vector includes a plurality of vector tuples, and adjacent vector tuples are separated by spaces; each vector tuple includes an address entry and a plurality of position numbers.
5. The Chinese address matching method based on vector similarity according to claim 1 is characterized in that: The process of calculating the similarity between the reference address vector and the matching address vector includes: Calculating the term similarity of the reference address vector with respect to the matching address vector to obtain a first similarity; Calculating the term similarity of the matching address vector with respect to the reference address vector to obtain a second similarity; The similarity between the reference address vector and the matching address vector is obtained based on the first similarity and the second similarity.
6. The Chinese address matching method based on vector similarity according to claim 5 is characterized in that: The expression for calculating the similarity between the reference address vector and the matching address vector is: s 1,2 =t 1,2 ×t 2,1 In the formula, s 1,2 is the similarity between v1 and v2, t 1,2 is the similarity of v1 to v2, n is the number of terms in v1, p i is the i-th entry number of v1, η i is the first existence factor, t 2,1 is the similarity of v2 to v1, m is the number of terms in v2, p j is the jth entry number of v2, η j is the second existence factor.
7. A computer terminal device, characterized in that: include: one or more processors; A memory, coupled to the processor, for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the Chinese address matching method based on vector similarity as described in any one of claims 1 to 6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Chinese address matching method based on vector similarity as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Text similarity analysis method and device and storage medium
CN111144112A
Address matching method and device
CN112559658A
Address query method, method for obtaining address vector representation model and corresponding device
CN114579883A
Cited By
Address type short text similarity calculation method and device, equipment and medium
CN120850990A
