Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何反查script类型词典内的多音节词组 #822

Closed
siuze opened this issue Feb 18, 2024 · 6 comments
Closed

如何反查script类型词典内的多音节词组 #822

siuze opened this issue Feb 18, 2024 · 6 comments

Comments

@siuze
Copy link
Contributor

siuze commented Feb 18, 2024

如果词库是通过 packs 配置引入的,似乎没有办法反查其中的词条,目前reverse_lookup 只能反查 *.dict.yaml中的词条。
【更新】:我验证了一下应该和packs无关,好像是rime本身的对script音节类型的码表反查时只能查单字。没办法查多音节的词组

例如,我通过如下配置中通过分别引入单字码表和词库

translator:
  dictionary: ShanRenMaLTS  #单字码表来自ShanRenMaLTS.dict.yaml
  packs:
    - ShanRenMaLTS.phrases_CORE  #核心词库来自build/ShanRenMaLTS.phrases_CORE.table.bin
    - ShanRenMaLTS.phrases_EXT   #扩展词库来自build/ShanRenMaLTS.phrases_EXT.table.bin


pinyin: #拼音副翻譯器
  tag: pinyin
  dictionary: pinyin_simp #使用袖珍简化字拼音进行反查
  prefix: "`"
  tips: 〔拼音反查〕
  
reverse_lookup:
  tags: [ pinyin ]   #掛在這個tag所對應的翻譯器上
  dictionary: ShanRenMaLTS #可以正常查询ShanRenMaLTS.dict.yaml中的单字
  packs:  #这个配置没用,无法查询下方packs中的词条
    - ShanRenMaLTS.phrases_CORE
    - ShanRenMaLTS.phrases_EXT

反查结果 正常打字

图1是用拼音反查script类型的码表,图2是正常打字;可以看到单字可以反查,但是词组不行。

即使将词库引入方式从packs更改为普通的dict.yaml文件也还是不行。

还没测试过table类型的码表能否反查词组,印象中是可以的。

@shewer
Copy link
Contributor

shewer commented Feb 18, 2024

多做幾個 reverse_lookup

reverse_lookup_filter@ShanRenMaLTS.phrases_CORE
reverse_lookup_filter@ShanRenMaLTS.phrases_EXT
ShanRenMaLTS.phrases_EXT:  
    tags: [pinyin]
    dictionary: ShanRenMaLTS.phrases_EXT
 
ShanRenMaLTS.phrases_CORE:
     tags: [pinyin]
     dictionary: ShanRenMaLTS.phrases_CORE

參考 https://github.com/LEOYoon-Tsaw/Rime_collections/blob/master/Rime_description.md#%E5%9B%9Breverse_lookup_filter

需要確認是否支持 #699 append_comment 機制(librime 1.9.0 支持)

@siuze
Copy link
Contributor Author

siuze commented Feb 18, 2024

pinyin: #拼音副翻譯器
  tag: pinyin
  dictionary: pinyin_simp #使用袖珍简化字拼音进行反查
  prefix: "`"
  tips: 〔拼音反查〕

不行,我突然发现好像问题和packs关系不大,而在于rime自身不能反查script类型字典内的多音节词组,只能查单字。

@siuze siuze changed the title 如何反查通过packs引入的词库内的词条 如何反查script类型词典内的多音节词组 Feb 18, 2024
@shewer
Copy link
Contributor

shewer commented Feb 19, 2024

反查表只是一個 hash table [text, code]
只要 候選字 不是 sentence candidate 或是 反查表內剛好有相同的詞組 應該就能找到。

sentence candidate 也是能找得到 多音節詞組,只是在librime 中沒機制可以完成 (也沒必要),但是多音節候選部份只出現在第一個,第二個以後的候選應該找得到

而且反查的目的不就是爲了 查找打不出字 或是 查找簡碼嗎 , 有必要在 一長串 text中 再加上 一長串 comment 嗎

雙拼方案 大部分是使用 prism轉換 ,字典還是 拼音碼 , 反查出來的拼音可以再次用 pattern 轉成雙拼碼

@siuze
Copy link
Contributor Author

siuze commented Feb 19, 2024

反查表只是一個 hash table [text, code]
只要 候選字 不是 sentence candidate 或是 反查表內剛好有相同的詞組 應該就能找到。

sentence candidate 也是能找得到 多音節詞組,只是在librime 中沒機制可以完成 (也沒必要),但是多音節候選部份只出現在第一個,第二個以後的候選應該找得到

而且反查的目的不就是爲了 查找打不出字 或是 查找簡碼嗎 , 有必要在 一長串 text中 再加上 一長串 comment 嗎

雙拼方案 大部分是使用 prism轉換 ,字典還是 拼音碼 , 反查出來的拼音可以再次用 pattern 轉成雙拼碼

词组反查的意义在于去重,例如用户希望查询“尴尬”一词或其中任意一个字的编码,直接反查gan ga 即可快速定位。

而先输入gan,需要在一堆同音字中找半天,再输入ga,又要翻好久

@siuze
Copy link
Contributor Author

siuze commented Feb 19, 2024

看了一下源码,反查字典是针对单音节序列syllabary进行构建的,因此只支持单音节查询。

@siuze
Copy link
Contributor Author

siuze commented Feb 19, 2024

暂时通过手动修改源码来实现,siuze@04f13a2 siuze@ccce90d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants