null+****@clear*****
null+****@clear*****
Tue Feb 28 16:32:58 JST 2012
SHIMADA Koji 2012-02-28 16:32:58 +0900 (Tue, 28 Feb 2012) New Revision: ed98495e7eb4e77896869b919e428b595108f495 Merged 5e13d76: Merge pull request #55 from logaling/fix-loga-config Log: Add importer for FreeBSD jpman project's glossary Added files: lib/logaling/external_glossaries/freebsd_jpman.rb Added: lib/logaling/external_glossaries/freebsd_jpman.rb (+38 -0) 100644 =================================================================== --- /dev/null +++ lib/logaling/external_glossaries/freebsd_jpman.rb 2012-02-28 16:32:58 +0900 (8beb453) @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012 Koji SHIMADA <koji.****@enish*****> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +require 'open-uri' + +module Logaling + class FreebsdJpman < ExternalGlossary + description 'FreeBSD jpman(http://www.jp.freebsd.org/man-jp/)' + source_language 'en' + target_language 'ja' + output_format 'csv' + + private + def convert_to_csv(csv) + url = 'http://www.jp.freebsd.org/man-jp/docs/wordlist.txt' + open(url,'r:iso-2022-jp') do |f| + f.each_line.map{|l| l.encode("utf-8")}.each do |line| + next if line =~ /^(#|\t)/ + csv << line.split(/\t+| {5}/, 2).map(&:strip) + end + end + end + end +end