Skip to content

Commit

Permalink
Add conversion for quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaka14732 committed Apr 18, 2021
1 parent e79fb30 commit 3b8dbb2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
14 changes: 5 additions & 9 deletions build/convert_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
# - cache/convert_table_words_twp.txt
# - cache/convert_table_chars_twp.txt

from itertools import chain
from opencc import OpenCC

def build_entries(twp=False):
with open('opencc_data/STCharacters.txt') as f: # s2t
for line in f:
k, vx = line.rstrip('\n').split('\t')
v = vx.split(' ')[0] # Only select the first candidate
v = t2twp(v) if twp else v # s2t -> s2twp
yield k, v

with open('opencc_data/STPhrases.txt') as f: # s2t
for line in f:
with open('opencc_data/STCharacters.txt') as f1, \
open('opencc_data/STPhrases.txt') as f2, \
open('build/extra_convert_table.txt') as f3: # s2t
for line in chain(f1, f2, f3):
k, vx = line.rstrip('\n').split('\t')
v = vx.split(' ')[0] # Only select the first candidate
v = t2twp(v) if twp else v # s2t -> s2twp
Expand Down
4 changes: 4 additions & 0 deletions build/extra_convert_table.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
“ 「
” 」
‘ 『
’ 』
4 changes: 2 additions & 2 deletions build/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import subprocess

FONT_VERSION = 1.005
FONT_VERSION = 1.006

# Define the max entries size in a subtable.
# We define a number that is small enough here, so that the entries will not exceed
Expand Down Expand Up @@ -194,7 +194,7 @@ def remove_glyph(obj, glyph_name):
# Remove glyph from glyph_order table
try:
obj['glyph_order'].remove(glyph_name)
except ValueError as e:
except ValueError:
pass

# Remove glyph from glyf table
Expand Down
2 changes: 1 addition & 1 deletion build/name.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"encodingID": 1,
"languageID": 1033,
"nameID": 0,
"nameString": "Copyright © 2020 Ayaka Mikazuki."
"nameString": "Copyright © 2020-2021 Ayaka Mikazuki."
},
{
"platformID": 3,
Expand Down
2 changes: 2 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ <h2>测试台湾字词转换</h2>
<p class="tw">我们在老挝的服务器的硬盘需要使用互联网算法软件解决异步的问题</p>
<p>为什么你在床里面睡着?</p>
<p class="tw">为什么你在床里面睡着?</p>
<p>他站起来问:“老师,‘有条不紊’的‘紊’是什么意思?”</p>
<p class="tw">他站起来问:“老师,‘有条不紊’的‘紊’是什么意思?”</p>
<p>台式机</p>
<p class="tw">台式机</p>
<p>着装污染虚伪发泄棱柱群众里面</p>
Expand Down

0 comments on commit 3b8dbb2

Please sign in to comment.