In php, Chinese characters are converted to pinyin. how can I find Chinese characters using pinyin?

Source: Internet
Author: User
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 .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.