#!/usr/bin/env ruby

require_relative 'database'
require_relative 'vocabularies'
require_relative 'migrants'

output = File.open(File.join('data', 'countries.ttl'), 'w')

output.puts prefixes(:rdfs, :schema, :country)
output.puts

countries = DB[:location].distinct.select(:Country).where(Sequel.~(Country: nil)).where(Sequel.~(Country: '')).order(:Country)

countries.each do |row|
  name = row[:Country]
  output.puts "country:#{toName(name)} a schema:Country ;"
  output.puts "  rdfs:label #{RDF::Literal.new(name, language: :en).to_ntriples} ."
  output.puts
end

output.close
