Skip to content
Snippets Groups Projects
Commit 91d68179 authored by finn's avatar finn
Browse files

Fix handling of nan values

parent 639a1aad
No related branches found
No related tags found
No related merge requests found
......@@ -55,9 +55,17 @@ def slot_accuracy(domain_knowledge, annotation):
Returns:
float: Slot accuracy score.
"""
if pd.isna(domain_knowledge) or pd.isna(annotation):
# Handle the nan values
return 0
domain_knowledge = domain_knowledge.replace('null', 'None')
annotation = annotation.replace('null', 'None')
domain_knowledge = ast.literal_eval(domain_knowledge)
annotation = ast.literal_eval(annotation)
count = {"True": 0, "False": 0, "Total": 0}
for detail in domain_knowledge["Details"]:
......@@ -88,6 +96,7 @@ def main(input_file, output_file):
input_file (str): Path to the input CSV file.
output_file (str): Path to the output CSV file.
"""
df = pd.read_csv(input_file, sep=',', quoting=csv.QUOTE_NONE, escapechar='/', index_col=False)
df['slot_accuracy_original'] = df.apply(lambda row: slot_accuracy(row['Domain Knowledge'], row['original_annotation']), axis=1)
df['slot_accuracy_generated'] = df.apply(lambda row: slot_accuracy(row['Domain Knowledge'], row['generated_annotation']), axis=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment