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
import spacy | |
# make sure to download the model first | |
# use either the CLI or this line of code | |
spacy.cli.download('en_core_web_sm') | |
# load pre-trained model pipeline | |
nlp = spacy.load('en_core_web_sm') | |
# text document |
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 import displacy | |
import spacy | |
# load pre-trained model pipeline | |
nlp = spacy.load('en_core_web_sm') | |
# text document | |
text = 'spaCy is pretty cool.' | |
# apply pipeline |
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 import displacy | |
import spacy | |
# load pre-trained model pipeline | |
nlp = spacy.load('en_core_web_sm') | |
# sentence with entities | |
text = """In 2015, independent researchers from Emory University and Yahoo! Labs showed that spaCy offered the fastest syntactic parser in the world and that its accuracy was within 1% of the best available.""" | |
# apply pipeline |
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
import pandas as pd | |
import spacy | |
from spacy import displacy | |
# load pre-trained model pipeline | |
nlp = spacy.load('en_core_web_sm') | |
# sentence for grammar rules | |
text = """He does not eat meat, but he loves Beyond Burgers.""" |
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
import typing as t | |
import spacy | |
# load pre-trained model pipeline | |
nlp = spacy.load('en_core_web_sm') | |
# sentence for grammar rules | |
text = """He does not eat meat, but he loves Beyond Burgers.""" | |
# apply pipeline |
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
import spacy | |
from spacy.pipeline import EntityRuler | |
from spacy import displacy | |
# load pre-trained model pipeline | |
nlp = spacy.load('en_core_web_sm') | |
# sentence for grammar rules | |
text = """He does not eat meat, but he loves Beyond Burgers.""" |
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
import time | |
from joblib import Parallel, delayed | |
class OnlyOne: | |
"""Singleton Class, inspired by | |
https://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html""" | |
class __OnlyOne: | |
def __init__(self, arg): | |
if arg is None: | |
raise ValueError("Pretend empty instantiation breaks code") |
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
import time | |
from joblib import Parallel, delayed | |
import os | |
class OnlyOne: | |
"""Singleton Class, inspired by | |
https://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html | |
Modified to work with parallel processes using environment | |
variables to store state across processes. |
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
import time | |
from joblib import Parallel, delayed | |
class OnlyOne: | |
"""Singleton Class, inspired by | |
https://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html""" | |
class __OnlyOne: | |
def __init__(self, arg): | |
if arg is None: | |
raise ValueError("Pretend empty instantiation breaks code") |