Coder Social home page Coder Social logo

luoliyan / chinese-support-redux Goto Github PK

View Code? Open in Web Editor NEW
102.0 13.0 49.0 138.93 MB

Anki add-on providing support for Chinese study

Home Page: https://ankiweb.net/shared/info/1128979221

License: GNU General Public License v3.0

Python 57.88% Makefile 0.01% OpenEdge ABL 42.10%
anki flashcards addon chinese mandarin cantonese study-aid

chinese-support-redux's Introduction

Archived

Due to “real life” getting in the way, this project has not been maintained for some time, and — from what I understand — does’t work with recent versions of Anki. Sadly, the time to archive the repo has arrived.

Thanks to the community for all your support, from the bug reports to pull requests to the random friendly email. Damien has cultivated a really heathly culture around his product. Much appreciation to Thomas Tempé as well, for obvious reasons.

For those looking for an alternative, I am reliably informed (thanks 3ter) that Chinese Support 3 is functional, and is actively maintained.

I may return to add-on development at some point, but currently I don’t develop in Python anymore, and haven’t updated Anki in over a year. That said, feel free to hit me up with an email if there’s anything I might be able to help with.

Chinese Support Redux

Codacy Badge Coverage Status

ko-fi

Chinese Support Redux is an Anki 2.1-compatible rewrite of the original Chinese Support add-on. It offers a number of features that streamline the process of creating flashcards for learning Chinese. The current focus of development effort is on improving the stability of the add-on and the accuracy of its output. Once the core functionality is sufficiently robust and reliable, additional features will be considered.

Please note that the add-on is still in beta and is sometimes shipped in an unstable state. Please upgrade with each new release and report any issues on GitHub. The automated test suite is a work-in-progress, so I still rely heavily on user reports to supplement my own manual testing.

Important Notes

  • If you find that a field is not filling at all, please check config.json for the complete list of valid field names. For those migrating from an older version of the add-on, you will need to rename any definition fields to English, German or French, depending on what you want.
  • If tone colours are not showing, ensure that the styling section of the template contains the following CSS:
.tone1 {color: red;}
.tone2 {color: orange;}
.tone3 {color: green;}
.tone4 {color: blue;}
.tone5 {color: gray;}

Features

  • Automatic field filling
    • Translation (from built-in dictionary; supports English, German and French)
    • Romanisation (supports Pīnyīn (拼音) and Cantonese Jyutping (粵拼))
    • Mandarin Audio (fetched from Google or Baidu)
    • Traditional (繁體字) and simplified (簡體字) characters
    • Bopomofo (ㄅㄆㄇㄈ), also known as Zhuyin (注音)
    • Rubies (small-print transcription placed above characters)
    • Frequency (from “very basic” to “obscure”) - based on anki-chinese-word-frequency
    • Usage Sentence Examples - Chinese/English sentence pairs from Tatoeba
  • Tone colours (applied to characters, romanisation and Bopomofo)
  • Built-in note types (Basic and Advanced)

Status

The vast majority of features have been successfully ported, and the add-on is in a usable state, albeit with some definite rough edges.

The add-on is still in beta. By this I mean “it works, but I wouldn’t trust it with my children”. Expect occasional issues, and please make a back-up before trying it. I use it myself and haven't experienced data loss, but your mileage may vary.

Please report any issues here on GitHub. Feature requests are also welcome.

If you are new to the Chinese Support add-on, the wiki from the previous version is still relevant (here).

Usage

The core feature of the add-on is the automatic field filling. To take advantage of this, you need to have an Anki note type with the appropriate fields (e.g., Hanzi, English, Pinyin, Sound). See config.json for a list of valid field names.

If you don't already have such a note type, the easiest approach is to use one of the built-in models. Two types are installed automatically: Basic and Advanced. The only important difference is that the Advanced model shows more information.

To use the field-filling features:

  1. Add a new note to Anki (press a)
  2. Select Chinese (Basic) or Chinese (Advanced) as the note type
  3. Enable Chinese Support Redux for this note type (click 汉字)
  4. Enter a word (e.g., 電話) into the Hanzi field (sentences will also work)
  5. Press Tab
  6. The remaining fields should then be populated automatically

Screenshots

Screenshot #1

Screenshot #2

Support

If you encounter any issues, the best way to have these addressed is to raise them on GitHub. Feature requests are welcome, with the caveat that all good things take time.

I understand the documentation is sparse. Anyone who wishes to add content to the wiki is more than welcome to.

Development

Testing

For those who wish to run the tests locally, this is fairly straightforward.

Clone the repository:

git clone https://github.com/luoliyan/chinese-support-redux
cd chinese-support-redux

Ideally, set up a virtual environment to isolate the project:

curl https://pyenv.run | bash
pyenv virtualenv 3.6.8 csr
pyenv local csr

Install dependencies and run the tests:

pip install -r requirements.txt
make test

Debugging with PyCharm

(a) Without Anki Source

  1. Copy the repo root to the Anki add-ons folder. As of version 2.1, this is %AppData%\Anki2\addons21
  2. Create a Python 3.8 virtual environment in PyCharm for the add-on folder (make sure you are running 64-bit Python). This can be done with:
import platform
platform.architecture()
  1. Run the following in the PyCharm console (these could be added to requirements.txt instead):
import subprocess
subprocess.check_call(["pip3", "install", "mypy", "anki", "ankirspy", "aqt", "pyqt5", pyqtwebengine"])
  1. Install the requirements.txt for the project venv
  2. Create a file for debugging in PyCharm as:
import aqt
aqt.run()
  1. Start debugging. The first Anki run will pick up the tests folder as a plugin and error out. This is expected.
  2. Go to the Tools → Add-ons menu and disable tests
  3. Enjoy coding!

(b) With Anki Source

  1. Download and extract Anki source code somewhere on the hard drive.
  2. Create a folder such as anki-addon-dev on your hard drive and open it on PyCharm as a project. Then, open Anki source code folder as another project within the current project window by choosing Attach.
  3. Under Preferences → Project → Project Dependencies → anki-addon-dev, check the box to approve the add-on depends on Anki source code.
  4. Under the run configurations beside run and debug buttons, edit the configuration as follows:
  • Script Path: [PATH_TO_ANKI_SOURCE_FOLDER]/anki-2.1.13/runanki
  • Parameters: -b [PATH_TO_ANKI_ADDON_PROJECT]/anki-addon-dev
  1. Create your project files and do the development on this path: anki-addon-dev/addons21/[YOUR_PROJECT_FOLDER]
  2. Happy debugging while developing

Additional Guidance

chinese-support-redux's People

Contributors

3ter avatar ajgrf avatar bendotli avatar codacy-badger avatar fsonntag avatar glutanimate avatar hoeken avatar infernalis avatar jasonbens avatar jkitching avatar luoliyan avatar mawis avatar ospalh avatar p2635 avatar telotortium avatar trevorld avatar ttempe avatar varbird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chinese-support-redux's Issues

Incorrect handling of sentences with English words

Describe the bug
If the Hanzi is a sentence with English characters (for example if it contains an English name), the pinyin and color fields are bad (especially the color)

To Reproduce
Steps to reproduce the behavior:

  1. Start adding a card
  2. Enter "Brian的" in the Hanzi field (or something along those lines)
  3. Let Chinese mode autofill the fields
  4. The reading now contains "Briande" (no space, minor), while the color just contains "Br"

Expected behavior
The reading should say "Brian de" (but not a big deal), and the color should say "Brian的" with appropriate tone colors (probably neutral tone for Brian).

Screenshots
screen shot 2019-01-06 at 7 05 21 pm

Specs (please complete the following information):

  • OS: Mac Os X
  • Anki Version 2.1.7
  • Chinese Support Redux v091

Unable to update due to error in send2trash

Describe the bug
Hi, again it is impossible to update the add-on, just like last time.

To Reproduce
When I try to update, I get this error:

Anki 2.1.7 (a6c34fd7) Python 3.6.7 Qt 5.12.0 PyQt 5.11.3
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
File "aqt\addons.py", line 394, in onCheckForUpdates
File "aqt\addons.py", line 156, in downloadIds
File "aqt\addons.py", line 117, in install
File "aqt\addons.py", line 140, in deleteAddon
File "lib\site-packages\send2trash\plat_win.py", line 86, in send2trash
<class 'OSError'>: [WinError 124] None: 'C:\Users\ASUS\AppData\Roaming\Anki2\addons21\112897~1'

Interferes with Japanese Support

While using both this and the Japanese Support addon together, Japanese won't auto add readings unless the Chinese Support option is on. And it adds comment to the reading field, which effects {{kana:Reading}} output. Also attempts to fill Meaning field from Chinese dictionary. This could be fixed by only operating on note types containing the word "Chinese" in its name, as the Japanese Support only operates on note types containing the word "Japanese."

Add support for monolingual definitions of cards

Once my studies advance a little more, I'd like to have the option to review certain cards with monolingual definitions (i.e., definitions in Chinese). Ideally, there exists a monolingual dictionary like CEDICT whose definitions we can use. I've already found http://www.zdic.net/z/, which seems to have a CC-Noncommercial license - perhaps that could be used.

Punctuation ruins the quality of Pinyin transcription

Describe the bug
I know there is still work being done on improving the transcription, but this is potentially a low hanging fruit: I've noticed that sometimes including a punctuation character makes the transcription a lot more mediocre.

To Reproduce
Steps to reproduce the behavior:

  1. Add a card, and write "我要喝湯" as the Hanzi. The transcription will be "wǒyàohētāng", which is correct.
  2. Add a card and write "我要喝湯!" (same as before but with an exclamation mark), the transcription will be "wǒ yāo hē tāng !" (with a first tone on "yao"), which is incorrect, even though it's the exact same sentence except for the exclamation mark at the end, far from the word that is affected.

Expected behavior
Punctuation doesn't affect transcription except to the extent that it indicates word separation.

Specs (please complete the following information):
OS: Mac Os X
Anki Version 2.1.7
Chinese Support Redux v091

Crash on character "睘"

Anki crashes whenever Chinese Support Redux attempts to fill in the card for "睘".

Specs (please complete the following information):

  • OS: [e.g. Windows, iOS, Ubuntu]: macOS Mojave 10.14.1
  • Anki Version [e.g. v2.0.52, v2.1.5] v2.1.6-test
  • Chinese Support Version [e.g. v0.5.3-beta] v0.8.2

Additional context
This character seems to have some fields missing in CEDICT, if MDBG is anything to go by.

Urllib3 dependency in tts.py

Hi luoliyan,

there's still another dependency error for me which results in failing to load the addon correctly.

It's line 8 in tts.py:
import urllib3

The same type of error as in #12:
ModuleNotFoundError: No module named 'urllib3'

Classifiers seem not to be filled in

Unlike with the old version of the add-on, this version doesn't seem to populate the classifier field. On my notes the field is entitled "Mean Word".

Incorrect handling of sentences with punctuation

Original report: ttempe/chinese-support-addon#71

Commas seem to be handled correctly now, unlike in older version. But several issues remain:

  1. If 没有,是我第一次来上海旅游。 is entered in the Hanzi field, the full stop is missing in the color field output.
  2. If the input is 没有。没有。 then the output is 没有。没

If anyone has other examples, please post them here.

Pinyin does not fill in after hitting tab key

Describe the bug
Pinyin does not fill in after hitting tab key

To Reproduce
Steps to reproduce the behavior:

  1. open deck
  2. enter Hanzi
  3. clink tab key
  4. pinyin field is empty

Expected behavior
Pinyin field should populate

Screenshots
See my screenshot
ankiscreenshot

Specs (please complete the following information):

  • OS: Windows 10
  • Anki Version: Version 2.1.11 (3cf770c7)
  • Chinese Support Version v0.10.0

Additional context
Not sure if this is my configuration or a bug but it worked before I upgraded

Problem with Zhuyin transcription

Describe the bug
After the last update, the problem with the space in the zhuyin/pinyin transcription persists (affecting tone colour and the ruby field). I have noticed that there is a new problem with the zhuyin transcription: some tone marks disappear, although the pinyin field is correct.
Examples:
神韻 zhuyin: ㄕㄣㄩㄣˋ but pinying: shényùn (right tones)
巨大無比 zhuyin: ㄐㄩㄉㄚˋ ㄨㄅㄧˇ but pinyin: jùdà wúbǐ
不錯 ㄅㄨㄘㄨㄛˋ but bùcuò
試圖 ㄕㄊㄨˊ but shìtú
不好意思 ㄅㄨㄏㄠㄧㄙˋ but bùhǎoyìsi
百戰百勝 ㄅㄞㄓㄢㄅㄞㄕㄥˋ but bǎizhànbǎishèng

So it seems to be a problem with zhuyin. I just tried with a few words and expressions, for most of them zhuyin has wrong tones.

Specs (please complete the following information):

  • OS: Windows 10
  • Anki Version 2.1.7 (a6c34fd7) Qt 5.12.0 PyQt 5.11.3
  • Chinese Support Version 0.10

Config file is reset to default after every restart

Describe the bug
Any time I close and re-open Anki, any edits I've made to the Add-on config file reset to default.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Anki Add-on menu and view config file for Anki Support.
  2. Change "Also Written" to "Alsox Written"
  3. Click "OK" and exit Anki
  4. Reopen Anki and navigate to config file
  5. See "Also Written"

Expected behavior
Changes to config file are persistent through restarts.

Screenshots
If applicable, add screenshots to help explain your problem.

Specs (please complete the following information):

  • OS: Windows 7
  • Anki Version 2.1.6
  • Chinese Support Redux V091

Sound doesn't fit for some characters

Hi there,

Synopsis

As one character may have multiple pronunciations there are cases where the sound doesn't match the reading.

Steps to reproduce

  • Put 分享 in the field "Hanzi"
  • Press TAB

Observed behavior

  • The reading is populated with "bì jìng"
  • The sound is "fēn xiǎng"

Expected behavior

  • The reading is populated with "fēn xiǎng" as is the sound.

Regards,
3ter

Color does not get filled when Pinyin is present

Describe the bug
FIeld "color" does not get filled when a field with name "pinyin" is present.

To Reproduce
Steps to reproduce the behavior:

  1. Add fields with names "color" and "pinyin".
  2. Add new note by inserting e.g. 拼音 and press TAB.
  3. Notice that "color" will be empty, wheres "pinyin" and "Pinyin" both get filled.

Expected behavior
All fields should be filled regardless which other fields are present.

Screenshots
Missing Color Field

Specs (please complete the following information):

  • OS: Arch Linux
  • Anki Version 2.1.11 (3cf770c7)
  • Chinese Support Version v0.10.0-beta

Add a tone number Pinyin field

Is your feature request related to a problem? Please describe.
I just started out learning Mandarin last week and immediately found Anki and your really great chinese-support addon. Thanks for maintaining! I also bought the Hanping Pro dictionary app on Android which I think has some really nice sound database. However, as far as I can see you can only combine Anki+Hanping using sth. like

<a href='android-app://com.embermitre.hanping.app.pro#Intent;action=com.hanpingchinese.cmn.intent.action.PLAY;S.p={{text:Pinyin}};S.s={{text:Simplified}};S.t={{text:Traditional}};S.LANG=cmn;S._SOURCE=anki;end'>

in cards, where S.p seems to be the important part for it to work. Unfortunately, it only takes pinyin in numbered form.

Describe the solution you'd like
Could you please add to config.json another field, e.g. NumPinyin, that will be filled with the corresponding numbered pinyin instead of the one with converted tone markings? That would also be helpful for cards with {{type:NumPinyin}} when learning with "simple" keyboards.

I would do it myself and provide a pull request, but because of lack of documentation it's somehow hard to go through your code.

Describe alternatives you've considered
Writing a JavaScript converter in each card's code.

Google TTS doesn't produce proper sound files anymore

Hi luoliyan,

Synopsis

Google TTS doesn't seem to produce proper sound files anymore on Anki version 2.1.5. Baidu TTS is producing sound.

Steps to reproduce

  • Use Anki version 2.1.5 (latest)
  • Use either the old version of this addon 839350950 (no longer available) or the one for Anki 2.1 1128979221
    • Use either Google TTS as speech engine
  • Create a note and make sure the sound field gets populated
    • I thought this was formerly achieved by tabbing, now I had to click on the first, then a second field
  • Save and preview the note

Observed behavior

  • There is no sound to be heard
    • The sound file in the media folder is also not playable (e.g. with VLC)

Expected behavior

  • Google TTS has been producing sound files
    • And the sound was added by pressing tab and not only by clicking

Regards,
3ter

wrong pinyin

Describe the bug
While I was adding new note it wrongly produced Pinyin for one common character in each word.

To Reproduce
Steps to reproduce the behavior:

  1. Press 'a' to add new note.
  2. Press '汉字' button.
  3. Type only '开' or a word that contain it.
  4. Press Tab.
  5. Instead of 'kāi' it will show 'fēng' in all readings I mean Pinyin, Ruby and Bopomofo.

Expected behavior
It was expected to input 'kāi' or it's sound in all reading fields.

Screenshots
If applicable, add screenshots to help explain your problem.
screen shot 2018-12-09 at 9 40 22 pm
screen shot 2018-12-09 at 9 41 08 pm

Specs (please complete the following information):

  • OS: mac OS High Sierra 10.13.6
  • Anki Version 2.1.4
  • Chinese Support Version v0.8.4-beta

Additional context
Add any other context about the problem here.

Make use of Sin-Ji Cantonese TTS on OSX

AwesomeTTS has Sin-Ji (zh-HK) on OSX.
Android has TTS support via Google yue-Hant-HK and some other speech engines too, like Ekho.

For Google TTS the locale is:
new Locale("yue", "HK"); //yue for 粤语

This addon should be able to use a Cantonese text to speech engine.

Profile and fix performance bottlenecks

I noticed a big performance degrade after updating to version 0.10.0 of the plugin.

What I do

  1. I have opened a card in the card overview (keyboard shortcut B).
  2. Cursor blinks in the first field (汉字 in my case).
  3. I press the TAB key on my keyboard.

What happens

  1. For several seconds nothing happens at all.
  2. After several seconds the cursor switches to the second input field (繁體字 in my case).

What I would expect
Cursor switches to the 繁體字 field without a noticable delay.

Specs:

  • OS: Windows
  • Anki Version 2.1.4
  • Chinese Support Version 0.10.0

Additional context

  • I have around 3500 notes (more than 10,000 cards)
  • The note template has been extended to 11 fields (汉字, 繁體字, 量詞, 意思, 拼音, 彩色, ㄅㄆㄇㄈ, RubyBPMF, Ruby, Alternative, Sound)

Filling transcription and color throws

Describe the bug

When I click on Chinese -> Fill transcription and Color, then I get the following error message:

Error 
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Windows 7
Flags: frz=True ao=True sv=1

Caught exception:
  File "E:\AnkiData\addons21\1128979221\fill.py", line 185, in fill_pinyin
    results += update_Pinyin_fields(hanzi, note_dict)
  File "E:\AnkiData\addons21\1128979221\behavior.py", line 143, in update_Pinyin_fields
    format_Pinyin_fields(d)
  File "E:\AnkiData\addons21\1128979221\behavior.py", line 130, in format_Pinyin_fields
    True
<class 'TypeError'>: accentuate() takes 1 positional argument but 2 were given

To Reproduce
Steps to reproduce the behavior:

  1. Open Anki
  2. Click on Chinese -> Fill transcription and Color
  3. Click on Yes
  4. See error

Expected behavior
It fills out my notes

Screenshots

image

Specs (please complete the following information):

  • OS: Windows 7
  • Anki Version 2.1.5 Qt 5.9.2 PyQt 5.9
  • Chinese Support Version v084

Additional context
It looks a bit like #22

UnicodeEncodeError

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.6-test Python 3.6.7 Qt 5.12.0 PyQt 5.11.3
Platform: Mac 10.14.1
Flags: frz=True ao=True sv=1

--- Logging error ---
Traceback (most recent call last):
File "logging/init.py", line 996, in emit
UnicodeEncodeError: 'ascii' codec can't encode character '\uff1f' in position 145: ordinal not in range(128)
Call stack:
File "runankimac", line 12, in
File "aqt/init.py", line 262, in run
File "aqt/init.py", line 347, in _run
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 346, in _onBridgeCmd
File "aqt/editor.py", line 268, in onBridgeCmd
File "anki/hooks.py", line 34, in runFilter
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 61, in onFocusLost
if updateFields(note, field, allFields):
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 469, in updateFields
update_all_Sound_fields(fieldsCopy[currentField], fieldsCopy)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 350, in update_all_Sound_fields
updated1, errors1 = update_Sound_fields(hanzi, dico)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 315, in update_Sound_fields
s = sound(hanzi)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_functions.py", line 410, in sound
return '[sound:%s]' % tts.download_sound(text, options[source])
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 34, in download_sound
tts = gTTS(text, lang=lang)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 108, in init
log.debug("%s: %s", k, v)
File "logging/init.py", line 1296, in debug
File "logging/init.py", line 1444, in _log
File "logging/init.py", line 1454, in handle
File "logging/init.py", line 1516, in callHandlers
File "logging/init.py", line 865, in handle
File "logging/init.py", line 1072, in emit
File "logging/init.py", line 1000, in emit
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
--- Logging error ---
Traceback (most recent call last):
File "logging/init.py", line 996, in emit
UnicodeEncodeError: 'ascii' codec can't encode characters in position 66-68: ordinal not in range(128)
Call stack:
File "runankimac", line 12, in
File "aqt/init.py", line 262, in run
File "aqt/init.py", line 347, in _run
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 346, in _onBridgeCmd
File "aqt/editor.py", line 268, in onBridgeCmd
File "anki/hooks.py", line 34, in runFilter
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 61, in onFocusLost
if updateFields(note, field, allFields):
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 469, in updateFields
update_all_Sound_fields(fieldsCopy[currentField], fieldsCopy)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 350, in update_all_Sound_fields
updated1, errors1 = update_Sound_fields(hanzi, dico)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 315, in update_Sound_fields
s = sound(hanzi)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_functions.py", line 410, in sound
return '[sound:%s]' % tts.download_sound(text, options[source])
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 34, in download_sound
tts = gTTS(text, lang=lang)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 108, in init
log.debug("%s: %s", k, v)
File "logging/init.py", line 1296, in debug
File "logging/init.py", line 1444, in _log
File "logging/init.py", line 1454, in handle
File "logging/init.py", line 1516, in callHandlers
File "logging/init.py", line 865, in handle
File "logging/init.py", line 1072, in emit
File "logging/init.py", line 1000, in emit
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
--- Logging error ---
Traceback (most recent call last):
File "logging/init.py", line 996, in emit
UnicodeEncodeError: 'ascii' codec can't encode characters in position 96-98: ordinal not in range(128)
Call stack:
File "runankimac", line 12, in
File "aqt/init.py", line 262, in run
File "aqt/init.py", line 347, in _run
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 346, in _onBridgeCmd
File "aqt/editor.py", line 268, in onBridgeCmd
File "anki/hooks.py", line 34, in runFilter
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 61, in onFocusLost
if updateFields(note, field, allFields):
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 469, in updateFields
update_all_Sound_fields(fieldsCopy[currentField], fieldsCopy)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 350, in update_all_Sound_fields
updated1, errors1 = update_Sound_fields(hanzi, dico)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 315, in update_Sound_fields
s = sound(hanzi)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_functions.py", line 410, in sound
return '[sound:%s]' % tts.download_sound(text, options[source])
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 35, in download_sound
tts.save(path)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 247, in save
self.write_to_fp(f)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 204, in write_to_fp
log.debug("payload-%i: %s", idx, payload)
File "logging/init.py", line 1296, in debug
File "logging/init.py", line 1444, in _log
File "logging/init.py", line 1454, in handle
File "logging/init.py", line 1516, in callHandlers
File "logging/init.py", line 865, in handle
File "logging/init.py", line 1072, in emit
File "logging/init.py", line 1000, in emit
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
--- Logging error ---
Traceback (most recent call last):
File "logging/init.py", line 996, in emit
UnicodeEncodeError: 'ascii' codec can't encode characters in position 177-179: ordinal not in range(128)
Call stack:
File "runankimac", line 12, in
File "aqt/init.py", line 262, in run
File "aqt/init.py", line 347, in _run
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 346, in _onBridgeCmd
File "aqt/editor.py", line 268, in onBridgeCmd
File "anki/hooks.py", line 34, in runFilter
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 61, in onFocusLost
if updateFields(note, field, allFields):
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 469, in updateFields
update_all_Sound_fields(fieldsCopy[currentField], fieldsCopy)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 350, in update_all_Sound_fields
updated1, errors1 = update_Sound_fields(hanzi, dico)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 315, in update_Sound_fields
s = sound(hanzi)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_functions.py", line 410, in sound
return '[sound:%s]' % tts.download_sound(text, options[source])
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 35, in download_sound
tts.save(path)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 247, in save
self.write_to_fp(f)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 230, in write_to_fp
log.debug("part-%i written to %s", idx, fp)
File "logging/init.py", line 1296, in debug
File "logging/init.py", line 1444, in _log
File "logging/init.py", line 1454, in handle
File "logging/init.py", line 1516, in callHandlers
File "logging/init.py", line 865, in handle
File "logging/init.py", line 1072, in emit
File "logging/init.py", line 1000, in emit
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
--- Logging error ---
Traceback (most recent call last):
File "logging/init.py", line 996, in emit
UnicodeEncodeError: 'ascii' codec can't encode characters in position 135-137: ordinal not in range(128)
Call stack:
File "runankimac", line 12, in
File "aqt/init.py", line 262, in run
File "aqt/init.py", line 347, in _run
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 346, in _onBridgeCmd
File "aqt/editor.py", line 268, in onBridgeCmd
File "anki/hooks.py", line 34, in runFilter
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 61, in onFocusLost
if updateFields(note, field, allFields):
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 469, in updateFields
update_all_Sound_fields(fieldsCopy[currentField], fieldsCopy)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 350, in update_all_Sound_fields
updated1, errors1 = update_Sound_fields(hanzi, dico)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_behavior.py", line 315, in update_Sound_fields
s = sound(hanzi)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/edit_functions.py", line 410, in sound
return '[sound:%s]' % tts.download_sound(text, options[source])
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 35, in download_sound
tts.save(path)
File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/lib/gTTS/gtts/tts.py", line 248, in save
log.debug("Saved to %s", savefile)
File "logging/init.py", line 1296, in debug
File "logging/init.py", line 1444, in _log
File "logging/init.py", line 1454, in handle
File "logging/init.py", line 1516, in callHandlers
File "logging/init.py", line 865, in handle
File "logging/init.py", line 1072, in emit
File "logging/init.py", line 1000, in emit
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.

Add character decomposition field

I'd love to have character decompositions available as a memory aid for learning Hanzi. Specifically, the cjkvi decomposition list could be integrated into Chinese Support, and then fields named "Decomposition" could be filled in with the decompositions listed therein. For bonus points, map these Unicode codepoints onto images of the components (maybe from Wikipedia?), since a user may not have the fonts to display some of the codepoints for more obscure glyphs, and then insert these images instead, keeping the original Unicode text as alt text.

Alternatively, I could write scripts to add this functionality to my own cards - the Unicode characters are trivial to encode, while the images will take just a bit more work. But others may appreciate having this out of the box.

Filling Pinyin throws

Describe the bug
When trying to fill Pinyin, it throws an error and stops. I assume the error is that you have two functions with the same name fill_pinyin, one in behaviour.py, one in fill.py. They are shadowed in fill.py.

To Reproduce
Steps to reproduce the behavior:

  1. Open a deck
  2. Click on Chinese -> Fill Notes -> Fill Transcription and Color
  3. See error

Expected behavior
It fills Pinyin fields.

Error Message

Error 
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Windows 7
Flags: frz=True ao=True sv=1

Caught exception:
  File "E:\AnkiData\addons21\1128979221\fill.py", line 185, in fill_pinyin
    results += fill_pinyin(hanzi, note_dict)
<class 'TypeError'>: fill_pinyin() takes 0 positional arguments but 2 were given

Specs (please complete the following information):

  • OS: Windows
  • Anki Version: v2.1.5
  • Chinese Support Version: v090

Provide mp3s for syllables

Request description

As a user I still prefer using a library of recorded Chinese sounds instead of machine generated sounds. The advantage of this file format over the computer generated sounds its that the recorded sound is clear and full of nuances. In my opinion this is really important in order to learn a language as Chinese.

This library I'm mentioning is a legacy of a previous Anki plugin Pinyin Toolkit I installed years ago and consists on about 1.630 sounds in MP3 format named with the pinyin system (sound and tone number).

So for the word 例如 I need to manually fill the field 'sound' with the following data: [sound:li4.mp3][sound:ru2.mp3]
Some examples:
举手 corresponds to [sound:ju3.mp3] [sound:shou3.mp3]
** needs to be filled with [sound:.zhong1.mp3] [sound:guo2.mp3]

It would be great if this task could be done automatically. It would be a huge time-saving feature.
Also the option to automatically fill the field on previous cards would be really helpful.

If further descriptions of the task is needed I would be glad to help.

Thank you in advance for your help and time dedicated to this plugin, personally I think it's one of the most useful ones you can use with Anki and has an invaluable resource for thousands of students around the world.

Can't download addon: Error 404

Hi, I cannot download the addon. When entering the code in Anki Desktop I get the error: "Download failed: Error downloading: 404". I tried with other addons and it's working, so it should be a specific problem with this addon.

Also, the addon does not appear on the Ankiweb addon browser (but the page exists, of course, I found it on Google).

Unreliable field filling

Is your feature request related to a problem? Please describe.

I have a deck with a lot of notes, for which I have a simplified and a traditional field each. The relevant fields are named "Hanzi" and "Traditional". This deck started out with Anki 1.x and the Chinese support available in there, from ttempe, and I am using the "Chinese (Advanced)" model for my notes.

When I was adding or editing a node in the old Anki (ie, it can also be an old note which I created long ago), I start out filling the simplified Chinese into the "Hanzi" field. In Anki 1.x and Anki 2.0.x, I was able to then press the Tab key while the cursor was in the Hanzi field, and if I was online, the software would fill most of the other fields as needed. Eg. it would automatically fill the Traditional field, but also Meaning, Ruby, Sound etc.

Oh. I just see that it is probably the same as #53.

Describe the solution you'd like

I would like to see this module to have the same behaviour regarding the auto-filling of fields.

Describe alternatives you've considered

None.

Additional context

From my POV, it looks like this module autofills no field at all, but I've changed the subject of this ticket to highlight those fields which are most important to me.

Failed to load

screen shot 2018-10-09 at 11 31 29

Hi, I installed the addon today and got this message. I'm not sure if it's a problem with my computer or something off with the addon itself. Please let me know if anything else is needed. Thanks!

Coloring when changing tone is wrong

What I do

  • I try to create a new note for 雄伟.
  • I see the field 拼音 is populated with xíongwei.
  • I want to change the tone of the second syllable to wěi.
  • I add the digit 3 at the end: xíongwei3

What happens

  • Field is updated to xiongwěi
  • Field is completely colored as tone 3.

What I would expect

  • Field gets updated to xióngwěi
  • Tone coloring is 2, 3.

Plugin version: 0.9.1
Anki version: 2.1.4

Addon fails to load

Mac Version:
10.13.2 (17C205)

Anki Version:
Version 2.1.0beta13
Qt 5.9.0 PyQt 5.8.2

Error message:
An add-on you installed failed to load. If problems persist, please go to the Tools>Add-ons menu, and disable or delete the add-on.

When loading 'Chinese_Support_Redux':
Traceback (most recent call last):
File "aqt/addons.py", line 58, in loadAddons
File "/Users/michaelfulton/Library/Application Support/Anki2/addons21/839350950/init.py", line 23, in
from . import edit
File "/Users/michaelfulton/Library/Application Support/Anki2/addons21/839350950/edit.py", line 10, in
from .config import chinese_support_config as config
File "/Users/michaelfulton/Library/Application Support/Anki2/addons21/839350950/config.py", line 32, in
chinese_support_config = ConfigManager()
File "/Users/michaelfulton/Library/Application Support/Anki2/addons21/839350950/config.py", line 14, in init
self.options = mw.addonManager.getConfig(name)
AttributeError: 'AnkiQt' object has no attribute 'addonManager'

Enforce traditional or simplified in the main deck

Is your feature request related to a problem? Please describe.
I am studying traditional characters but I sometimes accidentally copy and paste or import sentences with simplified characters in them. I would like to be able to convert these cards to traditional, but even searching for them is not so easy (my quick fix currently: I added a "Traditional" field that I let the plugin fill, and then I sort the cards by the Traditional field: all cards that have a non-empty Traditional field contain simplified characters).

Describe the solution you'd like
Two possible fixes:

  • Simply tag cards based on whether the Hanzi field contains simplified or traditional characters. This way it will be easier to look for problematic cards, but won't help with automatically fixing things.
  • Provide a way to bulk convert the Hanzi and Color fields to Traditional/Simplified. For cases that are ambiguous (multiple traditional characters mapping to the same simplified), give them a tag that makes them easier to find.

Incorrect alignment of ruby, and incorrect tone colors

Describe the bug
I have noticed some problems with zhuyin and then ruby when creating new cards.
The zhuyin is right but the color of the first character is always that of the second. For exemple, ㄐㄧㄔㄤˇ appears all in green.
The second character is often missing, but the whole zhuyin has the colour of the second character.
For instance, for 機場 in the ruby field I get 機 and above ㄐㄧㄔㄤˇ in green.

However, if I add manually a space between characters in the zhuyin field both the zhuyin color and the ruby field will become correct. The pinyin field and the colour field will remain wrong.

I guess the problem has to do with that space?

Specs (please complete the following information):

  • OS: Windows 10
  • Anki Version 2.1.7
  • Chinese Support Version 0.90

Error upon filling fields

Since updating to the latest versions of Anki and chinese-support-redux, when I try to use the "Fill Transcription and Color" feature Anki displays the following error message:

Caught exception:
File "/Users/MyName/Library/Application Support/Anki2/addons21/1128979221/fill.py", line 187, in bulk_fill_pinyin
results += bulk_fill_pinyin(hanzi, note_dict)
<class 'TypeError'>: bulk_fill_pinyin() takes 0 positional arguments but 2 were given

If I try to use the real time fill feature, (i.e. hitting tab after inputting Chinese characters to auto generate other fields) Anki just crashes or freezes.

Specs
Anki 2.1.8 (71e0c880) Python 3.6.7 Qt 5.12.0 PyQt 5.11.3
Platform: Mac 10.14.2
Flags: frz=True ao=True sv=1

  • Chinese Support Version e.g. v0.9.1.-beta

I don't know anything about programming, but please let me know if there's any other information I can provide that will help.

Thank you!

"Meaning" entry disappears when tab filling notes

Describe the bug
When I go through a library of notes and tab fill for the Pinyin, Meaning etc., the Meaning field will be emptied if I don't select a different field before proceeding to the next note to convert.

To Reproduce
Steps to reproduce the behavior:

  1. Select a note to be tab filled.
  2. Select the Chinese character field and hit tab.
  3. See the fields populated, with "Meaning" auto-selected.
  4. Select the next note in the library to tab-fill.
  5. Go back to the previous note and observe that the "Meaning" field is empty.

Expected behavior
The "Meaning" field should remain populated when switching notes.

Specs (please complete the following information):

  • MacOS
  • Anki Version v2.1.8
  • Chinese Support Version v0100 (also seen in previous version)

彩色 field not autofilling, and existing content erased

When I use the current version (0.9.1) of the plugin to write new notes the field 彩色 doesn't get filled. If I edit an existing note that had this field populated, the content of the field even gets cleared.
I'd expect the field to hold the colored version of the characters I entered.

Problems with and after update

Describe the bug
Hi, I tried to update the addon but got an error message. After I updated it using debug mode, I can add new cards but I get an error message every time I try to make changes to an aready existing card.

To Reproduce

Error message while updating:

Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt\addons.py", line 380, in onDelete
  File "aqt\addons.py", line 140, in deleteAddon
  File "site-packages\send2trash\plat_win.py", line 58, in send2trash
<class 'OSError'>: Couldn't perform operation. Error code: 124

I managed to update it by opening Anki in debug mode. Now, when I try to make changes to an already existing card, I get this error:

Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt\webview.py", line 27, in cmd
  File "aqt\webview.py", line 80, in _onCmd
  File "aqt\webview.py", line 333, in _onBridgeCmd
  File "aqt\editor.py", line 268, in onBridgeCmd
  File "anki\hooks.py", line 34, in runFilter
  File "C:\Users\ASUS\AppData\Roaming\Anki2\addons21\1128979221\edit.py", line 74, in onFocusLost
    if updateFields(note, field, allFields):
  File "C:\Users\ASUS\AppData\Roaming\Anki2\addons21\1128979221\behavior.py", line 438, in updateFields
    update_all_Transcription_fields(hanzi, fieldsCopy)
  File "C:\Users\ASUS\AppData\Roaming\Anki2\addons21\1128979221\behavior.py", line 205, in update_all_Transcription_fields
    update_Pinyin_fields(hanzi, d)
  File "C:\Users\ASUS\AppData\Roaming\Anki2\addons21\1128979221\behavior.py", line 143, in update_Pinyin_fields
    format_Pinyin_fields(d)
  File "C:\Users\ASUS\AppData\Roaming\Anki2\addons21\1128979221\behavior.py", line 130, in format_Pinyin_fields
    True
<class 'TypeError'>: accentuate() takes 1 positional argument but 2 were given

Specs (please complete the following information):

  • OS: Windows 10
  • Anki 2.1.5
  • Chinese Support Version v084

Thanks for your help!

Wrong and broken Ruby output with the Hanzi "答案"

Describe the bug
When creating a card with the Hanzi "答案" and using the Pinyin and Ruby generation functionality of this addon, the resulting Ruby output is wrong.

To Reproduce
Steps to reproduce the behavior:

  1. Create card with 答案 as Hanzi field
  2. Select Fill Notes -> Fill Transcription and Color
  3. Resulting Pinyin field is correct: dáàn
  4. Resulting Ruby field is incorrect:

HTML code of the ruby field:

<span class="tone4"><ruby><rt>dáàn</rt></ruby></span>

Expected behavior
The correct HTML would be:

<span class="tone2"><ruby><rt></rt></ruby></span><span class="tone4"><ruby><rt>àn</rt></ruby></span>

Screenshots
bildschirmfoto 2019-02-06 um 19 38 06

Specs (please complete the following information):

  • OS: macOS
  • Anki Version v2.1.8
  • Chinese Support Version v0.10.0

Exception filling missing fields

Mac Version:
10.13.2 (17C205)

Anki 2.1.0beta32 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Mac 10.13.2
Flags: frz=True ao=True

Caught exception:
File "/Users/michaelfulton/Library/Application Support/Anki2/addons21/839350950/fill_missing.py", line 267, in fill_simp_trad
if (has_field(Simplified_fields, note_dict) or has_field(Traditional_fields, note_dict)) and has_field(Hanzi_fields, note_dict):
<class 'NameError'>: name 'Simplified_fields' is not defined

Fields lists undef

Fill incomplete notes -> Fill simplified/traditional

Debug info:
Anki 2.1.0beta24 Python 3.6.3 Qt 5.10.0 PyQt 5.9.2
Platform: Linux
Flags: frz=False ao=True

Caught exception:
  File "/home/nbrr/.local/share/Anki2/addons21/839350950/fill_missing.py", line 267, in fill_simp_trad
    if (has_field(Simplified_fields, note_dict) or has_field(Traditional_fields, note_dict)) and has_field(Hanzi_fields, note_dict):
<class 'NameError'>: name 'Simplified_fields' is not defined

Simplified_fields and similar used to be defined in edit_behavior.py in the older version of the addon that is still on my disc, it is no longer present anywhere in the new version's files.

Attempted to copy the definitions from the old to the new edit_behavior.py file, got this error

Caught exception:
  File "/home/nbrr/.local/share/Anki2/addons21/839350950/fill_missing.py", line 290, in fill_simp_trad
    note.flush()
  File "/usr/share/anki/anki/notes.py", line 51, in flush
    fields = self.joinedFields()
  File "/usr/share/anki/anki/notes.py", line 69, in joinedFields
    return joinFields(self.fields)
  File "/usr/share/anki/anki/utils.py", line 256, in joinFields
    return "\x1f".join(list)
<class 'TypeError'>: sequence item 7: expected str instance, NoneType found

Better Cantonese tone colours

Currently, the add-on simply reuses the Mandarin tone colours, which is incorrect because:

  1. the contours are completely different between, e.g., Mandarin and Cantonese 3rd tones, and
  2. nothing above 5th tone is actually assigned a colour

Cantonese needs at least 6 distinct tone colours (ideally 7, because high falling tone is not extinct yet).

bulk_fill_hanzi: throws exception if contents of Hanzi field not present in dictionary

I was filling in some new cards and received the following error. Not sure what card it fails on:

Specs (please complete the following information):

  • OS: [e.g. Windows, iOS, Ubuntu]: Mac 10.14.2
  • Anki Version [e.g. v2.0.52, v2.1.5]: 2.1.7
  • Chinese Support Version [e.g. v0.5.3-beta] v0.9.1

Additional context

Anki 2.1.7 (a6c34fd7) Python 3.6.7 Qt 5.12.0 PyQt 5.11.3
Platform: Mac 10.14.2
Flags: frz=True ao=True sv=1

Caught exception:
  File "/Users/rmi1/Library/Application Support/Anki2/addons21/1128979221/fill.py", line 385, in bulk_fill_hanzi
    note.flush()
  File "/Users/rmi1/Library/Application Support/Anki2/addons21/877182321/enhancedMain.py", line 694, in noteFlush
    oldNoteFluh(note,mod=mod)
  File "anki/notes.py", line 51, in flush
  File "anki/notes.py", line 69, in joinedFields
  File "anki/utils.py", line 265, in joinFields
<class 'TypeError'>: sequence item 6: expected str instance, NoneType found

Removing field names will break users' cards

I have seen the commit 6640223 where multiple possible field names in notes have been removed. I'm affected myself, as the plugin will not be able to fill all my fields (without renaming them) as soon as I install the commit.

I'm wondering whether there is an important reason to remove possible field names from the plugin. Even if you imagine better names, I think it wouldn't hurt supporting the old ones as well. Removing support for field names will break cards of some of the existing users of the plugin. I think this should only be done if there are good reasons for doing so. Most users probably won't be able to easily find the reason for that, let alone find out how to fix it. It also makes migration from other Anki chinese plugins (e.g. when upgrading from Anki 2.0 to 2.1) a lot harder, when there is no common intersection of field names.

'NoneType' object has no attribute 'group'

Describe the bug
Error occurs when editing an existing card or adding a new card using Chinese Support Redux add-on.

To Reproduce
Steps to reproduce the behavior:

  1. Edit an existing card
    or
  2. Add a new card

Expected behavior
Fields are populated as expected

Screenshots

Error 
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Mac 10.14.1
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt/webview.py", line 27, in cmd
  File "aqt/webview.py", line 80, in _onCmd
  File "aqt/webview.py", line 333, in _onBridgeCmd
  File "aqt/editor.py", line 268, in onBridgeCmd
  File "anki/hooks.py", line 34, in runFilter
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 74, in onFocusLost
    if updateFields(note, field, allFields):
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/behavior.py", line 469, in updateFields
    update_all_Sound_fields(hanzi, fieldsCopy)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/behavior.py", line 350, in update_all_Sound_fields
    updated1, errors1 = update_Sound_fields(hanzi, d)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/behavior.py", line 315, in update_Sound_fields
    s = sound(hanzi)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/sound.py", line 54, in sound
    return '[sound:%s]' % download_sound(hanzi, options[source])
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 35, in download_sound
    tts.save(path)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts/tts.py", line 247, in save
    self.write_to_fp(f)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts/tts.py", line 187, in write_to_fp
    part_tk = self.token.calculate_token(part)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts_token/gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts_token/gtts_token.py", line 57, in _get_token_key
    tkk_expr = re.search(".*?(TKK=.*?;)W.*?", line).group(1)
<class 'AttributeError'>: 'NoneType' object has no attribute 'group'

**Specs (please complete the following information):**
 - OS: [e.g. Windows, iOS, Ubuntu]
 - Anki Version [e.g. v2.0.52, v2.1.5]
- Chinese Support Version [e.g. v0.5.3-beta]

Additional context
Add any other context about the problem here.

Characters with odd alternates have incorrect Pinyin tones / transcriptions

Synopsis
Characters with rare or infrequent alternates will use these for the pinyin and transcriptions.

Steps to reproduce
Put 草 in the field "Hanzi"
Press TAB
Observed behavior
The pinyin is filled with cao4
The meaning lists all of the definitions
Expected behavior
The pinyin is cao3.

If you check the dictionary, it lists cao3 as the more common pronounciation:
https://www.mdbg.net/chinese/dictionary?page=worddict&wdrst=0&wdqb=%E8%8D%89

I noticed the unihan dictionary has a field kFrequency mentioned in the comments. Is it as simple as changing the query to order results by this field?

Fails to Create new Notes

Describe the bug
When creating a new note, the note fails to pass the creation and formatting of fields. This can be solved locally by removing the extra 'True' argument being passed to the 'accentuate' function. This function is called in both format Pinyin and format Pinyin TW.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new note with a pinyin field
  2. Enter Chinese and click outside the field
  3. Observe the crash

Expected behavior
Notes should able to be created without error.

Screenshots
image

Classifier not filled on partially filled notes

Drop-down menu "Fill Notes" > "Fill Translation" doesn't populate Mean Word/Classifier fields. I tested it on a deck with definitions already filled in. If I manually press TAB in the "Hanzi" field on such cards that I've previously filled in using that menu, the mean word is filled in.

Specs (please complete the following information):

  • OS: [e.g. Windows, iOS, Ubuntu]: macOS Mojave 10.14.1
  • Anki Version [e.g. v2.0.52, v2.1.5] v2.1.6-test
  • Chinese Support Version [e.g. v0.5.3-beta] v0.8.2

Help a Python beginner

I've been experimenting with the code for this add-on a bit but I'm running into an issue where if I try to run a file in a console that contains a relative import statement (e.g. "from .hanzi import has_hanzi") I get a ModuleNotFoundError.

Anyone able to help me out? I'd love to participate more in the development of this add-on, but this error is making it hard to do any kind of testing.

Baidu Speech Engine returning empty files

I created some new cards yesterday using the same process I've been using for months, but now each of the sound files either does not play or are just 0-second files, or they are silent files. Each generated file, regardless of the length of the sentence are just 132 bytes.

Changing the TTS engine in Anki->Tools->Chinese Support->Set speech egnine->Google TTS works fine but Baidu does produce superior pronunciation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.