The method that a kind of smart mobile phone address list is searched for generally
Technical field
The present invention relates to the technical field of information processing of intelligent mobile phone terminal, particularly the address book contact intelligent search.
Background technology
Along with the development of intelligent mobile device system, people are also more and more higher to the demand of smart mobile phone, comprise the interface of more beautifying, more succinct operation efficiently, multi-purpose application software etc.Cell phone address book is as the most basic application of mobile phone, in daily life, bring into play enormous function, processes such as telephonic communication, transmitting-receiving note, transmission mail all need to call the contact phone book, and the address list function ratio that present mobile phone operating system carries is weak, especially experience serious hysteresis the user aspect contact person's search, cause the user send short messages, when making a phone call positioning contact much inconvenience.
The database full-text search is that big data text is carried out index, in the index of setting up the word that will search is searched for, and locatees which text data and comprises the word that will search for; Whole work of full-text search are exactly to set up index and search for the location in index, and all work is all carried out around these two; The method of participle is that binary is divided morphology, maximum matching method and statistical method basically, and the indexed data structure adopts the structure of inverted index basically.Text searching method is mainly used in the large data text, this simple in structure, scene that data volume is less of it and inapplicable address list.In addition, it also needs bigger storage space, and along with the renewal Dynamic Maintenance index of address list, overall cost is too big, uses underaction.
What traditional address list search was adopted is to carry out simple characters string coupling to importing key words and name of contact person and number, does not consider the special search such as spelling, simplicity and part phonetic of name.In addition, the subsequence of character string be from initial sequence by removing some element but do not destroy the new sequence that the relative position of remaining element forms, it is the working standard of describing two similar couplings of character string, in formal mode, a given sequence
X=<x
1, x
2, x
3..., x
m, another sequence
Z=<z
1, z
2, z
3..., z
kBe the subsequence of X, if exist
XA strictly increasing following table sequence<i
1, i
2..., i
k, make to all j=1,2 ..., k has.Traditional subsequence matching algorithm is not considered initial consonant and the simple or compound vowel of a Chinese syllable of phonetic, phonetic is not carried out dynamic participle coupling, therefore need carry out certain transformation.
The simple ease for use of thumb keyboard is attracting a large amount of smart mobile phone users, and the intelligence inquire that thumb keyboard the is provided requisite demand that is the user, therefore how to people provide more convenient, more efficiently address list search operation method and user to experience be problem demanding prompt solution.
Summary of the invention
The present invention is directed to the problems referred to above, the method that provides a kind of smart mobile phone address list to search for generally, purpose is convenient, address list search operation method efficiently, to support fuzzy matching and location to determinant attributes such as name of contact person (spelling, simplicity, part phonetic, thumb keyboard Serial No.), phone number, mailboxes, and provide faster, better user to experience to the user.
To achieve these goals, the present invention is by the following technical solutions:
The method that a kind of smart mobile phone address list is searched for generally may further comprise the steps:
1) reads the native contact book contact data by open interface, reject redundant data, only leave and take key messages such as name of contact person, phone number, mailbox;
2) by the information pretreater All Contacts's information is carried out pre-service, for the Chinese in the name, extract phonetic by looking into the encode Chinese characters for computer table, polyphone is corresponding many records then, simultaneously phonetic is transcoded into the Serial No. of thumb keyboard correspondence, in above-mentioned all record write memory and the buffer that designs;
3) to the search key key of input, at first whether the query caching device has corresponding record, directly locate if hit then, otherwise the global search address list is divided into three types with key word key: a) contain Chinese character; B) do not contain Chinese character, contain English alphabet and numeral; C) only comprise pure digi-tal;
4) carry out match search for given key word key by the search adaptation, if key word belongs to the b classification, then match objects is name of contact person phonetic; If belong to the c classification, then match objects is the thumb keyboard Serial No.; The concrete matched rule of search adaptation: name phonetic is converted to a phonetic array, each letter of traversal key word, letter and phonetic word are mated successively, if current letter coupling, then continue first letter of the next letter of coupling key and current word or next word, if all key word letters have corresponding coupling, then the match is successful, otherwise it fails to match;
5) obtain the contact person of all and key word key coupling by step 3, four, be weighted ordering and output by the weighting sorting unit according to coupling priority.
Further, in the described step 3), be name of contact person for a match objects; Be name of contact person phonetic and mailbox for the b match objects; Be the corresponding thumb keyboard Serial No. of contact phone number and name for the c match objects; Should adopt the phonetic fuzzy matching algorithm in the step 4) that Pinyin coding and thumb keyboard Serial No. are carried out fuzzy matching for b, c, during search, at first in buffer, inquire about, as if hitting or having current key word prefix, then in former result, carry out binary search.
Further, in the described step 4), specific algorithm thought is described as: to given key word key and name phonetic pinyin, earlier pinyin is separated into array pinyin[N with space character], definition s is the phonetic array index that begins to mate, k is the current key inferior that needs coupling, and i is the phonetic word subscript of current coupling, and j is the inferior of current word;
A. initialization s=0, k=0, i=s, j=0, namely first letter from first letter of key word and first word of phonetic begins coupling;
B. judge k==key.length, if true, then the match is successful, and algorithm stops; If false then changes 3;
C. judge key[k]==pinyin[i] [j], if true changes 4, if false changes 6;
D. k++, j++, it is next alphabetical with current phonetic word namely to attempt the next letter of coupling key word;
E. judge j<pinyin[i] .length, judge in advance namely whether current word all mates, if changeing 2, true continues the coupling next one, false commentaries on classics 7;
F. judge whether i phonetic has coupling, if true changes then s++ of 7, false, k=0, i=s, j=0 also changes 2, mates again since s phonetic word;
G. i++, j=0 namely attempts coupling key word and first letter of next word;
H. judge i<pinyin.length, if true then change 2, false then it fails to match, algorithm stops;
According to above arthmetic statement, can accurately judge key and pinyin[N] whether mate, in algorithmic procedure, can be with a match[N] the coupling details of array recording key and each phonetic, after algorithm finishes, according to match accurate description algorithmic match reason, for the thumb keyboard Serial No., employed ephemeral data in the algorithmic procedure just, the user also should oppositely inquire specifically fuzzy matching to pinyin according to the match array.
Further, in the described step 5), described coupling priority can be self-defined.
Further, in the described step 5), coupling priority is: mate fully〉the part coupling; Spelling〉simplicity〉part phonetic; Name matches〉numbers match〉the mailbox coupling.
Further, the key word key+ Search Results record to having searched should deposit in the buffer, next time is when searching for new key word, at first answer the query caching device, if key word hits or when having the key word prefix, directly carry out binary search on the outcome record of buffer memory.
The present invention compared with prior art has following beneficial effect:
Practical simple, the simple operation of method provided by the present invention, search efficiently, its supports Chinese character, telephone number, mailbox to search for the contact person; Support is searched for the contact person generally by name initial, spelling, part phonetic.
Further, support the thumb keyboard input digit directly the anti-phonetic of looking into search for the contact person generally.
Further, can provide concrete coupling reason to search contact person result by improved character string subsequence matching algorithm.
Further, support the thumb keyboard input digit directly the anti-phonetic of looking into search for the contact person generally.
Further, Search Results is carried out record buffer memory, binary search efficient is higher.
Description of drawings
The structural representation that Fig. 1 searches for generally for address list.
Fig. 2 is for searching for the schematic flow sheet of address book contact generally by key word.
Fig. 3 is improved character string subsequence matching algorithm schematic flow sheet.
Embodiment
Come invention is described in detail below in conjunction with embodiment and accompanying drawing.
What the present invention provided is that a kind of smart mobile phone address list is searched for contact person's method generally, has designed searching structure synoptic diagram as shown in Figure 1, specifically comprises:
Information pretreater: obtain and to the associated person information pre-service, filter redundant data, name is carried out Pinyin coding etc.
Buffer: pretreated associated person information is carried out buffer memory, simultaneously key word-Search Results is carried out buffer memory.
The search adaptation: to given search key, according to its all key messages of classification matching associated person, it has called transformed subsequence matching algorithm.
Weighting sorting unit: Search Results according to self-defining priority rule, is carried out overall weighting ordering output.
The schematic flow sheet that address book contact searched for generally in the key word as shown in Figure 2 searching method in the one embodiment of the invention as can be seen mainly comprises following flow process:
1) interface that provides by mobile phone operating system reads the native contact book contact data, rejects redundant data, only leaves and takes key messages such as name of contact person, phone number, mailbox.
2) personal information of all address book contacts is carried out pre-service, especially, name of contact person is extracted phonetic by looking into the Chinese-character sound dissection encode table, use space-separated between each phonetic transcriptions of Chinese characters, if there is polyphone in the name, then be transcoded into many records, simultaneously pinyin translations is become the Serial No. of thumb keyboard correspondence, associated person information to above-mentioned processing is maintained in the internal memory, backups to simultaneously in the buffer that has designed, and next search is record in the query caching device directly.
Table 1 is the thumb keyboard numeral transcoding table of phonetic alphabet correspondence.
When 4) searching for address book contact, the inputted search key word is divided into three kinds with key word and considers: a) contains Chinese character; B) do not contain Chinese character, comprise English alphabet; C) only comprise pure digi-tal.For a), key word comprises Chinese character, may contain Chinese and have only in the associated person information in the original name field of unprocessed mistake, therefore only needs key word and name of contact person string matching are got final product; For b), key word comprises English alphabet, the field that may meet should be phonetic or the mailbox of name of contact person, for the phonetic situation, be thought of as spelling, simplicity, part phonetic a kind of of name of contact person, can adopt the matching algorithm of key word in the step 4 and name spelling to handle, if mailbox then only needs a simple string matching to get final product; For c), key word only comprises pure digi-tal, should consider two kinds of situations of phone number and thumb keyboard Serial No., the former only need carry out the substring coupling to key word and contact number, and the latter then adopts the key word of step 4 and the matching algorithm of thumb keyboard Serial No..
5) similar to given key word key and name phonetic pinyin(pure digi-tal and thumb keyboard Serial No. coupling situation), earlier name phonetic is separated into array pinyin[N with space character], coupling key and pinyin[N].
Concrete transformed phonetic matching algorithm, be improved character string subsequence matching algorithm flow process as shown in Figure 3, specific as follows: definition s is the phonetic array index that begins to mate, k is the current key inferior that needs coupling, i is the phonetic word subscript of current coupling, and j is the inferior of current word.
A. initialization s=0, k=0, i=s, j=0, namely first letter from first key word letter and first word of phonetic begins coupling.
B. judge k==key.length, if true, then the match is successful, and algorithm stops; If false then changes 3.
C. judge key[k]==pinyin[i] [j], if true changes 4, if false changes 6.
D. k++, j++, it is next alphabetical with current phonetic word namely to attempt the next letter of coupling key word.
E. judge j<pinyin[i] .length, judge in advance namely whether current word all mates, if changeing 2, true continues the coupling next one, false commentaries on classics 7.
F. judge whether i phonetic has coupling, if true changes then s++ of 7, false, k=0, i=s, j=0 also changes 2, mates again since s phonetic word.
G. i++, j=0 namely attempts coupling key word and first letter of next word.
H. judge i<pinyin.length, if true then change 2, false then it fails to match, algorithm stops.
According to above arthmetic statement, can accurately judge key and pinyin[N] whether mate, in algorithmic procedure, we can be with a match[N] the coupling details of array recording key and each phonetic, after algorithm finishes, can be according to match accurate description algorithmic match reason, in addition for the thumb keyboard Serial No., it is employed ephemeral data in the algorithmic procedure, also should oppositely inquire specifically fuzzy matching to pinyin according to the match array for the user.
6) by step 3), 4) contact person that drawn all and key word key coupling, reason (match) according to coupling sorts to the result, priority can be self-defined as required, and among the embodiment, priority definition is as follows preferably in the present invention: coupling fully〉the part coupling; Spelling〉simplicity〉part phonetic; Name matches〉numbers match〉mailbox.
In order to improve search efficiency, we deposit the record of search key key-Search Results in the buffer in, when search for new key word next time like this, can in buffer, inquire about earlier, hit or when having prefix key as key word, can carry out binary search on the outcome record of buffer memory, this will improve search efficiency greatly.
Though the present invention with preferred embodiment openly as above; but it is not to limit the present invention; any those skilled in the art without departing from the spirit and scope of the present invention; can utilize method and the technology contents of above-mentioned announcement that technical solution of the present invention is made possible change and modification; therefore; every content that does not break away from technical solution of the present invention; to any simple modification, equivalent variations and modification that above embodiment does, all belong to the protection domain of technical solution of the present invention according to technical spirit of the present invention.