add changelog, and update the pakkau , etc.

This commit is contained in:
Tan, Kian-ting 2024-06-28 22:18:00 +08:00
parent eeffa16ec9
commit a0613809ca
6 changed files with 1584 additions and 11 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

Binary file not shown.

View file

@ -44,7 +44,11 @@ def genmod():
for i in new_data: for i in new_data:
hanji = i[0] hanji = i[0]
lomaji = i[1] lomaji = i[1]
'''111'''
hanji = list(zip(hanji, lomaji))
hanji = list(map(lambda x : x[0] + x[1], hanji))
for j in range(len(i[0])): for j in range(len(i[0])):
if not hanji[j] in char_to_pronounce: if not hanji[j] in char_to_pronounce:
char_to_pronounce[hanji[j]] = {lomaji[j] : 1} char_to_pronounce[hanji[j]] = {lomaji[j] : 1}
@ -65,7 +69,7 @@ def genmod():
for i in new_data: for i in new_data:
head_hanji = i[0][0] head_hanji = i[0][0]+i[1][0]
if head_hanji in init_freq: if head_hanji in init_freq:
init_freq[head_hanji] += 1 init_freq[head_hanji] += 1
@ -86,7 +90,8 @@ def genmod():
cur.execute("CREATE TABLE transition(prev_char, next_char, freq)") cur.execute("CREATE TABLE transition(prev_char, next_char, freq)")
for i in new_data: for i in new_data:
hanji = i[0] hanji_tmp = list(zip(i[0],i[1]))
hanji = list(map(lambda x: x[0]+ x[1], hanji_tmp))
for j in range(len(i[0])-1): for j in range(len(i[0])-1):
this_hanji = hanji[j] this_hanji = hanji[j]
next_hanji = hanji[j+1] next_hanji = hanji[j+1]
@ -111,7 +116,6 @@ def genmod():
def get_homophones(pron, cur, con): def get_homophones(pron, cur, con):
homophones_raw = cur.execute("select hanji FROM pronounce where lomaji = ?", (pron, )).fetchall() homophones_raw = cur.execute("select hanji FROM pronounce where lomaji = ?", (pron, )).fetchall()
homophones = list(map(lambda x: x[0], homophones_raw)) homophones = list(map(lambda x: x[0], homophones_raw))
return homophones return homophones
def convert(sentences): def convert(sentences):
@ -171,7 +175,7 @@ def convert_one_sentence(sentence):
for i in homophones_sequence[0]: for i in homophones_sequence[0]:
i_freq = cur.execute('''select initial.freq FROM initial i_freq = cur.execute('''select initial.freq FROM initial
WHERE initial.char = ?''', (i['char'])).fetchall()[0][0] WHERE initial.char = ?''', (i['char'],)).fetchall()[0][0]
i['prob'] = i_freq / head_freq_total i['prob'] = i_freq / head_freq_total
@ -268,8 +272,10 @@ on p.hanji = p2.hanji where p2.lomaji = ?''', (small_capized[i],)).fetchall()[0]
current = current_ls[0]["char"] current = current_ls[0]["char"]
prev_char = current_ls[0]["prev_char"] prev_char = current_ls[0]["prev_char"]
return_result = list(filter(lambda x : x != "", return_result))
return_result = list(map(lambda x : x[0] if re.match(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎𪜀-\U0002b73f]', x)
else x, return_result))
return return_result return return_result

3
CHANGELOG.md Normal file
View file

@ -0,0 +1,3 @@
# 2024-06-28
## Modify
- the clear button, and update the pakkau version.

1550
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,13 @@
<html> <!DOCTYPE html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Tâi-gí Lô-má-jī tsuán hàn-jī 臺語羅馬字轉漢字 (test)</title> <title>Tâi-gí Lô-má-jī tsuán hàn-jī 臺語羅馬字轉漢字 (test)</title>
<style> <style>
.div-table { .div-table {
display: table; display: table;
width: auto; width: auto;
font-style:italic;
margin: auto 2em;
} }
.div-table-row { .div-table-row {
display: table-row; display: table-row;
@ -24,7 +26,7 @@
} }
#hanji-input { #hanji-output {
width:50%; width:50%;
float: right; float: right;
@ -36,8 +38,15 @@
padding: none; padding: none;
width: auto; width: auto;
font-style:italic; font-style:italic;
text-decoration: underline;
color: blue;
}
#footer{
clear:both;
} }
</style> </style>
</head> </head>
<body> <body>
<h1>Tâi-gí Lô-má-jī tsuán hàn-jī <br/> 臺語羅馬字轉漢字</h1> <h1>Tâi-gí Lô-má-jī tsuán hàn-jī <br/> 臺語羅馬字轉漢字</h1>
@ -72,13 +81,14 @@ Kī-su̍t in-sòo, tsit-má kan-ta tsi-oan Kàu-io̍k-pōo Lô-mâ-jī kap kiàn
</div> </div>
<div id="hanji-input"> <div id="hanji-output">
<strong>Su-tshut Hàn-jī 輸出漢字:</strong> <strong>Su-tshut Hàn-jī 輸出漢字:</strong>
<div id="hanji-result"/></div> <div id="hanji-result"></div>
</div> </div>
</div> </div>
</body> <div id="footer">
<a href="https://kianting.info/wiki/w/ProgProject:Pakkau-webapp">Suat-bîng 說明</a></div>
<script> <script>
const convertButton = document.getElementById("convert"); const convertButton = document.getElementById("convert");
const hanjiTextBox = document.getElementById("lomaji-textare"); const hanjiTextBox = document.getElementById("lomaji-textare");
@ -107,4 +117,7 @@ var xhttpReq = new XMLHttpRequest();
convertButton.addEventListener('click', query); convertButton.addEventListener('click', query);
clearOne.addEventListener('click', clear); clearOne.addEventListener('click', clear);
</script> </script>
</body>
</html> </html>