-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGulpfile.coffee
33 lines (30 loc) · 1.17 KB
/
Gulpfile.coffee
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
fs = require("fs")
gulp = require("gulp")
glob = require("glob")
iconv = require("iconv-lite")
# Comments or unannotated kaomoji
IgnoredRowRegex = /^(b|j|k|!|゜|゛|・|かおすて|.+@|.+・)/
gulp.task "(゚з゚)イインデネーノ?", (callback) ->
faces = []
face_unique_keys = []
for filePath in glob.sync("src/*.txt")
data = iconv.decode(fs.readFileSync(filePath), "shift_jis")
for row in data.split("\n")
continue if row.match(IgnoredRowRegex)
rowParts = row.split(/\s+/)
rowParts.pop() # Pop off "顔文字" or "顔文字*"
annotation = rowParts.shift()
face = rowParts.join("")
face_unique_key = "#{annotation}#{face}"
continue if face_unique_key in face_unique_keys
face_unique_keys.push(face_unique_key)
faces.push({
annotation: annotation
face: face
})
console.log("Found #{faces.length} unique 顔文字")
facesJSON = JSON.stringify(faces, undefined, 2)
fs.writeFileSync("kao-shiftjis.json", iconv.encode(facesJSON, "shift_jis"))
fs.writeFileSync("kao-utf8.json", iconv.encode(facesJSON, "utf8"))
callback()
gulp.task("default", ["(゚з゚)イインデネーノ?"])