-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconvert_msime2cannna.rb
executable file
·42 lines (36 loc) · 1.31 KB
/
convert_msime2cannna.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
########################################################################
# convert_msime2canna.rb: Convert MS-IME Dictionary to Canna Format
#
# Description:
# This script converts a Microsoft IME dictionary file to a format
# compatible with the Canna Japanese input method system. It specifically
# targets entries labeled as "顔文字" (emoji) and formats them accordingly.
#
# Author: id774 (More info: http://id774.net)
# Source Code: https://github.com/id774/scripts
# License: The GPL version 3, or LGPL version 3 (Dual License).
# Contact: [email protected]
#
# Version History:
# v1.1 2023-12-06
# Refactored for improved readability and added detailed comments.
# v1.0 2009-11-16
# Initial release.
#
# Usage:
# ruby convert_msime2canna.rb < MS-IME_dictionary_file
#
########################################################################
require 'kconv'
while line = gets
# Split the line into components
str = line.split(/\t/)
# Skip lines without a third column or not labeled as "顔文字"
next unless str[2]
next unless str[2].toutf8.chop == "顔文字"
# Output the converted line in Canna format
print str[0].toutf8 # Original word
print " #KJ " # Canna keyword
puts str[1].toutf8.gsub(/ /, "\\ ") # Converted reading with escaped spaces
end