ninja33 / ODH

A chrome extension to show online dictionary content.
MIT License
1.4k stars 240 forks source link

自订脚本可以增加更多例句(sentence)吗? #318

Closed ohyeah5566 closed 10 months ago

ohyeah5566 commented 10 months ago

开发者好,这是我遇过最好用的学英文道具了

我使用的模板是ODH,除了原本的sentence外 还新增了sentence1、sentence2 希望能透过自订脚本的方式,将单字的例句放入sentence1 和 sentence2

例如查到的单字如下,字典提供了两个例句 greeting,問候;招呼;迎接

想将 They briskly exchanged greetings before starting the session. 放入sentence1 He nodded his head in greeting. 放入sentence2

请问这是有办法做到的吗?

ninja33 commented 10 months ago

sentence不是指例句的意思,是上下文的原句。

如果是词典本身带的例句,是放在glossary里的。

2023年9月14日 17:50,Yi-Wei @.***> 写道:

开发者好,这是我遇过最好用的学英文道具了

我使用的模板是ODH,除了原本的sentence外 还新增了sentence1、sentence2 希望能透过自订脚本的方式,将单字的例句放入sentence1 和 sentence2

例如查到的单字如下,字典提供了两个例句 greeting,問候;招呼;迎接

They briskly https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/briskly exchanged https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/exchange greetings before starting https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/start the session https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/session. 他們開會前簡短地互相致意。 He nodded https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/nod his head https://dictionary.cambridge.org/zht/%E8%A9%9E%E5%85%B8/%E8%8B%B1%E8%AA%9E-%E6%BC%A2%E8%AA%9E-%E7%B9%81%E9%AB%94/head in greeting. 他點頭致意。 想将 They briskly exchanged greetings before starting the session. 放入sentence1 He nodded his head in greeting. 放入sentence2

请问这是有办法做到的吗?

— Reply to this email directly, view it on GitHub https://github.com/ninja33/ODH/issues/318, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZ7BZAI563JLPREGVOPWJ3X2LHOTANCNFSM6AAAAAA4X2FQCE. You are receiving this because you are subscribed to this thread.

ohyeah5566 commented 10 months ago

词典本身带的例句,除了放在glossary里,我也想把例句放到 sentence1 和 sentence2 的欄位 就像下面的图片那样。 目前是用手动的方式做这件事,在想有没有办法透过自订脚本完成这件事 anki_RbRvRWVNIz

ninja33 commented 10 months ago

你新建两个栏位sentence1和sentence2,最后的目的是什么?是准备在卡片模版上摆放?

栏位最后的呈现,是要靠卡片模版体现的,那如果glossary里的例句,在不增加sentence1和2的栏位的前提下,也能显示,那就不需要增加栏位啦。 在ODH里,光改自定义脚本是不够的,他在连接到ankiconnect值卡的时候,只能传输glossary和sentence,因为所有信息都包含了,怎么用是后台模版的事情。

我这里举个例子,你有一点CSS基础的话很好理解,比如你在卡片反面想在glossary之外的地方显示例句。那么模版可以这么写

{{expression}}. <— its head word {{sentence}}. <— it’s context sentence —————— {{glossary}}. <— it’s glossary

<div class=‘example_sentence'>{{glossary}}

.

你观察一下脚本里的css定义,英语翻译在eng_trans这个class下面,中文翻译在chn_trans这个class下面 而例句在 ul 和li的排列下 所以你写一个css 在卡片模版的样式区域

.example_sentence .eng_trans { display:none; } .example_sentence .chn_trans { display:none; } 那么就把glossary里,但是套在.example_sentence这个div里的中文英文翻译隐藏了,只留下了例句,可以起到单独开一个栏位的效果

2023年9月14日 20:07,Yi-Wei @.***> 写道:

词典本身带的例句,除了放在glossary里,我也想把例句放到 sentence1 和 sentence2 的欄位 就像下面的图片那样。 目前是用手动的方式做这件事,在想有没有办法透过自订脚本完成这件事 https://user-images.githubusercontent.com/22759975/267967339-5f7b946a-3603-488a-81a1-addfe737943b.png — Reply to this email directly, view it on GitHub https://github.com/ninja33/ODH/issues/318#issuecomment-1719323902, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZ7BZB374ENDOWQGNYVARDX2LXOVANCNFSM6AAAAAA4X2FQCE. You are receiving this because you commented.

ohyeah5566 commented 10 months ago

你新建两个栏位sentence1和sentence2,最后的目的是什么?是准备在卡片模版上摆放?

有两个目的

  1. 卡片正面,会随机拿 sentence, sentence1, sentence2 来显示 卡片正面 {{expression}} {{sentence or sentence1 or sentence2}}
  2. 我希望让sentence可以有语音 有找到一个 anki套件 可以将text转成audio (tts) 用法是选择field然后就能产生audio

所以最后的呈现就是 卡片的正片除了播放单字以外,还会随机选一个sentence显示并唸出

如果只有1这个需求的话,觉得好酷,没想到css还能这样玩 但因为有2的需求,可能就不行这样了

另一个思路可能是,把text转成audio的方式,也放在脚本上 然后将sentence audio 塞在glossary,再用操作css的方式,显示其中一个sentence 和 播放语音 风险就是脚本只能放在公开网页上,text转成audio会需要使用API key,有点危险

ohyeah5566 commented 10 months ago

考慮到有些字典提供的例句太簡短,現階段還是手動新增好了

ohyeah5566 commented 10 months ago

感谢之前的回复!!