@@ -162,7 +162,7 @@ def create_plotly_viz(df):
162
162
conclusion = df ["conclusion" ].value_counts ()
163
163
conclusion_label = []
164
164
for i in list (conclusion .index ):
165
- conclusion_label .append (string_breaker ( i , 15 ))
165
+ conclusion_label .append (string_wordbreaker ( i ))
166
166
fig4 = px .bar (
167
167
x = conclusion .index ,
168
168
y = conclusion ,
@@ -274,7 +274,7 @@ def generate_UNCLEAR(df):
274
274
conclusion_boqa = df_unclear ["BOQA_prediction" ].value_counts ()
275
275
labels_trim = []
276
276
for i in list (conclusion_boqa .index ):
277
- labels_trim .append (string_breaker ( i , 15 ))
277
+ labels_trim .append (string_wordbreaker ( i ))
278
278
fig = px .bar (
279
279
x = conclusion_boqa .index ,
280
280
y = conclusion_boqa ,
@@ -311,7 +311,7 @@ def generate_confusion_BOQA(df):
311
311
labels = ["No_Pred" ] + df_no_unclear ["conclusion" ].unique ().tolist ()
312
312
labels_trim = []
313
313
for i in list (labels ):
314
- labels_trim .append (string_breaker ( i , 15 ))
314
+ labels_trim .append (string_wordbreaker ( i ))
315
315
matrix_results = confusion_matrix (
316
316
# y_true, y_pred, labels=["No_Pred", "CNM", "COM", "NM"]
317
317
y_true ,
@@ -449,3 +449,19 @@ def string_breaker(s, max_length=10):
449
449
new_string .append (s [i * max_length : i * max_length + max_length ])
450
450
new_string .append (s [lines_nb * max_length :])
451
451
return "<br>" .join (new_string )
452
+
453
+
454
+ def string_wordbreaker (s , max_length = 20 ):
455
+ s .replace ("-" , " " )
456
+ s = s .split (" " )
457
+ new_string = ["" ]
458
+ index_new_string = 0
459
+ for i in s :
460
+ if len (new_string [index_new_string ] + " " + i ) >= 20 :
461
+ index_new_string += 1
462
+ new_string .append ("" )
463
+ new_string [index_new_string ] = i
464
+ else :
465
+ new_string [index_new_string ] += " "
466
+ new_string [index_new_string ] += i
467
+ return "<br>" .join (new_string )
0 commit comments