Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Created January 30, 2012 21:33
Show Gist options
  • Save tacahiroy/1706847 to your computer and use it in GitHub Desktop.
Save tacahiroy/1706847 to your computer and use it in GitHub Desktop.
OmegaT glossary file -> logaling's
#! /usr/bin/env ruby
# coding: utf-8
require "yaml"
unless ARGV.size == 2
puts "USAGE: #$0 OMEGAT LOGA"
exit
end
src = ARGV[0]
dest = ARGV[1]
unless File.exist?(src)
puts "#{src} - No such file."
exit 1
end
g = []
File.open(src).each { |omegat|
next if omegat =~ /\A\n\Z/
omegat.chomp!
cols = omegat.split(/\t/)
g << ["source_term" => cols[0], "target_term" => cols[1], "note" => cols[2]]
}
YAML.dump(g.flatten, File.new(dest, "w"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment