Instructions to use Mbiot/spacy-custom with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- spaCy
How to use Mbiot/spacy-custom with spaCy:
!pip install https://huggingface.co/Mbiot/spacy-custom/resolve/main/spacy-custom-any-py3-none-any.whl # Using spacy.load(). import spacy nlp = spacy.load("spacy-custom") # Importing as module. import spacy-custom nlp = spacy-custom.load() - Notebooks
- Google Colab
- Kaggle
File size: 812 Bytes
f576f97 8d2f457 f576f97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import spacy
from typing import Dict, Any, List
class EndpointHandler:
def __init__(self, path: str = ""):
# Load the spaCy model. Make sure you've added it in requirements.txt
self.nlp = spacy.load(path)
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
# Accept both 'inputs' and 'text' as valid keys
text = data.get("inputs") or data.get("text") or ""
if not text:
return [{"error": "Missing input text"}]
doc = self.nlp(text)
results = []
for ent in doc.ents:
results.append({
"text": ent.text,
"start": ent.start_char,
"end": ent.end_char,
"label": ent.label_
})
return results |