change_number / app.py
xucx123's picture
Update app.py
8590c5d
import gradio as gr
import pandas as pd
num_dict =\
{'11':"伏位",\
'22':"伏位",\
'33':"伏位",\
'44':"伏位",\
'66':"伏位",\
'77':"伏位",\
'88':"伏位",\
'99':"伏位",\
'19':"延年",\
'26':"延年",\
'34':"延年",\
'43':"延年",\
'62':"延年",\
'78':"延年",\
'87':"延年",\
'91':"延年",\
'14':"生氣",\
'28':"生氣",\
'39':"生氣",\
'41':"生氣",\
'67':"生氣",\
'76':"生氣",\
'82':"生氣",\
'93':"生氣",\
'13':"天醫",\
'27':"天醫",\
'31':"天醫",\
'49':"天醫",\
'68':"天醫",\
'72':"天醫",\
'86':"天醫",\
'94':"天醫",\
'17':"禍害",\
'23':"禍害",\
'32':"禍害",\
'46':"禍害",\
'64':"禍害",\
'71':"禍害",\
'89':"禍害",\
'98':"禍害",\
'16':"六煞",\
'29':"六煞",\
'38':"六煞",\
'47':"六煞",\
'61':"六煞",\
'74':"六煞",\
'83':"六煞",\
'92':"六煞",\
'12':"絕命",\
'21':"絕命",\
'37':"絕命",\
'48':"絕命",\
'69':"絕命",\
'73':"絕命",\
'84':"絕命",\
'96':"絕命",\
'18':"五鬼",\
'24':"五鬼",\
'36':"五鬼",\
'42':"五鬼",\
'63':"五鬼",\
'79':"五鬼",\
'81':"五鬼",\
'97':"五鬼"}
alp_dict={\
'A':'01',
'B':'02',
'C':'03',
'D':'04',
'E':'05',
'F':'06',
'G':'07',
'H':'08',
'I':'09',
'J':'10',
'K':'11',
'L':'12',
'M':'13',
'N':'14',
'O':'15',
'P':'16',
'Q':'17',
'R':'18',
'S':'19',
'T':'20',
'U':'21',
'V':'22',
'W':'23',
'X':'24',
'Y':'25',
'Z':'26'}
def chg_number(Input):
x_text=str(Input).upper().replace(" ","").rstrip()
for i,j in alp_dict.items():
x_text=x_text.replace(i,j)
w=0
while w < len(x_text):
if x_text[w]!='0':
if w == 0:
x_text=x_text
else:
x_text=x_text[w-1:]
break
w=w+1
if x_text[0]=='5' or\
x_text[0]=='0':
x_text=x_text[1]+x_text[1:]
if x_text[-1]=='5' or\
x_text[-1]=='0':
x_text=x_text[0:-1]+x_text[-2]
x_text=x_text.replace('951',"9#1")
x_text=x_text.replace('159',"1#9")
x_text=x_text.replace('5',"")
for i in range(0,len(x_text)-1):
if x_text[i]=='0':
x_text=x_text[:i]+x_text[i-1]+x_text[i+1:]
chg_dict={}
for i in range(0,len(x_text)-1):
temp_x=x_text[i:i+2]
if temp_x=='9#':
temp_x='91'
elif temp_x=='#9':
temp_x='19'
elif temp_x=='1#':
temp_x='19'
elif temp_x=='#1':
temp_x='91'
else:
temp_x=temp_x
chg_dict[i]=[temp_x,num_dict[str(temp_x)]]
text="數字"+" "+"對應\n"
for key, value in chg_dict.items():
text=text+value[0]+" "+value[1]+"\n"
return text
demo = gr.Interface(
fn=chg_number,
inputs=gr.Textbox(lines=2, placeholder="英文或數字"),
outputs="text",
title="人生的易經數字",
description="輸人英文及數字尋找對應的吉星和凶星",
)
demo.launch()