-
-
Save dennisdv1/1c9e7754ae76e97fecbe5fa85b464dde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from spacy.pipeline import EntityRuler | |
from spacy import displacy | |
import jsonlines | |
# Create list with entity labels from jsonl file | |
with jsonlines.open(PROJECT_DIR + "data/skill_patterns.jsonl") as f: | |
created_entities = [line['label'].upper() for line in f.iter()] | |
def add_newruler_to_pipeline(skill_pattern_path): | |
'''Reads in all created patterns from a JSONL file and adds it to the pipeline after PARSER and before NER''' | |
new_ruler = EntityRuler(nlp).from_disk(skill_pattern_path) | |
nlp.add_pipe(new_ruler, after='parser') | |
def visualize_entity_ruler(entity_list, doc): | |
'''Visualize the Skill entities of a doc''' | |
options = {"ents": entity_list} | |
displacy.render(doc, style='ent', options=options) | |
visualize_entity_ruler(created_entities, doc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in this code
project_dir not defined i want know which file is that can someone explain that ??