Last active
December 13, 2023 08:47
-
-
Save luochen1990/cd78de31c2b2c91c7020ba63cefd5698 to your computer and use it in GitHub Desktop.
在输入法(Input Method) 中通过自定义短语输入数学符号, 该脚本用以生成相关配置文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| phrases = ''' | |
| ; 希腊字母: 参考 https://en.wikipedia.org/wiki/Greek_alphabet | |
| Alpha,1=Α | |
| alpha,1=α | |
| Nu,9=Ν | |
| nu,9=ν | |
| Beta,1=Β | |
| beta,1=β | |
| Xi,9=Ξ | |
| xi,9=ξ | |
| Gamma,1=Γ | |
| gamma,1=γ | |
| Omicron,1=Ο | |
| omicron,1=ο | |
| Delta,1=Δ | |
| delta,1=δ | |
| Pi,9=Π | |
| pi,9=π | |
| Epsilon,1=Ε | |
| epsilon,1=ε | |
| Rho,9=Ρ | |
| rho,9=ρ | |
| Zeta,1=Ζ | |
| zeta,1=ζ | |
| Sigma,1=Σ | |
| sigma,1=σ | |
| Eta,9=Η | |
| eta,9=η | |
| Tau,9=Τ | |
| tau,9=τ | |
| Theta,1=Θ | |
| theta,1=θ | |
| Upsilon,1=Υ | |
| upsilon,1=υ | |
| Iota,9=Ι | |
| iota,9=ι | |
| Phi,9=Φ | |
| phi,9=φ | |
| Kappa,1=Κ | |
| kappa,1=κ | |
| Chi,9=Χ | |
| chi,9=χ | |
| Lambda,1=Λ | |
| lambda,1=λ | |
| Psi,9=Ψ | |
| psi,9=ψ | |
| Mu,9=Μ | |
| mu,9=μ | |
| Omega,1=Ω | |
| omega,1=ω | |
| ; 数学: 参考 https://en.wikipedia.org/wiki/List_of_mathematical_symbols | |
| inf,2=∞ | |
| infinity,2=∞ | |
| le,2=≤ | |
| ge,2=≥ | |
| eq,2== | |
| neq,2=≠ | |
| mul,2=× | |
| times,2=× | |
| div,2=÷ | |
| xor,2=⊕ | |
| empty,2=∅ | |
| belong,2=∈ | |
| nbelong,2=∉ | |
| subset,2=⊆ | |
| subset,3=⊂ | |
| superset,2=⊇ | |
| superset,3=⊃ | |
| union,2=∪ | |
| intersection,2=∩ | |
| compose,2=o | |
| Nat,1=ℕ | |
| Int,1=ℤ | |
| Rat,1=ℚ | |
| Real,1=ℝ | |
| Complex,1=ℂ | |
| nat,1=ℕ | |
| int,1=ℤ | |
| rat,1=ℚ | |
| real,1=ℝ | |
| complex,1=ℂ | |
| integration,1=∫ | |
| gradient,1=∇ | |
| partiald,1=∂ | |
| propto,1=∝ | |
| proportional,1=∝ | |
| log,1=㏒ | |
| ln,3=㏑ | |
| ; 逻辑: 参考 https://en.wikipedia.org/wiki/List_of_logic_symbols | |
| because,1=∵ | |
| therefore,1=∴ | |
| qed,1=■ | |
| def,2=≔ | |
| equals,2=∷ | |
| bottom,2=⊥ | |
| top,2=⊤ | |
| and,2=∧ | |
| and,3=& | |
| or,2=∨ | |
| or,3=ǀǀ | |
| not,2=¬ | |
| neg,2=¬ | |
| imply,1=→ | |
| implies,1=→ | |
| imply,2=⇒ | |
| implies,2=⇒ | |
| equiv,1=≡ | |
| equiv,2=⇔ | |
| equiv,3=↔ | |
| iff,1=↔ | |
| infer,2=⊢ | |
| infers,2=⊢ | |
| provable,2=⊢ | |
| entails,2=⊧ | |
| forall,1=∀ | |
| exists,1=∃ | |
| ; 其它 | |
| dot,2=• | |
| right,2=→ | |
| left,2=← | |
| up,2=↑ | |
| down,2=↓ | |
| diamond,2=◇ | |
| degree,2=° | |
| no,2=№ | |
| chapter,2=§ | |
| male,2=♂ | |
| female,2=♀ | |
| ''' | |
| def sogou_phrases() -> str: | |
| head = ''' | |
| ; 搜狗输入法: 设置 -> 高级 -> 自定义短语设置 -> 直接编辑配置文件 | |
| ; 配置文件格式: <按键序列> "逗号" <位置> "等于号" <目标字符序列> | |
| rq,1=#$year-$month_mm-$day_dd | |
| today,2=#$year-$month_mm-$day_dd | |
| sj,1=#$year-$month_mm-$day_dd $fullhour:$minute:$second | |
| now,2=#$year-$month_mm-$day_dd $fullhour:$minute:$second | |
| ''' | |
| return head + phrases | |
| def rime_phrases() -> str: | |
| import re | |
| head = ''' | |
| # Rime 的 custom_phrase.txt 配置 | |
| ''' | |
| body = re.sub('^;', '#', re.sub(r'(\w*),([1-9])\=(.*)', r'\3\t\1\t\2', phrases), flags = re.MULTILINE) | |
| return head + body | |
| def mspy_phrases() -> str: | |
| import re | |
| head = ''' | |
| 微软拼音因为用二进制的配置文件, 所以暂时不支持生成配置并导入 | |
| ''' | |
| body = re.replace('', phrases) | |
| return head + body | |
| if __name__ == '__main__': | |
| print(sogou_phrases()) | |
| print(rime_phrases()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment