Skip to content

Instantly share code, notes, and snippets.

View iridiumblue's full-sized avatar
💭
Heads down on deep learning ...

iridiumblue

💭
Heads down on deep learning ...
View GitHub Profile
@schaunwheeler
schaunwheeler / doc_to_spans.py
Last active May 6, 2020 16:39
Example of how to use spaCy to process many texts at once
from spacy import load as spacy_load
# This loads the largest English corpus, which must be downloaded
# separate from package installation. Other choices are available.
nlp = spacy_load('en_core_web_lg')
def doc_to_spans(list_of_texts, join_string=' ||| '):
all_docs = nlp(' ||| '.join(list_of_texts))
split_inds = [i for i, token in enumerate(all_docs) if token.text == '|||'] + [len(all_docs)]
@jdreaver
jdreaver / scientificspin.py
Last active March 2, 2023 19:45
A Scientific Notation Double Spin Box for PyQt/PySide
# Regular expression to find floats. Match groups are the whole string, the
# whole coefficient, the decimal part of the coefficient, and the exponent
# part.
_float_re = re.compile(r'(([+-]?\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)')
def valid_float_string(string):
match = _float_re.search(string)
return match.groups()[0] == string if match else False