chmawia commited on
Commit
6875f34
·
verified ·
1 Parent(s): 37e484a

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -50
app.py DELETED
@@ -1,50 +0,0 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
- from PyDictionary import PyDictionary
4
-
5
- # Load translation model for English to Urdu
6
- @st.cache_resource
7
- def load_translation_model():
8
- return pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur")
9
-
10
- translator = load_translation_model()
11
-
12
- # Initialize PyDictionary for word meanings and synonyms
13
- dictionary = PyDictionary()
14
-
15
- # Streamlit App
16
- st.title("Bilingual Dictionary")
17
- st.write("Find meanings in **English** and **Urdu**, along with synonyms for any word!")
18
-
19
- # Input word
20
- word = st.text_input("Enter a word:", "").strip()
21
-
22
- if word:
23
- # Get word meaning
24
- with st.spinner("Fetching meaning in English..."):
25
- meaning = dictionary.meaning(word)
26
- if meaning:
27
- st.subheader("Meaning in English:")
28
- for part_of_speech, definitions in meaning.items():
29
- st.write(f"**{part_of_speech.capitalize()}**:")
30
- for definition in definitions:
31
- st.write(f"- {definition}")
32
-
33
- # Translate English definition to Urdu
34
- with st.spinner("Translating to Urdu..."):
35
- try:
36
- urdu_translation = translator(definition)
37
- st.write(f"**In Urdu:** {urdu_translation[0]['translation_text']}")
38
- except Exception as e:
39
- st.error("Could not translate the definition.")
40
- else:
41
- st.error("No meaning found for the word!")
42
-
43
- # Get synonyms
44
- with st.spinner("Fetching synonyms..."):
45
- synonyms = dictionary.synonym(word)
46
- if synonyms:
47
- st.subheader("Synonyms:")
48
- st.write(", ".join(synonyms))
49
- else:
50
- st.error("No synonyms found!")