Skip to content

Instantly share code, notes, and snippets.

@frutik
Last active April 3, 2023 16:34
Show Gist options
  • Save frutik/c42751d81842f8aa3f0005d9518dbb58 to your computer and use it in GitHub Desktop.
Save frutik/c42751d81842f8aa3f0005d9518dbb58 to your computer and use it in GitHub Desktop.
from spacy.pipeline import EntityRuler
import spacy
nlp = spacy.blank("nl")
ruler = nlp.add_pipe("entity_ruler")
ruler.from_disk('fb.jsonl')
doc = nlp("I like Ralph Lauren and fruit of THE LOOM")
print([(ent.text, ent.label_) for ent in doc.ents])
{"label":"FASHION_BRAND","pattern":[{"lower":"fruit"},{"lower":"of"},{"lower":"the"},{"lower":"loom"}]}
{"label":"FASHION_BRAND","pattern":[{"lower":"ralph"},{"lower":"lauren"}]}
{"label":"FASHION_BRAND","pattern":[{"lower":"uniqlo"}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment