Noah Settersten commited on
Commit
e7e9eaf
·
1 Parent(s): 046803b

chore: Display top keywords sorted by score

Browse files
lib/medical_transcription_web/components/components.ex CHANGED
@@ -82,7 +82,9 @@ defmodule MedicalTranscriptionWeb.Components do
82
  class="flex flex-col gap-14"
83
  >
84
  <!-- coronary, artery, disease, unstable, angina, admitted -->
85
- <%= Enum.join(@summary_keywords, ", ") %>
 
 
86
  </p>
87
  </div>
88
  </div>
@@ -92,6 +94,13 @@ defmodule MedicalTranscriptionWeb.Components do
92
  end
93
  end
94
 
 
 
 
 
 
 
 
95
  def result_list(assigns) do
96
  ~H"""
97
  <div
 
82
  class="flex flex-col gap-14"
83
  >
84
  <!-- coronary, artery, disease, unstable, angina, admitted -->
85
+ <%= for keyword <- format_keywords(@summary_keywords) do %>
86
+ <span class="" title={keyword.score}><%= keyword.label %>,</span>
87
+ <% end %>
88
  </p>
89
  </div>
90
  </div>
 
94
  end
95
  end
96
 
97
+ def format_keywords(keyword_predictions) do
98
+ keyword_predictions
99
+ |> List.flatten()
100
+ |> Enum.sort_by(& &1.score, :desc)
101
+ |> Enum.take(7)
102
+ end
103
+
104
  def result_list(assigns) do
105
  ~H"""
106
  <div
lib/medical_transcription_web/components/transcription_text_component.ex CHANGED
@@ -68,7 +68,7 @@ defmodule MedicalTranscriptionWeb.Components.TranscriptionTextComponent do
68
  "#{keyword.label} (#{trunc(keyword.score * 100) / 100.0})"
69
  end)
70
 
71
- send(parent_pid, {:new_keywords, keywords})
72
 
73
  keywords
74
  end
 
68
  "#{keyword.label} (#{trunc(keyword.score * 100) / 100.0})"
69
  end)
70
 
71
+ send(parent_pid, {:new_keywords, predictions})
72
 
73
  keywords
74
  end