日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

漢字轉(zhuǎn)換 漢字轉(zhuǎn)換拼音( 二 )


strict– 是否嚴格遵照《漢語拼音方案》來處理聲母和韻母,詳見 strict 參數(shù)的影響
import pypinyinfrom pypinyin import Stylepypinyin.slug('我是中國人')'wo-shi-zhong-guo-ren'pypinyin.slug('我是中國人', separator=' ')'wo shi zhong guo ren'pypinyin.slug('中國人2020雄起', separator=' ')#遇到數(shù)字等非漢字不注音'zhong guo ren 2020 xiong qi'pypinyin.slug('中國人2020雄起', style=Style.FIRST_LETTER)'z-g-r-2020-x-q'pypinyin.slug('我是中國人', style=Style.CYRILLIC)'во3-ши4-чжун1-го2-жэнь'【漢字轉(zhuǎn)換 漢字轉(zhuǎn)換拼音】
4、 pypinyin.load_single_dict功能:載入用戶自定義的單字拼音庫
語法:pypinyin.load_single_dict(pinyin_dict, style='default')
參數(shù):
pinyin_dict(dict) – 單字拼音庫 。比如: {0x963F: u"ā,ē"}
style– pinyin_dict 參數(shù)值的拼音庫風(fēng)格. 支持 ‘default’, ‘tone2’
5、 pypinyin.load_phrases_dict功能:載入用戶自定義的詞語拼音庫
語法:pypinyin.load_phrases_dict(phrases_dict, style='default')
參數(shù):
phrases_dict(dict) – 詞語拼音庫 。比如: {u"阿爸": [[u"ā"], [u"bà"]]}
style– phrases_dict 參數(shù)值的拼音庫風(fēng)格. 支持 ‘default’, ‘tone2’
五、一個案例假如需要找出一個垃圾評價的相似樣本,用漢語相似性遠遠小于拼音,這個時候 , 拼音就能發(fā)揮很大的優(yōu)勢 。
當然轉(zhuǎn)換成拼音后,把每個音節(jié)當一個詞,進行深度學(xué)習(xí),效果也是非常好的 。
S1 = '加公眾號:小優(yōu)惠,領(lǐng)券,便宜購買'S2 = '伽工仲號:小優(yōu)惠,伶綣,便宜購買'#漢語相似simi_1 = len(set(S1).intersection(set(S2)))/len(set(S1).union(set(S2)))#相似不懂的可以看我前面集合的文章simi_10.5#轉(zhuǎn)換成拼音后顯示S1 = lazy_pinyin(S1)S2 = lazy_pinyin(S2)simi_2 = len(set(S1).intersection(set(S2)))/len(set(S1).union(set(S2)))simi_20.875Python學(xué)習(xí)交流群
為了讓大家更加即時地溝通學(xué)習(xí),我們建了一個Python學(xué)習(xí)交流群 , 有想入群的同學(xué) , 可以添加下面小助手微信,他會拉大家入群哈~

推薦閱讀