TokiTranslate/lib/tasks/database.rake

22 lines
432 B
Ruby
Raw Normal View History

2023-10-13 00:04:20 +00:00
namespace :dataset do
desc "TODO"
task ingest: :environment do
ingest_data
end
end
def ingest_data
if PartOfSpeech.count > 0
puts "Data already exists in table! Aborting."
return
end
parts_of_speech = JSON.parse(File.read('db/dataset_en/toki-partsofspeech.json'))
parts_of_speech.each do |pos|
PartOfSpeech.create(pos: pos['pos'], definition: pos['definition'])
end
puts "Ingest complete."
end