Spaces:
Runtime error
Runtime error
Update sami
Browse files12345678910111213141516171819202122232425262728293031323334353637383940import gradio as grimport pandas as pdimport redef check_spacing(csv_file):# 讀取 CSV 檔案df = pd.read_csv(csv_file.name)# 將所有的內容合併成一個大的字串進行檢查text = ' '.join(df.astype(str).values.flatten())# 使用正則表達式來查找$符號兩側的中文字之間沒有空格的地方pattern = r'[\u4e00-\u9fa5]\$[\u4e00-\u9fa5]'matches = re.finditer(pattern, text)# 收集所有錯誤的地方errors = []for match in matches:errors.append((match.start(), match.group()))# 如果有錯誤,列出所有錯誤if errors:error_list = []for error in errors:error_list.append(f"錯誤位置:{error[0]},內容:{error[1]}")return "\n".join(error_list)else:return "未發現錯誤"# 使用 Gradio 來建立介面interface = gr.Interface(fn=check_spacing,inputs=gr.File(file_types=['.csv', '.xls', '.pdf']),outputs="text",title="中文校對系統",description="上傳一個CSV、XLS 或 PDF 檔案,系統會檢查$符號前後的中文字是否有空格")# 啟動 Gradio 介面interface.launch()
sami+40