Pclanglais commited on
Commit
1995166
1 Parent(s): 4c91de3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -24,18 +24,24 @@ css = """
24
  .manuscript {
25
  display: flex;
26
  margin-bottom: 20px;
 
27
  }
28
  .annotation {
29
- width: 30%;
30
  padding-right: 20px;
31
  color: grey;
32
  font-style: italic;
 
33
  }
34
  .content {
35
  width: 70%;
36
  }
37
- h3 {
38
  margin-top: 0;
 
 
 
 
39
  }
40
  </style>
41
  """
@@ -104,11 +110,11 @@ def transform_chunks(marianne_segmentation):
104
 
105
  html_output = []
106
  for _, row in marianne_segmentation.iterrows():
107
- entity_group = row['entity_group']
108
  word = row['word']
109
 
110
  if entity_group == 'title':
111
- html_output.append(f'<div class="manuscript"><div class="annotation">{entity_group}</div><div class="content"><h3>{word}</h3></div></div>')
112
  else:
113
  html_output.append(f'<div class="manuscript"><div class="annotation">{entity_group}</div><div class="content">{word}</div></div>')
114
 
@@ -131,7 +137,7 @@ class MistralChatBot:
131
  batch_prompts = [editorial_text]
132
 
133
  out = token_classifier(batch_prompts)
134
- out = transform_chunks(out[0])
135
  generated_text = f'{css}<h2 style="text-align:center">Réponse</h2>\n<div class="generation">{out}</div>'
136
  return generated_text
137
 
 
24
  .manuscript {
25
  display: flex;
26
  margin-bottom: 20px;
27
+ align-items: flex-start; /* Align items to the top */
28
  }
29
  .annotation {
30
+ width: 10%;
31
  padding-right: 20px;
32
  color: grey;
33
  font-style: italic;
34
+ padding-top: 5px; /* Add some top padding to align with the title */
35
  }
36
  .content {
37
  width: 70%;
38
  }
39
+ h2 {
40
  margin-top: 0;
41
+ margin-bottom: 10px; /* Add some bottom margin for spacing */
42
+ }
43
+ .title-content {
44
+ margin-top: -5px; /* Negative margin to offset the padding of annotation */
45
  }
46
  </style>
47
  """
 
110
 
111
  html_output = []
112
  for _, row in marianne_segmentation.iterrows():
113
+ entity_group = "<" + capitalize(row['entity_group']) + ">"
114
  word = row['word']
115
 
116
  if entity_group == 'title':
117
+ html_output.append(f'<div class="manuscript"><div class="annotation">{entity_group}</div><div class="content title-content"><h2>{word}</h2></div></div>')
118
  else:
119
  html_output.append(f'<div class="manuscript"><div class="annotation">{entity_group}</div><div class="content">{word}</div></div>')
120
 
 
137
  batch_prompts = [editorial_text]
138
 
139
  out = token_classifier(batch_prompts)
140
+ out = transform_chunks(pd.concat(out))
141
  generated_text = f'{css}<h2 style="text-align:center">Réponse</h2>\n<div class="generation">{out}</div>'
142
  return generated_text
143