Skip to content

Commit

Permalink
Refactor split method in robustness.py to split on space character ex…
Browse files Browse the repository at this point in the history
…plicitly
  • Loading branch information
chakravarthik27 committed Sep 11, 2024
1 parent 4448c71 commit 134de82
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions langtest/transform/robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def transform(sample_list: List[Sample], prob: Optional[float] = 1.0) -> List[Sa
"""
for idx, sample in enumerate(sample_list):
if isinstance(sample, str):
words = sample.split()
words = sample.split(" ")
num_transform_words = int(prob * len(words))
transformed_indices = random.sample(
range(len(words)), num_transform_words
Expand Down Expand Up @@ -422,7 +422,7 @@ def transform(sample_list: List[Sample], prob: Optional[float] = 1.0) -> List[Sa
"""
for idx, sample in enumerate(sample_list):
if isinstance(sample, str):
words = sample.split()
words = sample.split(" ")
num_transform_words = int(prob * len(words))
transformed_indices = random.sample(
range(len(words)), num_transform_words
Expand All @@ -433,7 +433,7 @@ def transform(sample_list: List[Sample], prob: Optional[float] = 1.0) -> List[Sa
]
sample_list[idx] = " ".join(transformed_words)
else:
words = sample.original.split()
words = sample.original.split(" ")
num_transform_words = int(prob * len(words))
transformed_indices = random.sample(
range(len(words)), num_transform_words
Expand Down Expand Up @@ -466,7 +466,7 @@ def transform(sample_list: List[Sample], prob: Optional[float] = 1.0) -> List[Sa
"""
for idx, sample in enumerate(sample_list):
if isinstance(sample, str):
words = sample.split()
words = sample.split(" ")
num_transform_words = int(prob * len(words))
transformed_indices = random.sample(
range(len(words)), num_transform_words
Expand All @@ -477,7 +477,7 @@ def transform(sample_list: List[Sample], prob: Optional[float] = 1.0) -> List[Sa
]
sample_list[idx] = " ".join(transformed_words)
else:
words = sample.original.split()
words = sample.original.split(" ")
num_transform_words = int(prob * len(words))
transformed_indices = random.sample(
range(len(words)), num_transform_words
Expand Down

0 comments on commit 134de82

Please sign in to comment.