Spaces:
Runtime error
Runtime error
Download modules/tokenizer/__init__.py from erc/entity-referring-classifier: direct link, hf CLI and curl.
- Browser
- Download file 471 Bytes
-
https://huggingface.co/spaces/erc/entity-referring-classifier/resolve/main/modules/tokenizer/__init__.py
- Command line
-
hf download hf://spaces/erc/entity-referring-classifier/modules/tokenizer/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/erc/entity-referring-classifier/resolve/main/modules/tokenizer/__init__.py
471 Bytes
| from transformers import BertTokenizer | |
| tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') | |
| # Parameters preparation. | |
| MAX_SENT_LENGTH = 128 | |
| PAD_TOKEN_ID = tokenizer.convert_tokens_to_ids(tokenizer.pad_token) | |
| def normalize_v2(text, entity): | |
| text = text.lower() | |
| entity = entity.lower() | |
| if entity not in text: | |
| return text | |
| text = text.replace(entity, tokenizer.mask_token) # TODO: not sure if this will be decoded by BERT. | |
| return text |