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

Develop to master merge, release 5.30.1 #153

Merged
merged 8 commits into from
Jul 3, 2024
Merged
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
12 changes: 6 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ gem 'redcarpet'


# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'master'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'master'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'master'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master'
gem 'goo', github: 'ncbo/goo', branch: 'master'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'master'
gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'develop'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'develop'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'develop'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop'
gem 'goo', github: 'ncbo/goo', branch: 'develop'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop'


group :development do
Expand Down
51 changes: 24 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ncbo/goo.git
revision: 2cec53c2d84179171def81d7dc0a18e462e78fc2
branch: master
revision: 70007faf43d0d96292809f89f15a27a757ccaa25
branch: develop
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand All @@ -16,8 +16,8 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_annotator.git
revision: 63c986880aa88c9384043e6611a682434a14aba7
branch: master
revision: 7531e10ad55ac66e925c099d7fc05a5a3ceae67e
branch: develop
specs:
ncbo_annotator (0.0.1)
goo
Expand All @@ -27,8 +27,8 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_cron.git
revision: f6c4ca0e014a1744d5a6460b9bf72784cb8428c8
branch: master
revision: 1fbfc8f7f3ca62de35912ec09f23cac72fea1550
branch: develop
specs:
ncbo_cron (0.0.1)
dante
Expand All @@ -45,8 +45,8 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_ontology_recommender.git
revision: 013abea4af3b10910ec661dbb358a4b6cae198a4
branch: master
revision: f92a42f660635522eb8709e618ff2e641aef0d17
branch: develop
specs:
ncbo_ontology_recommender (0.0.1)
goo
Expand All @@ -56,8 +56,8 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 70fc2c8b377b9deabc838ecd56d3bc75ec764cc2
branch: master
revision: 013a322440b4cfd899908d15ff605799acf8e6ef
branch: develop
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand All @@ -76,8 +76,8 @@ GIT

GIT
remote: https://github.com/ncbo/sparql-client.git
revision: e89c26aa96f184dbe9b52d51e04fb3d9ba998dbc
branch: master
revision: 1657f0dd69fd4b522d3549a6848670175f5e98cc
branch: develop
specs:
sparql-client (1.0.1)
json_pure (>= 1.4)
Expand Down Expand Up @@ -106,8 +106,8 @@ GEM
activesupport (3.2.22.5)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
airbrussh (1.5.2)
sshkit (>= 1.6.1, != 1.7.0)
ast (2.4.2)
Expand All @@ -119,7 +119,7 @@ GEM
bcrypt_pbkdf (1.1.1-x86_64-darwin)
bigdecimal (1.4.2)
builder (3.3.0)
capistrano (3.18.1)
capistrano (3.19.1)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
Expand Down Expand Up @@ -220,7 +220,7 @@ GEM
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.7.2)
jwt (2.8.1)
jwt (2.8.2)
base64
kgio (2.11.4)
language_server-protocol (3.17.0.3)
Expand All @@ -236,16 +236,15 @@ GEM
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0604)
mime-types-data (3.2024.0702)
mini_mime (1.1.5)
minitest (4.7.5)
minitest-stub_any_instance (1.0.3)
mlanett-redis-lock (0.2.7)
redis
multi_json (1.15.0)
mutex_m (0.2.0)
net-http-persistent (2.9.4)
net-imap (0.4.12)
net-imap (0.4.14)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -260,22 +259,22 @@ GEM
net-protocol
net-ssh (7.2.3)
netrc (0.11.0)
newrelic_rpm (9.10.2)
newrelic_rpm (9.11.0)
oj (3.16.1)
omni_logger (0.1.4)
logger
os (1.1.4)
parallel (1.25.1)
parseconfig (1.1.2)
parser (3.3.2.0)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
pony (1.13.1)
mail (>= 2.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.5)
public_suffix (5.1.1)
racc (1.8.0)
rack (1.6.13)
rack-accept (0.4.5)
Expand Down Expand Up @@ -316,7 +315,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.0)
rexml (3.3.1)
strscan
rsolr (2.6.0)
builder (>= 2.1.2)
Expand Down Expand Up @@ -367,16 +366,15 @@ GEM
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
sshkit (1.22.2)
sshkit (1.23.0)
base64
mutex_m
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
strscan (3.1.0)
systemu (2.6.5)
temple (0.10.3)
tilt (2.3.0)
tilt (2.4.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand All @@ -398,7 +396,6 @@ PLATFORMS
aarch64-linux
arm64-darwin-22
arm64-darwin-23
x86_64-darwin-18
x86_64-darwin-23
x86_64-linux

Expand Down
1 change: 1 addition & 0 deletions controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def process_search(params=nil)
doc[:ontology_rank] = (ontology_rank[doc[:submissionAcronym]] && !ontology_rank[doc[:submissionAcronym]].empty?) ? ontology_rank[doc[:submissionAcronym]][:normalizedScore] : 0.0
doc[:properties] = MultiJson.load(doc.delete(:propertyRaw)) if include_param_contains?(:properties)
instance = doc[:provisional] ? LinkedData::Models::ProvisionalClass.read_only(doc) : LinkedData::Models::Class.read_only(doc)
filter_language_attributes(params, instance)
docs.push(instance)
end

Expand Down
38 changes: 36 additions & 2 deletions helpers/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ module SearchHelper
VALUESET_ROOTS_ONLY_PARAM = "valueset_roots_only"
VALUESET_EXCLUDE_ROOTS_PARAM = "valueset_exclude_roots"
ONTOLOGY_TYPES_PARAM = "ontology_types"
LANGUAGES_PARAM = "lang"

ALSO_SEARCH_VIEWS = "also_search_views" # NCBO-961
MATCH_HTML_PRE = "<em>"
MATCH_HTML_POST = "</em>"
MATCH_TYPE_PREFLABEL = "prefLabel"
MATCH_TYPE_SYNONYM = "synonym"
MATCH_TYPE_PROPERTY = "property"
MATCH_TYPE_DEFINITION = "definition"
MATCH_TYPE_LABEL = "label"
MATCH_TYPE_LABELGENERATED = "labelGenerated"
NO_LANGUAGE_SUFFIX = "none"

MATCH_TYPE_MAP = {
"resource_id" => "id",
Expand Down Expand Up @@ -110,15 +113,15 @@ def get_term_search_query(text, params={})
query = "\"#{solr_escape(text)}\""
params["qt"] = "/suggest_ncbo"
params["qf"] = " prefLabelExact#{lang_suffix}^100 prefLabelSuggestEdge#{lang_suffix}^50 synonymSuggestEdge#{lang_suffix}^10 prefLabelSuggestNgram#{lang_suffix} synonymSuggestNgram#{lang_suffix} resource_id #{QUERYLESS_FIELDS_STR}"
params["pf"] = "prefLabelSuggest^50"
params["pf"] = "prefLabelSuggest#{lang_suffix}^50"
params["hl.fl"] = "prefLabelExact#{lang_suffix} prefLabelSuggestEdge#{lang_suffix} synonymSuggestEdge#{lang_suffix} prefLabelSuggestNgram#{lang_suffix} synonymSuggestNgram#{lang_suffix} resource_id #{QUERYLESS_FIELDS_STR}"
else
if text.strip.empty?
query = '*'
else
query = solr_escape(text)
end
params["qf"] = "resource_id^100 notation^100 oboId^100 prefLabelExact#{lang_suffix}^90 prefLabel#{lang_suffix}^70 synonymExact#{lang_suffix}^50 synonym^10 #{QUERYLESS_FIELDS_STR_NO_IDS}"
params["qf"] = "resource_id^100 notation^100 oboId^100 prefLabelExact#{lang_suffix}^90 prefLabel#{lang_suffix}^70 synonymExact#{lang_suffix}^50 synonym#{lang_suffix}^10 #{QUERYLESS_FIELDS_STR_NO_IDS}"
params["qf"] << " property" if params[INCLUDE_PROPERTIES_PARAM] == "true"
params["bq"] = "idAcronymMatch:true^80"
params["hl.fl"] = "resource_id prefLabelExact#{lang_suffix} prefLabel#{lang_suffix} synonymExact#{lang_suffix} synonym#{lang_suffix} #{QUERYLESS_FIELDS_STR}"
Expand Down Expand Up @@ -182,6 +185,10 @@ def get_term_search_query(text, params={})
params["fq"] = filter_query
params["q"] = query


# binding.pry


query
end

Expand Down Expand Up @@ -357,6 +364,33 @@ def populate_classes_from_search(classes, ontology_acronyms=nil)
classes_hash
end

def filter_language_attribute(params, class_instance, attr, is_single)
if class_instance.respond_to?(attr)
lang_param = (params["lang"] || params["language"])&.downcase
lang_suffix = lang_param && !lang_param.eql?("all") ? "_#{lang_param}" : ""

if !lang_suffix.empty? && class_instance.respond_to?("#{attr}#{lang_suffix}")
class_instance[attr] = is_single ? class_instance["#{attr}#{lang_suffix}"][0] : class_instance["#{attr}#{lang_suffix}"]
elsif !lang_param.eql?("all")
site_label = Goo.main_languages[0]

if class_instance.respond_to?("#{attr}_#{site_label}") && class_instance["#{attr}_#{site_label}"]
class_instance[attr] = is_single ? class_instance["#{attr}_#{site_label}"][0] : class_instance["#{attr}_#{site_label}"]
elsif class_instance.respond_to?("#{attr}_#{NO_LANGUAGE_SUFFIX}") && class_instance["#{attr}_#{NO_LANGUAGE_SUFFIX}"]
class_instance[attr] = is_single ? class_instance["#{attr}_#{NO_LANGUAGE_SUFFIX}"][0] : class_instance["#{attr}_#{NO_LANGUAGE_SUFFIX}"]
elsif is_single
class_instance[attr] = class_instance[attr][0]
end
end
end
end

def filter_language_attributes(params, class_instance)
filter_language_attribute(params, class_instance, MATCH_TYPE_PREFLABEL, true)
filter_language_attribute(params, class_instance, MATCH_TYPE_SYNONYM, false)
filter_language_attribute(params, class_instance, MATCH_TYPE_DEFINITION, false)
end

def validate_params_solr_population(allowed_includes_params)
leftover = includes_param - allowed_includes_params
invalid = leftover.length > 0
Expand Down
Loading