Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

app.py 3.2 KB

You have to be logged in to leave a comment. Sign In
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  1. # Core Pkgs
  2. import streamlit as st
  3. import json
  4. import pandas as pd
  5. import itertools
  6. # Fxn to Load Data
  7. @st.cache
  8. def load_data(json_file):
  9. with open(json_file) as f:
  10. data = json.load(f)
  11. return data
  12. # Get the Value
  13. def get_value(val,my_dict):
  14. for key ,value in my_dict.items():
  15. if val == key:
  16. return value
  17. # Get the Keys
  18. def get_key(val,my_dict):
  19. for key ,value in my_dict.items():
  20. if val == value:
  21. return key
  22. def main():
  23. """Emoji Lookup App"""
  24. st.title("Emoji Lookup")
  25. st.subheader("Built with Streamlit and :heart:")
  26. activities = ["Search","Reverse-Search","Emoji-2-Unicode","Unicode-2-Emoji","Combi","Sentiment-Table","About"]
  27. menu = st.sidebar.selectbox("Select Task",activities)
  28. data = load_data("data/emoji.json")
  29. if menu == 'Search':
  30. st.subheader("Search Emoji")
  31. raw_text = st.text_input("Search Emoji","Type Here")
  32. search_text = raw_text.lower()
  33. if raw_text is not 'Type Here':
  34. if search_text in tuple(data.keys()):
  35. result = ':{}:'.format(search_text)
  36. st.success("Found {}".format(result))
  37. st.markdown(result)
  38. st.text("Usage :=> {}".format(result))
  39. else:
  40. st.warning("{} Not Found".format(search_text))
  41. elif menu == 'Reverse-Search':
  42. st.subheader("Reverse-Search Emoji")
  43. raw_text = st.text_input("Search Emoji","Type Here")
  44. rsearch_text = raw_text.lower()
  45. if raw_text is not 'Type Here':
  46. if rsearch_text in tuple(data.values()):
  47. st.success("Found {}".format(rsearch_text))
  48. result2 = get_key(rsearch_text,data)
  49. st.text("Emoji Text is => :{}:".format(result2))
  50. else:
  51. st.warning("{} Not Found".format(rsearch_text))
  52. elif menu == 'Emoji-2-Unicode':
  53. st.subheader("Search Unicode for Emoji")
  54. raw_text = st.text_input("Search Unicode","Emoji Here")
  55. df = pd.read_csv("data/Emoji_Sentiment_Data.csv")
  56. new_df = df.loc[df['Emoji'] == raw_text]
  57. if new_df.empty:
  58. st.warning("{} Not Found".format(raw_text))
  59. else:
  60. st.dataframe(new_df[['Emoji','Unicode codepoint','Unicode name']])
  61. elif menu == 'Unicode-2-Emoji':
  62. st.subheader("Unicode-2-Emoji")
  63. raw_text = st.text_input("Search Emoji","Unicode Here")
  64. df = pd.read_csv("data/Emoji_Sentiment_Data.csv")
  65. new_df = df.loc[df['Unicode codepoint'] == raw_text]
  66. if new_df.empty:
  67. st.warning("{} Not Found".format(raw_text))
  68. else:
  69. st.dataframe(new_df[['Emoji','Unicode codepoint','Unicode name']])
  70. elif menu == 'Combi':
  71. st.subheader("Combine Multiple Emojis")
  72. limit = st.number_input("Select Number of Emoji Limit",5,len(data.items()))
  73. c_data = dict(itertools.islice(data.items(),limit))
  74. multi_combi = st.multiselect("Select Multiple Emoji",tuple(c_data.keys()))
  75. combi_list = [':{}:'.format(i) for i in multi_combi]
  76. # for i in multi_combi:
  77. # rsult = ':{}:'.format(i)
  78. st.markdown(' '.join(combi_list))
  79. elif menu == 'Sentiment-Table':
  80. st.subheader("Sentiment-Table For Emoji")
  81. df = pd.read_csv("data/Emoji_Sentiment_Data.csv")
  82. st.dataframe(df)
  83. elif menu == 'About':
  84. st.subheader("About Emoji Lookup App")
  85. st.markdown("Built with [Streamlit](https://www.streamlit.io/) by [JCharisTech](https://www.jcharistech.com/)")
  86. st.text("Jesse E.Agbe(JCharis)")
  87. st.text("Credits to [Omnidan,Thomasseleck,JCharis]")
  88. st.success("Jesus Saves @JCharisTech")
  89. if __name__ == '__main__':
  90. main()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...