From 3e2945d513f8a6f65aca42775cfa82db3684f604 Mon Sep 17 00:00:00 2001 From: aka Date: Tue, 15 Oct 2024 11:26:07 +0100 Subject: [PATCH] Create core.clj --- src/detect/core.clj | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/detect/core.clj diff --git a/src/detect/core.clj b/src/detect/core.clj new file mode 100644 index 0000000..b590501 --- /dev/null +++ b/src/detect/core.clj @@ -0,0 +1,14 @@ +(ns detect.core + (:require [clojure.string :as str])) + +(defn most-frequent-word [text] + (let [words (str/split (str/lower-case text) #"\W+") + freq-map (frequencies words) + most-frequent (apply max-key val freq-map)] + (println "✨ The most frequent word is ✨") + (println "==========================") + (println "🌟" (key most-frequent) "🌟") + (println "=========================="))) + +(defn -main [& args] + (most-frequent-word "Your sample text goes here. This is just a sample text for demonstration. This text will have a most frequent word."))