V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
sofish
V2EX  ›  Node.js

发个开源项目:han

  •  
  •   sofish · Oct 5, 2012 · 7079 views
    This topic created in 4964 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
        1
    liaa  
       Oct 5, 2012
    http://translate.google.com.tw/translate_tts?ie=UTF-8&q="你们好么,弯弯的河水从天上来."&tl=zh-CN&prev=input

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

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