Skip to content

Instantly share code, notes, and snippets.

View ahmedbesbes's full-sized avatar
💭
Building things, one line of code at a time 💻

Ahmed BESBES ahmedbesbes

💭
Building things, one line of code at a time 💻
View GitHub Profile
from spacy.matcher import Matcher
nlp = spacy.load("en_core_web_sm")
doc = nlp("Hello my friend!")
pattern = [
{"TEXT": "Hello"}
]
matcher = Matcher(nlp.vocab)
import spacy
# load a spacy model that detects DNA, RNA and PROTEINS from
# biomedical documents
model = spacy.load(
"en_ner_jnlpba_md",
disable=["tok2vec", "tagger", "parser", "attribute_ruler", "lemmatizer"],
)
import spacy
nlp = spacy.blanc("en")
doc_before = nlp("John lives in Atlanta")
# No entities are detected
print(doc_before.ents)
# ()
import spacy
from spacy import displacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("John lives in France and works at Apple Inc.")
print(doc.ents)
# (John, France, Apple Inc.)
import os
import spacy
nlp = spacy.load("en_core_news_sm")
texts = ... # a large list of documents
docs = []
for doc in nlp.pipe(texts, n_process=os.cpu_count()-1):
import streamlit as st
number_of_tabs = st.sidebar.number_input(
"Number of tabs",
min_value=1,
max_value=20,
value=1,
)
number_of_tabs = int(number_of_tabs)
import numpy as np
import pandas as pd
import streamlit as st
tabs = st.tabs(["metrics", "plots", "reports"])
tab_metrics = tabs[0]
with tab_metrics:
st.metric("Precision", 0.85, delta=0.2)
import streamlit as st
tabs = st.tabs(["metrics", "plots", "reports"])
tab_plots = tabs[1]
with tab_plots:
cols = st.columns(2)
with cols[0]:
st.image("./roc.png")
import streamlit as st
tabs = st.tabs(["metrics", "plots", "reports"])
tab_plots = tabs[1]
with tab_plots:
st.image("./roc.png")
import streamlit as st
tabs = st.tabs(["metrics", "plots", "reports"])
tab_metrics = tabs[0]
tab_metrics.metric("Precision", 0.85, delta=0.2)
tab_metrics.metric("Recall", 0.60, delta=-0.1)