-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmp.clj
138 lines (121 loc) · 3.08 KB
/
tmp.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
(def orthography-segment-order
["short low (L)"
"short high (H)"
"short lowfall"
"short superhigh"
"long low (LL)"
"long high (HH)"
"rising (LH)"
"falling (HL)"
"lowfall (LF)"
"superhigh (SH) = highfall"
"short low (L)"
"short high (H)"
"short lowfall"
"short superhigh"
"long low (LL)"
"long high (HH)"
"rising (LH)"
"falling (HL)"
"lowfall (LF)"
"superhigh (SH) = highfall"
"short low (L)"
"short high (H)"
"short lowfall"
"short superhigh"
"long low (LL)"
"long high (HH)"
"rising (LH)"
"falling (HL)"
"lowfall (LF)"
"superhigh (SH) = highfall"
"short low (L)"
"short high (H)"
"short lowfall"
"short superhigh"
"long low (LL)"
"long high (HH)"
"rising (LH)"
"falling (HL)"
"lowfall (LF)"
"superhigh (SH) = highfall"
"short low (L)"
"short high (H)"
"short lowfall"
"short superhigh"
"long low (LL)"
"long high (HH)"
"rising (LH)"
"falling (HL)"
"lowfall (LF)"
"superhigh (SH) = highfall"
"short low (L)"
"short high (H)"
"short lowfall"
"short superhigh"
"long low (LL)"
"long high (HH)"
"rising (LH)"
"falling (HL)"
"lowfall (LF)"
"superhigh (SH) = highfall"
"any vowel"
"unaspirated alveolar stop"
"aspirated alveolar stop"
"unaspirated velar stop"
"aspirated velar stop"
"unaspirated labiovelar stop"
"aspirated labiovelar stop"
"unaspirated alveolar affricate"
"aspirated alveolar affricate"
"lateral alveolar affricate"
"voiceless alveolar affricate"
"alveolar fricative"
"glottal fricative"
"glottal stop"
"alveolar liquid"
"palatal glide"
"labiovelar glide"
"bilabial nasal"])
(ns dailp-ingest-clj.orthographies
(:require [clojure.java.io :as io]
[clojure.string :as string]
[clojure.pprint :as pprint]
[dailp-ingest-clj.utils :refer [strip]]
[clojure.data.csv :as csv]))
(def orthographies-file-path "resources/private/orthographies.csv")
(defn clean-for-kw
"Clean an externally generated string so that it can be used as a keyword."
[str-th]
(-> str-th
string/trim
(string/replace #"," "")))
(defn spaces->hyphen
[thing]
(string/replace (clean-for-kw thing) #"\s+" "-"))
(defn csv-data->maps [csv-data]
(mapv zipmap
(->> (first csv-data) ;; First row is the header
(map (fn [x] (keyword (spaces->hyphen x)))) ;; Drop if you want string keys instead
repeat)
(rest csv-data)))
(defn fix-orth
[orth]
(assoc orth :segment (-> (:segment orth)
(strip " \"\n")
)))
(defn orthographies-csv->maps
[]
(with-open [reader (io/reader orthographies-file-path)]
(csv-data->maps (csv/read-csv reader))))
(comment
(orthographies-csv->maps)
(sort #(compare (last %1) (last %2)) {:b 1 :c 3 :a 2})
)
(string/includes? "abc" "abd")
(defn upload-orthographies
[state orthographies]
(println "you wanna upload these orths"))
(defn extract-upload-orthographies
[state]
(upload-orthographies state (extract-orthographies)))