A smart phonebook search method based on a TF-IDF pinyin vector model
By using the TF-IDF Pinyin vector model, combined with cosine similarity and edit distance algorithms, the problems of low efficiency and poor accuracy in phonebook search in embedded communication devices are solved, achieving efficient and accurate contact search.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING FANGWEI ZHILIAN TECHNOLOGY CO LTD
- Filing Date
- 2025-06-17
- Publication Date
- 2026-05-12
AI Technical Summary
Existing methods for searching phonebooks in embedded communication devices suffer from weak semantic understanding, low computational efficiency, high memory consumption, and limited fuzzy matching capabilities, making it difficult to meet the need for quickly finding specific contacts.
By adopting the TF-IDF-based pinyin vector model, the TF-IDF vector is calculated by converting the contact's name into pinyin and indexing the characters. Combined with cosine similarity and edit distance algorithms, efficient and accurate fuzzy search is achieved.
It improves search accuracy, shortens response time, reduces storage space requirements, and can correctly handle spelling errors, making it suitable for resource-constrained embedded devices.
Smart Images

Figure CN120743976B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of communications, specifically relating to an intelligent phonebook search method based on the TF-IDF pinyin vector model. Background Technology
[0002] With the development of communication technology, embedded communication devices such as IP phones and conference phones are widely used by enterprises and individuals. These devices usually need to store a large amount of contact information, but users often need to quickly find specific contacts in their daily use, and a large amount of information slows down the search speed.
[0003] Currently, the common methods for searching phonebooks in embedded telephone products mainly include:
[0004] 1. Prefix matching method: This method only matches contacts whose names begin with the characters entered by the user. For example, if you enter "li", it will only match "li" and not "lixiaoming". This method has a limited matching range.
[0005] 2. Substring matching method: This method searches for substrings containing the user's input in the contact name or pinyin. Although it increases the matching range, it cannot distinguish the importance of the matches and has low computational efficiency.
[0006] 3. Edit distance method: This method assesses similarity by calculating the edit distance (such as Levenshtein distance) between the user input and the contact. While it can tolerate spelling errors, it does not consider the importance of characters and has a high computational cost for long strings.
[0007] The above methods share the following common problems:
[0008] 1) Weak semantic understanding: Unable to recognize the importance of different characters, such as rare characters should contribute more to the matching than common characters.
[0009] 2) Low computational efficiency: Especially when there are a large number of contacts, the response speed is slow and it is difficult to meet the needs of real-time search.
[0010] 3) High memory consumption: Especially for resource-constrained embedded devices, it is difficult to achieve efficient storage.
[0011] 4) Limited fuzzy matching capability: It is difficult to handle user input errors or partial matching cases, which reduces the user experience.
[0012] With the development of artificial intelligence technology, vectorization methods in natural language processing have provided new ideas for solving the above problems. However, traditional word embedding models (such as Word2Vec, BERT, etc.) require a large corpus for training, have high computational complexity, and are difficult to implement on resource-constrained embedded devices.
[0013] Therefore, there is a need for a computationally efficient, compact, and accurate intelligent phonebook search method. Summary of the Invention
[0014] This invention provides an intelligent phonebook search method based on the TF-IDF Pinyin vector model, aiming to solve the problems of low efficiency, poor accuracy, large memory consumption, and difficulty in adapting to fuzzy search requirements in existing phonebook search technologies; it is suitable for embedded communication devices with limited processing power and storage space, and can achieve efficient and accurate contact search function with minimal system resource consumption.
[0015] The intelligent phonebook search method based on the TF-IDF Pinyin vector model comprises the following steps:
[0016] Step 1: Save the contact information of an embedded communication device to a phonebook CSV file;
[0017] The phonebook CSV file includes information such as the name, department, email address, and landline number of all contacts.
[0018] Step 2: Convert the contact names in the phone book CSV file to Pinyin to obtain Pinyin strings and build a character index table; at the same time, calculate the IDF value of each character to form an IDF matrix;
[0019] Specifically: First, convert the names of all contacts in the phone book to pinyin to obtain pinyin strings;
[0020] Then, a character-level index table is created, and an index position is assigned to each unique Pinyin character.
[0021] The Chinese Pinyin system uses 26 English letters, so the index table size is 26. Each letter corresponds to an index position: 'a' corresponds to index 0, 'b' corresponds to index 1, and so on, with 'z' corresponding to index 25.
[0022] Next, the document frequency of each character in all contact pinyin entries in the corpus was statistically analyzed, and the IDF value of each character was calculated:
[0023] IDF(*) = log(m / (n+1))+1
[0024] * represents any of the 26 characters from a to z, m represents the total number of contacts, and n represents the number of contacts containing the character *.
[0025] Step 3: Perform word frequency statistics on the pinyin string of each contact to obtain the word frequency TF value of each character. Combine the IDF values of each character to calculate the TF-IDF value, and perform normalization processing to obtain the TF-IDF vector of each contact.
[0026] First, for each contact's Pinyin string, count the occurrences of each character and divide by the total number of characters in that Pinyin string to obtain the term frequency (TF) value for that character.
[0027] TF(*) = t(*) / Z;
[0028] t(*) represents the number of times the character * appears, and Z represents the total number of characters in the Pinyin.
[0029] Then, calculate the TF-IDF value of each character: TF-IDF(*) = TF(*) × IDF(*).
[0030] Next, based on the character index table, construct the TF-IDF vector for each contact, filling the positions where no character appears with 0;
[0031] The TF-IDF vector consists of 26 elements, each with a value that is either the TF-IDF value of the character or 0.
[0032] Finally, L2 normalization is performed on the TF-IDF vector: each element of the vector is divided by the Euclidean norm of the vector; the normalized vector is then associated with and stored with the contact information.
[0033] Step 4: Serialize and save the character index table, IDF value matrix, and TF-IDF vector of each contact in binary format;
[0034] Specifically, this includes: serializing and saving the character index table and IDF value matrix in binary format; and serializing and saving the TF-IDF vectors and contact information of all contacts in binary format.
[0035] Step 5: When the user enters the information of the contact M to be queried, convert the name into Pinyin, and calculate the TF-IDF vector of the contact M according to the above steps;
[0036] Step 6: Calculate the cosine similarity between the TF-IDF vector of contact M and the saved TF-IDF vectors of each contact;
[0037] Cosine similarity calculation: Similarity = Query TF-IDF vector · Contact's TF-IDF vector;
[0038] Step 7: For the saved current contact N, calculate the standardized edit distance between the Chinese name and the pinyin of the names of contacts M and N respectively, and select the maximum value as the final edit distance similarity between contacts M and N;
[0039] Standardized Chinese editing distance: Standardized Chinese editing distance = 1 – d1 / L1;
[0040] d1 represents the Chinese edit distance, which is the difference in the number of Chinese characters in the names of contacts M and N.
[0041] L1 represents the length of the longer Chinese name between the two contacts M and N;
[0042] Standardized Pinyin Edit Distance: Standardized Pinyin Edit Distance = 1 – d² / L²;
[0043] d2 is the Pinyin edit distance, which refers to the difference in the number of characters in the Pinyin of the two names of contacts M and N;
[0044] L2 is the longer pinyin length of the two contacts M and N.
[0045] Step 8: Construct similarity scores for contacts M and N using a weighted average of cosine similarity and final edit distance similarity;
[0046] The final similarity score is calculated by combining cosine similarity and edit distance.
[0047] Final similarity = α × cosine similarity + (1-α) × standardized edit distance
[0048] Where α is the weighting coefficient, and its value ranges from [0,1].
[0049] Step 9: Return to Step 7, iterate through each saved contact, calculate the similarity score between contact M and each contact, sort the contacts in descending order according to the similarity score, and filter out all contacts with a similarity score higher than the preset threshold as search results.
[0050] Step 10: Display the search results to the user, allowing the user to select a contact and providing details viewing and call functions;
[0051] The advantages of this invention are:
[0052] 1. A smart phonebook search method based on the TF-IDF Pinyin Vector Model, which achieves efficient and accurate fuzzy search by vectorizing the Pinyin information of contacts and combining it with the edit distance algorithm; it significantly improves the search accuracy and greatly increases the probability of the target contact appearing at the top of the search results; it achieves high computational performance with a short search response time, which is faster than traditional methods.
[0053] 2. A smart phonebook search method based on the TF-IDF Pinyin vector model, which adopts sparse vector storage and binary serialization technology, significantly reduces storage space requirements and saves a lot of storage space compared with traditional indexing methods.
[0054] 3. An intelligent phonebook search method based on the TF-IDF Pinyin Vector Model, which automatically understands the importance of characters through IDF values, without the need for manual definition of weight rules, and can correctly handle most spelling errors.
[0055] 4. A smart phonebook search method based on the TF-IDF Pinyin vector model, which does not require external corpus training, builds the model only based on the device's own contact data, has better privacy, can work normally even in offline environment, has low resource consumption, and can still run efficiently on embedded devices with limited memory. Attached Figure Description
[0056] Figure 1 This is a flowchart of an intelligent phonebook search method based on the TF-IDF Pinyin Vector Model of the present invention;
[0057] Figure 2 This is a flowchart of the contact person's pinyin vectorization process in an embodiment of the present invention;
[0058] Figure 3 This is a flowchart of query processing and similarity calculation in an embodiment of the present invention;
[0059] Figure 4 This is a flowchart illustrating the dual editing distance optimization effect of an embodiment of the present invention. Detailed Implementation
[0060] To facilitate understanding and implementation of the present invention by those skilled in the art, the present invention will be further described in detail and in depth below with reference to the accompanying drawings.
[0061] This invention discloses an intelligent phonebook search method based on the TF-IDF pinyin vector model, applicable to embedded devices such as IP phones, conference phones, and smart communication terminals that require efficient and accurate contact retrieval. Specifically, the system converts the names of all contacts in the phonebook into pinyin, establishes a character-level index table, and calculates IDF values. For each contact's pinyin string, word frequency statistics are performed to obtain the TF value of each character. The TF-IDF vector is calculated based on the IDF value and then normalized. The character index table, IDF value matrix, and contact vectors are serialized and saved in binary format. When a user inputs a query string, the system receives the input, converts it to pinyin, and calculates the TF-IDF vector of the query string using the same method. Based on this vector, the cosine similarity and edit distance with each contact vector are calculated. After comprehensive scoring, the similarities are sorted, and the most relevant contacts are displayed to the user. The edit distance includes the edit distance between the Chinese name and the pinyin; the maximum value is taken as the final edit distance similarity, improving search accuracy. This invention achieves efficient and accurate fuzzy search by vectorizing contact pinyin information and combining it with the edit distance algorithm, simplifying the steps for users to find contacts.
[0062] like Figure 1 The diagram illustrates the complete process from contact data preprocessing to user query response; the specific steps are as follows:
[0063] Step 1: Save the contact information of an embedded communication device to a phonebook CSV file;
[0064] The phonebook CSV file includes information such as the name, department, email address, and landline number of all contacts.
[0065] Step 2: Convert the contact names in the phone book CSV file to Pinyin to obtain Pinyin strings and build a character index table; at the same time, calculate the IDF value of each character to form an IDF matrix;
[0066] Specifically: First, convert the names of all contacts in the phone book to pinyin to obtain pinyin strings;
[0067] Then, a character-level index table is created, and an index position is assigned to each unique Pinyin character.
[0068] The Chinese Pinyin system uses only 26 English letters, so the index table size is 26. Each letter corresponds to an index position: 'a' corresponds to index 0, 'b' corresponds to index 1, and so on, with 'z' corresponding to index 25.
[0069] Next, the document frequency of each character in all contact pinyin entries in the corpus was statistically analyzed, and the IDF value of each character was calculated:
[0070] IDF(*) = log(m / (n+1))+1
[0071] * represents any of the 26 characters from a to z, m represents the total number of contacts, and n represents the number of contacts containing the character *.
[0072] Step 3: Perform word frequency statistics on the pinyin string of each contact to obtain the word frequency TF value of each character. Combine the IDF values of each character to calculate the TF-IDF value, and perform normalization processing to obtain the TF-IDF vector of each contact.
[0073] First, for each contact's Pinyin string, count the occurrences of each character and divide by the total number of characters in that Pinyin string to obtain the term frequency (TF) value for that character.
[0074] TF(*) = t(*) / Z;
[0075] t(*) represents the number of times the character * appears, and Z represents the total number of characters in the Pinyin.
[0076] Then, calculate the TF-IDF value of each character: TF-IDF(*) = TF(*) × IDF(*).
[0077] Next, based on the character index table, construct the TF-IDF vector for each contact, filling the positions where no character appears with 0;
[0078] The TF-IDF vector consists of 26 elements, each with a value that is either the TF-IDF value of the character or 0.
[0079] Finally, L2 normalization is performed on the TF-IDF vector: each element of the vector is divided by the Euclidean norm of the vector; the normalized vector is then associated with and stored with the contact information.
[0080] Step 4: Serialize and save the character index table, IDF value matrix, and TF-IDF vector of each contact in binary format;
[0081] Specifically, this includes: serializing and saving the character index table and IDF value matrix in binary format; and serializing and saving the TF-IDF vectors and contact information of all contacts in binary format.
[0082] Step 5: When the user enters the information of the contact M to be queried, convert the name into Pinyin, and calculate the TF-IDF vector of the contact M according to the above steps;
[0083] Step 6: Calculate the cosine similarity between the TF-IDF vector of contact M and the saved TF-IDF vectors of each contact;
[0084] Cosine similarity calculation: Similarity = Query TF-IDF vector · Contact's TF-IDF vector;
[0085] Step 7: For the saved current contact N, calculate the standardized edit distance between the Chinese name and the pinyin of the names of contacts M and N respectively, and select the maximum value as the final edit distance similarity between contacts M and N;
[0086] The dual edit distance method includes: simultaneously calculating the edit distance of the Chinese names and the edit distance of the pinyin for the initial screening result set; and taking the maximum value of the two standardized edit distances as the final edit distance similarity.
[0087] Standardized Chinese editing distance: Standardized Chinese editing distance = 1 - Chinese editing distance / length of the longer Chinese name in the contact;
[0088] Standardized Pinyin Edit Distance: Standardized Pinyin Edit Distance = 1 - Pinyin Edit Distance / Longest Pinyin Length in the Contact.
[0089] Chinese edit distance refers to the difference in the number of Chinese characters in the names of contacts M and N;
[0090] Pinyin edit distance refers to the difference in the number of characters in the pinyin of the two names of contacts M and N;
[0091] Step 8: Construct similarity scores for contacts M and N using a weighted average of cosine similarity and final edit distance similarity;
[0092] The final similarity score is calculated by combining cosine similarity and edit distance.
[0093] Final similarity = α × cosine similarity + (1-α) × standardized edit distance
[0094] Where α is the weighting coefficient, and its value ranges from [0,1].
[0095] Step 9: Return to Step 7, iterate through each saved contact, calculate the similarity score between contact M and each contact, sort the contacts in descending order according to the similarity score, and select the top K contacts with similarity scores higher than the preset threshold as search results.
[0096] K is set manually as an integer value based on actual needs. When two similarity scores are close, the contact with the higher edit distance similarity is prioritized based on the final edit distance similarity between the contact M and the two saved contacts. When the similarity of the search results is less than a preset threshold, the contact with the higher edit distance similarity is selected and ranked higher.
[0097] Step 10: Display the search results to the user, allowing the user to select a contact and providing details viewing and call functions;
[0098] 1) Results Display;
[0099] Specifically, this includes: displaying search results to users in sorted order by similarity; and supporting users to select contacts via buttons or touch.
[0100] 2) User interaction;
[0101] Specifically, this includes providing contact details viewing and calling functionality.
[0102] Example:
[0103] Step 1: Pinyin vectorization preprocessing, including character frequency statistics, IDF value calculation, and index table construction, to prepare for subsequent vectorization.
[0104] The parameter configuration includes: a phonebook CSV file, which is used to obtain information about all contacts. The specific configuration process can be exported through the device's phonebook function.
[0105] 1), Pinyin conversion and index construction;
[0106] Specifically include: converting the names of all contacts in the phone book into pinyin to obtain pinyin strings;
[0107] For example, the contact "Li Xiaoming" is converted to "lixiaoming", "Zhang San" is converted to "zhangsan", and "Wang Wu" is converted to "wangwu";
[0108] Establish a character-level index table and assign index positions to each unique pinyin character;
[0109] Considering that Chinese pinyin only uses 26 English letters, the size of the index table is 26, and each letter corresponds to an index position: 'a' corresponds to index 0, 'b' corresponds to index 1, and so on, 'z' corresponds to index 25.
[0110] 2), IDF value calculation and storage;
[0111] Specifically include: counting the document frequency of each character in all contacts' pinyin in the corpus;
[0112] For example, assume there are 1000 contacts in the system, the character 'l' appears in 300 contacts, and the character 'i' appears in 50 contacts; calculate the IDF value of each character: IDF(character) = log(total number of contacts / (number of contacts containing the character + 1)) + 1. For example, IDF('a') = log(1000 / (300 + 1)) + 1 ≈ 1.519, IDF('i') = log(1000 / (50 + 1)) + 1 ≈ 2.293;
[0113] Store the character index table and the IDF value matrix to form the basis of the TF-IDF model.
[0114] Step 2, construction of the contact TF-IDF vector. Conduct word frequency statistics on the pinyin string of each contact, calculate the TF-IDF vector in combination with the IDF value, and perform normalization processing to form the feature representation of the contact;
[0115] The system conducts character frequency statistics on the pinyin string of each contact, calculates the TF value, calculates the TF-IDF value in combination with the IDF value, constructs a vector, and performs normalization processing. This process constructs a unique TF-IDF vector representation for each contact;
[0116] The main process of converting the contact name into a standardized TF-IDF vector is as Figure 2 shown;
[0117] 1), Word frequency statistics and TF-IDF calculation;
[0118] Specifically, for the pinyin string of each contact, count the frequency of each character;
[0119] Taking the contact "Li Xiaoming (lixiaoming)" as an example, 'l' appears 1 time, 'i' appears 3 times, 'x' appears 1 time, 'a' appears 1 time, 'o' appears 1 time,'m' appears 1 time, 'n' appears 1 time, 'g' appears 1 time;
[0120] Calculate the TF value of each character: TF(character) = number of character occurrences / total number of pinyin characters. For example, TF('a') = 1 / 10 ≈ 0.1, TF(i) = 3 / 10 ≈ 0.3; Combine with the IDF value in step 1 to calculate the TF-IDF value: TF-IDF(character) = TF(character) × IDF(character). For example, TF-IDF('a') = 0.1 * 1.519 ≈ 0.152, TF-IDF('i') = 0.3 * 2.293 ≈ 0.459;
[0121] 2), Vector construction and normalization;
[0122] Specifically, according to the character index table, construct the TF-IDF vector of the contact, and fill 0 at the positions where characters do not appear;
[0123] For example, the vector of "Li Xiaoming (lixiaoming)" is [0.152, 0,..., 0.459, 0.377, 0.310, 0.144, 0.149, 0,..., 0.255, 0,..., 0];
[0124] Perform L2 normalization on the TF-IDF vector: divide each element of the vector by the Euclidean norm of the vector. For example, the Euclidean norm of the "Li Xiaoming" vector is sqrt(0.152² + 0.459² + 0.377² + 0.310² + 0.144² + 0.149² + 0.255²) ≈ 0.7616, and the normalized vector is [0.20, 0,..., 0.603, 0.495, 0.407, 0.189, 0.196, 0,..., 0.335, 0,..., 0];
[0125] Associate and store the normalized vector with the contact information.
[0126] Step 3: Model Persistent Storage. Serialize and save the character index table, IDF value matrix, and contact vectors in binary format, and adopt a compact storage structure to reduce memory occupancy.
[0127] To improve the system startup speed and reduce runtime calculations, this method persists the preprocessing results. The vectorizer contains the character index table and IDF value matrix, which are stored in binary format. The contact vectors adopt the sparse representation method, only storing non-zero elements, significantly reducing the storage space occupancy.
[0128] 1). Data serialization;
[0129] Specifically, it includes: Serialize and save the character index table and IDF value matrix in binary format. When specifically implemented, a vectorizer data structure can be used, which contains the mapping from characters to indices and the IDF value array; Serialize and save the normalized TF-IDF vectors and contact information of all contacts in binary format.
[0130] 2). Optimize the storage structure;
[0131] Specifically, it includes: Design a compact storage structure to reduce memory occupancy, and adopt the sparse representation method to store non-zero elements. For example, the contact vectors can use a data structure that contains contact IDs, names, pinyin, and sparse vectors (index-value pairs); By only storing non-zero elements, the storage space occupancy is significantly reduced. When fully implemented, all data is serialized and saved in binary format to the Flash storage, and is directly loaded into memory when the device starts up, without recalculation.
[0132] Step 4: User Query Vectorization. Receive the user input and convert it to pinyin, calculate the TF-IDF vector of the query string using the same method as for contacts, and normalize it.
[0133] When the user enters a query string, the system first performs preprocessing, then calculates the TF-IDF vector of the query string using the same method as for contacts, and performs normalization processing to ensure the same dimension as the contact vectors. The main process is as Figure 3 shown.
[0134] 1). Pinyin preprocessing;
[0135] Specifically, it includes: Receive the query string entered by the user. For example, when the user enters "Li Xia", convert it to pinyin "lixia".
[0136] 2). Query vectorization;
[0137] Specifically, it includes: using the same method as in step two to calculate the TF-IDF vector of the query string. For the query "lixia", the character frequencies are counted: 'l' appears 1 time, 'i' appears 2 times, 'x' appears 1 time, 'a' appears 1 time. Calculate the TF values: TF('l') = 1 / 5 = 0.2, TF('i') = 2 / 5 = 0.4, TF('x') = 1 / 5 = 0.2, TF('a') = 1 / 5 = 0.2;
[0138] Calculate the TF-IDF values: TF-IDF('l') = 0.2 * 1.519 ≈ 0.304, TF-IDF('i') = 0.4 * 1.301 ≈ 0.520, TF-IDF('x') = 0.2 * 1.699 ≈ 0.340, TF-IDF('a') = 0.2 * 1.398 ≈ 0.280;
[0139] Perform L2 normalization on the query vector to ensure the same dimension as the contact vector. For example, the normalization coefficient of "lixia" is sqrt(0.304² + 0.520² + 0.340² + 0.280²) ≈ 0.746, and the normalized vector is [0.375, 0,..., 0.697, 0.408, 0.456, 0,..., 0].
[0140] Step five, similarity calculation, calculate the cosine similarity between the query vector and the contact vector;
[0141] The system calculates the cosine similarity between the query vector and each contact vector.
[0142] 1). Similarity calculation;
[0143] Specifically, it includes: calculating the cosine similarity between the normalized query vector and each normalized contact vector; the cosine similarity calculation is simplified to the vector dot product: similarity = query vector · contact vector;
[0144] For example, calculate the cosine similarity between the query "Li Xia (lixia)" and the contact "Li Xiaoming (lixiaoming)":
[0145] dot_product = 0.375 * 0.20 + 0.697 * 0.603 + 0.408 * 0.189 + 0.456 * 0.335 + 0 * 0.495 + 0 * 0.407 + 0 * 0.196 = 0.075 + 0.420 + 0.077 + 0.153 + 0 + 0 + 0 ≈ 0.725;
[0146] Step 6: Double optimization of similarity and edit distance. Calculate the edit distances of both Chinese names and pinyin simultaneously, take the maximum value as the final edit distance similarity, and construct a new similarity score through weighted combination of the two similarities. Screen through a threshold to improve search accuracy;
[0147] The present invention particularly introduces a double edit distance optimization mechanism, which calculates the edit distances of both Chinese names and pinyin simultaneously to obtain more accurate results. This double edit distance optimization mechanism effectively solves the matching problems of similar pinyin but different Chinese meanings, and the situations where the pinyin edit distance is large but the semantics are similar, making the search results more in line with the user's intention.
[0148] 1). Double edit distance calculation;
[0149] Specifically include: For the result set obtained through preliminary screening, calculate the edit distances of both Chinese names and pinyin simultaneously; Chinese edit distance normalization: Normalized Chinese edit distance = 1 - Chinese edit distance / Chinese name length;
[0150] For example, when the user searches for "Li Xia" and matches the contact "Li Xiaoming", the Chinese edit distance between "Li Xiaoming" and "Li Xia" = 2 (replace "Xia" with "Xiao", add "Ming"), and the normalized Chinese edit distance = 1 - 2 / 3 = 0.33; Pinyin edit distance normalization: Normalized pinyin edit distance = 1 - pinyin edit distance / pinyin length. The pinyin edit distance between "lixiaoming" and "lixia" = 5 (insert "oming"), and the normalized pinyin edit distance = 1 - 5 / 10 = 0.5.
[0151] 2). Result optimization and re - sorting.
[0152] Specifically include: Take the maximum value of the two normalized edit distances as the final edit distance similarity. For example, for "Li Xiaoming": max(0.50, 0.33) = 0.50.
[0153] Integrate the cosine similarity and edit distance to form the final similarity score:
[0154] For example, assume the TF - IDF cosine similarity between Li Xia and Li Xiaoming: "Li Xiaoming" = 0.725. Comprehensive similarity (α = 0.6): "Li Xiaoming" = 0.6 * 0.725 + 0.4 * 0.50 = 0.635; Sort all contacts in descending order according to the similarity score; Screen out the top K contacts with similarity higher than the preset threshold as search results. When the similarities of two results are close (the difference is less than the preset threshold β), preferentially select the result with a higher edit distance similarity.
[0155] Step 7: Results Display and Interaction. The search results are displayed to the user in sorted order of final similarity. Users can select contacts and view details and make calls.
[0156] The system sorts the search results in descending order of similarity and displays them to the user. Users can use the up and down navigation keys to select the desired contact, press the confirmation button to view the contact's details, or make a direct call. The sorting results accurately reflect the degree of similarity to the query terms, including exact matches, prefix matches, and similar-sound matches.
[0157] 1) Results Display;
[0158] Specifically, this includes displaying the top K results that meet the final similarity threshold to the user, such as... Figure 4 As shown, the system calculates the similarity of all contacts, sorts them in descending order, and displays the top K results (K=3 in this embodiment): 1. Li Xiao: similarity 0.891, 2. Liu Xiao: similarity 0.823, 3. Li Xiaoming: similarity 0.635; Users can select contacts by pressing buttons or touching the screen.
[0159] 2) User interaction;
[0160] Specifically, this includes providing contact details viewing and calling functions. Users can select the desired contact using the up and down navigation keys, press the confirmation key to view the contact's detailed information, or make a direct call.
Claims
1. A smart phonebook search method based on the TF-IDF Pinyin vector model, characterized in that, The specific steps are as follows: Step 1: Save the contact information of an embedded communication device to a phonebook CSV file; Step 2: For each contact name in the phone book CSV file, convert it to Pinyin to obtain Pinyin strings and build a character index table; at the same time, calculate the IDF value of each character to form an IDF matrix; The formula for calculating the IDF value is: IDF(*) = log(m / (n+1))+1 * represents any character from a to z (26 characters in total), m represents the total number of contacts, and n represents the number of contacts containing the character *. Step 3: Perform word frequency statistics on the pinyin string of each contact to obtain the word frequency TF value of each character. Combine the IDF values of each character to calculate the TF-IDF value, and perform normalization processing to obtain the TF-IDF vector of each contact. The formula for calculating the term frequency (TF) value is: TF(*) = t(*) / Z; t(*) represents the number of times the character * appears, and Z represents the total number of characters in the Pinyin. The formula for calculating the TF-IDF value is: TF-IDF(*) = TF(*) × IDF(*); Step 4: Serialize and persistently save the character index table, IDF value matrix, and TF-IDF vector of each contact in binary format; Step 5: When the user enters the information of the contact M to be queried, convert the name into Pinyin, and calculate the TF-IDF vector of the contact M according to the above steps; Step 6: Calculate the cosine similarity between the TF-IDF vector of contact M and the saved TF-IDF vectors of each contact; Step 7: For the saved current contact N, calculate the double-standardized edit distance between the Chinese name and the pinyin of the names of contacts M and N respectively, and select the maximum value as the final edit distance similarity between contacts M and N; Step 8: Construct the final similarity score for contacts M and N by weighting cosine similarity and final edit distance similarity; The final similarity score is calculated by combining the cosine similarity and the final edit distance similarity. Final similarity = α × cosine similarity + (1-α) × final edit distance similarity Where α is the weighting coefficient, and its value ranges from [0,1]. Step 9: Return to Step 7, iterate through each saved contact, calculate the final similarity score between contact M and each contact, and sort the contacts in descending order according to the final similarity score; The top K contacts with a final similarity score higher than a preset threshold are selected as search results; K is set to an integer value manually according to actual needs; Step 10: Display the search results to the user, allowing the user to select a contact and providing details viewing and calling functions.
2. The intelligent phonebook search method based on the TF-IDF Pinyin Vector Model as described in claim 1, characterized in that, The phonebook CSV file includes the name, department, email address, and landline number information of all contacts.
3. The intelligent phonebook search method based on the TF-IDF Pinyin Vector Model as described in claim 1, characterized in that, Step two specifically involves: First, convert the names of all contacts in the phone book to pinyin to obtain the pinyin strings; Then, a character-level index table is created, and an index position is assigned to each unique Pinyin character; The Chinese Pinyin uses 26 English letters, so the index table size is 26. Each letter corresponds to an index position: 'a' corresponds to index 0, 'b' corresponds to index 1, and so on, 'z' corresponds to index 25. Next, the document frequency of each character in all contact pinyin in the corpus was counted, and the IDF value of each character was calculated.
4. The intelligent phonebook search method based on the TF-IDF Pinyin Vector Model as described in claim 1, characterized in that, Step three specifically involves: First, for each contact's pinyin string, count the number of times each character appears, and divide by the total number of characters in that pinyin string to obtain the word frequency (TF) value of that character; Then, calculate the TF-IDF value of each character; Next, based on the character index table, construct the TF-IDF vector for each contact, filling the positions where no character appears with 0; The TF-IDF vector consists of 26 elements, each element having a value that is either the TF-IDF value of the character or 0. Finally, L2 normalization is performed on the TF-IDF vector: each element of the vector is divided by the Euclidean norm of the vector; the normalized vector is then associated with and stored with the contact information.
5. The intelligent phonebook search method based on the TF-IDF Pinyin vector model as described in claim 1, characterized in that, Step four specifically includes: serializing and saving the character index table and IDF value matrix in binary format; serializing and saving the TF-IDF vectors and contact information of all contacts in binary format; that is, the contact vectors are stored using sparse representation, and only the indices and values of non-zero elements are saved.
6. The intelligent phonebook search method based on the TF-IDF Pinyin Vector Model as described in claim 1, characterized in that, In step six, the cosine similarity calculation is simplified to the dot product operation of two normalized vectors, that is: Similarity = TF-IDF vector of the query · TF-IDF vector of the contact.
7. The intelligent phonebook search method based on the TF-IDF Pinyin Vector Model as described in claim 1, characterized in that, In step seven, the edit distance uses the Levenshtein distance algorithm, and the standardized formula is: Standardized Chinese editing distance: Standardized Chinese editing distance = 1 – d1 / L1; d1 represents the Chinese edit distance, which is the difference in the number of Chinese characters in the names of contacts M and N. L1 represents the length of the longer Chinese name between the two contacts M and N; Standardized Pinyin Edit Distance: Standardized Pinyin Edit Distance = 1 – d² / L²; d2 is the Pinyin edit distance, which refers to the difference in the number of characters in the Pinyin of the two names of contacts M and N; L2 is the longer pinyin length of the two contacts M and N.
8. The intelligent phonebook search method based on the TF-IDF Pinyin vector model as described in claim 1, characterized in that, In step nine, when the similarity scores of the two contacts are close, the contact with the higher edit distance similarity is prioritized based on the final edit distance similarity between the contact M and the two saved contacts.