Lamp Socrates commited on
Commit
100e8bf
·
1 Parent(s): b5dd5bc

fixed model id

Browse files
Files changed (1) hide show
  1. app.py +48 -5
app.py CHANGED
@@ -21,6 +21,53 @@ def load_trained_model():
21
  ner_pipeline = pipeline("ner", model=model, tokenizer = tokenizer)
22
  return ner_pipeline
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  def prep_page():
25
  model = load_trained_model()
26
 
@@ -70,11 +117,7 @@ def prep_page():
70
 
71
  st.markdown(styled_text, unsafe_allow_html=True)
72
 
73
- def load_data():
74
- from datasets import load_dataset
75
- dat_CW = load_dataset("surrey-nlp/PLOD-CW")
76
-
77
-
78
 
79
  if __name__ == '__main__':
80
 
 
21
  ner_pipeline = pipeline("ner", model=model, tokenizer = tokenizer)
22
  return ner_pipeline
23
 
24
+ def load_data():
25
+ from datasets import load_dataset
26
+ dat_CW = load_dataset("surrey-nlp/PLOD-CW")
27
+
28
+
29
+ def render_entities(tokens, entities):
30
+ """
31
+ Renders a page with a 2-column table showing the entity corresponding to each token.
32
+ """
33
+ # Page configuration
34
+ st.set_page_config(page_title="NER Token Entities", layout="centered")
35
+
36
+ # Custom CSS for chilled and cool theme
37
+ st.markdown("""
38
+ <style>
39
+ body {
40
+ font-family: 'Arial', sans-serif;
41
+ background-color: #f0f0f5;
42
+ color: #333333;
43
+ }
44
+ table {
45
+ width: 100%;
46
+ border-collapse: collapse;
47
+ }
48
+ th, td {
49
+ padding: 12px;
50
+ text-align: left;
51
+ border-bottom: 1px solid #dddddd;
52
+ }
53
+ th {
54
+ background-color: #4CAF50;
55
+ color: white;
56
+ }
57
+ tr:hover {
58
+ background-color: #f5f5f5;
59
+ }
60
+ </style>
61
+ """, unsafe_allow_html=True)
62
+
63
+ # Title and description
64
+ st.title("Token Entities Table")
65
+ st.write("This table shows the entity corresponding to each token in a cool and chilled theme.")
66
+
67
+ # Create the table
68
+ table_data = {"Token": tokens, "Entity": entities}
69
+ st.table(table_data)
70
+
71
  def prep_page():
72
  model = load_trained_model()
73
 
 
117
 
118
  st.markdown(styled_text, unsafe_allow_html=True)
119
 
120
+ render_entities(text, entities)
 
 
 
 
121
 
122
  if __name__ == '__main__':
123