|
import streamlit as st |
|
import pandas as pd |
|
from transformers import pipeline |
|
|
|
|
|
translator = pipeline("translation_ru_to_en", model="Helsinki-NLP/opus-mt-ru-en") |
|
summarizer = pipeline("summarization", model="facebook/bart-large-cnn") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def translate_and_summarize(text): |
|
translated_text = translator(text)[0]['translation_text'] |
|
summary = summarizer(translated_text, max_length=140, min_length=110, do_sample=False)[0]['summary_text'] |
|
return summary |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
st.title("CSV Translator and Summarizer") |
|
|
|
|
|
uploaded_file = st.file_uploader("Choose a CSV file", type="csv") |
|
if uploaded_file is not None: |
|
|
|
data = pd.read_csv(uploaded_file) |
|
|
|
|
|
|
|
if 'Description' in data.columns: |
|
|
|
|
|
data['Summary'] = data['Description'].apply(translate_and_summarize) |
|
|
|
|
|
st.write(data[['ID', 'Title', 'Summary']]) |
|
|
|
else: |
|
st.error("Uploaded CSV does not contain 'Description' column.") |
|
|
|
if __name__ == "__main__": |
|
main() |