-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_dic.jq
executable file
·51 lines (49 loc) · 1.46 KB
/
generate_dic.jq
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
#!/usr/bin/jq -rf
# Takes a filtered dictionary as input, and produces a hunspell(5)
# .dic file.
# Prefix all the data with a word count, as per hunspell(5).
(.words | keys | length)+(.names | length),
(.words
# Do the actual data processing
| map(
.word
+ "/kc" # Mark all words as not allowing changes in their case.
+ (
# Forbid suggesting words that are neither recognized by
# either >=66% of word survey respondants, nor in pu.
if (
(.book == "pu")
or (
(.usage >= ((1/3)*2)*100)
)
) then
""
else
"/ns"
end
)
+ (
# If the word object contains an array with the parts of speech,
# include it. If it does not, just silently move on.
# Parts of speech are currently not stored in Linku itself,
# but rather comes from our augment.json, awaiting it appearing
# in nimi Linku someday.
if (.pos != null) then
(.pos | " po:" + join(" po:"))
else
""
end
)
# + (
# # Add any additional hunspell flags.
# if (.flags != null) then
# (.flags | join(" "))
# else
# ""
# end
# )
)[]
)
, (.names
| map(. + "/kc po:name")[]
)