Skip to content

Commit

Permalink
refactor freebase download
Browse files Browse the repository at this point in the history
  • Loading branch information
dimus committed Aug 17, 2012
1 parent 2f931cc commit f468b5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bin/dwca-hunt.rb
Expand Up @@ -6,8 +6,8 @@
DwcaHunter::logger = Logger.new($stdout)
resources = [
# DwcaHunter::ResourceWikispecies.new(opts),
# DwcaHunter::ResourceFreebase.new(opts),
DwcaHunter::ResourceITIS.new(opts),
DwcaHunter::ResourceFreebase.new(opts),
# DwcaHunter::ResourceITIS.new(opts),
# DwcaHunter::ResourceNCBI.new(opts),
# DwcaHunter::ResourceWoRMS.new(opts)
]
Expand Down
24 changes: 12 additions & 12 deletions lib/dwca-hunter/resource_freebase.rb
Expand Up @@ -31,11 +31,6 @@ def download
name: nil,
scientific_name: nil,
synonym_scientific_name: [],
# key: {
# namespace: "/wikipedia/en_id",
# value: nil,
# optional: true,
# },
higher_classification: {
id: nil,
guid: nil,
Expand All @@ -45,6 +40,18 @@ def download
}],
cursor: true,
}

run_query(q)

data = JSON.pretty_generate @data
f = open(@download_path, "w:utf-8")
f.write(data)
f.close
end

private

def run_query(q)
count = 0
requests_num = 0
while true
Expand All @@ -56,15 +63,8 @@ def download
res["result"].each { |d| @data << d }
q[:cursor] = res["cursor"]
end

data = JSON.pretty_generate @data
f = open(@download_path, "w:utf-8")
f.write(data)
f.close
end

private

def organize_data
@data = JSON.load(open(@download_path, "r:utf-8").read)
@data.each do |d|
Expand Down

0 comments on commit f468b5e

Please sign in to comment.