Skip to content
WooKyoung Noh edited this page Jan 22, 2019 · 2 revisions
module G
s = read("az.html", String)
re = r""">(?<name_hanzi>[\w ]+)</a>"""m

using ThreeKingdoms: 人名錄
登場人物 = keys(人名錄.登場人物)

d = Dict()
matches = collect(eachmatch(re, s))
for m in matches
    name_hanzi = m[:name_hanzi]
    !occursin(" ", name_hanzi) && continue
    (name, hanzi) = rsplit(name_hanzi; limit=2)
    if hanzi in 登場人物
        d[hanzi] = name
        #@info :name_hanzi (name, hanzi, hanzi in 登場人物)
    end
end
end # module

for line in readlines("in.jl")
    line2 = replace(line, "const " => "")
    l = eval(Meta.parse(line2))
    if haskey(G.d, l.名)
        Name = G.d[l.名]
        l = merge(l, (Name=Name,))
    else
        l
    end
    println(string("const ", l.名, " = ", l))
end

Clone this wiki locally