Skip to content

dongyuwei/hallelujahIM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

368 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Platform:macOS Platform:windows Platform:linux github actions License: GPL v3 GitHub downloads

中文版 | English Version

哈利路亚英文输入法

哈利路亚英文输入法 是 Mac(10.9+ OSX)及 Windows 平台上一款智能英语输入法。其特性如下:

  1. 离线词库较大较全,词频精准。参见 Google's 1/3 million most frequent English words.
  2. 内置拼写校正功能。不用担心拼写错误,能记住大概字形、发音,本输入法就会自动显示最可能的候选词。
  3. 具备 Text-Expander 功能(可在偏好设置Web页面 http://localhost:62718 中添加/删除)。 用户可以定义自己常用的词组,比如 {"yem":"you expand me"},那么当输入 yem 时会显示 you expand me
  4. 即时翻译功能(显示音标,及英文单词的中文释义)。
  5. 支持按拼音来输出对应英文。如输入suanfa,输入法会候选词中会显示 algorithm
  6. 支持按英文单词的模糊音来输入。 如输入 cerrage 或者 kerrage 可以得到 courage 候选词,也可以输入 aosome 或者 ausome 来得到 awesome 候选词。
  7. 按键盘右侧shift 键可以在智能英语输入模式与传统英语输入模式间切换。
  8. 选词方式:数字键 1~9 及 Enter 回车键和 Space 空格键均可选词提交。Space 空格键选词默认会自动附加一个空格在单词后面,可以在配置页面关闭自动附加空格功能。Enter 回车键选词则不会附加空格。
  9. 上下文预测(Next-Word Prediction):基于 Google Books Ngram Corpus (2010-2019) 英语语料库的 n-gram 频率数据,在用户输入时根据前文预测下一个单词。例如输入"i do not"后,输入法会优先推荐"know"、"think"、"want"等高频后续词。目前默认关闭这个功能,需要在输入法配置中手动打开。
  10. 拼音输入中文(Pinyin to Chinese):按右Command 键切换到拼音输入模式,输入拼音(或首字母缩写)即可打出中文汉字。例如输入 niha 或首字母 nh,候选词会显示"你好"、"你还"等。再次按右Command 切回智能英语输入模式。

下载与安装

  1. 下载编译好的输入法应用(注意:不要点击 "Clone or download",要从下面的链接下载 pkg 文件或者 exe 文件)
  1. 打开下载后的 hallelujah .pkg 文件,会自动安装、注册、激活哈利路亚输入法。

⚠️ Attention: Mac系统如果本输入法不能正常使用,请退出当前用户重新登录,在 Input source 中手动删除再重新添加 Hallelujah 输入法.

⚠️ Attention: macOS 14 以上系统用户需要在 Input source 中手动添加 Hallelujah 输入法:

image image

注意:因为本程序不是通过 App store 发布的,Macos 会有下面的安全警告。选中 hallelujah pkg 安装程序,右键点击 Open 来打开,即可开始安装输入法。

unidentified

为什么叫 hallelujah 这个名字?

主要是受这篇文章启发: hallelujah_autocompletion.

少数派网友(@北堂岚舞)测评

英文拼写心里「没底」?这个输入法能把拼音补全为英文:哈利路亚输入法

偏好设置

点击输入法的 Preferences 或者直接访问本地 HTTP 服务: http://localhost:62718/index.html preference

image

编译本输入法

  1. open hallelujah.xcworkspace 使用 Xcode 打开 hallelujah.xcworkspace 工程,注意不是打开 hallelujah.xcodeproj
  2. command + b 构建.
  3. 构建编译后的输入法可以拷贝到 /Library/Input\ Methods/ 目录内测试。

如何调试输入法?

  1. 使用 NSLog() 在关键或可疑处打 log 日志。
  2. 没有 log 输出时,可以查看崩溃日志,位置可通过 ls -l ~/Library/Logs/DiagnosticReports/ | grep hallelujah 命令来查找。
  3. 深思熟虑。
  4. 使用 debug 版 build,在 Xcode 中 Debug -> Attach to Process By PID or Name... 。这个流程可以 work,但 Xcode 反应会较慢,需要在合适的地方加断点。大杀器,不得已而用之。
  5. 自动化测试(后续重构目标就是可测试性要加强)。

格式化代码

  • sh format-code.sh

CI build

sh build.sh

local dev script

sh dev.sh

构建安装包 pkg

bash package/build-package.bash

DeepWiki

https://www.deepwiki.com/dongyuwei/hallelujahIM

开源协议

GPL3(GNU GENERAL PUBLIC LICENSE Version 3)

数据存储

本输入法使用两个 SQLite 数据库,基于 FMDB (SQLite wrapper) 进行查询:

  1. 英文词库数据库: ~/Library/Application Support/hallelujah/words_with_frequency_and_translation_and_ipa.sqlite3

    • 包含约 140,402 个英文单词的词频、中文释义和国际音标
    • 包含约 9,955 条英语 n-gram (2~5 词短语) 频率数据,用于上下文预测
    • 安装时从 app bundle 自动复制到用户目录
    • 通过前缀匹配查询候选词

    表结构:

    -- 单词表:存储英文单词、词频、中文释义、国际音标
    CREATE TABLE words (
        word TEXT PRIMARY KEY,
        frequency INT,
        translation TEXT,
        ipa TEXT
    );
    CREATE INDEX idx_word ON words(word);
    
    -- n-gram 表:存储 2~5 词短语频率,用于上下文预测下一个词
    -- n: 短语长度 (2~5)
    -- context: 前缀(除最后一个词外的所有词),如 "i do not"
    -- next_word: 最后一个词,即预测的目标词,如 "know"
    -- frequency: 该短语在 Google Books 语料库中的出现次数
    CREATE TABLE ngrams (
        n INTEGER NOT NULL,
        context TEXT NOT NULL,
        next_word TEXT NOT NULL,
        frequency INTEGER NOT NULL,
        PRIMARY KEY (n, context, next_word)
    );
    CREATE INDEX idx_ngrams_context ON ngrams(n, context);
  2. 拼音数据库: ~/Library/Application Support/hallelujah/pinyin_data.sqlite3

    • 包含约 55,320 条拼音→汉字映射,基于 Google 拼音词库
    • 通过右 Command 键切换到拼音输入模式
    • 支持完整拼音和首字母缩写两种输入方式
    • 候选项按词频排序
    • 安装时从 app bundle 自动复制到用户目录

    表结构:

    CREATE TABLE pinyin_data (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        hz TEXT NOT NULL,      -- 汉字
        py TEXT NOT NULL,      -- 完整拼音
        abbr TEXT NOT NULL,    -- 拼音首字母缩写
        freq REAL NOT NULL     -- 词频
    );
    CREATE INDEX idx_pinyin ON pinyin_data(py);
    CREATE INDEX idx_abbr ON pinyin_data(abbr);
  3. 自定义替换数据库: ~/Library/Application Support/hallelujah/substitutions.sqlite3

    • 存储用户自定义的 Text-Expander 替换规则
    • 可在偏好设置页面 (http://localhost:62718) 中添加/删除
    • 安装和更新时保留(不会被覆盖)

    表结构:

    CREATE TABLE substitutions (
        key TEXT PRIMARY KEY,
        value TEXT
    );

感谢以下开源项目:

  1. FMDB,SQLite 数据库封装库,用于高效的前缀匹配查询。
  2. dictionary/cedict.json is transformed from cc-cedict,拼音-英语词库。
  3. dictionary/pinyin_data.sqlite3 基于 Google 拼音词库 (65,105 条原始数据),拼音-汉字映射。
  4. cmudict and https://github.com/mphilli/English-to-IPA, 国际音标。
  5. GCDWebServer,用于用户使用偏好配置。
  6. talisman,使用其中的 phonex 算法,实现模糊近似音输入。
  7. MDCDamerauLevenshtein,配合 talisman 的 phonex 算法,在音似词中按 Damerau Levenshtein 编辑距离筛选最接近的候选词。
  8. Google Books Ngram Corpus,提供英语 n-gram (2~5 词短语) 频率数据,用于上下文预测功能。
  9. 鼠鬚管 squirrel 输入法 哈利路亚输入法安装包 pkg 的制作 copy/参考了 squirrel 的实现。

贡献代码

提交 PR 之前请执行 sh format-code.sh 格式化代码。

问题反馈,意见和建议

请提交问题单到 https://github.com/dongyuwei/hallelujahIM/issues

咨询服务

提供输入法功能定制开发。联系方式:

  • 微信: dongyuwei
  • gmail: newdongyuwei

一些截图

auto suggestion from local dictionary:
auto-suggestion auto-suggestion auto-suggestion

Text Expander:
Text Expander Text Expander

translation(inspired by MacUIM):
translation

spell check:
spell-check spell-check spell-check spell-check spell-check

pinyin in, English out:
pinyin pinyin pinyin pinyin pinyin pinyin

Star History

Star History Chart

About

hallelujahIM(哈利路亚 英文输入法) is an intelligent English input method with auto-suggestions and spell check features.

Topics

Resources

License

GPL-3.0, Unknown licenses found

Licenses found

GPL-3.0
LICENSE
Unknown
COPYING.md

Stars

Watchers

Forks

Packages

 
 
 

Contributors