Skip to main content

textpipe: clean and extract metadata from text

Project description

textpipe: clean and extract metadata from text

Build Status

The textpipe logo

textpipe is a Python package for converting raw text in to clean, readable text and extracting metadata from that text. Its functionalities include transforming raw text into readable text by removing HTML tags and extracting metadata such as the number of words and named entities from the text.

Vision: the zen of textpipe

  • Designed for use in production pipelines without adult supervision.
  • Rechargeable batteries included: provide sane defaults and clear examples to adapt.
  • A uniform interface with thin wrappers around state-of-the-art NLP packages.
  • As language-agnostic as possible.
  • Bring your own models.


  • Clean raw text by removing HTML and other unreadable constructs
  • Identify the language of text
  • Extract the number of words, number of sentences, named entities from a text
  • Calculate the complexity of a text
  • Obtain text metadata by specifying a pipeline containing all desired elements
  • Obtain sentiment (polarity and a subjectivity score)
  • Generates word counts
  • Computes minhash for cheap similarity estimation of documents


It is recommended that you install textpipe using a virtual environment.

python3 -m venv .venv
  • Using virtualenv.
virtualenv venv -p python3.6
  • Using virtualenvwrapper
mkvirtualenv textpipe -p python3.6
  • Install textpipe using pip.
pip install textpipe
  • Install the required packages using requirements.txt.
pip install -r requirements.txt

A note on spaCy download model requirement

While the requirements.txt file that comes with the package calls for spaCy's en_core_web_sm model, this can be changed depending on the model and language you require for your intended use. See's page on their different models for more information.

Usage example

>>> from textpipe import doc, pipeline
>>> sample_text = 'Sample text! <!DOCTYPE>'
>>> document = doc.Doc(sample_text)
>>> print(document.clean)
'Sample text!'
>>> print(document.language)
>>> print(document.nwords)

>>> pipe = pipeline.Pipeline(['CleanText', 'NWords'])
>>> print(pipe(sample_text))
{'CleanText': 'Sample text!', 'NWords': 3}

In order to extend the existing Textpipe operations with your own proprietary operations;

test_pipe = pipeline.Pipeline(['CleanText', 'NWords'])
def custom_op(doc, context=None, settings=None, **kwargs):
    return 1

custom_argument = {'argument' :1 }
test_pipe.register_operation('CUSTOM_STEP', custom_op)
test_pipe.steps.append(('CUSTOM_STEP', custom_argument ))


See CONTRIBUTING for guidelines for contributors.



  • Bumps redis, tqdm, pyling


  • Bumps versions of many dependencies including textacy. Results for keyterm extraction changed.


  • Exposes arbitrary SpaCy ents properties


  • Exposes SpaCy's cats attribute


  • Bumps spaCy and redis versions


  • Fixes bug where gensim model is not cached in pipeline


  • Raise TextpipeMissingModelException instead of KeyError


  • Bumps spaCy and datasketch dependencies


  • Replaces codacy with pylint on CI
  • Fixes pylint issues


  • Adds wrapper around Gensim keyed vectors to construct document embeddings from Redis cache


  • Adds functionality to compute document embeddings using a Gensim word2vec model


  • Removes non standard utf chars before detecting language


  • Bump spaCy to 2.1.3


  • Fix broken install command


  • Fix broken install command


  • Fix copy-paste error in word vector aggregation (#118)


  • Fixes bugs in several operations that didn't accept kwargs


  • Bumps Spacy to 2.1


  • Pins Spacy and Pattern versions (with pinned lxml)


  • change operation's registry from list to dict
  • global pipeline data is available across operations via the context kwarg
  • load custom operations using register_operation in pipeline
  • custom steps (operations) with arguments

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for textpipe, version 0.12.2
Filename, size File type Python version Upload date Hashes
Filename, size textpipe-0.12.2.tar.gz (37.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page