<commit_before>(ns cmr.ingest.api.translation
  "Defines an API for translating metadata between formats."
  (:require
   [clojure.java.io :as io]
   [clojure.test.check.generators :as test-check-gen]
   [cmr.common.cache :as cache]
   [cmr.common.mime-types :as mt]
   [cmr.common.services.errors :as errors]
   [cmr.common.xml.xslt :as xslt]
   [cmr.umm-spec.legacy :as umm-legacy]
   [cmr.umm-spec.test.umm-generators :as umm-generators]
   [cmr.umm-spec.umm-spec-core :as umm-spec]
   [cmr.umm-spec.util :as util]
   [cmr.umm-spec.versioning :as versioning]
   [compojure.core :refer :all]))

(def concept-type->supported-formats
  "A map of concept type to the list of formats that are supported both for input and output of
  translation."
  {:collection #{mt/echo10
                 mt/umm-json
                 mt/iso19115
                 mt/dif
                 mt/dif10
                 mt/iso-smap}
   :granule #{mt/echo10
              mt/umm-json
              mt/iso-smap
              mt/iso19115}})

(defn- umm-errors
  "Returns a seq of errors found by UMM validation."
  [context concept-type umm]
  (seq
   (umm-legacy/validate-metadata concept-type
                                 :umm-json
                                 (umm-spec/generate-metadata context umm :umm-json))))

(def xsl-transformer-cache-name
  "This is the name of the cache to use for XSLT transformer templates. Templates are thread
  safe but transformer instances are not.
  http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/?page=9"
  :xsl-transformer-templates)

(def ^:private echo10-iso19115-xslt<commit_msg>CMR-5387: Updated comment.<commit_after>(ns cmr.ingest.api.translation
  "Defines an API for translating metadata between formats."
  (:require
   [clojure.java.io :as io]
   [clojure.test.check.generators :as test-check-gen]
   [cmr.common.cache :as cache]
   [cmr.common.mime-types :as mt]
   [cmr.common.services.errors :as errors]
   [cmr.common.xml.xslt :as xslt]
   [cmr.umm-spec.legacy :as umm-legacy]
   [cmr.umm-spec.test.umm-generators :as umm-generators]
   [cmr.umm-spec.umm-spec-core :as umm-spec]
   [cmr.umm-spec.util :as util]
   [cmr.umm-spec.versioning :as versioning]
   [compojure.core :refer :all]))

(def concept-type->supported-formats
  "A map of concept type to the list of formats that are supported both for input and output of
  translation."
  {:collection #{mt/echo10
                 mt/umm-json
                 mt/iso19115
                 mt/dif
                 mt/dif10
                 mt/iso-smap}
   :granule #{mt/echo10
              mt/umm-json
              mt/iso-smap
              mt/iso19115}})

(defn- umm-errors
  "Returns a seq of errors found by UMM validation."
  [context concept-type umm]
  (seq
   (umm-legacy/validate-metadata concept-type
                                 :umm-json
                                 (umm-spec/generate-metadata context umm :umm-json))))

(def xsl-transformer-cache-name
  "This is the name of the cache to use for XSLT transformer templates. Templates are thread
  safe but transformer instances are not."
  :xsl-transformer-templates)

(def ^:private echo10-iso19115-xslt
{'fraction_non_alphanumeric': 0.11153119092627599, 'fraction_numerical': 0.01638311279143037, 'mean_word_length': 2.2731958762886597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1780175', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1058, 'n_words': 264}