# Your script here from transformers import MarianMTModel, MarianTokenizer model_name = "Helsinki-NLP/opus-mt-en-hi" model = MarianMTModel.from_pretrained(model_name) tokenizer = MarianTokenizer.from_pretrained(model_name) def translate_english_to_hindi(text): inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True) translated = model.generate(**inputs) translated_text = tokenizer.decode(translated[0], skip_special_tokens=True) return translated_text idiom_meanings = { "Break the ice": "पहली बार बातचीत शुरू करना, ताकि माहौल हल्का हो सके", "A blessing in disguise": "कोई नज़र में मुश्किल, लेकिन अंत में फायदेमंद", "Hit the nail on the head": "सही बात कहना या करना", "Bite the bullet": "मुसीबत को सहना और उसका सामना करना", "Burn the midnight oil": "रात-रात भर काम करना", "Cry over spilt milk": "जो हो चुका है उसके लिए पछताना", "Cut to the chase": "सीधे मुद्दे पर आना", "Give someone the cold shoulder": "किसी को अनदेखा करना", "Once in a blue moon": "बहुत कम होना", "Out of the blue": "अचानक से", "Spill the beans": "गुप्त बातों का खुलासा करना", "The ball is in your court": "अब तुम्हारी बारी है", "Through thick and thin": "सुख-दुख में साथ देना", "Under the weather": "स्वस्थ नहीं होना", "When pigs fly": "जब कुछ असंभव हो", "Your guess is as good as mine": "मुझे भी उतना ही पता है जितना तुम्हें", "You scratch my back, and I’ll scratch yours": "आप मेरी मदद करेंगे तो मैं भी आपकी मदद करूंगा" } def get_meaning_and_translation(idiom): meaning = idiom_meanings.get(idiom, "Meaning not found.") translation = translate_english_to_hindi(idiom) return {"idiom": idiom, "meaning": meaning, "translation": translation} input_idiom = "When pigs fly" result = get_meaning_and_translation(input_idiom) print(f"Idiom: {result['idiom']}") print(f"Meaning: {result['meaning']}") print(f"Translation: {result['translation']}")