From 472de4398ec3feb9906e2d3811aec89a0088aa38 Mon Sep 17 00:00:00 2001 From: Ryuichi Takano <45957617+tknrych@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:05:44 +0900 Subject: [PATCH] Fixing: Error due to no available words in the sentence If there are no available words in the sentence, the process exits this function. --- code/eda.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/eda.py b/code/eda.py index e4cedb2..8dc464f 100644 --- a/code/eda.py +++ b/code/eda.py @@ -176,6 +176,10 @@ def eda(sentence, alpha_sr=0.1, alpha_ri=0.1, alpha_rs=0.1, p_rd=0.1, num_aug=9) words = sentence.split(' ') words = [word for word in words if word is not ''] num_words = len(words) + + # If there are no available words in the sentence, the process exits this function. + if num_words == 0: + return words augmented_sentences = [] num_new_per_technique = int(num_aug/4)+1 @@ -220,4 +224,4 @@ def eda(sentence, alpha_sr=0.1, alpha_ri=0.1, alpha_rs=0.1, p_rd=0.1, num_aug=9) #append the original sentence augmented_sentences.append(sentence) - return augmented_sentences \ No newline at end of file + return augmented_sentences