Created
May 9, 2025 16:01
-
-
Save hpcdisrespecter/2d33999568f66e65144cd72626a4625f to your computer and use it in GitHub Desktop.
Lemurs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ccru (:require [clojure.test :as test] [clojure.string :as str])) | |
(defn- ascii->ccru [c] (-> c int (- 55))) | |
(def abc "ABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
(def ccru-map (into (hash-map) (map #(vector % (ascii->ccru %)) (seq abc)))) | |
(defn- ccru [word] (reduce + (map #(get ccru-map % 0) (str/upper-case word)))) | |
(defn- web-parse [html] (map #(nth % 2) (re-seq #"<a href(.*?)>(.*)</a>" html))) | |
(def dict-url "https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/PG/2006/04/1-10000") | |
(def words (->> dict-url slurp web-parse (map str/upper-case) (drop 2) (take 10000))) | |
(def ccru-word-map (group-by ccru words)) | |
(defn evaluate [word] | |
(let [aq (ccru word) | |
matches (ccru-word-map aq) | |
hit-count (count matches) | |
percent (format "%.2f" (/ (* 100.0 hit-count) (count words)))] | |
(println "Word:" (str/upper-case word) "AQ:" aq "Hits:" hit-count (str "(" percent "%)")) | |
(println "Matches:" (shuffle matches)))) | |
(defn- test-aq [] | |
;See page 259 "AQ notes" | |
;https://libcom.org/files/[Ccru,_Nick_Land]_Ccru_Writings_1997-2003(BookZZ.org).pdf | |
(test/is (= (ccru "CHRONO") 127)) | |
(test/is (= (ccru "CHRONOLOGY") 222)) | |
(test/is (= (ccru "CHRONOS") 155))) | |
(test-aq) ;run tests | |
(println "Word count:" (count words)) | |
(println "CCRU map:" ccru-map) | |
(println "===============") | |
(evaluate "ALPHABETICA") | |
(println "---------------") | |
(println "Evaluate words like: (evaluate \"WORD\")") | |
; --> evaluate words in the REPL on the right like: (evaluate "WORD") | |
; ################################################################### | |
(evaluate "zojirushi") | |
(evaluate "neurofuzzy") | |
(evaluate "ricesheaf") | |
(evaluate "statmech") | |
(evaluate "nonmonotonic") | |
(evaluate "canon") | |
(evaluate "engine") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment