Sha256: 0c1c1df3e7380e1245a1ffa970d81e378ae233639ca7abf352749b6d52eb6b93
Contents?: true
Size: 1.49 KB
Versions: 10
Compression:
Stored size: 1.49 KB
Contents
#!/usr/bin/env ruby require 'creek' require 'pp' require 'pathname' require 'fileutils' require_relative '../lib/tc211/termbase.rb' # require 'pry' filepath = ARGV[0] #'./tc211-termbase.xlsx' if filepath.nil? puts 'Error: no filepath given as first argument.' exit 1 end if Pathname.new(filepath).extname != ".xlsx" puts 'Error: filepath given must have extension .xlsx.' exit 1 end workbook = Tc211::Termbase::TermWorkbook.new(filepath) workbook.glossary_info.metadata_section.structure workbook.glossary_info.metadata_section.attributes languages = {} workbook.languages_supported.map do |lang| puts "************** WORKING ON LANGUAGE (#{lang})" sheet = workbook.language_sheet(lang) termsec = sheet.terms_section languages[sheet.language_code] = termsec.terms end collection = Tc211::Termbase::ConceptCollection.new languages.each_pair do |lang, terms| terms.each do |term| collection.add_term(term) end end # collection[1206].inspect output_dir = Dir.pwd collection.to_file(File.join(output_dir, Pathname.new(filepath).basename.sub_ext(".yaml"))) collection_output_dir = File.join(output_dir, "concepts") FileUtils.mkdir_p(collection_output_dir) collection.keys.each do |id| collection[id].to_file(File.join(collection_output_dir, "concept-#{id}.yaml")) end # french = workbook.language_sheet("French") # french.sections[3].structure # french.sections[3].terms # english = workbook.language_sheet("English") # english.terms_section # english.terms_section.terms #pry.binding
Version data entries
10 entries across 10 versions & 1 rubygems