Pleco-to-Anki - Tone Marks vs Numbers

284 views
Skip to first unread message

Adin Ermie

unread,
Apr 7, 2018, 10:14:39 PM4/7/18
to public...@ankidroid.org

Hello, AnkiDroid Support/Forum,

I prefer to use your software for flashcard learning, but I use Pleco to create my own custom categories for words I want to learn.


I am aware that we are able to export our cards from Pleco and import them into a custom deck in Anki, however, what I am really looking for is an add-on or feature to convert the PinYin tone numbers (which is how it is exported from Pleco) into PinYin tone marks. 


Is there an add-on, or feature that would achieve this?


Thanks. 


Sincerely,
Adin Ermie

Adin Ermie
MVP: Cloud and Datacenter Management
MCSE: Cloud Platform and Infrastructure
Message has been deleted
Message has been deleted

Mark Carter

unread,
Apr 8, 2018, 1:35:13 AM4/8/18
to AnkiDroid
Please take a look at the Hanping Chinese HSK 1-6 Shared Deck to see how tone-numbered pinyin can be displayed as tone-marked (using Javascript).

(note: for some reason, when I include links, my reply here gets auto-deleted).

Mike Hardy

unread,
Apr 8, 2018, 2:53:57 PM4/8/18
to AnkiDroid

Admin noye: Not sure why it is deleting replies? The list gets plenty of spam so it is moderated, but please know I have been approving the posts and your contributions are valued! They were flagged as spam for some reason but I did approve them. Perhaps your originating systems have an abuser on them at the moment, affecting how Google scores the messages. Either way if they keep looking legitimate I'll keep passing them personally..

On Saturday, April 7, 2018 at 9:14:39 PM UTC-5, Adin Ermie wrote:
> Hello, AnkiDroid Support/Forum,
>
> I prefer to use your software for flashcard learning, but I use Pleco to create my own custom categories for words I want to learn.
>
>
>
>
>
> I am aware that we are able to export our cards from Pleco and import them into a custom deck in Anki, however, what I am really looking for is an add-on or feature to convert the PinYin tone numbers (which is how it
> is exported from Pleco) into PinYin tone marks. 
>
>
>
>
>
> Is there an add-on, or feature that would achieve this?
>
>
>
>
>
> Thanks. 
>
>
>
>
>
>
>
>
> Sincerely,
>
> Adin Ermie
>
>
>

aer...@gmail.com

unread,
Apr 12, 2018, 7:59:36 AM4/12/18
to AnkiDroid

Thanks Mark.
However, I'm not a developer. What I am looking for if there is a way (via an add-on, conversion process, etc.) that can take the export from Pleco and convert the tone numbers into tone marks inside the AnkiDeck. 

I looked at the Hanping Chinese HSK (1-6) deck you referenced, and I see that the description says it can display marks vs tones, but I don't see how I can use that in my case. 

Sorry if I'm not understanding clearly.

Mark Carter

unread,
Apr 12, 2018, 11:01:34 AM4/12/18
to AnkiDroid
You could try installing Hanping Chinese Dictionary Pro (disclaimer: I'm the developer) and importing the file you exported from your dictionary app. Then you can export to AnkiDroid (from Hanping).

This is probably only a solution if you want to do a one-off export. If you want to do regular exports from your dictionary app to AnkiDroid then you would have to ask them.

Note: Hanping Chinese Pro is a paid app (costs a few dollars) but there is a 30-day refund policy (for whatever reason), so you are welcome to take advantage of that. 

For more support, you're welcome to contact us directly (the email address can be found in the link above), since this is not so much about AnkiDroid.

luc wastiaux

unread,
May 2, 2018, 8:04:32 AM5/2/18
to AnkiDroid
How familiar are you with programming ? you can convert the pinyin numbers into tone marks quite easily with python code.

Here's some python code which does this for Cantonese/Yale:

tone_map_a = {1: 'ā',
             
2: 'á',
             
3: 'â',
             
4: 'à',
             
5: 'ǎ',
             
6: 'a'}

tone_map_i
= {1: 'ī',
             
2: 'í',
             
3: 'î',
             
4: 'ì',
             
5: 'ǐ',
             
6: 'i'}

tone_map_o
= {1: 'ō',
             
2: 'ó',
             
3: 'ô',
             
4: 'ò',
             
5: 'ǒ',
             
6: 'o'}

tone_map_u
= {1: 'ū',
             
2: 'ú',
             
3: 'û',
             
4: 'ù',
             
5: 'ǔ',
             
6: 'u'}

def yale_tone_character(char, tone):
   
if char == 'e':
       
return tone_map_e[tone]
   
if char == 'a':
       
return tone_map_a[tone]
   
if char == 'i':
       
return tone_map_i[tone]
   
if char == 'o':
       
return tone_map_o[tone]
   
if char == 'u':
       
return tone_map_u[tone]
   
raise Exception("unknown char %c"%char)
   

def yale_tone_marks_syllable(syllable):
   
# extract tone
    m
= re.search("([a-z]+)([0-9])", syllable)
   
if m == None:
       
raise Exception("couldn't parse syllable [%s]" % syllable)
    sound
= m.group(1)
    tone
= int(m.group(2))
       
   
# find the first vowel in the sound
    index
=0
   
for char in sound:
       
if char in ('a','e','i','o','u'):
           
break
        index
+= 1
   
   
if index >= len(sound):
       
return sound
   
   
# the index of the first vowel is in "index"
    sound_characters
= list(sound)
    sound_characters
[index] = yale_tone_character(sound_characters[index], tone)
    updated_sound
= "".join(sound_characters)
   
   
return updated_sound


def yale_tone_marks(input):
   
try:
        syllables
= input.split(" ")
        syllables_modified
= [yale_tone_marks_syllable(s) for s in syllables]
       
return " ".join(syllables_modified)
   
except Exception as e:
       
print("Couldn't convert yale [%s]: %s"%(input, e))
       
return ""
Reply all
Reply to author
Forward
0 new messages