-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
110 lines (71 loc) · 2.23 KB
/
app.py
File metadata and controls
110 lines (71 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import pandas as pd
import numpy as np
import streamlit as st
from nltk.tokenize import word_tokenize
import os
import re
from translate import Translator
import nltk
@st.cache
def tokenize(msg):
text=msg
nltk_tokens = word_tokenize(text)
return(nltk_tokens)
@st.cache
def extract_email(msg):
text=msg
emails=re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", text)
return(emails)
@st.cache
def translate(msg):
text=msg
translator=Translator(to_lang="German")
translation = translator.translate(msg)
return(translation)
@st.cache
def count(msg):
text=msg
nltk_tokens = nltk.word_tokenize(text)
print(nltk_tokens)
print("\n")
return("Number of Words: " , len(nltk_tokens))
def main():
st.title("Visual NLP Tasks application")
st.subheader("Welcome to the application !!!! Visualize NLP tasks in one click")
if st.sidebar.checkbox("Show tokenization"):
st.subheader("tokenize your text data")
msg=st.text_area("Enter your text","Type here")
if st.button("Tokenize"):
final_result=tokenize(msg)
st.write(final_result)
if st.sidebar.checkbox("Show extracted e-mails"):
st.subheader("Extract emails from your text data")
msg=st.text_area("Enter your text for extracting e-mails","Type here")
if st.button("Extract e-mails"):
final_result=extract_email(msg)
st.write(final_result)
if st.sidebar.checkbox("Show translation into german"):
st.subheader("Translate your text data into german")
msg=st.text_area("Enter your text for translation","Type here")
if st.button("translate"):
final_result=translate(msg)
st.write(final_result)
if st.sidebar.checkbox("Calculate no. of words"):
st.subheader("calculate no. of words from text data")
msg=st.text_area("Enter your text for word counting","Type here")
if st.button("calculate"):
final_result=count(msg)
st.write(final_result)
st.markdown("""
<style>
body {
color: #fff;
background-color: #001f3f;
etc.
}
</style>
""", unsafe_allow_html=True)
st.sidebar.subheader("About App")
st.sidebar.info("This app can help you visualize NLP tasks on your text")
if __name__ == '__main__':
main()