Generate a Chinese name and pinyin table for the railway station! Solution
Source: Internet
Author: User
Generate a Chinese name and pinyin table for the railway station! One appendix is the list of Chinese names of railway stations nationwide, and the other is the Chinese pinyin Database. based on the two documents, a table (one row, use a colon to separate Chinese characters and pinyin characters in a row. Note that if the program is used to generate the program, you must manually remove the wrong polyphonic words and try to solve the problem. The php array index is implemented, how should I write scores to generate a Chinese name and pinyin table for the railway station! Thoughts
One attachment is the Chinese name list of the national railway station and the other is the Chinese pinyin database. based on the two documents, a table corresponding to the Chinese name and pinyin of the railway station is generated (one row, use a colon to separate Chinese and pinyin characters in a row)
Note that if the program is used to generate the program, you must manually remove the wrong polyphonic words.
I would like to ask how to write php array indexes.
Small score, please forgive me
------ Solution --------------------
Set
Pinyin database .txt
A:
A:
A: e
AH:
Generation:
Generation:
Generation:
AH: ai
Mourning: ai
......
Then
Function foo ($ v ){
Return explode (':', trim ($ v ));
}
Foreach (array_map ('foo', file('pinyin repository .txt ') as $ v)
$ Dict [$ v [0] = $ v [1];
The Chinese character is the key, and the pinyin is the worthwhile array $ dict
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