Skip to content

Commit

Permalink
1231
Browse files Browse the repository at this point in the history
  • Loading branch information
osfans committed Dec 31, 2024
1 parent 6716d5c commit cff6dfc
Show file tree
Hide file tree
Showing 786 changed files with 169,528 additions and 128,862 deletions.
3 changes: 2 additions & 1 deletion cgi/cgi-bin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def rich(r, k):
s = r[k]
if k == "白-沙": return s
s = s.replace(" ", "")
s = s.replace(" ", " ").replace(" ", "").replace(" ", " ")
s = re.sub(", ?", ", ", s)
s = s.replace("\n", "<br>")
s = re.sub("\{(.*?)\}", "<div class=desc>\\1</div>", s)
Expand Down Expand Up @@ -73,6 +73,7 @@ def getColorName(k):
return fmt % (color, name)

def getVariant(hzs, vars):
if not vars: return ""
for i in hzs:
if i in vars:
return i
Expand Down
2 changes: 1 addition & 1 deletion cgi/cgi-bin/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
for r in getSqls(value, word):
hz = r[HZ]
output += "<p><div class=hz>%s</div>"%(hz)
if variant:
if variant and r[VA]:
va = getVariant(hzs, r[VA])
if va: output += "<div class=variant>(%s)</div>"%(va)
output += "<div class=y>U+%04X</div>" % (ord(hz))
Expand Down
2 changes: 1 addition & 1 deletion tools/tables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def getLangs(dicts, argv, 省=None):
except Exception as e:
print(f"\t\t\t{e} {mod}")
continue
if d["繁簡"] == "简": lang.simplified = 2
if "繁" not in d["繁簡"]: lang.simplified = 2
if d["地圖集二分區"] == None: d["地圖集二分區"] = ""
if "聯表列名" in d:
a = d["聯表列名"].upper()
Expand Down
29 changes: 0 additions & 29 deletions tools/tables/_古音小鏡.py

This file was deleted.

10 changes: 6 additions & 4 deletions tools/tables/_縣志.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def 常熟古裡_repl(match):
return line

class (_表):
disorder = True
orderByJs = True
sm = ""
ym = ""
ym2 = ""
Expand Down Expand Up @@ -287,8 +287,8 @@ def update(self):
yb = sm + ym + sd
yb = self.checkYb(yb)
hzs = self.normG(hzs)
hzs = re.findall(r"(.)[\d₁₂₃]?([<+\-/=\\\*?$&r@]?)[\d₁₂₃]? *({.*?})?", hzs)
for hz, c, js in hzs:
hzs = re.findall(r"(.)([\d₀-₉]?)([<+\-/=\\\*?$&r@]?)[\d₀-₉]? *({.*?})?", hzs)
for hz, o, c, js in hzs:
if hz == " ": continue
p = ""
if c:
Expand All @@ -314,7 +314,9 @@ def update(self):
if js.count("{") != js.count("}"):
self.errors.append(f"大括號未成對:{js}")
js = js.replace("{", "").replace("}", "")
p = yb + c + "\t" + p + js
if o and ("₀" <= o <= "₉"):
o = chr(ord(o) - ord("₀") + ord("0"))
p = yb + c + "\t" + o + p + js
if p not in d[hz]:
d[hz].append(p)
self.write(d)
15 changes: 11 additions & 4 deletions tools/tables/_表.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def docx2tsv(doc):
t.writelines(lines)
t.close()

def ybKey(x):
if "\t" not in x:
return x[-1]
yb, js = x.split("\t", 1)
if js: js = js[0]
return js + yb[-1]

class :
_time = os.path.getmtime(__file__)
_file = None
Expand All @@ -152,7 +159,7 @@ class 表:
url = ""
dictionary = False

disorder = False
orderByJs = False
patches = None
ybTrimSpace = True
kCompatibilityVariants = getCompatibilityVariants()
Expand Down Expand Up @@ -205,7 +212,7 @@ def spath(self):
sname = g[0]
self._file = os.path.basename(sname)
if isXls(sname):
page = 1 if self.short in ("中山石岐", "通城", "1796建甌") else 0
page = 1 if self.short in ("中山石岐", "通城大坪", "1796建甌") else 0
if self.short == "開平護龍": page = 3
xls2tsv(sname, page)
sname = getTsvName(sname)
Expand Down Expand Up @@ -354,8 +361,8 @@ def write(self, d):
if self.isDialect():
self.errors.append(f"【{hz}】不是漢字,讀音爲:{','.join([i.strip() for i in pys])}")
continue
if self.disorder:
pys = sorted(pys,key=lambda x:x.split("\t", 1)[0][-1])
if self.orderByJs:
pys = sorted(pys,key=ybKey)
for py in pys:
if "\t" in py:
yb, js = py.split("\t", 1)
Expand Down
16 changes: 12 additions & 4 deletions tools/tables/_跳跳老鼠.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re, regex

class (_表):
disorder = True
orderByJs = True
sm = ""
ym = ""
sy = ""
Expand Down Expand Up @@ -45,7 +45,7 @@ def parse(self, fs):
sy = self.sy
yb = sy + sd
hzs = self.normS(hzs)
elif name in ("宜章巖泉","望城"):
elif name in ("望城"):
sy, sd, hzs = fs[:3]
hzs = hzs.replace("?", "□")
elif name in ("天台東鄕"):
Expand Down Expand Up @@ -101,10 +101,13 @@ def parse(self, fs):
hzs = re.sub(r"(\d)([-=])", "\\2\\1", hzs)
hzs = self.normS(hzs)
elif name in ("通城",):
_, sy, sd, _, hzs = fs[:5]
yb = sy + sd
elif name in ("通城大坪",):
_, sy, sd, hzs = fs[:4]
sd = sd.strip("[]")
hzs = self.normG(hzs, "[\\1]")
elif name in ("灌陽","全州文橋"):
elif name in ("灌陽","全州文橋", "宜章巖泉",):
sy, sd, hzs = fs[:3]
hzs = self.normG(hzs, "[\\1]")
elif name in ("江華河路口", "江華粟米塘", "全州黃沙河", "安仁新洲", "1935長沙", "長沙黃花", "瀏陽鎭頭"):
Expand Down Expand Up @@ -175,8 +178,13 @@ def parse(self, fs):
yb = self.dz2dl(yb)
else:
return
elif name in ("江永上江墟",):
ns, _, hzs, py = fs[:4]
py = re.sub("^h", "x", py)
py = py.replace("nj", "ȵ").replace('ng', 'ŋ').replace("c", "ɕ").replace('h', 'ʰ')
py = py.replace("oe", "ø").replace('e', 'ə').replace('iə', 'ie').replace('w', 'ɯ')
yb = self.dz2dl(py)+ns
elif name in ("揚州",):
self.disorder = False
self.simplified = 0
yb, hzs = fs[:2]
hzs = self.normS(hzs, "(\\1)").replace("?", "?")
Expand Down
14 changes: 14 additions & 0 deletions tools/tables/_音典.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ def parse(self, fs):
hz, yb, js = fs[:3]
elif name in ("建陽連墩",):
hz, yb, js = fs[:3]
elif name in ("塔玆語", "海倫","宜興南",):
hz, sy, tv, js = fs[:4]
ipa = sy + tv
elif name in ("虎林", "吳江菀坪","景寧鄭坑","慈谿觀海衛","當塗霍里", "南陵", "南陵湖南街"):
hz, sm, ym, tv, js = fs[:5]
ipa = sm + ym + tv
elif name in ("滁州",):
_, hz, sm, ym, tv, js = fs[:6]
ipa = sm + ym + tv
elif name in ("宣平",):
hz, _, ipa, js = fs[:4]
elif name in ("淮南","懷遠","鳳陽","陽新新街","上猶", "南陵仙坊", "武昌", "連州", "連州保安", "連州星子", "連州西岸", "連州豐陽"):
_, hz, sm, ym, tv, _, js = fs[:7]
ipa = sm + ym + tv
elif self._file.startswith("粤西闽语方言字表"):
if len(fs) < 6: return
hz = fs[0]
Expand Down
Loading

0 comments on commit cff6dfc

Please sign in to comment.