Rijgersberg commited on
Commit
09bfa0e
β€’
1 Parent(s): a2dd461

Move translations to top

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -11,6 +11,18 @@ from argilla.client.feedback.dataset.remote.dataset import RemoteFeedbackDataset
11
  import gradio as gr
12
  import pandas as pd
13
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  def obtain_source_target_datasets() -> (
16
  Tuple[
@@ -84,7 +96,7 @@ def donut_chart_total() -> alt.Chart:
84
  source = pd.DataFrame(
85
  {
86
  "values": [annotated_records, pending_records],
87
- "category": ["Vertaald", "Nog te gaan"],
88
  "colors": ["#4CAF50", "#757575"], # Green for Completed, Grey for Remaining
89
  }
90
  )
@@ -94,7 +106,7 @@ def donut_chart_total() -> alt.Chart:
94
  radius=alt.Radius(
95
  "values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)
96
  ),
97
- color=alt.Color("category:N", legend=alt.Legend(title="Categorie")),
98
  )
99
 
100
  c1 = base.mark_arc(innerRadius=20, stroke="#fff")
@@ -123,7 +135,7 @@ def donut_chart_target() -> alt.Chart:
123
  source = pd.DataFrame(
124
  {
125
  "values": [annotated_records, pending_records],
126
- "category": ["Vertaald", "Nog te gaan"],
127
  "colors": ["#4CAF50", "#757575"], # Green for Completed, Grey for Remaining
128
  }
129
  )
@@ -154,14 +166,14 @@ def kpi_chart_remaining() -> alt.Chart:
154
 
155
  pending_records = int(os.getenv("TARGET_RECORDS")) - len(target_dataset)
156
  # Assuming you have a DataFrame with user data, create a sample DataFrame
157
- data = pd.DataFrame({"Category": ["Nog te gaan"], "Value": [pending_records]})
158
 
159
  # Create Altair chart
160
  chart = (
161
  alt.Chart(data)
162
  .mark_text(fontSize=100, align="center", baseline="middle", color="steelblue")
163
  .encode(text="Value:N")
164
- .properties(title="Nog te gaan", width=250, height=200)
165
  )
166
 
167
  return chart
@@ -177,14 +189,14 @@ def kpi_chart_submitted() -> alt.Chart:
177
  total = len(target_dataset)
178
 
179
  # Assuming you have a DataFrame with user data, create a sample DataFrame
180
- data = pd.DataFrame({"Category": ["Totaal vertaald"], "Value": [total]})
181
 
182
  # Create Altair chart
183
  chart = (
184
  alt.Chart(data)
185
  .mark_text(fontSize=100, align="center", baseline="middle", color="#e68b39")
186
  .encode(text="Value:N")
187
- .properties(title="Totaal vertaald", width=250, height=200)
188
  )
189
 
190
  return chart
@@ -203,7 +215,7 @@ def kpi_chart() -> alt.Chart:
203
 
204
  # Assuming you have a DataFrame with user data, create a sample DataFrame
205
  data = pd.DataFrame(
206
- {"Category": ["Aantal vertalers"], "Value": [total_annotators]}
207
  )
208
 
209
  # Create Altair chart
@@ -211,7 +223,7 @@ def kpi_chart() -> alt.Chart:
211
  alt.Chart(data)
212
  .mark_text(fontSize=100, align="center", baseline="middle", color="steelblue")
213
  .encode(text="Value:N")
214
- .properties(title="Aantal vertalers", width=250, height=200)
215
  )
216
 
217
  return chart
@@ -234,10 +246,10 @@ def obtain_top_5_users(user_ids_annotations: Dict[str, int]) -> pd.DataFrame:
234
  """
235
 
236
  dataframe = pd.DataFrame(
237
- user_ids_annotations.items(), columns=["Username", "Aantal vertalingen"]
238
  )
239
- dataframe["Username"] = dataframe["Username"].apply(render_hub_user_link)
240
- dataframe = dataframe.sort_values(by="Aantal vertalingen", ascending=False)
241
  return dataframe.head(50)
242
 
243
 
@@ -357,7 +369,7 @@ def main() -> None:
357
  )
358
 
359
  top5_df_plot = gr.Dataframe(
360
- headers=["Username", "Aantal vertalingen"],
361
  datatype=[
362
  "markdown",
363
  "number",
 
11
  import gradio as gr
12
  import pandas as pd
13
 
14
+ # Translation of legends and titels
15
+ ANNOTATED = 'Vertaald'
16
+ NUMBER_ANNOTATED = 'Totaal vertaald'
17
+ PENDING = 'Nog te gaan'
18
+
19
+ NUMBER_ANNOTATORS = "Aantal vertalers"
20
+ NAME = 'Username'
21
+ NUMBER_ANNOTATIONS = 'Aantal vertalingen'
22
+
23
+ CATEGORY = 'Categorie'
24
+
25
+
26
 
27
  def obtain_source_target_datasets() -> (
28
  Tuple[
 
96
  source = pd.DataFrame(
97
  {
98
  "values": [annotated_records, pending_records],
99
+ "category": [ANNOTATED, PENDING],
100
  "colors": ["#4CAF50", "#757575"], # Green for Completed, Grey for Remaining
101
  }
102
  )
 
106
  radius=alt.Radius(
107
  "values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)
108
  ),
109
+ color=alt.Color("category:N", legend=alt.Legend(title=CATEGORY)),
110
  )
111
 
112
  c1 = base.mark_arc(innerRadius=20, stroke="#fff")
 
135
  source = pd.DataFrame(
136
  {
137
  "values": [annotated_records, pending_records],
138
+ "category": [ANNOTATED, PENDING],
139
  "colors": ["#4CAF50", "#757575"], # Green for Completed, Grey for Remaining
140
  }
141
  )
 
166
 
167
  pending_records = int(os.getenv("TARGET_RECORDS")) - len(target_dataset)
168
  # Assuming you have a DataFrame with user data, create a sample DataFrame
169
+ data = pd.DataFrame({"Category": [PENDING], "Value": [pending_records]})
170
 
171
  # Create Altair chart
172
  chart = (
173
  alt.Chart(data)
174
  .mark_text(fontSize=100, align="center", baseline="middle", color="steelblue")
175
  .encode(text="Value:N")
176
+ .properties(title=PENDING, width=250, height=200)
177
  )
178
 
179
  return chart
 
189
  total = len(target_dataset)
190
 
191
  # Assuming you have a DataFrame with user data, create a sample DataFrame
192
+ data = pd.DataFrame({"Category": [NUMBER_ANNOTATED], "Value": [total]})
193
 
194
  # Create Altair chart
195
  chart = (
196
  alt.Chart(data)
197
  .mark_text(fontSize=100, align="center", baseline="middle", color="#e68b39")
198
  .encode(text="Value:N")
199
+ .properties(title=NUMBER_ANNOTATED, width=250, height=200)
200
  )
201
 
202
  return chart
 
215
 
216
  # Assuming you have a DataFrame with user data, create a sample DataFrame
217
  data = pd.DataFrame(
218
+ {"Category": [NUMBER_ANNOTATORS], "Value": [total_annotators]}
219
  )
220
 
221
  # Create Altair chart
 
223
  alt.Chart(data)
224
  .mark_text(fontSize=100, align="center", baseline="middle", color="steelblue")
225
  .encode(text="Value:N")
226
+ .properties(title=NUMBER_ANNOTATORS, width=250, height=200)
227
  )
228
 
229
  return chart
 
246
  """
247
 
248
  dataframe = pd.DataFrame(
249
+ user_ids_annotations.items(), columns=[NAME, NUMBER_ANNOTATIONS]
250
  )
251
+ dataframe[NAME] = dataframe[NAME].apply(render_hub_user_link)
252
+ dataframe = dataframe.sort_values(by=NUMBER_ANNOTATIONS, ascending=False)
253
  return dataframe.head(50)
254
 
255
 
 
369
  )
370
 
371
  top5_df_plot = gr.Dataframe(
372
+ headers=[NAME, NUMBER_ANNOTATIONS],
373
  datatype=[
374
  "markdown",
375
  "number",