Download augmentoolkit/utils/extract_first_words.py from Leon4gr45/agent-0: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/extract_first_words.py
- Command line
-
hf download hf://spaces/Leon4gr45/agent-0/augmentoolkit/utils/extract_first_words.py
-
curl -L -o extract_first_words.py https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/extract_first_words.py
481 Bytes
| import re | |
| def extract_first_words(character_name, text): | |
| # Regular expression pattern to extract first word after the character's name | |
| pattern = rf"{character_name}: \"(\w+)" | |
| # Find all matches in the text | |
| matches = re.findall(pattern, text) | |
| return matches | |
| def remove_think_tags(text): | |
| # Use regex to remove anything between <think> and </think> tags | |
| cleaned_text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL) | |
| return cleaned_text | |