How to Enable Mixed Chinese and Punctuation Input for rime Input Method

Recently, I needed to solve a requirement: enable mixed input of Chinese characters and punctuation marks for the Rime input method.

For example, I want to input a section from a classic Chinese medicine text, 病人胸满,唇痿舌青.

My vocabulary database is composed of phrases split by commas, where 病人胸满 and 唇痿舌青 are two separate words. When I input bing ren xiong man chun wei she qing, the output is 病人胸满唇痿舌青.

I hope to be able to input a comma after bing ren xiong man, then continue inputting chun wei she qing, so that the result would be 病人胸满,唇痿舌青, instead of the input being terminated immediately after entering the comma.

In other words, how to achieve mixed input of Chinese characters and punctuation marks?

Solution

Modify the *.custom.yaml like this, enabling only what you need:

patch:
  speller:
    # If you don't want certain punctuation marks to be directly output, you can add them to the alphabet, or edit punctuation mappings to consist of two or more characters
    alphabet: zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA,

References:

what’s more

There is a big move coming later

Main Text

I know this one; I implemented English punctuation to participate in lexical association without affecting the actual candidates:

Image

Image

This is done using the memory API and does not affect the actual symbols.

Code reference:

https://f.mirtle.cn/librime-lua/parrot_translator.lua

    if inp:find( '%p' ) and not inp:find('^%p') then yield_entry( env.mem, seg, inp ) end
    if inp:find( '^.+' .. env.space_pattern ) then yield_entry( env.mem, seg, input, match ) end

Source