-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSW.clj
72 lines (51 loc) · 1.51 KB
/
PSW.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
;===========================================
(def home-dir "/home/david/Programming_Projects/PhoneticallySimilarWords/")
(def n1 (slurp (str home-dir "nouns2")))
(def n2 (str/split-lines nouns))
(def n3 (into #{} nouns-separated))
(def p1 (slurp (str home-dir "cmudict-0.7b")))
(def p2 (str/split-lines phonetic-dictionary))
(def p3 (map (fn[x] (str/split x #" ")) phonetic-dictionary-split))
(def f1 (slurp (str home-dir "en_freq_list.txt")))
(def f2 (str/split-lines freq-list))
(def f3 (map (fn[x] (first (str/split x #" ")))
freq-list-split))
;===========================================
(require '[clojure.string :as str])
;===========================================
(defn positions
[pred coll]
(keep-indexed (fn [idx x]
(when (pred x)
idx))
coll))
(def regex-char-esc-smap
(let [esc-chars "()*&^%$#!"]
(zipmap esc-chars
(map #(str "\\" %) esc-chars))))
(defn str-to-pattern
[string]
(->> string
(replace regex-char-esc-smap)
(reduce str)
re-pattern))
(defn parse-int [s]
(Integer. (re-find #"\d+" s )))
;===========================================
n1
n2
n3
p1
p2
p3
f1
f2
f3
;===========================================
(map (fn[x] (Integer. (re-find #"\d+" (second (str/split x #" ")))))
f2)
(filter (fn[x] (if (Integer. (re-find #"\d+" (second x))) true false))
(map (fn[x] (str/split x #" "))
f2))
(into #{} '(["a" 100]))
;===========================================