Sha256: b1ee43cbaddf2f74bdde417627d8cef039562d7ce43217bac283034f285cd3fd

Contents?: true

Size: 1.3 KB

Versions: 10

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-01-04/ directory"
    task :stanford_core_nlp => :environment do
      puts 'Please be patient...This could take a while.'
      file = "#{Rails.root}/lib/stanford-corenlp-full-2014-01-04.zip"
      open(file, 'wb') do |fo|
        fo.print open('http://nlp.stanford.edu/software/stanford-corenlp-full-2014-01-04.zip').read
      end

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

      file = "#{Rails.root}/lib/stanford-corenlp-full-2014-01-04/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

10 entries across 10 versions & 1 rubygems

Version Path
abstractor-1.0.23 lib/tasks/abstractor_tasks.rake
abstractor-1.0.22 lib/tasks/abstractor_tasks.rake
abstractor-1.0.20 lib/tasks/abstractor_tasks.rake
abstractor-1.0.19 lib/tasks/abstractor_tasks.rake
abstractor-1.0.18 lib/tasks/abstractor_tasks.rake
abstractor-1.0.17 lib/tasks/abstractor_tasks.rake
abstractor-1.0.16 lib/tasks/abstractor_tasks.rake
abstractor-1.0.15 lib/tasks/abstractor_tasks.rake
abstractor-1.0.14 lib/tasks/abstractor_tasks.rake
abstractor-1.0.13 lib/tasks/abstractor_tasks.rake