Download utils.py from adorkin/GliLem: direct link, hf CLI and curl.
- Browser
- Download file 315 Bytes
-
https://huggingface.co/spaces/adorkin/GliLem/resolve/main/utils.py
- Command line
-
hf download hf://spaces/adorkin/GliLem/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/adorkin/GliLem/resolve/main/utils.py
315 Bytes
| def sentence_to_spans(tokenized_sentence: list[str]) -> dict[str, int]: | |
| span_to_token_id_ = dict() | |
| start = 0 | |
| for index, token_ in enumerate(tokenized_sentence): | |
| span_to_token_id_[f"{start + index}-{start + index + len(token_)}"] = index | |
| start += len(token_) | |
| return span_to_token_id_ | |