跳转到内容

User:ColorfulGalaxy/Programs

此后如竟没有炬火,我便是唯一的光。
ColorfulGalaxy留言 | 贡献2025年9月6日 (六) 21:33的版本 (Update the programs list with new programs written in September 2025)

xdi8tools.py

Unfortunately, I still have no idea how to obtain the entire Shidinn dictionary database (including ).

from xdict import dict_xdi8
# dict_xdi8 is a Shidinn dictionary e.g. { '一':'NV','二':'42' }

b1i45=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,(0),0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,44,39,42,22,23,38,26,41,0,0,0,0,0,0,0,
       0,35,27,0,11,34,25,0,14,0,0,0,37,0,15,0,
       0,0,0,0,40,0,43,0,0,36,0,0,0,0,0,0,
       0,31,1,28,17,33,29,19,21,45,5,20,16,3,9,32,
       2,6,13,12,18,30,24,4,7,8,10,0,0,0,0,0,0]+65535*[0]
b1i90000=[(((i-1)%9+1) * (10**((i-1)//9))if i!=0 else 0) for i in b1i45]
xdi8hanzi=list(dict_xdi8.keys())

def b1i45encode(word):
    return ' '.join((str(b1i45[ord(q)]) if len(str(b1i45[ord(q)]))>=2 else '0'+str(b1i45[ord(q)])) for q in word)

def b1i90000sum(word):
    return sum([b1i90000[ord(q)] for q in word])

def translate_into_xdi8(word,sep=''):
    return sep.join((dict_xdi8[q] if (q in xdi8hanzi) else q) for q in word)

Infinite song list tools

The chart will be placed in User:ColorfulGalaxy/荆哲歌单/可排序表格. (citation needed)

Convert json to python dictionary

Takes Module:Songlist-brief.json as input.

import json
version="03443a"
with open("songlist-brief-"+version+".json","r",encoding="utf-8") as f:
    data=json.load(f)

with open("songlist_brief_"+version+".py","w",encoding="utf-8") as g:
    print('songlist=',data,file=g)

print('done')

Convert python dictionary to wiki chart

from songlist_brief_03443a import songlist
import sys
import os.path
from xdi8tools import *

songnumbers=list(songlist['songlist'].keys())

timelist={}
keylist={}
keymodlist={}
titleclasslist={}

# 30 day song challenge
tdsclist={}

saltdatelist={}

# 与之 旋律/和声/节奏/曲风 相近的音游曲目
rhythmgamesonglist={} 

f=open("songlist-wikifile.txt","w",encoding="utf-8")

f.write("\'\'\'Lucas Song List\'\'\', also called the Infinite Song List, is a system organized by Lucas that maps popular songs to integers in a somewhat mathematical manner. \n")
f.write("The current database version is 03443a. The list below may contain errors, mainly because the Shidinn translator (programmed manually by ColorfulGalaxy) is unable to handle homograph.\n\n")

f.write("{| class=\"wikitable sortable\"\n");
f.write("! Number !! Song title !! Singers !! Title in Shidinn !! b1i45 index !! Shidinn numeral sum !! Time signature !! Key signature !! Key modulation (half-steps) !! [http://puzzling.stackexchange.com/questions/106137 Title category] !! Day # in<br>original<br>30-day song<br>challenge !! Salt song guess date !! 与之 旋律/和声/节奏/曲风 相近的音游曲目\n");

for p in range(len(songnumbers)):
    f.write("|-\n")
    f.write("| "+songnumbers[p]+" || ")
    f.write(songlist['songlist'][songnumbers[p]]['song']['name']+" || "+','.join(songlist['songlist'][songnumbers[p]]['song']['singers'])+" || ")
    f.write(translate_into_xdi8(songlist['songlist'][songnumbers[p]]['song']['name'],sep=' ')+" || ")
    f.write(b1i45encode(translate_into_xdi8(songlist['songlist'][songnumbers[p]]['song']['name']))[0:17]+" || ")
    f.write(str(b1i90000sum(translate_into_xdi8(songlist['songlist'][songnumbers[p]]['song']['name'])))+" || \n") # TODO
f.write("|}")

f.close()

Older programs

Chart generator (August 2025 - a new version using custom xdi8tools module should be uploaded)

import sys
import os.path
import pypinyin
import xdi8string # all the characters spaced out translated into shidinn
f=open("wikifile.txt","w",encoding="utf-8")

characters=[chr(i) for i in range(0x4e00,0xa000)]
plaintext=' '.join(chr(n) for n in range(0x4e00,0xa000))
ciphertext=xdi8string.output

b1i45=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,(0),0,0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,44,39,42,22,23,38,26,41,0,0,0,0,0,0,0,
       0,35,27,0,11,34,25,0,14,0,0,0,37,0,15,0,
       0,0,0,0,40,0,43,0,0,36,0,0,0,0,0,0,
       0,31,1,28,17,33,29,19,21,45,5,20,16,3,9,32,
       2,6,13,12,18,30,24,4,7,8,10,0,0,0,0,0,0]
b1i90000=[(((i-1)%9+1) * (10**((i-1)//9))if i!=0 else 0) for i in b1i45]

def b1i45encode(word):
    return ' '.join((str(b1i45[ord(q)]) if len(str(b1i45[ord(q)]))>=2 else '0'+str(b1i45[ord(q)])) for q in word)

def b1i90000sum(word):
    return sum([b1i90000[ord(q)] for q in word])

plain=plaintext.split()
cipher=ciphertext.split()

maxlength=0
maxlench=[]

f.write("Do not simply rely on this chart to translate, as this chart did not handle [[talk:希顶日本语#注意多音字|homograph]] properly. The calculation may be incorrect. If so, please fix it.")

f.write("{| class=\"wikitable sortable\"\n");
f.write("! Character !! Unicode decimal !! Stroke count !! han4 yu3 pin1 yin1 !! xdi8 aho !! [[b1i45密码|b1i45]] !! xdi8 aho letter count !! [[希顶解经|Numeral sum]] !! Stress pattern !! Notes\n")
for p in range(len(plain)):
    if(plain[p]!=cipher[p]):
        f.write("|-\n");
        f.write("| "+plain[p]+" || ")
        f.write(str(ord(plain[p])))
        f.write(" || || ")
        f.write(pypinyin.pinyin(characters[p],style=pypinyin.Style.TONE3,neutral_tone_with_five=True)[0][0])
        f.write(" || "+cipher[p])
        f.write(" || "+b1i45encode(cipher[p]))
        f.write(" || "+str(len(cipher[p])))
        f.write(" || "+str(b1i90000sum(cipher[p])) + "\n")
        if(maxlength<len(cipher[p])):
            maxlench=[p]
            maxlength=len(cipher[p])
        elif(maxlength<=len(cipher[p])):
            maxlench+=[p]
f.write("|}")
print(maxlench,maxlength,len(maxlench))

f.close();