noahsettersten commited on
Commit
af81663
1 Parent(s): c3c8822

fix: Don't highlight keywords including "and"

Browse files
lib/medical_transcription_web/components/transcription_text_component.ex CHANGED
@@ -59,14 +59,18 @@ defmodule MedicalTranscriptionWeb.Components.TranscriptionTextComponent do
59
  # split the text at those points, and then join it back together, wrapping the keyword portion in a span with the
60
  # `text-brand` class.
61
  defp format_text(text, [first | rest]) do
62
- with_replaced_keyword =
63
- text
64
- |> String.split(first.label)
65
- |> Enum.join(
66
- "<span class=\"text-brand\" title=\"Score: #{Float.round(first.score, 2)}\">#{first.label}</span>"
67
- )
 
 
 
68
 
69
- format_text(with_replaced_keyword, rest)
 
70
  end
71
 
72
  defp format_text(text, []), do: text
 
59
  # split the text at those points, and then join it back together, wrapping the keyword portion in a span with the
60
  # `text-brand` class.
61
  defp format_text(text, [first | rest]) do
62
+ if String.contains?(first.label, "and") do
63
+ format_text(text, rest)
64
+ else
65
+ with_replaced_keyword =
66
+ text
67
+ |> String.split(first.label)
68
+ |> Enum.join(
69
+ "<span class=\"text-brand\" title=\"Score: #{Float.round(first.score, 2)}\">#{first.label}</span>"
70
+ )
71
 
72
+ format_text(with_replaced_keyword, rest)
73
+ end
74
  end
75
 
76
  defp format_text(text, []), do: text