Atharva commited on
Commit
cebe0ce
1 Parent(s): d716414

style update

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,6 +1,6 @@
 
1
  import pandas as pd
2
  import streamlit as st
3
- import streamlit.components.v1 as components
4
  from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
5
 
6
  from src import GBRT, wikipedia_search, google_search
@@ -67,11 +67,9 @@ def get_candidates(mentions_tags):
67
  # ---------------------------------------------------------------------------
68
  def display_tag(text, typ, label):
69
  if label != 'NIL':
70
- label = "https://en.wikipedia.org/wiki/" + label
71
- return f'<a style="margin: 0px 5px 0px 0px; padding: 2px 4px; border-radius: 4px; text-decoration:none; background-color:{COLOR[typ]}; color: white; cursor:pointer; white-space: nowrap; font-weight:400" href={label} target="_blank"><span style="margin-right:2px;">{text}</span><span style="background-color: white; color: {COLOR[typ]}; padding: 1px 2px; border-radius: 4px; font-size: 0.8em">{typ}</span></a>'
72
  else:
73
- return f'<span style="margin: 0px 5px 0px 0px; padding: 2px 4px; border-radius: 4px; text-decoration:none; background-color: #EF4444; color: white; cursor:not-allowed; white-space: nowrap;"><span style="margin-right:2px">{text}</span><span style="background-color: white; color: #EF4444; padding: 1px 2px; border-radius: 4px; font-size: 0.8em">{typ}</span></span>'
74
-
75
 
76
 
77
  # ---------------------------------------------------------------------------
@@ -97,8 +95,8 @@ def main(text):
97
 
98
  with col2:
99
  st.write("### Disambiguated Text")
100
- components.html(f'<div style="white-space: pre-line; line-height: 1.65; font-family: sans-serif">{tagged}</div>',
101
- height=700, scrolling=True)
102
 
103
  df = pd.DataFrame(data=preditions, columns=['Mention', 'Prediction', 'Confidence'])
104
  st.write("**Additional Information**")
@@ -114,5 +112,3 @@ if __name__ == '__main__':
114
  'George Washington went to Washington.', height=350)
115
  if user_input:
116
  main(user_input)
117
-
118
-
 
1
+ from turtle import color
2
  import pandas as pd
3
  import streamlit as st
 
4
  from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
5
 
6
  from src import GBRT, wikipedia_search, google_search
 
67
  # ---------------------------------------------------------------------------
68
  def display_tag(text, typ, label):
69
  if label != 'NIL':
70
+ return f'<span style="color: {COLOR[typ]}" class="tag">[**{text}** <small>{typ}</small>](https://en.wikipedia.org/wiki/{label})</span>'
 
71
  else:
72
+ return f'<span style="color: #EF4444" class="tag">**{text}** <small>{typ}</small></span>'
 
73
 
74
 
75
  # ---------------------------------------------------------------------------
 
95
 
96
  with col2:
97
  st.write("### Disambiguated Text")
98
+ st.markdown("<style>a {color: inherit !important; text-decoration: none;} .tag {border: 1px solid; border-radius: 5px; padding: 0px 3px;}</style>", unsafe_allow_html=True)
99
+ st.write(tagged, unsafe_allow_html=True)
100
 
101
  df = pd.DataFrame(data=preditions, columns=['Mention', 'Prediction', 'Confidence'])
102
  st.write("**Additional Information**")
 
112
  'George Washington went to Washington.', height=350)
113
  if user_input:
114
  main(user_input)