C/Migemo is regexp pattern generator/expander.
C/Migemo is a C-language implementation of Migemo (Ruby/Migemo). Software utilizing the C/Migemo library gains the ability to perform incremental Japanese searches using Romaji input. Because it is implemented in C, it is easier to integrate with the vast amount of software written in C compared to the original Ruby/Migemo, and —presumably— it offers improved execution speed.
The original Migemo is a tool devised by Satoru Takabayashi that converts Romaji input into regular expressions for Japanese text searching. It was implemented using Ruby and Emacs Lisp to enable incremental Japanese searches in Emacs while typing in Romaji.
$ cmake -B build
$ cmake --build build$ cmake --build build --target test$ cmake --build build --target profileSee build/profile.log for the profiling result.
$ cmake --build build --target cleanOr just rm -rf build.
-
Building the program
- CMake (3.21 or above)
- C11 compiler and binutils equivalents (gcc, clang, msvc or so)
-
Building the dictionary
- CMake (3.21 or above)
- curl
- iconv
- gzip
- perl
The dictionary is built from
SKK-JISYO.L -
Profiling
- gprof
$ cmake -B build
$ cmake --build build
The following options and components are available for selective building and installation (e.g., for distribution packaging):
-
BUILD_DICT(CMake Option, default:ON):Set to
OFF(cmake -B build -DBUILD_DICT=OFF) to skip dictionary generation and its external build dependencies (perl,iconv,gzip, etc.). -
Target
dictionaries:Builds all dictionary encodings at once:
cmake --build build --target dictionaries
-
Install Components:
Allows installing core files or dictionary files separately:
# Install core binary, library, and headers only cmake --install build --component core # Install generated dictionary files only cmake --install build --component dict
C/Migemo supports a pre-compiled binary dictionary format called sdict (Static Dictionary).
- Fast Startup: Drastically reduces initialization/load time (e.g., from ~50ms down to ~4ms).
- Memory Efficiency: Significantly reduces memory footprint (e.g., from ~18MB down to ~8MB).
- Improved Performance: Enhances query execution speed due to better CPU cache locality.
cmigemo provides the following options for sdict:
--convert: Converts loaded dynamic dictionaries tosdictin-memory and continues execution. Useful for testingsdictperformance quickly.--save <dict>: Saves the convertedsdictto a specified file path (implies--convert).--sdict <dict>: Loads a pre-compiledsdictfile directly (conflicts with-d/-s/-uand--convert/--save).
$ make
# Generate and save an sdict file (using -w '' to exit immediately after saving)
$ ./build/bin/cmigemo --save build/dict/utf-8/migemo-sdict -w ''
# Launch cmigemo using the saved sdict
$ ./build/bin/cmigemo --sdict build/dict/utf-8/migemo-sdictIf you want to use C/Migemo only as a vim plugin, use https://github.com/haya14busa/vim-migemo
C/Migemo is distributed under the MIT License.
The built dictionary is subject to the GPL, in accordance with the license of the source SKK-JISYO.L.