Spaces:
Sleeping
Sleeping
Update app.py
Browse filesNER for Boycott dataset
app.py
CHANGED
@@ -1,38 +1,26 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
from spacy import displacy
|
4 |
-
from collections import Counter
|
5 |
|
6 |
-
# Load the
|
7 |
-
|
|
|
8 |
|
9 |
-
def
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
# Count the occurrences of each entity type
|
17 |
-
entity_counts = Counter([ent[1] for ent in entities])
|
18 |
-
|
19 |
-
# Visualize the named entities using displacy
|
20 |
-
ent_html = displacy.render(doc, style="ent")
|
21 |
-
|
22 |
-
return ent_html, dict(entity_counts)
|
23 |
|
24 |
def main():
|
25 |
-
st.set_page_config(page_title="
|
26 |
-
st.title("
|
27 |
-
st.write("This app uses spaCy to extract named entities from the given text and visualize them.")
|
28 |
|
29 |
-
|
30 |
|
31 |
-
if
|
32 |
-
|
33 |
-
st.markdown(
|
34 |
-
st.subheader("Entity Type Counts")
|
35 |
-
st.dataframe(entity_counts, use_container_width=True)
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
+
import json
|
|
|
|
|
3 |
|
4 |
+
# Load the data from the JSON file
|
5 |
+
with open('data.json', 'r') as f:
|
6 |
+
data = json.load(f)
|
7 |
|
8 |
+
def display_brand_info(parent_company):
|
9 |
+
brand_info = ''
|
10 |
+
for brand_id, brand in data['brands'].items():
|
11 |
+
if parent_company.lower() in brand['description'].lower():
|
12 |
+
brand_info += f"# {brand['name']}\n{brand['description']}\n---\n"
|
13 |
+
return brand_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def main():
|
16 |
+
st.set_page_config(page_title="Brand Information")
|
17 |
+
st.title("Brand Information")
|
|
|
18 |
|
19 |
+
parent_company = st.text_input("Enter Parent Company")
|
20 |
|
21 |
+
if parent_company:
|
22 |
+
brand_info = display_brand_info(parent_company)
|
23 |
+
st.markdown(brand_info)
|
|
|
|
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
main()
|