Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hantang committed Oct 14, 2024
1 parent 16826cc commit dfe8819
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 7 additions & 3 deletions scripts/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

RENAMED_COLS = {
"Unicode": "unicode",
"全码": "fullCode",
# "全码": "fullCode",
"简码": "shortCode",
"容错码": "faultCode",
"拼音": "pinyin",
"字根拆解": "units",
# "字根拆解": "units",
"字表来源": "source",
"识别码": "flag",
}
Expand All @@ -26,7 +26,7 @@
"faultCode",
"units",
"segments",
"flag"
"flag",
]


Expand Down Expand Up @@ -66,6 +66,10 @@ def tsv_to_json(data_dir: str, save_dir: str) -> None:

df.index = df["汉字"]
df = df.rename(columns=RENAMED_COLS)
df["fullCode"] = df[["全码", "flag"]].apply(
lambda x: "{};{}".format(x["全码"][:-1], x["全码"][-1]) if x["flag"] else x["全码"]
, axis=1)
df["units"] = df["字根拆解"].apply(lambda x: " ".join(x.split("※")))
df["segments"] = df["笔画拆解"].apply(_to_int_array)

keys = ["现代汉语语料库字频(%)", "刑红兵25亿字语料字频(百万)"]
Expand Down
6 changes: 6 additions & 0 deletions site/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ code {
font-size: larger;
border: 1px solid #ddd;
line-height: 2rem;
letter-spacing: 0.2rem;
}

code span {
font-weight: bold;
color: var(--secondary-color);
}

#note-area {
Expand Down
6 changes: 4 additions & 2 deletions site/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function getListData(keys, values) {
listItem.append(tip);
listItem.append(container);
} else {
let val = item.trim() ? `&nbsp;&nbsp;<code>${item}</code>` : "";
let val = "";
if (item.trim() && item.includes("/")) {
val =
"<br>" +
Expand All @@ -70,12 +70,14 @@ function getListData(keys, values) {
.split("/")
.map((item) => `&nbsp;&nbsp;<code>${item}</code>`)
.join("<br>");
} else {
val = item.replace(/;(.+)/, "<span>$1</span>");
val = `&nbsp;&nbsp;<code>${val}</code>`;
}
if (item.startsWith("*")) {
val = `&nbsp;⚠️${val}`;
}
if (val) {
val = val.replace(//g, " ");
listItem.innerHTML = `<strong>${keys[index]}</strong>:${val}`;
}
}
Expand Down

0 comments on commit dfe8819

Please sign in to comment.