Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh 2016 #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,3 @@ DEPENDENCIES
spring
uglifier (>= 1.3.0)
web-console (~> 2.0)

BUNDLED WITH
1.11.2
2 changes: 1 addition & 1 deletion app/models/adrg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Adrg < ActiveRecord::Base
include MultiLanguageText

searchkick word_middle: [:text_de, :text_fr, :text_it],
callbacks: false, language: 'german', batch_size: 50,
callbacks: false, language: 'german', batch_size: 10,
synonyms: -> { CSV.read('data/mesh_2016/synonyms.csv', {col_sep: ';'}) }

def code_display
Expand Down
2 changes: 1 addition & 1 deletion data
Submodule data updated from 0915ea to 086ee0
35 changes: 34 additions & 1 deletion lib/tasks/db.rake
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,37 @@ namespace :db do
Rake::Task['db:seed_numcase_data'].reenable
Rake::Task['db:seed_numcase_data'].invoke(File.join(args.directory, '2013'), '2013')
end
end

desc 'Reads synonyms.csv and writes relevant synonyms to synonyms_reduced.csv.'
task :reduce_synonyms, [:directory] => :environment do |t, args|
Searchkick.timeout = 20

file_name = File.join(args.directory, 'mesh_2016/synonyms.csv')
csv_contents = CSV.read(file_name, col_sep: ';')
count = csv_contents.length
pg = ProgressBar.create(total: count, title: "Outputting relevant synonyms...")

CSV.open(File.join(args.directory, 'mesh_2016/synonyms_reduced.csv',), "w", col_sep: ';') do |csv|
csv_contents.each do |row|
pg.increment
found = false
row.each do |item|
[Adrg, Drg, Mdc].each do |model|
['de'].each do |locale| # at the moment ['de'] is enough because the synonyms list only contains german synonyms
result = model.search item,
fields: ['code^5', {'text_' + locale.to_s + '^2' => :word_middle}, 'relevant_codes_' + locale.to_s],
limit: 1, highlight: {tag: '<mark>'},
misspellings: {edit_distance: 1}, execute: false
found = (found or result.length > 0)
end
end
end
if found
csv << row
else
end
end
end
pg.finish
end
end