分享和討論倉頡輸入法相關的資訊和内容
版面规则
公正客觀講理,杜絶廢話連篇
回复
头像
ejsoon
一枝独秀
帖子: 6355
注册时间: 2022年 11月 18日 17:36
联系:

拿到全倉的詞庫

帖子 ejsoon »

https://zh.wikipedia.org/wiki/%E5%85%A8 ... 5%E6%B3%95

全方位倉頡輸入法,簡稱全倉,Omni Cangjie(OCJ),是全倉研發小組在2001年發明,是一種在傳統倉頡輸入法中加入大量單字簡碼和簡碼詞[註 1]改良而成的中文輸入法(「只加不減」原則)。根據科學化的統計,全倉使用者的打字速度比倉頡使用者高最少百分之三十。全倉輸入法由「全倉研發小組」於2001年開始研究,同年推出正式版供用家下載,並擁有這輸入法的版權。

代码: 全选

==詞碼輸入==
全倉的詞碼輸入可分兩種,分別是簡碼詞及一般詞組,現時的全倉只設有簡碼詞輸入,簡碼詞的法則是「;」+首字首碼+次字首碼(用簡碼字編碼),以下是全倉的簡碼詞對應表。
{| class="wikitable mw-collapsible mw-collapsed" style="text-align: center;"
! colspan="30" | 全倉簡碼詞對應表
|-
! || {{n/a|—}} || 日 || 月 || 金 || 木 || 水 || 火 || 土 || 竹 || 戈 || 十 || 大 || 中 || 一 || 弓 || 人 || 心 || 手 || 口 || -{尸}- || 廿 || 山 || 女 || 田 || 難 || 卜 || 重 || ; || -{,}-
|-
! 日 
| -{時間}- || -{問題}- || -{既然}- || -{時期}- || -{日本}- || -{開演}- || -{最近}- || -{日報}- || -{明白}- || -{需求}- || -{記載}- || -{時候}- || -{最初}- || -{顯示}- || -{景色}- || -{記念}- || -{記憶}- || -{開拓}- || -{開放}- || -{早已}- || -{日益}- || -{最多}- || -{影響}- || -{景點}- || -{需要}- || -{時刻}- || -{顯著}- || {{n/a}} || -{開展}-
|-
! 月 
| -{同時}- || -{同盟}- || -{眼睛}- || -{目錄}- || -{同樣}- || -{講演}- || -{目光}- || -{勝利}- || -{然後}- || -{講座}- || -{財富}- || -{然而}- || -{目標}- || -{財政}- || -{服務}- || -{賠償}- || -{同情}- || -{隨便}- || -{用品}- || -{爭取}- || -{目前}- || -{瞬間}- || -{愛好}- || -{睡覺}- || -{目的}- || -{同意}- || -{隨著}- || {{n/a}} || -{等待}-
|-
! 金 
| -{公司}- || -{公開}- || -{公用}- || -{分鐘}- || -{分析}- || -{分泌}- || -{分類}- || -{領域}- || -{鍵盤}- || -{公式}- || -{從事}- || -{從而}- || -{讀書}- || -{金融}- || -{期限}- || -{價值}- || -{公平}- || -{領先}- || -{價格}- || -{金屬}- || -{針對}- || -{期間}- || -{曾經}- || -{父母}- || -{讀者}- || -{分享}- || -{公認}- || {{n/a}} || -{期待}-
|-
! 木 
| -{機會}- || -{登記}- || -{欄目}- || -{本質}- || -{檢查}- || -{刺激}- || -{材料}- || -{本地}- || -{查看}- || -{模式}- || -{檢察}- || -{東西}- || -{本身}- || -{模型}- || -{樣子}- || -{本人}- || -{核心}- || -{根據}- || -{整合}- || -{檢驗}- || -{整備}- || -{機關}- || -{檔案}- || -{機構}- || -{機能}- || -{禁止}- || -{來自}- || {{n/a}} || -{查詢}-
|-
! 水 
| -{注意}- || -{測量}- || -{活用}- || -{消除}- || -{清楚}- || -{污染}- || -{減少}- || -{測試}- || -{消息}- || -{英語}- || -{決定}- || -{沒有}- || -{消費}- || -{準確}- || -{海外}- || -{消化}- || -{水平}- || -{演奏}- || -{混合}- || -{瀏覽}- || -{準備}- || -{演出}- || -{各級}- || -{各位}- || -{流行}- || -{遊戲}- || -{各種}- || {{n/a}} || -{洽談}-
|-
! 火 
| -{方法}- || -{當時}- || -{當然}- || -{方針}- || -{發動}- || -{近況}- || -{網站}- || -{嘗試}- || -{方向}- || -{方式}- || -{研究}- || -{站在}- || -{當初}- || -{發現}- || -{此外}- || -{類似}- || -{煩惱}- || -{發生}- || -{風格}- || -{光臨}- || -{當前}- || -{發出}- || -{判斷}- || -{發覺}- || -{道理}- || -{發言}- || -{方面}- || {{n/a}} || -{發展}-
|-
! 土 
| -{利用}- || -{聲明}- || -{幫助}- || -{地質}- || -{積極}- || -{起源}- || -{地方}- || -{地址}- || -{場所}- || -{幸福}- || -{赤字}- || -{喜歡}- || -{熱鬧}- || -{鼓勵}- || -{走了}- || -{工作}- || -{幫忙}- || -{更換}- || -{場合}- || -{增長}- || -{利益}- || -{更多}- || -{幸運}- || -{地點}- || -{執行}- || -{聲音}- || -{報告}- || {{n/a}} || -{培養}-
|-
! 竹 
| -{香港}- || -{反映}- || -{失敗}- || -{學期}- || -{學校}- || -{看法}- || -{欣賞}- || -{失去}- || -{微笑}- || -{徹底}- || -{穩定}- || -{循環}- || -{怎麼}- || -{特殊}- || -{印象}- || -{簡介}- || -{特性}- || -{學生}- || -{簡單}- || -{印刷}- || -{反對}- || -{舉辦}- || -{所以}- || -{範圍}- || -{重要}- || -{所謂}- || -{失業}- || {{n/a}} || -{系列}-
|-
! 戈 
| -{資料}- || -{或是}- || -{應用}- || -{成分}- || -{成本}- || -{資源}- || -{麻煩}- || -{姿勢}- || -{之後}- || -{態度}- || -{視窗}- || -{允許}- || -{之中}- || -{成功}- || -{永久}- || -{應付}- || -{永遠}- || -{救援}- || -{應該}- || -{成長}- || -{之前}- || -{之間}- || -{成績}- || -{成果}- || -{或者}- || -{成熟}- || -{成形}- || {{n/a}} || -{座談}-
|-
! 十 
| -{突然}- || -{容易}- || -{協助}- || -{十分}- || -{未來}- || -{憲法}- || -{乾燥}- || -{栽培}- || -{轉移}- || -{家庭}- || -{事故}- || -{實在}- || -{索引}- || -{實現}- || -{事務}- || -{軟件}- || -{突破}- || -{支持}- || -{實踐}- || -{協議}- || -{定義}- || -{空間}- || -{轉變}- || -{定位}- || -{軟體}- || -{考慮}- || -{安裝}- || {{n/a}} || -{十五}-
|-
! 大 
| -{希望}- || -{有時}- || -{而且}- || -{有錢}- || -{大概}- || -{交流}- || -{大約}- || -{環境}- || -{有所}- || -{首次}- || -{大家}- || -{存在}- || -{大幅}- || -{首頁}- || -{有限}- || -{加入}- || -{奇怪}- || -{選擇}- || -{奇跡}- || -{而已}- || -{痛苦}- || -{有些}- || -{加以}- || -{有點}- || -{獲得}- || -{有效}- || -{而這}- || {{n/a}} || -{交談}-
|-
! 中 
| -{中國}- || -{數量}- || -{費用}- || -{身分}- || -{版本}- || -{標準}- || -{非常}- || -{順利}- || -{書籍}- || -{幅度}- || -{數字}- || -{親友}- || -{中央}- || -{數碼}- || -{條例}- || -{條件}- || -{中心}- || -{數據}- || -{儘管}- || -{引進}- || -{版權}- || -{引導}- || -{中斷}- || -{中國人}- || -{身體}- || -{由於}- || -{親自}- || {{n/a}} || -{中藥}-
|-
! 一 
| -{電話}- || -{不是}- || -{電腦}- || -{不錯}- || -{一樣}- || -{電源}- || -{一方面}- || -{一起}- || -{一番}- || -{電視}- || -{下載}- || -{現在}- || -{歷史}- || -{不敢}- || -{現象}- || -{一個}- || -{一切}- || -{代表}- || -{不管}- || -{互聯網}- || -{覆蓋}- || -{一些}- || -{不斷}- || -{一點}- || -{不能}- || -{不過}- || -{確認}- || {{n/a}} || -{不但}-
|-
! 弓 
| -{解決}- || -{鮮明}- || -{張貼}- || -{解除}- || -{危機}- || -{預測}- || -{附近}- || -{名稱}- || -{解釋}- || -{角度}- || -{名字}- || -{免疫}- || -{免費}- || -{障礙}- || -{了解}- || -{製作}- || -{小心}- || -{負責}- || -{製品}- || -{階層}- || -{隱藏}- || -{勇氣}- || -{例如}- || -{限界}- || -{小企業}- || -{防止}- || -{承認}- || {{n/a}} || -{承受}-
|-
! 人 
| -{知道}- || -{依照}- || -{仍然}- || -{保護}- || -{人材}- || -{無法}- || -{知識}- || -{優勢}- || -{似乎}- || -{健康}- || -{內容}- || -{保存}- || -{什麼}- || -{年代}- || -{保障}- || -{任何}- || -{個性}- || -{保持}- || -{作品}- || -{無聊}- || -{年前}- || -{人們}- || -{介紹}- || -{焦點}- || -{作者}- || -{停止}- || -{創造}- || {{n/a}} || -{保養}-
|-
! 心 
| -{包括}- || -{也是}- || -{必然}- || -{必須}- || -{老板}- || -{情況}- || -{全省}- || -{平均}- || -{平衡}- || -{也應}- || -{比較}- || -{也許}- || -{心中}- || -{全球}- || -{比例}- || -{也會}- || -{懷疑}- || -{性感}- || -{性格}- || -{老師}- || -{恢復}- || -{世間}- || -{快樂}- || -{世界}- || -{也可}- || -{全部}- || -{情形}- || {{n/a}} || -{比率}-
|-
! 手 
| -{表示}- || -{按照}- || -{規則}- || -{排除}- || -{感到}- || -{生活}- || -{技術}- || -{生命}- || -{損失}- || -{投資}- || -{損害}- || -{擁有}- || -{打算}- || -{表現}- || -{接觸}- || -{責任}- || -{感謝}- || -{先生}- || -{規格}- || -{搜尋}- || -{推薦}- || -{感想}- || -{持續}- || -{感覺}- || -{生物}- || -{批評}- || -{控制}- || {{n/a}} || -{接受}-
|-
! 口 
| -{處理}- || -{只是}- || -{戰爭}- || -{品質}- || -{教材}- || -{啤酒}- || -{味道}- || -{員工}- || -{嚴重}- || -{格式}- || -{教室}- || -{只有}- || -{吸引}- || -{唯一}- || -{另外}- || -{合作}- || -{放心}- || -{教授}- || -{嚴格}- || -{教師}- || -{股權}- || -{股市}- || -{足以}- || -{教育}- || -{合理}- || -{民族}- || -{叫做}- || {{n/a}} || -{距離}-
|-
! 尸 
| -{今日}- || -{臨時}- || -{居然}- || -{長期}- || -{聽到}- || -{取消}- || -{尋常}- || -{區域}- || -{今後}- || -{尋求}- || -{聯繫}- || -{已有}- || -{那麼}- || -{今天}- || -{緊張}- || -{進入}- || -{屬性}- || -{尋找}- || -{職員}- || -{改進}- || -{改善}- || -{那些}- || -{已經}- || -{職位}- || -{進行}- || -{屬於}- || -{改正}- || {{n/a}} || -{進展}-
|-
! 廿 
| -{普通}- || -{若是}- || -{共同}- || -{前期}- || -{調整}- || -{美洲}- || -{對方}- || -{權利}- || -{前後}- || -{商店}- || -{觀察}- || -{共有}- || -{前輩}- || -{甚至}- || -{商務}- || -{對付}- || -{對比}- || -{對手}- || -{差別}- || -{前進}- || -{權益}- || -{某些}- || -{難以}- || -{觀點}- || -{普及}- || -{對於}- || -{警告}- || {{n/a}} || -{對待}-
|-
! 山 
| -{完全}- || -{關閉}- || -{相同}- || -{關鍵}- || -{出來}- || -{辦法}- || -{相當}- || -{市場}- || -{高科技}- || -{完成}- || -{豐富}- || -{配套}- || -{出版}- || -{出現}- || -{完了}- || -{想像}- || -{關心}- || -{間接}- || -{配合}- || -{高層}- || -{相對}- || -{相關}- || -{很好}- || -{幽默}- || -{辦理}- || -{關於}- || -{多種}- || -{導致}- || -{關係}-
|-
! 女 
| -{如果}- || -{總是}- || -{運用}- || -{維護}- || -{結束}- || -{經濟}- || -{經常}- || -{變更}- || -{幾乎}- || -{變成}- || -{編輯}- || -{努力}- || -{經費}- || -{經歷}- || -{以外}- || -{變化}- || -{女性}- || -{維持}- || -{組合}- || -{經驗}- || -{以前}- || -{幻想}- || -{繼續}- || -{結果}- || -{以及}- || -{經過}- || -{維修}- || {{n/a}} || -{以致}-
|-
! 田 
| -{因此}- || -{黑暗}- || -{雖然}- || -{國公}- || -{回來}- || -{四海}- || -{異常}- || -{買賣}- || -{回答}- || -{因為}- || -{固定}- || -{因而}- || -{圖片}- || -{回覆}- || -{國際}- || -{男人}- || -{習慣}- || -{因素}- || -{國民}- || -{羅馬}- || -{困難}- || -{思想}- || -{圍繞}- || -{位置}- || -{覺得}- || -{畢竟}- || -{畢業}- || {{n/a}} || {{n/a}}
|-
! 難 
| -{使用}- || -{可是}- || -{可愛}- || -{物質}- || -{得到}- || -{能源}- || -{說道}- || -{興趣}- || -{訊息}- || -{要求}- || -{其實}- || -{能力}- || -{理由}- || -{行政}- || -{理解}- || -{提供}- || -{可憐}- || -{醫生}- || -{使館}- || -{建議}- || -{提前}- || -{提高}- || -{可以}- || -{願望}- || -{可能}- || -{建立}- || -{企業}- || {{n/a}} || -{醫藥}-
|-
! 卜 
| -{就是}- || -{還是}- || -{意見}- || -{評價}- || -{遇到}- || -{逐漸}- || -{通常}- || -{立場}- || -{熟悉}- || -{速度}- || -{設定}- || -{還有}- || -{計劃}- || -{週刊}- || -{避免}- || -{通知}- || -{遺憾}- || -{誕生}- || -{適合}- || -{步驟}- || -{意義}- || -{過程}- || -{詳細}- || -{意思}- || -{主要}- || -{諮詢}- || -{文章}- || {{n/a}} || {{n/a}}
|-
! 重 
| -{自己}- || -{正是}- || -{並且}- || -{自從}- || -{這樣}- || -{廣泛}- || -{正常}- || -{形勢}- || -{自衛}- || -{形式}- || -{認定}- || -{正在}- || -{自由}- || -{正確}- || -{制限}- || -{這個}- || -{這也}- || -{證據}- || -{段落}- || -{修改}- || -{面對}- || -{我們}- || -{傳統}- || -{原因}- || -{真的}- || -{告訴}- || -{傳真}- || {{n/a}} || {{n/a}}
|-
! , 
| -{但是}- || -{離開}- || -{五月}- || -{基金}- || -{基本}- || -{基準}- || -{談判}- || -{致命}- || -{參與}- || -{養成}- || -{參考}- || -{參加}- || -{指標}- || -{基礎}- || -{受了}- || -{受傷}- || -{恐怕}- || -{指南}- || -{滿足}- || -{展覽}- || -{參觀}- || -{指導}- || -{團結}- || -{展望}- || -{團體}- || -{滿意}- || -{但這}- || {{n/a}} || {{n/a}}
|}
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
帖子: 6355
注册时间: 2022年 11月 18日 17:36
联系:

Re: 拿到全倉的詞庫

帖子 ejsoon »

做一個html+css+js程式《哈哈倉頡詞庫比對》:

代码: 全选

做一個html+css+js程式《哈哈倉頡詞庫比對》:
一,兩個讀取文本按鈕

左邊按鈕是「碼表」,右邊按鈕是「詞庫」。

把它們做成兩個div,左右排布,平分屏幕。當選取文本文件後,div中展示的是文件名。

當兩個按鈕都讀取了文件,則往下進行。

二,拿到碼表的詞語

碼表中,以z開頭,在\t前還有其它英文字母但不含z,就是詞語,如:

zue	山水
zue	崩潰
zue	幽浮
zue	山洞

前面的zue是編碼,\t後面是詞語。把同編碼的詞語按出現次序放到一個陣列中,分類為二碼,三碼,四碼。比如上面的四個詞語是三碼,「山水」是三碼首位,「崩潰」是三碼第二位,「幽浮」是三碼第三位,「山洞」是三碼第四位。

在對應的div下方居中標出碼表的詞語總數。

三,比對詞庫

在詞庫文本中,在{…}之中且不包含英文字母以及「,。」標點的就是它的詞語。在對應的div下方居中標出詞庫的詞語總數。

在下方展示比對結果:碼表中沒有的詞語,二碼首位,二碼第二位,二碼第三位,二碼第四位,二碼第五位,三碼首位,三碼第二位,三碼第三位,三碼第四位,四碼首位,四碼其餘位。

每一種類型都用一個h3標題和內容展示,標題右方用括號給出當前內容的詞語數量,再右方是一個複製按鈕,當按下時複製其內容。內容中的每一個詞用一個span包住,當點擊其中一個詞語,將複製這個詞語。

四,最下方有reset按鈕

當點擊reset,頁面恢復成一開始的狀態。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
帖子: 6355
注册时间: 2022年 11月 18日 17:36
联系:

Re: 拿到全倉的詞庫

帖子 ejsoon »

gemini 3.1 pro

代码: 全选

這是一個使用 HTML、CSS 和 JavaScript 打造的單頁面應用程式(SPA),完全符合你對《哈哈倉頡詞庫比對》的需求。你可以將以下的代碼保存為 `index.html`,然後用瀏覽器打開即可使用。

```html
<!DOCTYPE html>
<html lang="zh-TW">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>哈哈倉頡詞庫比對</title>
    <style>
        :root {
            --primary: #4F46E5;
            --primary-hover: #4338CA;
            --bg: #F9FAFB;
            --card-bg: #FFFFFF;
            --text: #1F2937;
            --border: #E5E7EB;
        }

        body {
            font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
            background-color: var(--bg);
            color: var(--text);
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
        }

        h1 {
            text-align: center;
            margin-bottom: 30px;
        }

        /* 第一部分:上傳按鈕 (平分屏幕) */
        #upload-container {
            display: flex;
            width: 100%;
            max-width: 800px;
            gap: 20px;
            margin-bottom: 20px;
        }

        .upload-box {
            flex: 1;
            background-color: var(--card-bg);
            border: 2px dashed var(--primary);
            border-radius: 12px;
            padding: 40px 20px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .upload-box:hover {
            background-color: #EEF2FF;
        }

        .upload-box input[type="file"] {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            opacity: 0;
            cursor: pointer;
        }

        .file-name {
            font-size: 1.2rem;
            font-weight: bold;
            color: var(--primary);
            word-break: break-all;
        }

        /* 詞語總數展示 */
        #counts-container {
            display: flex;
            width: 100%;
            max-width: 800px;
            gap: 20px;
            margin-bottom: 30px;
        }

        .count-box {
            flex: 1;
            text-align: center;
            font-size: 1.1rem;
            color: #4B5563;
        }

        /* 第三部分:結果展示 */
        #results-container {
            width: 100%;
            max-width: 1000px;
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .category-card {
            background-color: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 15px 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .category-header {
            display: flex;
            align-items: center;
            border-bottom: 1px solid var(--border);
            padding-bottom: 10px;
            margin-bottom: 15px;
        }

        .category-header h3 {
            margin: 0;
            flex: 1;
            font-size: 1.2rem;
        }

        .copy-btn {
            background-color: var(--primary);
            color: white;
            border: none;
            padding: 6px 16px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: background 0.2s;
        }

        .copy-btn:hover {
            background-color: var(--primary-hover);
        }

        .word-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .word-span {
            background-color: #F3F4F6;
            padding: 6px 12px;
            border-radius: 4px;
            cursor: pointer;
            transition: background 0.2s;
            user-select: none;
        }

        .word-span:hover {
            background-color: #E5E7EB;
        }

        /* 提示框 */
        #toast {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: #374151;
            color: white;
            padding: 10px 20px;
            border-radius: 8px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
            z-index: 1000;
        }

        /* 第四部分:重置按鈕 */
        #reset-btn {
            margin-top: 40px;
            margin-bottom: 40px;
            background-color: #EF4444;
            color: white;
            border: none;
            padding: 12px 32px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: bold;
            display: none;
            transition: background 0.2s;
        }

        #reset-btn:hover {
            background-color: #DC2626;
        }
    </style>
</head>
<body>

    <h1>哈哈倉頡詞庫比對</h1>

    <div id="upload-container">
        <div class="upload-box">
            <input type="file" id="file-code" accept=".txt">
            <div class="file-name" id="name-code">讀取「碼表」</div>
        </div>
        <div class="upload-box">
            <input type="file" id="file-vocab" accept=".txt">
            <div class="file-name" id="name-vocab">讀取「詞庫」</div>
        </div>
    </div>

    <div id="counts-container">
        <div class="count-box" id="count-code"></div>
        <div class="count-box" id="count-vocab"></div>
    </div>

    <div id="results-container"></div>

    <button id="reset-btn">Reset</button>

    <div id="toast">已複製</div>

    <script>
        // DOM 元素
        const fileCodeInput = document.getElementById('file-code');
        const fileVocabInput = document.getElementById('file-vocab');
        const nameCode = document.getElementById('name-code');
        const nameVocab = document.getElementById('name-vocab');
        const countCode = document.getElementById('count-code');
        const countVocab = document.getElementById('count-vocab');
        const resultsContainer = document.getElementById('results-container');
        const resetBtn = document.getElementById('reset-btn');
        const toast = document.getElementById('toast');

        // 狀態變量
        let codeText = null;
        let vocabText = null;

        const categories = [
            "碼表中沒有的詞語",
            "二碼首位", "二碼第二位", "二碼第三位", "二碼第四位", "二碼第五位",
            "三碼首位", "三碼第二位", "三碼第三位", "三碼第四位",
            "四碼首位", "四碼其餘位"
        ];

        // 監聽文件上傳
        fileCodeInput.addEventListener('change', (e) => handleFileUpload(e, 'code'));
        fileVocabInput.addEventListener('change', (e) => handleFileUpload(e, 'vocab'));

        // 重置按鈕
        resetBtn.addEventListener('click', resetApp);

        function handleFileUpload(event, type) {
            const file = event.target.files[0];
            if (!file) return;

            // 更新文件名顯示
            if (type === 'code') nameCode.textContent = file.name;
            if (type === 'vocab') nameVocab.textContent = file.name;

            const reader = new FileReader();
            reader.onload = (e) => {
                if (type === 'code') codeText = e.target.result;
                if (type === 'vocab') vocabText = e.target.result;

                // 兩個文件都加載完成後往下進行
                if (codeText !== null && vocabText !== null) {
                    processFiles();
                }
            };
            reader.readAsText(file);
        }

        function processFiles() {
            // 1. 處理碼表
            const codeLines = codeText.split(/\r?\n/);
            const codeWordMap = new Map(); // 存儲 詞語 -> 它的分類
            const codePositionTracker = {}; // 存儲 編碼 -> 當前出現的次數
            let totalCodeWords = 0;

            for (let line of codeLines) {
                // 檢查是否符合格式:z開頭,然後是英文字母(不含z),然後是Tab(\t),然後是詞語
                // 正則解釋:^z = z開頭;([a-yA-Y]+) = z以外的英文字母;\t = Tab;(.+) = 詞語
                const match = line.match(/^z([a-zA-Z]+)\t(.+)$/);
                if (match) {
                    const lettersPart = match[1].toLowerCase();
                    if (lettersPart.includes('z')) continue; // 條件:不含z

                    const codeLength = lettersPart.length + 1; // 加上開頭的z
                    const codeString = "z" + lettersPart;
                    const word = match[2].trim();

                    // 計算該編碼的出現次序
                    codePositionTracker[codeString] = (codePositionTracker[codeString] || 0) + 1;
                    const pos = codePositionTracker[codeString];

                    const category = getCodeCategory(codeLength, pos);
                    totalCodeWords++;

                    // 記錄該詞語的分類(如果同一個詞在多處出現,我們保留它第一次被定義的分類)
                    if (category && !codeWordMap.has(word)) {
                        codeWordMap.set(word, category);
                    } else if (!codeWordMap.has(word)) {
                        codeWordMap.set(word, 'OTHER'); // 碼表中有,但不在我們要求的分類裡(如五碼)
                    }
                }
            }

            countCode.textContent = `碼表提取詞語總數: ${totalCodeWords}`;

            // 2. 處理詞庫
            const vocabRegex = /\{([^}]+)\}/g;
            let vocabMatch;
            const vocabSet = new Set();
            let totalVocabWords = 0;

            while ((vocabMatch = vocabRegex.exec(vocabText)) !== null) {
                const word = vocabMatch[1];
                // 條件:不包含英文字母,不包含「,」「。」「,」「.」
                if (!/[a-zA-Z,。,\.]/.test(word)) {
                    vocabSet.add(word); // 用 Set 自動去重
                    totalVocabWords++;
                }
            }
            countVocab.textContent = `詞庫提取詞語總數: ${totalVocabWords}`;

            // 3. 進行比對與分類
            const results = {};
            categories.forEach(cat => results[cat] = []);

            vocabSet.forEach(word => {
                if (codeWordMap.has(word)) {
                    const cat = codeWordMap.get(word);
                    if (results[cat]) {
                        results[cat].push(word);
                    }
                } else {
                    // 碼表中沒有
                    results["碼表中沒有的詞語"].push(word);
                }
            });

            // 4. 渲染結果
            renderResults(results);
            resetBtn.style.display = 'block';
        }

        function getCodeCategory(len, pos) {
            if (len === 2) {
                const map = {1: "二碼首位", 2: "二碼第二位", 3: "二碼第三位", 4: "二碼第四位", 5: "二碼第五位"};
                return map[pos] || null;
            } else if (len === 3) {
                const map = {1: "三碼首位", 2: "三碼第二位", 3: "三碼第三位", 4: "三碼第四位"};
                return map[pos] || null;
            } else if (len === 4) {
                if (pos === 1) return "四碼首位";
                if (pos > 1) return "四碼其餘位";
            }
            return null;
        }

        function renderResults(results) {
            resultsContainer.innerHTML = ''; // 清空之前的內容

            categories.forEach(cat => {
                const words = results[cat];
                if (words.length === 0) return; // 如果該分類沒有詞語,也可選擇不渲染

                const card = document.createElement('div');
                card.className = 'category-card';

                // 標題區
                const header = document.createElement('div');
                header.className = 'category-header';
                
                const title = document.createElement('h3');
                title.textContent = `${cat} (${words.length})`;
                
                const copyBtn = document.createElement('button');
                copyBtn.className = 'copy-btn';
                copyBtn.textContent = '複製';
                copyBtn.onclick = () => copyText(words.join(' '), `已複製 ${cat} 全部詞語`);

                header.appendChild(title);
                header.appendChild(copyBtn);
                card.appendChild(header);

                // 詞語列表區
                const wordList = document.createElement('div');
                wordList.className = 'word-list';

                words.forEach(word => {
                    const span = document.createElement('span');
                    span.className = 'word-span';
                    span.textContent = word;
                    span.onclick = () => copyText(word, `已複製:${word}`);
                    wordList.appendChild(span);
                });

                card.appendChild(wordList);
                resultsContainer.appendChild(card);
            });
        }

        // 複製文本功能
        function copyText(text, message) {
            navigator.clipboard.writeText(text).then(() => {
                showToast(message);
            }).catch(err => {
                console.error('複製失敗:', err);
                showToast('複製失敗');
            });
        }

        function showToast(message) {
            toast.textContent = message;
            toast.style.opacity = '1';
            setTimeout(() => {
                toast.style.opacity = '0';
            }, 2000);
        }

        function resetApp() {
            codeText = null;
            vocabText = null;
            
            // 重置輸入框
            fileCodeInput.value = '';
            fileVocabInput.value = '';
            
            // 重置顯示文字
            nameCode.textContent = '讀取「碼表」';
            nameVocab.textContent = '讀取「詞庫」';
            countCode.textContent = '';
            countVocab.textContent = '';
            
            // 清空結果
            resultsContainer.innerHTML = '';
            resetBtn.style.display = 'none';
        }
    </script>
</body>
</html>

```

### 功能說明

1. **左右排版與文件讀取**:使用了 Flexbox 將兩個按鈕平分為左右區塊。點擊虛線框即可選取文件,選取後會顯示檔名。
2. **正則匹配抓取碼表**:在代碼中以 `^z([a-zA-Z]+)\t(.+)$` 抓取規則,然後代碼邏輯過濾了帶 `z` 的字串並精準判斷碼長與所在順序。
3. **過濾詞庫詞語**:使用 `/\{([^}]+)\}/g` 取得括號內容,再透過正則 `/[a-zA-Z,。,\.]/` 排除含有英文字母與「,。」符號的內容。
4. **精準的一鍵複製體驗**:
* 點擊大分類右方的「複製」按鈕,能直接複製該分類下的**所有詞語**(以空格分隔)。
* 點擊單個詞語的 `span` 標籤,則僅複製**該單一詞語**。
* 複製時會有一個居中的彈出 Toast 提示「已複製」。


5. **重置功能**:一鍵還原到開啟網頁時的初始狀態。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
帖子: 6355
注册时间: 2022年 11月 18日 17:36
联系:

Re: 拿到全倉的詞庫

帖子 ejsoon »

chatgpt think

代码: 全选

<!DOCTYPE html>
<html lang="zh-Hant">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>哈哈倉頡詞庫比對</title>
  <style>
    :root {
      --bg: #f6f7fb;
      --card: #ffffff;
      --border: #d9dce6;
      --text: #1f2430;
      --muted: #6b7280;
      --accent: #3b82f6;
      --accent-2: #2563eb;
      --chip: #eef2ff;
      --danger: #b91c1c;
      --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    }

    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
      background: var(--bg);
      color: var(--text);
    }

    .app {
      max-width: 1400px;
      margin: 0 auto;
      padding: 16px;
    }

    h1 {
      margin: 4px 0 14px;
      font-size: 28px;
      letter-spacing: 0.5px;
    }

    .top-row {
      display: flex;
      gap: 12px;
      align-items: stretch;
      width: 100%;
    }

    .file-box {
      flex: 1 1 0;
      min-height: 110px;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 16px;
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 14px;
      position: relative;
      overflow: hidden;
    }

    .file-box.ready {
      border-color: rgba(59, 130, 246, 0.55);
      background: linear-gradient(180deg, #fff, #f8fbff);
    }

    .file-box input[type="file"] {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      cursor: pointer;
    }

    .btn-text {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 8px;
      color: var(--accent-2);
    }

    .filename {
      font-size: 14px;
      color: var(--muted);
      text-align: center;
      word-break: break-all;
      line-height: 1.4;
    }

    .hint {
      font-size: 12px;
      color: var(--muted);
      margin-top: 6px;
      text-align: center;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin-top: 12px;
    }

    .stat {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: var(--shadow);
      padding: 10px 12px;
      text-align: center;
      font-size: 15px;
      color: var(--text);
    }

    .stat b { color: var(--accent-2); }

    .results {
      margin-top: 18px;
      display: grid;
      gap: 14px;
    }

    .section {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 16px;
      box-shadow: var(--shadow);
      padding: 12px 14px 14px;
    }

    .section-header {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
    }

    .section-header h3 {
      margin: 0;
      font-size: 18px;
      line-height: 1.2;
    }

    .count {
      color: var(--muted);
      font-size: 14px;
    }

    .copy-btn, .reset-btn {
      border: 1px solid var(--border);
      background: #fff;
      color: var(--text);
      border-radius: 10px;
      padding: 6px 10px;
      cursor: pointer;
      font-size: 13px;
      transition: 0.15s ease;
    }

    .copy-btn:hover, .reset-btn:hover { border-color: var(--accent); color: var(--accent-2); }
    .copy-btn:active, .reset-btn:active { transform: translateY(1px); }

    .content {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      min-height: 24px;
      padding: 4px 0 2px;
    }

    .word {
      display: inline-block;
      padding: 4px 8px;
      border-radius: 999px;
      background: var(--chip);
      border: 1px solid rgba(59, 130, 246, 0.18);
      cursor: pointer;
      user-select: none;
      max-width: 100%;
      word-break: break-all;
      line-height: 1.2;
    }

    .word:hover {
      background: #dbeafe;
      border-color: rgba(59, 130, 246, 0.45);
    }

    .empty {
      color: var(--muted);
      font-size: 14px;
      padding: 4px 0;
    }

    .footer {
      margin-top: 18px;
      display: flex;
      justify-content: center;
    }

    .reset-btn {
      min-width: 130px;
      padding: 10px 16px;
      font-size: 15px;
      background: #fff;
    }

    .status {
      margin-top: 12px;
      text-align: center;
      color: var(--muted);
      font-size: 14px;
      min-height: 20px;
    }

    .status.error { color: var(--danger); }

    @media (max-width: 840px) {
      .top-row, .stats-grid { grid-template-columns: 1fr; flex-direction: column; }
      .file-box { min-height: 96px; }
    }
  </style>
</head>
<body>
  <div class="app">
    <h1>哈哈倉頡詞庫比對</h1>

    <div class="top-row">
      <div class="file-box" id="codeBox">
        <div class="btn-text">碼表</div>
        <div class="filename" id="codeFileName">點擊或拖放選取文本文件</div>
        <div class="hint">只要讀入一個文本檔</div>
        <input id="codeInput" type="file" accept=".txt,text/plain" />
      </div>

      <div class="file-box" id="dictBox">
        <div class="btn-text">詞庫</div>
        <div class="filename" id="dictFileName">點擊或拖放選取文本文件</div>
        <div class="hint">只要讀入一個文本檔</div>
        <input id="dictInput" type="file" accept=".txt,text/plain" />
      </div>
    </div>

    <div class="stats-grid">
      <div class="stat" id="codeStat">碼表詞語總數:<b>0</b></div>
      <div class="stat" id="dictStat">詞庫詞語總數:<b>0</b></div>
    </div>

    <div class="status" id="status">尚未載入文件。</div>

    <div class="results" id="results" style="display:none;">
      <div class="section" data-section="missing">
        <div class="section-header">
          <h3>碼表中沒有的詞語</h3>
          <span class="count" id="count-missing"></span>
          <button class="copy-btn" data-copy="missing">複製</button>
        </div>
        <div class="content" id="content-missing"></div>
      </div>

      <div class="section" data-section="two-1">
        <div class="section-header">
          <h3>二碼首位</h3>
          <span class="count" id="count-two-1"></span>
          <button class="copy-btn" data-copy="two-1">複製</button>
        </div>
        <div class="content" id="content-two-1"></div>
      </div>

      <div class="section" data-section="two-2">
        <div class="section-header">
          <h3>二碼第二位</h3>
          <span class="count" id="count-two-2"></span>
          <button class="copy-btn" data-copy="two-2">複製</button>
        </div>
        <div class="content" id="content-two-2"></div>
      </div>

      <div class="section" data-section="two-3">
        <div class="section-header">
          <h3>二碼第三位</h3>
          <span class="count" id="count-two-3"></span>
          <button class="copy-btn" data-copy="two-3">複製</button>
        </div>
        <div class="content" id="content-two-3"></div>
      </div>

      <div class="section" data-section="two-4">
        <div class="section-header">
          <h3>二碼第四位</h3>
          <span class="count" id="count-two-4"></span>
          <button class="copy-btn" data-copy="two-4">複製</button>
        </div>
        <div class="content" id="content-two-4"></div>
      </div>

      <div class="section" data-section="two-5">
        <div class="section-header">
          <h3>二碼第五位</h3>
          <span class="count" id="count-two-5"></span>
          <button class="copy-btn" data-copy="two-5">複製</button>
        </div>
        <div class="content" id="content-two-5"></div>
      </div>

      <div class="section" data-section="three-1">
        <div class="section-header">
          <h3>三碼首位</h3>
          <span class="count" id="count-three-1"></span>
          <button class="copy-btn" data-copy="three-1">複製</button>
        </div>
        <div class="content" id="content-three-1"></div>
      </div>

      <div class="section" data-section="three-2">
        <div class="section-header">
          <h3>三碼第二位</h3>
          <span class="count" id="count-three-2"></span>
          <button class="copy-btn" data-copy="three-2">複製</button>
        </div>
        <div class="content" id="content-three-2"></div>
      </div>

      <div class="section" data-section="three-3">
        <div class="section-header">
          <h3>三碼第三位</h3>
          <span class="count" id="count-three-3"></span>
          <button class="copy-btn" data-copy="three-3">複製</button>
        </div>
        <div class="content" id="content-three-3"></div>
      </div>

      <div class="section" data-section="three-4">
        <div class="section-header">
          <h3>三碼第四位</h3>
          <span class="count" id="count-three-4"></span>
          <button class="copy-btn" data-copy="three-4">複製</button>
        </div>
        <div class="content" id="content-three-4"></div>
      </div>

      <div class="section" data-section="four-1">
        <div class="section-header">
          <h3>四碼首位</h3>
          <span class="count" id="count-four-1"></span>
          <button class="copy-btn" data-copy="four-1">複製</button>
        </div>
        <div class="content" id="content-four-1"></div>
      </div>

      <div class="section" data-section="four-rest">
        <div class="section-header">
          <h3>四碼其餘位</h3>
          <span class="count" id="count-four-rest"></span>
          <button class="copy-btn" data-copy="four-rest">複製</button>
        </div>
        <div class="content" id="content-four-rest"></div>
      </div>
    </div>

    <div class="footer">
      <button class="reset-btn" id="resetBtn">reset</button>
    </div>
  </div>

  <script>
    const codeInput = document.getElementById('codeInput');
    const dictInput = document.getElementById('dictInput');
    const codeBox = document.getElementById('codeBox');
    const dictBox = document.getElementById('dictBox');
    const codeFileName = document.getElementById('codeFileName');
    const dictFileName = document.getElementById('dictFileName');
    const codeStat = document.getElementById('codeStat');
    const dictStat = document.getElementById('dictStat');
    const results = document.getElementById('results');
    const statusEl = document.getElementById('status');
    const resetBtn = document.getElementById('resetBtn');

    let codeText = '';
    let dictText = '';
    let codeFile = null;
    let dictFile = null;
    let analysis = null;

    const sectionIds = ['missing','two-1','two-2','two-3','two-4','two-5','three-1','three-2','three-3','three-4','four-1','four-rest'];

    function setStatus(msg, isError = false) {
      statusEl.textContent = msg;
      statusEl.classList.toggle('error', isError);
    }

    function escapeHtml(str) {
      return str
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;')
        .replace(/'/g, '&#39;');
    }

    function normalizeLineEndings(text) {
      return text.replace(/\r\n?/g, '\n');
    }

    function readFile(file, callback) {
      const reader = new FileReader();
      reader.onload = () => callback(String(reader.result || ''));
      reader.onerror = () => setStatus(`讀取失敗:${file.name}`, true);
      reader.readAsText(file, 'utf-8');
    }

    function extractCodeEntries(text) {
      const map = new Map();
      const order = [];
      const lines = normalizeLineEndings(text).split('\n');

      for (const rawLine of lines) {
        const line = rawLine.trimEnd();
        if (!line) continue;
        const tabIndex = line.indexOf('\t');
        if (tabIndex <= 0) continue;
        const code = line.slice(0, tabIndex).trim();
        const word = line.slice(tabIndex + 1).trim();
        if (!word) continue;
        if (!/^[A-Za-z]+$/.test(code)) continue;
        if (!code.includes('z')) continue;
        if (/[zZ]/.test(code.slice(1))) continue;
        if (code[0].toLowerCase() !== 'z') continue;

        if (!map.has(code)) {
          map.set(code, []);
          order.push(code);
        }
        map.get(code).push(word);
      }

      const allWords = [];
      const byLen = {
        2: [],
        3: [],
        4: []
      };
      const positions = {
        'two-1': [], 'two-2': [], 'two-3': [], 'two-4': [], 'two-5': [],
        'three-1': [], 'three-2': [], 'three-3': [], 'three-4': [],
        'four-1': [], 'four-rest': []
      };

      for (const code of order) {
        const words = map.get(code) || [];
        const len = code.length;
        if (len !== 2 && len !== 3 && len !== 4) continue;
        allWords.push(...words);
        byLen[len].push(...words);

        words.forEach((word, idx) => {
          const pos = idx + 1;
          if (len === 2) {
            const key = `two-${pos}`;
            if (positions[key]) positions[key].push(word);
          } else if (len === 3) {
            const key = `three-${pos}`;
            if (positions[key]) positions[key].push(word);
          } else if (len === 4) {
            if (pos === 1) positions['four-1'].push(word);
            else positions['four-rest'].push(word);
          }
        });
      }

      return { map, order, allWords, byLen, positions };
    }

    function extractDictWords(text) {
      const out = [];
      const seen = new Set();
      const normalized = normalizeLineEndings(text);
      const regex = /\{([^{}]*)\}/g;
      let match;

      while ((match = regex.exec(normalized)) !== null) {
        const inner = match[1];
        if (/[A-Za-z,。]/.test(inner)) continue;
        const words = inner.split(/[\s,,。;;、]+/).map(s => s.trim()).filter(Boolean);
        for (const word of words) {
          if (!seen.has(word)) {
            seen.add(word);
            out.push(word);
          }
        }
      }

      return out;
    }

    function computeAnalysis() {
      if (!codeText || !dictText) return null;
      const codeData = extractCodeEntries(codeText);
      const dictWords = extractDictWords(dictText);
      const codeWordSet = new Set(codeData.allWords);

      const missing = dictWords.filter(word => !codeWordSet.has(word));

      return {
        codeData,
        dictWords,
        missing,
        sections: {
          'missing': missing,
          'two-1': codeData.positions['two-1'],
          'two-2': codeData.positions['two-2'],
          'two-3': codeData.positions['two-3'],
          'two-4': codeData.positions['two-4'],
          'two-5': codeData.positions['two-5'],
          'three-1': codeData.positions['three-1'],
          'three-2': codeData.positions['three-2'],
          'three-3': codeData.positions['three-3'],
          'three-4': codeData.positions['three-4'],
          'four-1': codeData.positions['four-1'],
          'four-rest': codeData.positions['four-rest']
        }
      };
    }

    function renderFileState() {
      codeBox.classList.toggle('ready', !!codeFile);
      dictBox.classList.toggle('ready', !!dictFile);
      codeFileName.textContent = codeFile ? codeFile.name : '點擊或拖放選取文本文件';
      dictFileName.textContent = dictFile ? dictFile.name : '點擊或拖放選取文本文件';
      codeStat.innerHTML = `碼表詞語總數:<b>${analysis ? analysis.codeData.allWords.length : 0}</b>`;
      dictStat.innerHTML = `詞庫詞語總數:<b>${analysis ? analysis.dictWords.length : 0}</b>`;
    }

    function renderSection(key, words) {
      const countEl = document.getElementById(`count-${key}`);
      const contentEl = document.getElementById(`content-${key}`);
      countEl.textContent = `(${words.length})`;
      contentEl.innerHTML = '';
      if (!words.length) {
        const empty = document.createElement('div');
        empty.className = 'empty';
        empty.textContent = '(無)';
        contentEl.appendChild(empty);
        return;
      }
      for (const word of words) {
        const span = document.createElement('span');
        span.className = 'word';
        span.textContent = word;
        span.title = '點擊複製';
        span.addEventListener('click', async () => {
          await copyText(word);
          setStatus(`已複製:${word}`);
        });
        contentEl.appendChild(span);
      }
    }

    function renderResults() {
      if (!analysis) {
        results.style.display = 'none';
        return;
      }
      results.style.display = 'grid';
      for (const key of sectionIds) {
        renderSection(key, analysis.sections[key] || []);
      }
      const total = analysis.dictWords.length;
      const missingCount = analysis.missing.length;
      setStatus(`已完成比對。詞庫詞語 ${total} 個,碼表中沒有的詞語 ${missingCount} 個。`);
    }

    async function copyText(text) {
      try {
        await navigator.clipboard.writeText(text);
      } catch {
        const ta = document.createElement('textarea');
        ta.value = text;
        ta.style.position = 'fixed';
        ta.style.left = '-9999px';
        document.body.appendChild(ta);
        ta.focus();
        ta.select();
        document.execCommand('copy');
        document.body.removeChild(ta);
      }
    }

    function maybeAnalyze() {
      if (!codeText || !dictText) {
        analysis = null;
        renderFileState();
        renderResults();
        if (codeText && !dictText) setStatus('碼表已讀入,請再讀入詞庫。');
        else if (!codeText && dictText) setStatus('詞庫已讀入,請再讀入碼表。');
        else setStatus('尚未載入文件。');
        return;
      }
      analysis = computeAnalysis();
      renderFileState();
      renderResults();
    }

    codeInput.addEventListener('change', () => {
      const file = codeInput.files && codeInput.files[0];
      if (!file) return;
      codeFile = file;
      readFile(file, text => {
        codeText = text;
        setStatus(`已讀入碼表:${file.name}`);
        maybeAnalyze();
      });
    });

    dictInput.addEventListener('change', () => {
      const file = dictInput.files && dictInput.files[0];
      if (!file) return;
      dictFile = file;
      readFile(file, text => {
        dictText = text;
        setStatus(`已讀入詞庫:${file.name}`);
        maybeAnalyze();
      });
    });

    document.addEventListener('click', async (e) => {
      const btn = e.target.closest('.copy-btn');
      if (!btn) return;
      const key = btn.dataset.copy;
      const words = (analysis && analysis.sections[key]) ? analysis.sections[key] : [];
      const text = words.join('\n');
      await copyText(text);
      setStatus(`已複製 ${key} 內容(${words.length} 個詞)。`);
    });

    resetBtn.addEventListener('click', () => {
      codeText = '';
      dictText = '';
      codeFile = null;
      dictFile = null;
      analysis = null;
      codeInput.value = '';
      dictInput.value = '';
      renderFileState();
      renderResults();
      setStatus('已重置為初始狀態。');
    });

    function preventDefaults(e) {
      e.preventDefault();
      e.stopPropagation();
    }

    ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(evt => {
      codeBox.addEventListener(evt, preventDefaults);
      dictBox.addEventListener(evt, preventDefaults);
    });

    function handleDrop(boxType, e) {
      const files = e.dataTransfer.files;
      if (!files || !files.length) return;
      const file = files[0];
      if (boxType === 'code') {
        codeFile = file;
        codeInput.files = e.dataTransfer.files;
        readFile(file, text => {
          codeText = text;
          setStatus(`已讀入碼表:${file.name}`);
          maybeAnalyze();
        });
      } else {
        dictFile = file;
        dictInput.files = e.dataTransfer.files;
        readFile(file, text => {
          dictText = text;
          setStatus(`已讀入詞庫:${file.name}`);
          maybeAnalyze();
        });
      }
    }

    codeBox.addEventListener('drop', e => handleDrop('code', e));
    dictBox.addEventListener('drop', e => handleDrop('dict', e));

    renderFileState();
  </script>
</body>
</html>
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
帖子: 6355
注册时间: 2022年 11月 18日 17:36
联系:

Re: 拿到全倉的詞庫

帖子 ejsoon »

附件
shrest2.zip
(713.3 KiB) 尚未被下载
BIAU1.zip
(1002.96 KiB) 尚未被下载
BIAU1.pdf
(963.97 KiB) 尚未被下载
https://ejsoon.vip/
弈趣極光:享受思維樂趣
回复
  • 相似主题
    回复总数
    阅读次数
    最新帖子

在线用户

正浏览此版面之用户: 没有注册用户 和 16 访客