Skip to content

Commit

Permalink
Fix: Annotator fast context special chars issues & statistics page sy…
Browse files Browse the repository at this point in the history
…ntax error (#561)

* fix statistics page syntax error

* update ontoportal instances home section title

* fix fast context option in annotator page

* remove special chars from annotator's input on submit to avoid errors
  • Loading branch information
Bilelkihal authored and syphax-bouazzouni committed Apr 5, 2024
1 parent 03d2f2e commit e9839ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion app/controllers/annotator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def annotator_results(uri)
if params[:text] && !params[:text].empty?
@init_whole_word_only = true
api_params = {
text: escape(params[:text]),
text: remove_special_chars(params[:text]),
ontologies: params[:ontologies],
semantic_types: params[:semantic_types],
semantic_groups: params[:semantic_groups],
Expand Down Expand Up @@ -210,5 +210,13 @@ def json_link(url, optional_params)
return base_url + optional_params_str + "&apikey=#{$API_KEY}"
end

def remove_special_chars(input)
regex = /^[a-zA-Z0-9\s]*$/
unless input.match?(regex)
input.gsub!(/[^\w\s]/, '')
end
input
end

end

6 changes: 3 additions & 3 deletions app/views/statistics/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
= t('statistics.lead', last_years: Date.today.year - Date.parse(@merged_data[:labels].first).year)
%div.container
%div
= chart_component(title: nil, type: 'line', show_legend: true,
labels: @merged_data[:labels],
datasets: visits_chart_dataset_array({ t('statistics.ontologies'): @merged_data[:visits][2] ,t('statistics.users'): @merged_data[:visits][0], t('statistics.projects'): @merged_data[:visits][1]}, fill: false))
= chart_component(title: nil, type: 'line', show_legend: true,
labels: @merged_data[:labels], datasets: visits_chart_dataset_array({ t('statistics.ontologies') => @merged_data[:visits][2],
t('statistics.users') => @merged_data[:visits][0], t('statistics.projects') => @merged_data[:visits][1] }, fill: false))

%div.pb-3.pb-md-4
- size = @merged_data[:labels].size - 1
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ en:
paste_text_prompt: Enter a paragraph of text or some keywords...
recommender_annotator: Recommender and Annotator
support_and_collaborations: Support & Collaborations
ontoportal_instances: Ontoportal Instances
ontoportal_instances: Other OntoPortal Instances
see_details: See details
info_tooltip_text: "You are seing the average scores for all the public ontologies in AgroPortal. FAIR scores are computed with the O'FAIRe methodology. More details here: https://github.com/agroportal/fairness"
average: Average
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ fr:
</blockquote>
home:
ontoportal_instances: "Instances d'Ontoportal"
ontoportal_instances: "Autres installations d’OntoPortal"
bug: Bug
proposition: Proposition
question: Question
Expand Down

0 comments on commit e9839ed

Please sign in to comment.