Instructions to use magepol/en_generic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- spaCy
How to use magepol/en_generic with spaCy:
!pip install https://huggingface.co/magepol/en_generic/resolve/main/en_generic-any-py3-none-any.whl # Using spacy.load(). import spacy nlp = spacy.load("en_generic") # Importing as module. import en_generic nlp = en_generic.load() - Notebooks
- Google Colab
- Kaggle
Download custom_functions.py from magepol/en_generic: direct link, hf CLI and curl.
- Browser
- Download file 671 Bytes
-
https://huggingface.co/magepol/en_generic/resolve/main/custom_functions.py
- Command line
-
hf download hf://magepol/en_generic/custom_functions.py
-
curl -L -o custom_functions.py https://huggingface.co/magepol/en_generic/resolve/main/custom_functions.py
671 Bytes
| import spacy | |
| from spacy.tokenizer import Tokenizer | |
| def create_custom_tokenizer(): | |
| def create_tokenizer(nlp): | |
| infixes = nlp.Defaults.infixes + [ | |
| r"/", | |
| r"-", | |
| r",", | |
| r":", | |
| ] | |
| prefixes = nlp.Defaults.prefixes + [ | |
| r"-", | |
| ] | |
| prefix_regex = spacy.util.compile_prefix_regex(prefixes) | |
| infix_regex = spacy.util.compile_infix_regex(infixes) | |
| return Tokenizer( | |
| nlp.vocab, | |
| prefix_search=prefix_regex.search, | |
| infix_finditer=infix_regex.finditer, | |
| ) | |
| return create_tokenizer | |