Spaces:
Running
Running
Rohan Kumar Singh
commited on
Commit
•
c46f47a
1
Parent(s):
866bf4b
added app.py
Browse files- .gitattributes +2 -0
- app.py +47 -0
- requirements.txt +6 -0
- translator/fingerprint.pb +3 -0
- translator/saved_model.pb +3 -0
- translator/variables/variables.data-00000-of-00001 +3 -0
- translator/variables/variables.index +0 -0
- vocab_data.pkl +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
translator/variables/variables.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
36 |
+
vocab_data.pkl filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pickle
|
3 |
+
import pandas as pd
|
4 |
+
import numpy
|
5 |
+
import tensorflow as tf
|
6 |
+
import tensorflow_text as tf_text
|
7 |
+
from metaphone import doublemetaphone
|
8 |
+
import re
|
9 |
+
|
10 |
+
with open('vocab_data.pkl', 'rb') as fp:
|
11 |
+
hin_vocab = pickle.load(fp)
|
12 |
+
vocab_keys=[l for l in hin_vocab]
|
13 |
+
reloaded = tf.saved_model.load("translator")
|
14 |
+
|
15 |
+
def t_text(line):
|
16 |
+
line=re.sub("[.!?\\-\'\"]", "",line).lower().strip()
|
17 |
+
string=''
|
18 |
+
for j in line.split(' '):
|
19 |
+
if doublemetaphone(j)[0]+'*'+doublemetaphone(j[::-1])[0]+'*'+j[:2]+'*'+j[len(j)-1:] in vocab_keys:
|
20 |
+
string=string+list(hin_vocab[doublemetaphone(j)[0]+'*'+doublemetaphone(j[::-1])[0]+'*'+j[:2]+'*'+j[len(j)-1:]])[0]+' '
|
21 |
+
else:
|
22 |
+
string=string+j+' '
|
23 |
+
return string.lower().strip()
|
24 |
+
|
25 |
+
|
26 |
+
st.header("Hinglish-English Translator")
|
27 |
+
|
28 |
+
st.subheader("Please enter your text!")
|
29 |
+
st.text("")
|
30 |
+
|
31 |
+
input = st.text_area("Enter here")
|
32 |
+
|
33 |
+
if st.button('Check Now!'):
|
34 |
+
#transformed_sms = transform_text(input)
|
35 |
+
#vector_input = tfidf.transform([transformed_sms])
|
36 |
+
#result = model.predict(vector_input)[0]
|
37 |
+
#if result == 1:
|
38 |
+
# st.error("Spam")
|
39 |
+
#else:
|
40 |
+
# st.success("Not Spam")
|
41 |
+
st.write(reloaded.tf_translate(
|
42 |
+
tf.constant([
|
43 |
+
t_text(input)
|
44 |
+
]))['text'][0].numpy().decode())
|
45 |
+
#st.write(t_text(input))
|
46 |
+
#st.write("Thank you! I hope you liked it. ")
|
47 |
+
#st.write("Check out this Repo's [GitHub Link](https://github.com/RohanHBTU/spam_classifier)")
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy==1.23.4
|
2 |
+
pandas==1.5.1
|
3 |
+
streamlit==1.16.0
|
4 |
+
tensorflow==2.10.1
|
5 |
+
tensorflow-text==2.10.0
|
6 |
+
Metaphone==0.6
|
translator/fingerprint.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f36c3ac5042d694f91674e5d57803c0849690d0d19b5f2aec36fc2f00b1ad1d8
|
3 |
+
size 53
|
translator/saved_model.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4edad44ea730e1a765211878b7e98a8eaa29f692161d61395de173b2973232a8
|
3 |
+
size 869541
|
translator/variables/variables.data-00000-of-00001
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2c23e4e0810af1b0c2fa933ca31b43a2716a5e311a5b020c8a806eba57f7bd3f
|
3 |
+
size 79039391
|
translator/variables/variables.index
ADDED
Binary file (1.24 kB). View file
|
|
vocab_data.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bd4663d6290c3455a6425c08142a0122613bfc4893f34089486ad8ed51d51cc2
|
3 |
+
size 1710406
|