汉字拼音数据库

原创
2016-06-07 15:10:52 1304浏览

所以要先对txt文件进行筛选,只留下简体汉字跟拼音,代码如下(WinDev语言,法文版) MonBuffer est un Buffer MonBuffer = fChargeTexte(C:\Users\stagiaire57\Desktop\Notes\BD_donne\cedit.txt) MaCha?ne est une cha?ne UNICODE MaCha?ne = MonBuffer nI



所以要先对txt文件进行筛选,只留下简体汉字跟拼音,代码如下(WinDev语言,法文版)

MonBuffer est un Buffer
MonBuffer = fChargeTexte("C:\Users\stagiaire57\Desktop\Notes\BD_donne\cedit.txt")
MaCha?ne est une cha?ne UNICODE
MaCha?ne = MonBuffer
nIDFichier est int= fOuvre("C:\Users\stagiaire57\Desktop\Notes\BD_donne\cedittestSimplifie.txt", foLectureEcriture)
i est un int=1
TANTQUE ExtraitLigne(MaCha?ne,i) EOT //是不等于的意思,就是说只要不等边界付就继续执行,一旦等于就停止执行。
unechaine est une cha?ne=ExtraitLigne(MaCha?ne,i)
//sUneNouvelleChaine1 est une cha?ne=ExtraitCha?ne(unechaine,1," ",DepuisDébut)
sUneNouvelleChaine2 est une cha?ne=ExtraitCha?ne(unechaine,2," ",DepuisDébut)
sUneNouvelleChaine3 est une cha?ne=ExtraitCha?ne(unechaine,2,["[","]"," and "])
sUneNouvelleChaine4 est une cha?ne=sUneNouvelleChaine2+TAB+sUneNouvelleChaine3
fEcritLigne(nIDFichier,sUneNouvelleChaine4)
i++
FIN

可以看出WinDev非常方便,几行代码就解决了可能其他语言要写一页的代码。处理后的txt文件如下:


那么现在大家可以清楚地看到,原始txt文件里面的拼音虽然有声调,但是都是用数组表示的,并没有真正的显示在字母上面,下面就是我的程序的新颖的地方,我把声调加在了相应的字母上面,然后再把数据放到数据库里面。代码如下:

PROCEDURE DetecterETchanger(UnPinyin):cha?ne UNICODE
sChaineTest est une cha?ne UNICODE=Milieu(UnPinyin,Taille(UnPinyin),1)


sLettreAremplace est une cha?ne UNICODE=""
sLettreRemplace est une cha?ne UNICODE=""


nTrouve est un entier=0


SI ChercherVoyelle(UnPinyin,"a")=Vrai ALORS
nTrouve=1
sLettreAremplace="a"
SELON sChaineTest
CAS "1"
sLettreRemplace="ā"
CAS "2"
sLettreRemplace="á"
CAS "3"
sLettreRemplace="ǎ"
CAS "4"
sLettreRemplace="à"
CAS "5"
sLettreRemplace="a"
AUTRE CAS
RENVOYER UnPinyin
FIN
FIN

SI nTrouve=0 _ET_ ChercherVoyelle(UnPinyin,"o")=Vrai ALORS
nTrouve=1
sLettreAremplace="o"
SELON sChaineTest
CAS "1"
sLettreRemplace="ō"
CAS "2"
sLettreRemplace="ó"
CAS "3"
sLettreRemplace="ǒ"
CAS "4"
sLettreRemplace="ò"
CAS "5"
sLettreRemplace="o"
AUTRE CAS
RENVOYER UnPinyin
FIN
FIN


SI nTrouve=0 _ET_ ChercherVoyelle(UnPinyin,"e")=Vrai ALORS
nTrouve=1
sLettreAremplace="e"
SELON sChaineTest
CAS "1"
sLettreRemplace="ē"
CAS "2"
sLettreRemplace="é"
CAS "3"
sLettreRemplace="ě"
CAS "4"
sLettreRemplace="è"
CAS "5"
sLettreRemplace="e"
AUTRE CAS
RENVOYER UnPinyin
FIN
FIN


SI nTrouve=0 _ET_ ChercherVoyelle(UnPinyin,"i")=Vrai ALORS
nTrouve=1
sLettreAremplace="i"
SELON sChaineTest
CAS "1"
sLettreRemplace="ī"
CAS "2"
sLettreRemplace="í"
CAS "3"
sLettreRemplace="ǐ"
CAS "4"
sLettreRemplace="ì"
CAS "5"
sLettreRemplace="i"
AUTRE CAS
RENVOYER UnPinyin
FIN
FIN


SI nTrouve=0 _ET_ ChercherVoyelle(UnPinyin,"u")=Vrai ALORS
nTrouve=1
sLettreAremplace="u"
SELON sChaineTest
CAS "1"
sLettreRemplace="ū"
CAS "2"
sLettreRemplace="ú"
CAS "3"
sLettreRemplace="ǔ"
CAS "4"
sLettreRemplace="ù"
CAS "5"
sLettreRemplace="u"
AUTRE CAS
RENVOYER UnPinyin
FIN
FIN

SI nTrouve=0 _ET_ ChercherVoyelle(UnPinyin,"v")=Vrai ALORS
nTrouve=1
sLettreAremplace="u:"
SELON sChaineTest
CAS "1"
sLettreRemplace="ǖ"
CAS "2"
sLettreRemplace="ǘ"
CAS "3"
sLettreRemplace="ǚ"
CAS "4"
sLettreRemplace="ǜ"
CAS "5"
sLettreRemplace="ü"
AUTRE CAS
RENVOYER UnPinyin
FIN
FIN

SI nTrouve=0 ALORS
RENVOYER UnPinyin
FIN
sUnPinyinRemplace est une cha?ne UNICODE=Remplace(UnPinyin,sLettreAremplace,sLettreRemplace)
RENVOYER Milieu(sUnPinyinRemplace,1,Taille(sUnPinyinRemplace)-1)

PROCEDURE ChangerPinyinAccent()
MonBuffer est un Buffer
MonBuffer = fChargeTexte("C:\Users\stagiaire57\Desktop\PinyinTest.txt")
MaCha?ne est une cha?ne UNICODE
MaCha?ne = MonBuffer
HOuvre(ChangerPinyin1)
i est un int=1

TANTQUE ExtraitLigne(MaCha?ne,i) EOT
PinyinFinale est une cha?ne UNICODE=""
unechaine est une cha?ne=ExtraitLigne(MaCha?ne,i)
ChangerPinyin1.Hanzi=ExtraitCha?ne(unechaine,1,TAB)
PinyinInitiale est une cha?ne UNICODE=ExtraitCha?ne(unechaine,2,TAB)

numbre est un entier=1
BOUCLE
UnPinyin est une cha?ne UNICODE=ExtraitCha?ne(PinyinInitiale,numbre," ",DepuisDébut)
numbre++
SI UnPinyin=EOT ALORS SORTIR
PinyinFinale+=DetecterETchanger(UnPinyin)
SI ExtraitCha?ne(PinyinInitiale,numbre," ",DepuisDébut)EOT ALORS PinyinFinale+=" "
FIN

ChangerPinyin1.Pinyin=PinyinFinale

HAjoute(ChangerPinyin1)
i++
FIN

PROCEDURE ChercherVoyelle(UnPinyin,lettre):booléen
i est un entier=1
longuerUnPinyin est un entier = Taille(UnPinyin)

SI lettre="v" ALORS
BOUCLE
chaineInstant est une cha?ne UNICODE=Milieu(UnPinyin,i,1)
SI chaineInstant="u" ET Milieu(UnPinyin,i+1,1)=":"ALORS
RENVOYER Vrai
FIN
SI i=longuerUnPinyin ALORS
RENVOYER Faux
FIN
i++
FIN
FIN

SI lettre="u" ALORS
BOUCLE
chaineInstant est une cha?ne UNICODE=Milieu(UnPinyin,i,1)
SI chaineInstant=lettre ET Milieu(UnPinyin,i+1,1)":" ALORS
RENVOYER Vrai
FIN
SI i=longuerUnPinyin ALORS
RENVOYER Faux
FIN
i++
FIN
FIN

BOUCLE
chaineInstant est une cha?ne UNICODE=Milieu(UnPinyin,i,1)
SI chaineInstant=lettre ALORS
RENVOYER Vrai
FIN
SI i=longuerUnPinyin ALORS
RENVOYER Faux
FIN
i++
FIN

最终的数据库如下:



好了所有的数据库程序就这些,可以看出WinDev真的是一门很方便的语言,它的数据库是HyperSQL,但是这个语言也可以往其他的数据库中写数据。

希望文章对大家有帮助。

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。