Instructions to use kenisgod/en_ingredient_extract with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- spaCy
How to use kenisgod/en_ingredient_extract with spaCy:
!pip install https://huggingface.co/kenisgod/en_ingredient_extract/resolve/main/en_ingredient_extract-any-py3-none-any.whl # Using spacy.load(). import spacy nlp = spacy.load("en_ingredient_extract") # Importing as module. import en_ingredient_extract nlp = en_ingredient_extract.load() - Notebooks
- Google Colab
- Kaggle
File size: 597 Bytes
190f79e 066e2b0 190f79e | 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 | from typing import Dict, List, Any
import spacy
class EndpointHandler:
def __init__(self, path=""):
self.nlp = spacy.load(path)
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
Your mom.
"""
# Get inputs
text_input = data.pop("inputs", "")
# Perform regular model task
result = self.nlp(text_input)
# Return the result
entities = []
for ent in result.ents:
entities.append({"text": ent.text, "label": ent.label_, "id": ent.ent_id_})
return entities
|