Fralet commited on
Commit
688b656
·
verified ·
1 Parent(s): 0f375b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -29,17 +29,18 @@ def main():
29
  # Read data
30
  data = pd.read_csv(uploaded_file)
31
  # Check if 'Description' and 'Published' columns exist
32
- if 'Description' in data.columns and 'Published' in data.columns:
33
- # Apply full translation and summarization based on 'Published' column
34
- data['Full Summary'] = data.apply(
35
- lambda row: translate_and_summarize(row['Description']) if pd.isna(row['Published']) else "", axis=1
36
- )
37
- # Apply first paragraph translation and summarization
38
- data['First Paragraph Summary'] = data['Description'].apply(translate_and_summarize_first_paragraph)
39
  # Display data in a table
40
- st.write(data[['ID', 'Title', 'Full Summary', 'First Paragraph Summary']])
 
 
 
41
  else:
42
- st.error("Uploaded CSV does not contain required 'Description' and 'Published' columns.")
43
 
44
  if __name__ == "__main__":
45
  main()
 
29
  # Read data
30
  data = pd.read_csv(uploaded_file)
31
  # Check if 'Description' and 'Published' columns exist
32
+ if 'Description' in data.columns:
33
+ # Apply full translation and summarization
34
+ data['DescriptionEn'] = data['Description'].apply(translate_and_summarize)
35
+ # Apply first paragraph translation and summarization for Title
36
+ data['Title'] = data['Description'].apply(translate_and_summarize_first_paragraph)
 
 
37
  # Display data in a table
38
+ st.write(data[['ID', 'Title', 'DescriptionEn']])
39
+ # Provide download link for the updated CSV
40
+ csv = data.to_csv(index=False)
41
+ st.download_button(label="Download updated CSV", data=csv, file_name="updated_data.csv", mime="text/csv")
42
  else:
43
+ st.error("Uploaded CSV does not contain required 'Description' column.")
44
 
45
  if __name__ == "__main__":
46
  main()