爱意满满的作品展示区。
Elethom

也寫了一個給通訊錄添加注音的工具,支援中日韓語言選擇,支援多音字選擇,提供兩種格式設定

  •  2
     
  •   Elethom ·
    Elethom · Feb 2, 2016 · 3878 views
    This topic created in 3934 days ago, the information mentioned may be changed or developed.

    在 GitHub 上查看

    嘛。懶得寫介紹,直接把 readme 拖過來了。目前 Homebrew 還沒 merge ,請自行編譯安裝。在 Mac 上運行完了就可以直接通過 iCloud 同步到所有設備上去了。

    E 一個畫圖喵一年多沒寫代碼了,就這些,將就著用吧。

    很慚愧,做了一點微小的貢獻,謝謝大家。


    功能:

    • 簡體中文(多音字)
    • 繁體中文(多音字)
    • 日本語
    • 韓語
    • 注音符號
    • 過濾空格

    建議運行的時候加上 -i 參數把所有的注音都重新設定,如果聯繫人只有中國人的話,可以加上 -j 和 -k 忽略掉日本語和韓語。

    關於實現方式:

    • 語言初次判斷用的 Core Foundation 的 tokenizer ,名字比較難判斷語言,所以後面還加了二次對比;
    • 簡繁體中文和韓語用的都是很簡單的 CFStringTransform ,可以參考 NSHipster 的文章;
    • 日語因為和中文有很多重合部分,用 CFStringTransform 無法處理, CFStringTransform 本身也沒提供 Kanji -> Romaji 的轉換選項,所以還是直接用了 Core Foundation 的 tokenizer 提取了 Latin transcription ;
    • 過濾 accents and diacritcs 用的也是 CFStringTransform ;
    • 去空格直接手拼 NSString ;
    • API 用了 ABAddressBook ,如果誰有興趣也可以拿 Contacts 重新實現一遍。

    ContactsUtil-PhoneticName

    General

    Add phonetic names to contacts. Supports all CJK characters and multiple formats.

    Install

    With Homebrew:

    $ brew install contacts-phonetic
    

    Compile on your own:

    $ git clone https://github.com/Elethom/ContactsUtil-PhoneticName.git
    $ cd ContactsUtil-PhoneticName
    $ make install
    

    Usage

    -i, --ignore-existing
        Ignore existing phonetic names. Use of this option will update all person entries in the address book.
    
    -m, --keep-marks
        Keep accents and diacritcs.
    
    -s, --keep-spaces
        Keep spaces between characters.
    
    -c, --ignore-chinese
        Ignore Chinese. (Will use Japanese Romaji if both are possible.)
    
    -j, --ignore-japanese
        Ignore Japanese. (Will use Chinese Pinyin if both are possible.)
    
    -k, --ignore-korean
        Ignore Korean.
    

    Example:

    $ contacts-phonetic
    --------------------
    Alice Alstromeria
    --------------------
    Dieter Rams
    --------------------
    Elethom Alstromeria
    --------------------
    ことり 椎名
    椎名 1. Japanese (shiina); 2. Chinese (chuí míng). Select: Select: 1
    Kotori Shiina
    --------------------
    直人 深澤
    直人 1. Japanese (naoto); 2. Chinese (zhí rén). Select: Select: 1
    深澤 1. Japanese (fukazawa); 2. Chinese (shēn zé). Select: Select: 1
    Naoto Fukazawa
    --------------------
    研哉 原
    研哉 1. Japanese (ken'ya); 2. Chinese (yán zāi). Select: Select: 1
    原 1. Japanese (hara); 2. Chinese (yuán). Select: Select: 1
    Ken'ya Hara
    --------------------
    

    License

    This code is distributed under the terms and conditions of the MIT license.

    Donate

    You can support me by:

    :-)

    Contact

    26 replies  •  2016-02-06 22:59:08 +08:00
    wbsdty331
    wbsdty331
    Feb 2, 2016
    1
    强行膜
    Elethom
    Elethom
    OP
    Feb 2, 2016
    3
    @jjgod
    Fixed.
    49
    49
    Feb 2, 2016 via iPhone
    4
    一个人的命运啊,当然要靠自我奋斗。但也要考虑历史的进程。
    你写的这个工具啊, excited !刚好要用到!
    xhacker
    xhacker
    Feb 3, 2016
    5
    `--ignore-existing` 和 `--ignore-(chinese|japanese|korean)` 似乎语义是反的?
    xhacker
    xhacker
    Feb 3, 2016
    6
    另外:

    潇袆 李
    Xiāohuī Lǐ

    这是个 bug 么……
    Elethom
    Elethom
    OP
    Feb 3, 2016 via iPhone
    7
    @xhacker

    --ignore-existing 是不再對已經標註過的聯繫人重新注音。

    查了一下這個條目,讀音並沒有標註錯。中文讀音來自 ICU ,多音字抓取自漢語字典。應該不會有錯。
    xhacker
    xhacker
    Feb 3, 2016
    8
    @Elethom: 呃居然是我写错字了……了解了。
    xhacker
    xhacker
    Feb 3, 2016
    9
    加 -k 参数就不干活了。似乎 https://github.com/Elethom/ContactsUtil-PhoneticName/blob/master/src/main.m#L107-L109 这里有点问题?
    ppwangs
    ppwangs
    Feb 3, 2016
    10
    现在的孩子们连汉字都不认得了,需要注音了吗?
    Elethom
    Elethom
    OP
    Feb 3, 2016 via iPhone
    11
    @xhacker
    暈。對不起,那一段應該向下移動一行。稍後起來改。 _(:з」∠)_
    imn1
    imn1
    Feb 3, 2016
    12
    注音还是拼音?大陆这边懂注音的恐怕不多
    Elethom
    Elethom
    OP
    Feb 3, 2016 via iPhone
    13
    @imn1
    這個也支援其它語言所以用「拼音」似乎不太合適。
    Elethom
    Elethom
    OP
    Feb 3, 2016
    14
    @xhacker
    Repo 更新了。 Homebrew 待 merge 。
    https://github.com/Homebrew/homebrew/pull/48749
    Elethom
    Elethom
    OP
    Feb 3, 2016
    15
    @xhacker

    $ brew audit contacts-phonetic --online
    contacts-phonetic:
    * GitHub repository not notable enough (<10 forks, <10 watchers and <20 stars)
    * GitHub repository too new (<30 days old)

    Error: 2 problems in 1 formula

    CI 失敗。 😭
    xhacker
    xhacker
    Feb 3, 2016
    16
    @xhacker: 「 Ignore existing phonetic names. Use of this option will update all person entries in the address book.」你这两句话似乎是自相矛盾的?
    Elethom
    Elethom
    OP
    Feb 3, 2016
    17
    @xhacker
    並沒有呀。忽略掉已經存在的 phonetic names 不就是不管原來有沒有全部都更新嗎。默認的話是會檢查是否存在的,存在即跳過。
    zander
    zander
    Feb 3, 2016
    18
    Absolutely great job.
    几天前我还在那个帖子里提到日文名字的发音问题, LZ 行动力挺高的。

    不过 CFStringTokenizer 对日文支持不是很好,例如 相哲 soutetsu 就会认成 aiakira 。不过我也没找到更好的方法,就把项目搁置了。反正我添加联系人的机会也不多。
    won
    won
    Feb 3, 2016 via Android
    19
    小爱桑好厉害哦
    Elethom
    Elethom
    OP
    Feb 3, 2016
    20
    @zander
    嗯。 Core Foundation 的 tokenizer 也不能處理帶音調的日文,會直接展開。
    Elethom
    Elethom
    OP
    Feb 3, 2016
    21
    @won
    f7u12 請叫「愛醬」。
    xhacker
    xhacker
    Feb 3, 2016
    22
    @Elethom: 哦哦,这个意思……「 Ignore existing phonetic names 」我第一反应是忽略已经存在的名字不处理……
    Elethom
    Elethom
    OP
    Feb 3, 2016
    23
    @xhacker
    怕前一句說不明白就在後面加了這句⋯⋯ 😭
    n6DD1A640
    n6DD1A640
    Feb 3, 2016
    24
    @Elethom 直接删掉这句就行了,只要后面一句。。。参数改为 -a 。。
    blueset
    blueset
    Feb 6, 2016
    25
    提个建议:
    关于 -i 的说明,可以改成 Overwrite existing phonetic names.

    顺便问一下,这个工具可以用于 Google Contact 吗?
    Elethom
    Elethom
    OP
    Feb 6, 2016
    26
    @blueset
    未測試。在 Contacts app 中顯示出來的應該都可以。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4851 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 02:45 · PVG 10:45 · LAX 18:45 · JFK 21:45
    ♥ Do have faith in what you're doing.