• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

hchunhui/librime-lua: Extending RIME with Lua scripts

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

hchunhui/librime-lua

开源软件地址(OpenSource Url):

https://github.com/hchunhui/librime-lua

开源编程语言(OpenSource Language):

C++ 79.8%

开源软件介绍(OpenSource Introduction):

librime-lua: Extending RIME with Lua scripts

Features

  • Supports extending RIME processors, segmentors, translators and filters
  • Provides high-level programming model for translators and filters
  • Loaded dynamically as a librime plugin

Usage

  1. Create PATH_TO_RIME_USER_DATA_DIR/rime.lua:

    function date_translator(input, seg)
       if (input == "date") then
          --- Candidate(type, start, end, text, comment)
          yield(Candidate("date", seg.start, seg._end, os.date("%Y年%m月%d日"), " 日期"))
       end
    end
    
    function single_char_first_filter(input)
       local l = {}
       for cand in input:iter() do
          if (utf8.len(cand.text) == 1) then
             yield(cand)
          else
             table.insert(l, cand)
          end
       end
       for i, cand in ipairs(l) do
          yield(cand)
       end
    end
    

    More sample: rime.lua

    Documentation: TODO

  2. Reference Lua functions in your schema:

    engine:
      ...
      translators:
        ...
        - lua_translator@date_translator
        - lua_translator@other_lua_function1
        ...
      filters:
        ...
        - lua_filter@single_char_first_filter
        - lua_filter@other_lua_function2
    
  3. Deploy & try

Build

Build dependencies

  • librime >= 1.5.0
  • LuaJIT 2 / Lua 5.1 / Lua 5.2 / Lua 5.3 / Lua 5.4

Instructions

  1. Prepare source code

    Move the source to the plugins directory of librime:

    mv librime-lua $PATH_TO_RIME_SOURCE/plugins/lua
    

    Or you can use the install-plugins.sh script to automatically fetch librime-lua:

    cd $PATH_TO_RIME_SOURCE
    bash install-plugins.sh hchunhui/librime-lua
    
  2. Install dependencies

    Install development files of Lua:

    # For Debian/Ubuntu:
    sudo apt install liblua5.3-dev   # or libluajit-5.1-dev
    

    The build system will use pkg-config to search Lua.

    The build system also supports building Lua from source in the thirdparty directory. The thirdparty directory can be downloaded using the following commands:

    cd $PATH_TO_RIME_SOURCE/plugins/lua
    git clone https://github.com/hchunhui/librime-lua.git -b thirdparty --depth=1 thirdparty
    
  3. Build

    Follow the librime's build instructions.

    # On Linux, merged build
    make merged-plugins
    sudo make install
    

    For more information on RIME plugins, see here.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap