mirror of https://github.com/percyliang/sempre
71 lines
1.6 KiB
Ruby
Executable File
71 lines
1.6 KiB
Ruby
Executable File
#!/usr/bin/ruby
|
|
|
|
$modules = [:core,
|
|
:emnlp2013,
|
|
:acl2014,
|
|
:geofreebase_vdb,
|
|
:geofreebase_ttl,
|
|
:fullfreebase_vdb,
|
|
:fullfreebase_ttl]
|
|
|
|
def usage
|
|
puts "Usage: ./download-dependencies <#{$modules.join('|')}>"
|
|
end
|
|
|
|
if ARGV.size == 0
|
|
usage
|
|
exit 1
|
|
end
|
|
|
|
def run(command)
|
|
puts "RUNNING: #{command}"
|
|
if not system(command)
|
|
puts "FAILED: #{command}"
|
|
exit 1
|
|
end
|
|
end
|
|
|
|
def download(release, path, baseUrl='http://nlp.stanford.edu/software/sempre')
|
|
url = baseUrl + '/release-' + release.to_s
|
|
isDirectory = (path.end_with?('.exec') or path.end_with?('vdb') or
|
|
path.end_with?('free917') or path.end_with?('inexact') or path.end_with?('prolog')) # Superficial test for directory
|
|
if release != :code and !path.end_with?('.gz', '.tgz', '.jar')
|
|
path += '.tar' if isDirectory
|
|
path += '.bz2'
|
|
end
|
|
run("mkdir -p #{File.dirname(path)}")
|
|
run("wget -c '#{url}/#{path}' -O #{path}")
|
|
if release != :code and path.end_with?('.bz2')
|
|
if isDirectory
|
|
run("cd #{File.dirname(path)} && tar xjf #{File.basename(path)}")
|
|
else
|
|
run("bzip2 -fd #{path}")
|
|
end
|
|
end
|
|
end
|
|
|
|
def downloadFromFileList(release)
|
|
files = []
|
|
File.foreach('release-' + release.to_s + '.files') { |line|
|
|
file = line.sub(/#.*$/, '').sub(/^\s*/, '').sub(/\s*$/, '')
|
|
next if file.size == 0
|
|
files << file
|
|
}
|
|
files.each { |path|
|
|
download(release, path)
|
|
}
|
|
end
|
|
|
|
def main(which)
|
|
if not $modules.include?(which)
|
|
usage
|
|
exit 1
|
|
end
|
|
downloadFromFileList(which)
|
|
end
|
|
|
|
ARGV.each { |mod|
|
|
mod = mod.to_sym
|
|
main(mod)
|
|
}
|