cecilemacaire commited on
Commit
e25275e
·
verified ·
1 Parent(s): 9faa492

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -26,12 +26,24 @@ def get_id_picto_from_predicted_lemma(df_lexicon, lemma):
26
 
27
  # Génération du contenu HTML pour afficher les pictogrammes
28
  def generate_html(ids):
29
- html_content = '<html><body>'
 
 
 
 
 
 
 
 
 
 
 
 
30
  for picto_id, lemma in ids:
31
  if picto_id != 0: # ignore invalid IDs
32
  img_url = f"https://static.arasaac.org/pictograms/{picto_id}/{picto_id}_500.png"
33
  html_content += f'''
34
- <figure style="display:inline-block; margin:1px;">
35
  <img src="{img_url}" alt="{lemma}" width="200" height="200" />
36
  <figcaption>{lemma}</figcaption>
37
  </figure>
@@ -52,4 +64,4 @@ if sentence:
52
  pictogram_ids = [get_id_picto_from_predicted_lemma(lexicon, lemma) for lemma in sentence_to_map]
53
 
54
  html = generate_html(pictogram_ids)
55
- st.components.v1.html(html, height=600, scrolling=True)
 
26
 
27
  # Génération du contenu HTML pour afficher les pictogrammes
28
  def generate_html(ids):
29
+ html_content = '<html><head><style>'
30
+ html_content += '''
31
+ figure {
32
+ display: inline-block;
33
+ margin: 1px;
34
+ text-align: center;
35
+ font-family: Arial, sans-serif;
36
+ }
37
+ figcaption {
38
+ margin-top: 5px;
39
+ }
40
+ '''
41
+ html_content += '</style></head><body>'
42
  for picto_id, lemma in ids:
43
  if picto_id != 0: # ignore invalid IDs
44
  img_url = f"https://static.arasaac.org/pictograms/{picto_id}/{picto_id}_500.png"
45
  html_content += f'''
46
+ <figure>
47
  <img src="{img_url}" alt="{lemma}" width="200" height="200" />
48
  <figcaption>{lemma}</figcaption>
49
  </figure>
 
64
  pictogram_ids = [get_id_picto_from_predicted_lemma(lexicon, lemma) for lemma in sentence_to_map]
65
 
66
  html = generate_html(pictogram_ids)
67
+ st.components.v1.html(html, height=600, width=1200, scrolling=True)