In php, Chinese characters are converted to pinyin. how can I find Chinese characters using pinyin? How can I find Chinese characters using pinyin?
If you call the text in a txt file, convert each line of content to pinyin,
This is simple and highly efficient, so we can use pinyin to find Chinese characters and suddenly find that the efficiency is surprisingly low,
A headache !!!!!
Define ("DIR", dirname (_ FILE __));
$ Titleline = file (DIR. "/hanzi.txt ");
$ TC = count ($ Titleline );
$ Pinyin = "woaini ";
For ($ I = 1; $ I <= $ TC; $ I ++ ){
$ X = strcmp ($ yuming, py ($ Titleline [$ I]);
If ($ x = 0 ):
$ Title1 = $ Titleline [$ I];
Break;
Endif;
}
The code looks like above
Py is a function for converting Chinese characters to pinyin.
The problem is that when the hanzi.txt size exceeds 1-3 M, the speed will be very slow ,,,
How to deal with this problem ,,,
Reply to discussion (solution)
First, it should be noted that because of the existence of homophone (many different meanings of homophone)
Therefore, searching for Chinese characters in pinyin is meaningless.
Using multiple hash tables to organize data can be efficiently queried
First, it should be noted that because of the existence of homophone (many different meanings of homophone)
Therefore, searching for Chinese characters in pinyin is meaningless.
Using multiple hash tables to organize data can efficiently query this homophone, which may be reduced ,,,
Can I use multiple hash tables to organize data efficiently? can I give an example?
First, it should be noted that because of the existence of homophone (many different meanings of homophone)
Therefore, searching for Chinese characters in pinyin is meaningless.
By using a multi-hash table to organize data, you can efficiently query data. I cannot use databases .. Only txt operations can be performed.
You can use the trie algorithm.
According to the Chinese Pinyin scheme, all Chinese characters only consist of the initials and the vowels. it would be better to add a tone.
At most, the triple hash table is complete.
You can use the trie algorithm.
According to the Chinese Pinyin scheme, all Chinese characters only consist of the initials and the vowels. it would be better to add a tone.
At most, the triple hash table completes the moderator's rich experience. I am a newbie and don't know how to get started .....