Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# transformers パイプラインのインポート
|
@@ -29,11 +30,16 @@ text = st.text_area("入力テキスト", default_text)
|
|
29 |
|
30 |
# 翻訳ボタンが押されたときの処理
|
31 |
if st.button("翻訳する"):
|
32 |
-
# Create an empty element for displaying the result
|
33 |
-
result_container = st.empty()
|
34 |
-
|
35 |
# Perform translation
|
36 |
result = st.session_state.session_models[model](text)[0]['translation_text']
|
37 |
|
38 |
-
#
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# transformers パイプラインのインポート
|
|
|
30 |
|
31 |
# 翻訳ボタンが押されたときの処理
|
32 |
if st.button("翻訳する"):
|
|
|
|
|
|
|
33 |
# Perform translation
|
34 |
result = st.session_state.session_models[model](text)[0]['translation_text']
|
35 |
|
36 |
+
# Save the data to a CSV file
|
37 |
+
data = {'ID': [1], 'Original Text': [text], 'Result': [result]}
|
38 |
+
df = pd.DataFrame(data)
|
39 |
+
df.to_csv('translation_data.csv', mode='a', header=not st.session_state.csv_created, index=False)
|
40 |
+
|
41 |
+
# Update the CSV creation flag
|
42 |
+
st.session_state.csv_created = True
|
43 |
+
|
44 |
+
# Display the result
|
45 |
+
st.write(f"翻訳結果: {result}")
|