Coverage for src/wiktextract/extractor/de/utils.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-12-27 08:07 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-12-27 08:07 +0000
1import re
4def extract_sense_index(node_text: str) -> tuple[str, str]:
5 # [1], [1-2], [1, 2], [1.1], [1a]
6 match = re.match(r"\[[\d\sa-z,.\-?]*\]", node_text)
7 if match is not None:
8 sense_idx = match.group(0).replace("?", "").strip("[] ")
9 node_text = node_text[match.end() :].strip()
10 else:
11 sense_idx = ""
13 return sense_idx, node_text