Remove double spaces in the prompt and generations to standardize spacing.
(self)
| 89 | return len(self.generations) |
| 90 | |
| 91 | def remove_extra_spaces(self): |
| 92 | """ |
| 93 | Remove double spaces in the prompt and generations to standardize spacing. |
| 94 | """ |
| 95 | def clean(text: str) -> str: |
| 96 | return re.sub(r'[ \t]{2,}', ' ', text) |
| 97 | |
| 98 | # Clean the prompt |
| 99 | for turn in self.prompt: |
| 100 | turn['content'] = clean(turn['content']) |
| 101 | |
| 102 | # Clean the generations |
| 103 | for x in self.generations: |
| 104 | for turn in x: |
| 105 | turn["content"] = clean(turn["content"]) |
| 106 | |
| 107 | |
| 108 | class Dataset: |
no outgoing calls
no test coverage detected