Update app.py
Browse files1 unmodified line234567891016 unmodified lines27282930313233343 unmodified lines3839404142434468 unmodified lines1131141151 unmodified linefrom transformers import pipeline, AutoTokenizerfrom sentence_transformers import SentenceTransformer, utilimport nltknltk.download('punkt')from nltk.tokenize import sent_tokenize# Translation modelstranslation_models = {'Vietnamese': "Helsinki-NLP/opus-mt-en-vi",16 unmodified lines# Helper function to generate bullet pointsdef generate_bullet_points(text):model = SentenceTransformer('paraphrase-MiniLM-L6-v2')sentences = sent_tokenize(text)embeddings = model.encode(sentences, convert_to_tensor=True)clusters = util.community_detection(embeddings, threshold=0.75)3 unmodified linesmain_sentence = cluster_sentences[0] if cluster_sentences else ""bullet_points.append(main_sentence.strip())return "\n".join(f"- {point}" for point in bullet_points)# Helper function to split text into chunksdef split_text(text, max_tokens=1024):68 unmodified lines1 unmodified line2345678910111216 unmodified lines29303132333435363738393 unmodified lines4344454647484950515268 unmodified lines1211221231241 unmodified linefrom transformers import pipeline, AutoTokenizerfrom sentence_transformers import SentenceTransformer, utilimport nltkfrom nltk.tokenize import sent_tokenize# Download NLTK datanltk.download('punkt')# Translation modelstranslation_models = {'Vietnamese': "Helsinki-NLP/opus-mt-en-vi",16 unmodified lines# Helper function to generate bullet pointsdef generate_bullet_points(text):print("Original Text:", text)sentences = sent_tokenize(text)print("Sentences:", sentences)model = SentenceTransformer('paraphrase-MiniLM-L6-v2')embeddings = model.encode(sentences, convert_to_tensor=True)clusters = util.community_detection(embeddings, threshold=0.75)3 unmodified linesmain_sentence = cluster_sentences[0] if cluster_sentences else ""bullet_points.append(main_sentence.strip())result = "\n".join(f"- {point}" for point in bullet_points)print("Bullet Points:", result)return result# Helper function to split text into chunksdef split_text(text, max_tokens=1024):68 unmodified lines
app.py+12-3