sofish
V2EX  ›  Node.js

发个开源项目:han

  •  
  •   sofish · Oct 5, 2012 · 7676 views
    This topic created in 5159 days ago, the information mentioned may be changed or developed.
    源代码: https://github.com/sofish/han

    # 初衷与效果

    初衷是想用在 url 上,当然结果也是,比如这样一句话,希望用在 url 中,可以这样来:

    var han require('han')
    han.letter('要实现 Speaker Deck 那种中文转拼音的', '-')
    //输出 yao-shi-xian-speaker-deck-na-zhong-zhong-wen-zhuan-pin-yin-de

    有乱码也没关系,可以看这个 testcase https://github.com/sofish/han#translating-messy-code

    # 安装和使用

    安装:npm install han
    使用:见 repo 的 readme

    # 开源协议

    像我其他开源代码一样,基于 MIT 开源,也就是说你可以随便用,随便改。

    欢迎各种 issue 和 pull request,哈哈。
    14 replies  •  1970-01-01 08:00:00 +08:00
    liaa
    liaa
    Oct 5, 2012
    1
    http://translate.google.com.tw/translate_tts?ie=UTF-8&q="你们好么,弯弯的河水从天上来."&tl=zh-CN&prev=input

    如果加上发音就更好了,可以弄些有意思和好玩的东西(比如帮学中文的人做个取词阅读的bookmarklet)。 /*用想要发音的词替换掉双引号里面的文字*/.
    liaa
    liaa
    Oct 5, 2012
    2
    好奇怪,竟然不出声了...
    translate.google.com.tw/translate_tts?ie=UTF-8&q=你好,弯弯的河水从天上来&tl=zh-CN&prev=input 这个复制到网址栏能发声的呀
    NemoAlex
    NemoAlex
    Oct 5, 2012
    3
    最近有个改进敝厂产品的想法,正好可以用到这个
    sofish
    sofish
    OP
    Oct 5, 2012
    4
    @liaa 初衷是 url,目前我自己的项目要用,所以实现了一个。

    其实 lib/index.js 中还保留一个 pinyin 的功能,转换出来的是纯拼音,不过看起来不是特别有用,目前保留着,有空实现出来(如果有人愿意实现,我提供一下思路,哈哈哈)。
    sofish
    sofish
    OP
    Oct 5, 2012
    5
    @NemoAlex 我也在用,目前没出现什么问题,用了有问题随时找我
    reorx
    reorx
    Oct 5, 2012
    6
    想起来以前自己做过一个 Python + MongoDB 的,原理是把 unicode 和拼音的对应码存到 MongoDB 里面,需要转化的时候从数据库进行查询,因为不需要从文件中读取,且不把整个表全部放到内存中,所以效率不错。推荐利用数据库进行查询的做法。
    benzhe
    benzhe
    Oct 5, 2012
    7
    真巧,国庆回家时在火车上也写了个叫 hansort 的 kissy 工具,只不过它是用来按拼音/笔画排序的
    Sync
    Sync
    Oct 6, 2012
    8
    对seo应该好处多多吧
    ine181x
    ine181x
    Oct 7, 2012
    9
    Nice 其实我更感兴趣你的 Mandarin.json 是哪里找来的?
    sofish
    sofish
    OP
    Oct 7, 2012
    10
    @ine181x json 注释第一行不就是?
    luciferlu
    luciferlu
    Oct 8, 2012
    11
    如何处理多因子的?比如"还有"和"还给"
    luciferlu
    luciferlu
    Oct 8, 2012
    12
    写错了,多音字,比如"还有"和"还给"
    s173779714
    s173779714
    Oct 8, 2012
    13
    hehe
    ghyghoo8
    ghyghoo8
    Oct 8, 2012
    14
    两万多个汉字,工作量啊~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4321 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 08:07 · PVG 16:07 · LAX 00:07 · JFK 03:07
    ♥ Do have faith in what you're doing.