ikey4u / wikit

Wikit - A universal lookup tool
MIT License
205 stars 16 forks source link

Wikit 词典格式提案 #5

Closed ikey4u closed 2 years ago

ikey4u commented 3 years ago

wikit.db: sqlite 格式

  一共三列, 如下所示

      key, value_offset, value_size

  这里的 key 必须是唯一的不能重复的, 其值可以是单词, 图片名称, 音频名称,
  value_offset 和 value_size 分别表示对应值在 wikit.data 中的偏移地址和大小,
  比如当 key 为单词时, value_offset 就表示其释义在 wikit.data 中的偏移地址以及释义长度,
  当 key 为图片名称时, value_offset 就表示图片在 wikit.data 中的偏移地址及图片大小.

wikit.cache: 用户查询缓存, 也就是 wikit.db 的一个子集

wikit.data: binary

  meanings[0], meanings[1], ...
  imagns[0], images[1], ...
  audios[0], audios[1], ...
rainhear commented 3 years ago
PageDemo:
  text: Demo
  image: Demo.png

Abc:
  __include: /PageDemo

Def:
  __include: /PageDemo
  __patch:
    text: [ Def, Demo ]
ikey4u commented 3 years ago

@rainhear 是否能给一个稍微完整的, 能够体现你编辑痛点的例子? 我对 yaml 这种语法(指include, patch)不是特别熟悉, 也许可以用另一种方式解决.

rainhear commented 3 years ago

ImageA
PageUpPageDown </>

ImageB
PageUpPageDown </>

PageA @@@INCLUDE=[TextArticle, ImageA] </>

PageB @@@INCLUDE=[TextArticle, ImageB] </>

KeyA Love him love his dog
@@@INCLUDE=PageA </>

KeyB God Save the Queen
@@@INCLUDE=PageB </>


- 期待打包工具編譯後的效果
``` html
TextArticle
<span> Proverb </span><br>
</>

ImageA
<img src="/ImageA.png" width="100%"><br><a href="entry://ImageZ">PageUp</a>&emsp;<a href="entry://ImageB">PageDown</a>
</>

ImageB
<img src="/ImageB.png" width="100%"><br><a href="entry://ImageA">PageUp</a>&emsp;<a href="entry://ImageC">PageDown</a>
</>

PageA
<span> Proverb </span><br><img src="/ImageA.png" width="100%"><br><a href="entry://ImageZ">PageUp</a>&emsp;<a href="entry://ImageB">PageDown</a>
</>

PageB
<span> Proverb </span><br><img src="/ImageB.png" width="100%"><br><a href="entry://ImageA">PageUp</a>&emsp;<a href="entry://ImageC">PageDown</a>
</>

KeyA
<span> Love him love his dog </span><br><span> Proverb </span><br><img src="/ImageA.png" width="100%"><br><a href="entry://ImageZ">PageUp</a>&emsp;<a href="entry://ImageB">PageDown</a>
</>

KeyB
<span> God Save the Queen </span><br><span> Proverb </span><br><img src="/ImageB.png" width="100%"><br><a href="entry://ImageA">PageUp</a>&emsp;<a href="entry://ImageC">PageDown</a>
</>
ikey4u commented 3 years ago

@rainhear 明白了, 这个想法不错, 我已经收录到项目的 wiki 页面, 作为对传统 mdx 源文件的一种扩展.

rainhear commented 3 years ago
TextArticle
  <span> Proverb </span>
  <br>
</>

ImageA
  <img src="/ImageA.png" width="100%">
  <br>
  <a href="entry://ImageZ">PageUp</a>
  &emsp;
  <a href="entry://ImageB">PageDown</a>
</>

ImageB
  <img src="/ImageB.png" width="100%">
  <br>
  <a href="entry://ImageA">PageUp</a>
  &emsp;
  <a href="entry://ImageC">PageDown</a>
</>

PageA
  @@@INCLUDE=[TextArticle, ImageA]
</>

PageB
  @@@INCLUDE=[TextArticle, ImageB]
</>

KeyA
  <span> Love him love his dog </span>
  <br>
  @@@INCLUDE=PageA
</>

KeyB
  <span> God Save the Queen </span>
  <br>
  @@@INCLUDE=PageB
</>
rainhear commented 3 years ago
@private
TextArticle
  <span> Proverb </span>
  <br>
</>

@private
ImageA
  <img src="/ImageA.png" width="100%">
  <br>
  <a href="entry://ImageZ">PageUp</a>
  &emsp;
  <a href="entry://ImageB">PageDown</a>
</>

@private
ImageB
  <img src="/ImageB.png" width="100%">
  <br>
  <a href="entry://ImageA">PageUp</a>
  &emsp;
  <a href="entry://ImageC">PageDown</a>
</>

@public
PageA
  @@@INCLUDE=[TextArticle, ImageA]
</>

@public
PageB
  @@@INCLUDE=[TextArticle, ImageB]
</>

@public
KeyA
  <span> Love him love his dog </span>
  <br>
  @@@INCLUDE=PageA
</>

@public
KeyB
  <span> God Save the Queen </span>
  <br>
  @@@INCLUDE=PageB
</>
ikey4u commented 3 years ago
* 如果著手引入 `@@@INCLUDE=` 指令,此時也當考慮 `換行符號` 是否會導致打包工具無法準確編譯的潛在風險。

* 現有 `MDict` 標準規定了 `節點` 須符合 `三行式` 編寫規範,多餘的 `換行` 與 `縮進` 可能會導致打包工具無法準確編譯。

* 個人認為源碼 `txt` 中應當能夠支援必要的排版 `縮進` 與 `換行`,這樣在源碼編寫過程中,代碼可讀性會更高。

* 最終的數據格式化工序應該交由打包工具來實現。
TextArticle
  <span> Proverb </span>
  <br>
</>

ImageA
  <img src="/ImageA.png" width="100%">
  <br>
  <a href="entry://ImageZ">PageUp</a>
  &emsp;
  <a href="entry://ImageB">PageDown</a>
</>

ImageB
  <img src="/ImageB.png" width="100%">
  <br>
  <a href="entry://ImageA">PageUp</a>
  &emsp;
  <a href="entry://ImageC">PageDown</a>
</>

PageA
  @@@INCLUDE=[TextArticle, ImageA]
</>

PageB
  @@@INCLUDE=[TextArticle, ImageB]
</>

KeyA
  <span> Love him love his dog </span>
  <br>
  @@@INCLUDE=PageA
</>

KeyB
  <span> God Save the Queen </span>
  <br>
  @@@INCLUDE=PageB
</>

对, 类似于格式化这种方便编辑人阅读, 这个我已经考虑到了.

ikey4u commented 3 years ago
* 更近一步,敝人可能想到了數據的封裝性,比如提供類似 `Java` 語言中的 `private` `public` 限定修飾符。

* `私有` 節點僅平臺內部調用,`公開` 節點則用戶可見。

* 當然這種設計可能會加重作者的編寫難度和打包工具的編譯成本。
@private
TextArticle
  <span> Proverb </span>
  <br>
</>

@private
ImageA
  <img src="/ImageA.png" width="100%">
  <br>
  <a href="entry://ImageZ">PageUp</a>
  &emsp;
  <a href="entry://ImageB">PageDown</a>
</>

@private
ImageB
  <img src="/ImageB.png" width="100%">
  <br>
  <a href="entry://ImageA">PageUp</a>
  &emsp;
  <a href="entry://ImageC">PageDown</a>
</>

@public
PageA
  @@@INCLUDE=[TextArticle, ImageA]
</>

@public
PageB
  @@@INCLUDE=[TextArticle, ImageB]
</>

@public
KeyA
  <span> Love him love his dog </span>
  <br>
  @@@INCLUDE=PageA
</>

@public
KeyB
  <span> God Save the Queen </span>
  <br>
  @@@INCLUDE=PageB
</>

这种做法, 如果对于有编程经验的人而言可能比较好理解, 但是对于普通人, 这种规则恐怕引入了不必要的复杂性.