def generate_highlight_table(dataframe, max_rows=10): usecolumns_df = ("residue", "EBI_section", "sent") usecolumns_names = ("Residue", "Section", "Sentence Context") table_list = [] header = html.Tr([html.Th(col) for col in usecolumns_names]) table_list.append(header) for i in range(min(len(dataframe), max_rows)): row_list = [] for col in usecolumns_df: if col == "sent": children = [ dataframe.iloc[i]["prefix"], html.Mark(dataframe.iloc[i]["string"]), dataframe.iloc[i]["postfix"] ] row_list.append(html.Td(html.P(children=children))) else: row_list.append(html.Td(dataframe.iloc[i][col])) table_list.append(html.Tr(row_list)) return html.Table(table_list)
def highlight_multiple_materials(body, materials): if len(materials) > 0 and any([material in body for material in materials]): newtext = [] for material in materials: highlighted_phrase = html.Mark(material) if len(newtext) > 0: for body in newtext: if type(body) == 'string' and len(material) > 0 and material in body: chopped = body.split(material) newnewtext = [] i = newtext.index(body) for piece in chopped[:-1]: newnewtext.append(piece) newnewtext.append(highlighted_phrase) newnewtext.append(chopped[-1]) newtext[i:i + 1] = newnewtext else: if len(material) > 0 and material in body: chopped = body.split(material) for piece in chopped[:-1]: newtext.append(piece) newtext.append(highlighted_phrase) newtext.append(chopped[-1]) return newtext return body
def highlight_material(body, material): highlighted_phrase = html.Mark(material) if len(material) > 0 and material in body: chopped = body.split(material) newtext = [] for piece in chopped[:-1]: newtext.append(piece) newtext.append(highlighted_phrase) newtext.append(chopped[-1]) return newtext return body
def generate_errors_tab_html_components(sentences): html_components = [] for i_sent, sent in enumerate(sentences): sent_span = sent.get_spans("ner") if not sent_span: html_components.append(html.P(sent.to_original_text())) else: temp_list = [] index = 0 for span in sent_span: start = span.start_pos end = span.end_pos temp_list.append(sent.to_original_text()[index:start]) index = end tag = span.tag type_tag = tag[-1] new_tag = tag[:-2] if type_tag == "C": # this is a correct tag. Put it in green in CSS style tagged_text = html.Mark(children=span.text, **{ "data-correcttab": ENTITIES_DICT[new_tag], "data-index": "" }) elif type_tag == "E": tagged_text = html.Mark(children=span.text, **{ "data-errortab": ENTITIES_DICT[new_tag], "data-index": "" }) temp_list.append(tagged_text) temp_list.append(sent.to_original_text()[index:]) html_components.append(html.P(temp_list)) return html_components
def highlight_pseudo(paragraph): """ Hghlight pseudonymized text for Dash tool """ index = 0 new_str = [] for change in re.finditer('<ano>(.*?)</ano>', paragraph): b = change.start(0) e = change.end(0) new_str.append(paragraph[index:b]) new_str.append(html.Mark(change.group(1), style={'color': 'blue'})) index = e new_str.append(paragraph[index:]) return html.P(new_str)
def generate_upload_tab_html_components(sentences, original_text): html_components = [] for i_sent, sent in enumerate(sentences): sent_span = sent.get_spans("ner") if not sent_span: html_components.append(html.P(sent.to_original_text())) else: temp_list = [] index = 0 for span in sent_span: start = span.start_pos end = span.end_pos temp_list.append(original_text[i_sent][index:start]) index = end temp_list.append( html.Mark(children=span.text, **{"data-entity": ENTITIES[span.tag], "data-index": ""})) temp_list.append(original_text[i_sent][index:]) html_components.append(html.P(temp_list)) return html_components
def decode_text(res, keywords=None): txt = res['_source']['raw_txt'] if keywords: parts = [txt] for kw in keywords: i = 0 while i < len(parts): t = parts[i] if isinstance(t, str): els = re.split(kw, t, flags=re.IGNORECASE) new_list = intersperse(els, html.Mark(kw)) parts = parts[:i] + new_list + parts[i + 1:] i += 1 el = [html.Code(parts)] else: el = html.Code(txt) return html.Pre(el, style={ "border": "3px", "border-style": "solid", "padding": "1em" })
'select * from "gharchivemomtest" order by month_created_at_1', con=conn) recent = pd.read_sql_query( 'select count_1 from "gharchive" order by date_created_at_1 desc limit 1', con=conn).count_1[0] text = df4.weekly_increase_rate.round(3).apply(lambda x: str(x * 100) + '%') text = df_mom.monthly_increase_rate.round(3).apply( lambda x: str(x * 100) + '%') app_alyout = html.Div([ html.Ul([ html.Li([ html.H1([ html.Mark('Repo Census', style={ 'display': 'inline-block', 'line-height': '0em', 'padding-bottom': '0.5em' }) ]) ], style={ 'display': 'inline-block', 'float': 'left' }), html.Li([ html.Div( [ html.Div([ html.Center([ html.P( 'YESTERDAY (' + str(df4['date_created_at_1'][
def text_style(text, search_term): if search_term in text: words = text.split(search_term) return html.Div( [words[0], html.Mark(search_term, style={'color': 'red'}), words[1]])
dcc.Markdown(f""" La performance d'un modèle de REN dépend du nombre de documents et d'entités annotées. Estimer la quantité des données à annoter est un premier pas lors du lancement d'une campagne d'annotation. Nous affichons ici un aperçu sur l'impact du volume des données d'entrainement par rapport à la pertinence d'un système REN. À droite, nous observons les annotations faites par huit modèles différents sur la même décision de justice. Ces modèles varient par rapport à la taille du corpus d'entraînement utilisé (de 80 à 2400 documents). """), html.P( ["""Ces annotations se distinguent par trois types de résultats :"""]), html.P([ "1. ", html.Mark("Entité bien repérée", **{"data-correcttab": "PRENOM"}), ": une entité à occulter bien identifiée." ]), html.P([ "2. ", html.Mark("Entité non-repérée", **{"data-errortab": "NON REPÉRÉ"}), ": une entité à occulter non identifiée par le modèle ;" ]), html.P([ "3. ", html.Mark("Entité sur-repérée", **{"data-errortab": "PRENOM"}), ": un mot identifié tandis qu'il ne faut pas l'occulter." ]), html.Br(), dcc.Markdown("""
html.H1('一级标题', id='demo1'), html.H2('二级标题'), html.H3('三级标题'), html.H4('四级标题'), html.H5('五级标题'), html.H6('六级标题'), html.Br(), # 换行 html.Hr(), # 水平分割线 html.P('这是一段文字。' * 20), html.P('这是另一段带有首行缩进的文字。' * 10, style={'text-indent': '3rem'}), html.A('跳转到费弗里的Github仓库', target='_blank', href='https://github.com/CNFeffery/DataScienceStudyNotes' ), # 跳转到外部链接 html.Br(), html.A('跳转到六级标题', href='#demo2'), html.P([ '一段文字中出现了', html.I('斜体'), ',以及代码片段', html.Code('import dash'), ',还有一段', html.U('带下划线的文字'), ',一段', html.Mark('高亮标注文字'), ',以及另一段', html.Mark('不同颜色的高亮标注文字。', style={'background-color': 'lightblue'}) ]) ] + [html.Br()] * 50 + [html.A('回到顶端一级标题', href='#demo1'), html.H1('页内元素跳转示例标题', id='demo2')])) if __name__ == '__main__': app.run_server(debug=True)
# asd flask_app = flask.Flask(__name__) bootstrapcss = ['https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', ] app = dash.Dash(__name__,external_stylesheets = bootstrapcss,server=flask_app, suppress_callback_exceptions=True) app.title = "MutualFund - Allocation" app.layout = html.Div(children = [ html.Div(className = "text-center p-3 mb-2 bg-dark text-white",children = [ html.H1(className = ".text-secondary display-2 ",children = [ 'Mutual Fund - Allocation' ]), html.P(children = ["Analysis Done by ",html.Mark(html.A('Syed Shahab Uddin', href = 'https://github.com/syedshahab698/'))]) ]), html.Div([ html.Div(className = "text-center p-3 mb-2",children = [ html.Blockquote(className = "blockquote text-center",children = [ html.P(className = "mb-0", children = """A mutual fund can do for you what you would do for yourself if you had sufficient time, training and money to diversify, plus the temperament to stand back from your money and make rational decisions. """), html.Br(), html.Footer(className = "blockquote-footer", children="Venita VanCaspel") ]) ]),