Download augmentoolkit/utils/extract_steps.py from Leon4gr45/agent-0: direct link, hf CLI and curl.
- Browser
- Download file 668 Bytes
-
https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/extract_steps.py
- Command line
-
hf download hf://spaces/Leon4gr45/agent-0/augmentoolkit/utils/extract_steps.py
-
curl -L -o extract_steps.py https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/extract_steps.py
668 Bytes
| import re | |
| def extract_steps(text, steps=[2, 4, 5]): | |
| """ | |
| Extracts the specified steps from the text. | |
| Args: | |
| text (str): The input text containing various steps. | |
| steps (list of int): The step numbers to extract. | |
| Returns: | |
| str: A new string with each specified step's content on its own line. | |
| """ | |
| step_pattern = "|".join([f"Step {step}\." for step in steps]) | |
| matches = re.findall( | |
| f"({step_pattern})\s*(.*?)\s*(?=(Step \d\.|$))", text, re.DOTALL | |
| ) | |
| # Extract and join the matched content, skipping the "Step n." part | |
| extracted_text = "\n".join(match[1].strip() for match in matches) | |
| return extracted_text | |