Sha256: bff537cefd07ecab25c4ff477b9a68e0026f8df12bd0af6d2d627bde24bca164

Contents?: true

Size: 1.3 KB

Versions: 17

Compression:

Stored size: 1.3 KB

Contents

require 'open-uri'
require 'zip'

namespace :abstractor do
  namespace :setup do
    desc 'Load abstractor system tables'
    task :system => :environment do
      Abstractor::Setup.system
    end

    desc "Setup Stanford CoreNLP library in lib/stanford-corenlp-full-2014-06-16/ directory"
    task :stanford_core_nlp => :environment do
      puts 'Please be patient...This could take a while.'
      file = "#{Rails.root}/lib/stanford-corenlp-full-2014-06-16.zip"
      open(file, 'wb') do |fo|
        fo.print open('http://nlp.stanford.edu/software/stanford-corenlp-full-2014-06-16.zip').read
      end

      file = "#{Rails.root}/lib/stanford-corenlp-full-2014-06-16.zip"
      destination = "#{Rails.root}/lib/"
      puts 'Unzipping...'
      unzip_file(file, destination)

      file = "#{Rails.root}/lib/stanford-corenlp-full-2014-06-16/bridge.jar"
      open(file, 'wb') do |fo|
        fo.print open('https://github.com/louismullie/stanford-core-nlp/blob/master/bin/bridge.jar?raw=true').read
      end
    end
  end

  private
    def unzip_file (file, destination)
      Zip::File.open(file) { |zip_file|
       zip_file.each { |f|
         f_path=File.join(destination, f.name)
         FileUtils.mkdir_p(File.dirname(f_path))
         zip_file.extract(f, f_path) unless File.exist?(f_path)
       }
      }
    end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
abstractor-4.2.2 lib/tasks/abstractor_tasks.rake
abstractor-4.2.1 lib/tasks/abstractor_tasks.rake
abstractor-4.2.0 lib/tasks/abstractor_tasks.rake
abstractor-4.1.5 lib/tasks/abstractor_tasks.rake
abstractor-4.1.4 lib/tasks/abstractor_tasks.rake
abstractor-4.1.3 lib/tasks/abstractor_tasks.rake
abstractor-4.1.2 lib/tasks/abstractor_tasks.rake
abstractor-4.1.1 lib/tasks/abstractor_tasks.rake
abstractor-4.1.0 lib/tasks/abstractor_tasks.rake
abstractor-4.0.2 lib/tasks/abstractor_tasks.rake
abstractor-4.0.1 lib/tasks/abstractor_tasks.rake
abstractor-4.0.0 lib/tasks/abstractor_tasks.rake
abstractor-2.1.2 lib/tasks/abstractor_tasks.rake
abstractor-2.1.01 lib/tasks/abstractor_tasks.rake
abstractor-2.1.0 lib/tasks/abstractor_tasks.rake
abstractor-2.0.1 lib/tasks/abstractor_tasks.rake
abstractor-2.0.0 lib/tasks/abstractor_tasks.rake