Spacy Streamlit Visualizing Custom Entity Ruler

Hey everyone,

I’m new to Spacy Streamlit, I’m trying to visualize tagged text from patterns added to my custom entity_ruler. This is the example from the Github:

models = [“en_core_web_sm”, “en_core_web_md”]
default_text = “Sundar Pichai is the CEO of Google.”
spacy_streamlit.visualize(models, default_text)

I have an Excel document I’m pulling in for creating custom labels that get added to the ruler. I’ve tried replacing the model names in the code above with “nlp” and defining the nlp as spacy.load(“en_core_web_md”). No dice. Has anyone figured this out?

When I did that, it threw an error saying cannot find ‘nlp’ model.

This is what I’m using to pull in the dataframes as labels:

nlp = spacy.load(“en_core_web_lg”)
ruler = nlp.add_pipe(“entity_ruler”, before=“ner”, config={“phrase_matcher_attr”: “LOWER”})
patterns =
for word in df_:
patterns.append({“label”: “Relationship”, “pattern”: word})
for word1 in df1_:
patterns.append({“label”: “Event”, “pattern”: word1})
for word2 in df2_:
patterns.append({“label”: “Name Type”, “pattern”: word2})
for word3 in df3_:
patterns.append({“label”: “A Type”, “pattern”: word3})
for word4 in df4_:
patterns.append({“label”: “B Type”, “pattern”: word4})
ruler.add_patterns(patterns)
ruler.add_patterns(repatterns)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.