Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

waynezhang/toyskkserv-go

Repository files navigation

toyskkserv

Deprecated, check toyskkserv instead.

A toy SKK skkserv. Just made this for fun.

Features

  • Configurable dictionary via urls
  • Automatically dictionary update
  • Google Transliterate API

Protocol

The following commands are supported:

  • 0: disconnect
  • 1midashi : request candidates
  • 2: get skkserv version
  • 3: get skkserv host
  • 4midashi : request completion

Some custom protocol for internal us:

  • creload: reload dictionaries without restart
  • ...

Install

Build from source

$ make && copy bin/toyskkserv /usr/local/bin

Via Homebrew

$ brew tap waynezhang/homebrew-tap && brew install toyskkserv

Usage

A configuration file is required. toyskkserv tries to find toyskkserv.yml in the following order:

  • $HOME/.config
  • Current directory

Copy the sample file to the directory and start running:

  • $ toyskkserv [-v] serve
  • Or brew services start toyskkserv

All command

  • help: Show all commands
  • version: Show the version
  • reload: Reload all dictionaries
  • update: Update dictionaries manually
  • serve: Start the server

Configuration

Dictionary path

DictionaryDirectory: The directory where the dictionaries are downloaded to.

Host, Port

ListenAddr: 127.0.0.1:1178: The host and port that the server listens to. It's recommended to only listen to localhost.

Google Input

FallbackToGoogle: true: Enable the request to Google Transliterate API.

If it's enabled, toyskkserv calls this API if there is no candidates found in local directionaries.

Plus, toyskkserv doesn't return any candidates if no candidates are found for exactly the original word segment to avoid the noise. For example, Goolge API returns the following response for ここではきものをぬぐ:

[
  ["ここでは",
    ["ここでは", "個々では", "此処では"],
  ],
  ["きものを",
    ["着物を", "きものを", "キモノを"],
  ],
  ["ぬぐ",
    ["脱ぐ", "ぬぐ", "ヌグ"],
  ],
]

Since there are no word segment for the original request ここではきものをぬぐ, no candidates will be returned. However, if the request word is ここでは and Google API returns the following response:

[
  [
    "ここでは",
    [
      "ここでは",
      "個々では",
      "此処では",
      "ココでは",
      "ココデは"
    ]
  ]
]

toyskkserv returns /ここでは/個々では/此処では/ココでは/ココデは/ as response to SKK client.

Use disk cache

UseDiskCache: Use memory mapped file as cache to suppress memory usage. Temp file is located in $TMPDIR. Use TOYSKKSERV_CACHE to override the file path.

Scheduled dictionary update (experimentally)

UpdateSchedule: monthly: toyskkserv will try to update the dictionaries on very first day of the monthly. The following options are supporte

  • disabled
  • daily
  • weekly
  • monthly
  • debug: this is only for debug purposes

Dictionaries

Dictionaries:
  - https://github.com/skk-dev/dict/raw/refs/heads/master/SKK-JISYO.L # 基本辞書
  - https://github.com/skk-dev/dict/raw/refs/heads/master/SKK-JISYO.jinmei # 人名、特に日本人の姓名
  - xxxx

URL and local file paths are supported. toyskkserv downloads remote dictionaries to the folder that defined above. The local dictionaries are refered directly and not copied to anywhere.