<commit_before>(ns cmr.search.services.query-walkers.keywords-extractor
  "Defines protocols and functions to extract keywords from a query."
  (:require
   [clojure.string :as str]
   [cmr.common-app.services.search.query-model :as cqm]
   [cmr.common.services.errors :as errors]
   [cmr.search.models.query :as qm]))

(defprotocol ExtractKeywords
  "Defines a function to extract keywords"
  (extract-keywords-seq
    [c]
    "Extracts keywords and keyword like values from keyword conditions and conditions which apply
     to keywords scoring. Returns 2 sequences of keywords - one list from the
     keyword condition and one from fields.")
  (contains-keyword-condition?
   [c]
   "Returns true if the query contains a keyword condition?"))

(defn extract-keywords
  "Extracts keywords and keyword like values from keyword conditions and conditions which apply
   to keywords scoring. Returns 2 sequences of distinct keywords - one list from the<commit_msg>CMR-3823 Update comment<commit_after>(ns cmr.search.services.query-walkers.keywords-extractor
  "Defines protocols and functions to extract keywords from a query."
  (:require
   [clojure.string :as str]
   [cmr.common-app.services.search.query-model :as cqm]
   [cmr.common.services.errors :as errors]
   [cmr.search.models.query :as qm]))

(defprotocol ExtractKeywords
  "Defines a function to extract keywords"
  (extract-keywords-seq
    [c]
    "Extracts keywords and keyword like values from keyword conditions and conditions which apply
     to keywords scoring. Returns 2 sequences of keywords - one list from the
     keyword condition and one from fields in the format {:keywords [...] :field-keywords [...]}")
  (contains-keyword-condition?
   [c]
   "Returns true if the query contains a keyword condition?"))

(defn extract-keywords
  "Extracts keywords and keyword like values from keyword conditions and conditions which apply
   to keywords scoring. Returns 2 sequences of distinct keywords - one list from the
{'fraction_non_alphanumeric': 0.07993966817496229, 'fraction_numerical': 0.004022121669180492, 'mean_word_length': 4.037974683544304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5713125', 'n_tokens_mistral': 548, 'n_tokens_neox': 531, 'n_words': 216}