Spaces:
Runtime error
Runtime error
Download llmriddles/questions/math_tools.py from OpenDILabCommunity/LLMRiddlesChatGPTEN: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN/resolve/main/llmriddles/questions/math_tools.py
- Command line
-
hf download hf://spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN/llmriddles/questions/math_tools.py
-
curl -L -o math_tools.py https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN/resolve/main/llmriddles/questions/math_tools.py
552 Bytes
| import re | |
| def check_if_is_number(text: str): | |
| try: | |
| int(text) | |
| return True | |
| except ValueError: | |
| return False | |
| def get_all_numbers_in_a_sentence(text: str): | |
| return [int(i) for i in re.findall(r'[-+]?\d+', text)] | |
| def get_all_numbers_in_a_sentence_with_comma(text: str): | |
| #remove comma in numbers | |
| text = text.replace(',', '') | |
| return [int(i) for i in re.findall(r'[-+]?\d+', text)] | |
| def get_all_numbers(text: str): | |
| return get_all_numbers_in_a_sentence(text) + get_all_numbers_in_a_sentence_with_comma(text) | |