Created
January 30, 2012 21:33
-
-
Save tacahiroy/1706847 to your computer and use it in GitHub Desktop.
OmegaT glossary file -> logaling's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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