Number spaCy
Number spaCy is a custom spaCy pipeline component that enhances the identification of number entities in text and fetches the parsed numeric values using spaCy's token extensions. It uses RegEx to identify number entities written in words and then leverages the word2number library to convert those words into structured numeric data. The output numeric value is stored in a custom entity extension: ._.number.
This lightweight component can be seamlessly added to an existing spaCy pipeline or integrated into a blank model. If using within an existing spaCy pipeline, ensure to insert it before the NER model.
Installation
To install Number spaCy, execute:
pip install number-spacy
Usage
Integrating the Component into your spaCy Pipeline
Begin by importing the find_numbers component and then integrating it into your spaCy pipeline:
import spacy
from number_spacy import find_numbers
# Initialize your preferred spaCy model
nlp = spacy.blank('en')
# Integrate the component into the pipeline
nlp.add_pipe('find_numbers')
Text Processing with the Pipeline
Post the component addition, you can process text as you typically would:
doc = nlp("I have three apples. She gave me twenty-two more, and now I have twenty-five apples in total.")
Retrieving the Parsed Numbers
You can loop through the entities in the doc and access the specific number extension:
for ent in doc.ents:
if ent.label_ == "NUMBER":
print(f"Text: {ent.text} -> Parsed Number: {ent._.number}")
This should output:
Text: three -> Parsed Number: 3
Text: twenty-two -> Parsed Number: 22
Text: twenty-five -> Parsed Number: 25
Metadata
Release files for number-spacy 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| number_spacy-0.0.1.tar.gz | 3.3 kB | Without provenance | Details for number_spacy-0.0.1.tar.gz |
Release files / number_spacy-0.0.1.tar.gz
| Download URL | number_spacy-0.0.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4c27e7f7ed093223bc48abf24b13a4dc3444b2639860cd3267d754cdb36f372
|
|
BLAKE2b-256 checksum How to use checksums |
dbaea3ec63882ffb200376d6c32269885f14e4fae6470fe3aac6c22030e25e88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.5
|
Security for number-spacy 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.