Here is my code. It fails on this row: """ print(predtext) PyDev console: starting.…
- User
Here is my code. It fails on this row:
""" print(pred_text) PyDev console: starting. כידוע לנו בגיל ההתבגרות חלק גדול מהזהות של הפרט מתגבשת ביחס לקבוצת השווים הנער המתבגר מרגיש צורך רב להשתלב ולהיות חלק ולכן לעיתים יבצע מעשים וייסחף אחרי חבריו גם אם לא היה עושה זאת בעצמו לבד print(gold_text) כידוע לנו בגיל ההתבגרות חלק גדול מהזהות של הפרט מתגבשת ביחס לקבוצת השווים הנער המתבגר מרגיש צורך רב להשתלב ו להיות חלק ולכן לעיתים יבצע מעשים וייסחף אחרי חבריו גם אם לא היה עושה זאת בעצמו לבד """
def compute_etu_boundary_accuracy(gold_df: pd.DataFrame, pred_df: pd.DataFrame, segmented_unit_col: str, gold_segmentation_col: str): """ Computes the boundary accuracy between the gold segmentation and the predicted segmentation. - - - :param gold_df: :param pred_df: :param unit_col: :param segmented_unit_col: :param gold_segmentation_col: :return: """ # hold a list of dictionaries to store the results all_turn_boundaries = [] # for each discussion and turn, create a list of boundaries, add it to the DataFrame for (discussion, turn, du_id), gold_group in gold_df.groupby(['discussion', "turn", "du_id"]): # find the corresponding predicted segments for this discussion and turn pred_group = pred_df[ (pred_df['discussion'] == discussion) & (pred_df["turn"] == turn) & (pred_df["du_id"] == du_id) ] gold_text = get_text(gold_group)
# assure the the pred text is the same as the gold text # if they dont then we cannot compare the boundaries pred_text = get_text(pred_group) assert len(gold_text.split()) == len(pred_text.split()) acc, edit_dist, gold_b, pred_b = calc_metrics(gold_group, gold_segmentation_col, pred_group, segmented_unit_col, gold_text, pred_text) # create a dictionary with the results turn_boundary = { 'discussion': discussion, 'turn': turn, 'du_id': du_id, 'gold_boundaries': gold_b, 'pred_boundaries': pred_b, 'accuracy': acc, 'edit_distance': edit_dist, } all_turn_boundaries.append(turn_boundary) boundary_df = pd.DataFrame(all_turn_boundaries) print("Total number of DUs evaluated:", len(boundary_df)) print("Average boundary accuracy:", boundary_df['accuracy'].mean()) print("Average edit distance:", boundary_df['edit_distance'].mean()) return boundary_df - Assistant
Thanks for sharing the code and the problematic example. Based on the error context and the two print() statements: textCopyEditprint(pred_text) כידוע לנו בגיל ההתבגרות חלק גדול מהזהות של הפרט מתגבשת ביחס לקבוצת השווים הנער המתבגר מרגיש צורך רב להשתלב ולהיות חלק ולכן לעיתים יבצע מעשים וייסחף אחרי חבריו גם אם לא היה עושה זאת בעצמו לבד