Sha256: 2aa44b337485dc590e0958764928305b904adc45617e89f52c39a5a39f2a3ec2

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# -*- coding: utf-8 -*-
#
# Copyright (C) 2012  Koji SHIMADA <koji.shimada@enishi-tech.com>
#
# 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 "logaling/glossary_sources/base"
require "csv"

module Logaling::GlossarySources
  class GlossaryTsvSource < Base
    def load
      glossary_source = []
      CSV.open(absolute_path, "r:utf-8",  {:col_sep => "\t"}) do |tsv|
        tsv.each do |row|
          glossary_source << {"source_term" => row[0], "target_term" => row[1], "note" => ""} if row.size >= 2
        end
      end
      glossary_source
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logaling-command-0.2.5 lib/logaling/glossary_sources/glossary_tsv_source.rb
logaling-command-0.2.4 lib/logaling/glossary_sources/glossary_tsv_source.rb
logaling-command-0.2.3 lib/logaling/glossary_sources/glossary_tsv_source.rb
logaling-command-0.2.2 lib/logaling/glossary_sources/glossary_tsv_source.rb
logaling-command-0.2.1 lib/logaling/glossary_sources/glossary_tsv_source.rb