All Projects → jfilter → Clean Text

jfilter / Clean Text

Licence: other
🧹 Python package for text cleaning

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Clean Text

Mtnt
Code for the collection and analysis of the MTNT dataset
Stars: ✭ 48 (-83.1%)
Mutual labels:  scraping, natural-language-processing
Data Science
Collection of useful data science topics along with code and articles
Stars: ✭ 315 (+10.92%)
Mutual labels:  scraping, natural-language-processing
Tacred Relation
PyTorch implementation of the position-aware attention model for relation extraction
Stars: ✭ 271 (-4.58%)
Mutual labels:  natural-language-processing
Languagecrunch
LanguageCrunch NLP server docker image
Stars: ✭ 281 (-1.06%)
Mutual labels:  natural-language-processing
Bluebert
BlueBERT, pre-trained on PubMed abstracts and clinical notes (MIMIC-III).
Stars: ✭ 273 (-3.87%)
Mutual labels:  natural-language-processing
Chatbot ner
chatbot_ner: Named Entity Recognition for chatbots.
Stars: ✭ 273 (-3.87%)
Mutual labels:  natural-language-processing
Adaptnlp
An easy to use Natural Language Processing library and framework for predicting, training, fine-tuning, and serving up state-of-the-art NLP models.
Stars: ✭ 278 (-2.11%)
Mutual labels:  natural-language-processing
Awesome Ai Awesomeness
A curated list of awesome awesomeness about artificial intelligence
Stars: ✭ 268 (-5.63%)
Mutual labels:  natural-language-processing
Link Grammar
The CMU Link Grammar natural language parser
Stars: ✭ 286 (+0.7%)
Mutual labels:  natural-language-processing
Pyswip
PySwip is a Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
Stars: ✭ 276 (-2.82%)
Mutual labels:  natural-language-processing
Lambdasoup
Functional HTML scraping and rewriting with CSS in OCaml
Stars: ✭ 280 (-1.41%)
Mutual labels:  scraping
Nlp tasks
Natural Language Processing Tasks and References
Stars: ✭ 2,968 (+945.07%)
Mutual labels:  natural-language-processing
Nlp Tutorial
Tutorial: Natural Language Processing in Python
Stars: ✭ 274 (-3.52%)
Mutual labels:  natural-language-processing
Awesome Distributed Deep Learning
A curated list of awesome Distributed Deep Learning resources.
Stars: ✭ 277 (-2.46%)
Mutual labels:  natural-language-processing
Olivia
💁‍♀️Your new best friend powered by an artificial neural network
Stars: ✭ 3,114 (+996.48%)
Mutual labels:  natural-language-processing
Scrapy Crawlera
Crawlera middleware for Scrapy
Stars: ✭ 281 (-1.06%)
Mutual labels:  scraping
Awesomefakenews
This repository contains recent research on fake news.
Stars: ✭ 270 (-4.93%)
Mutual labels:  natural-language-processing
Autonlp
🤗 AutoNLP: train state-of-the-art natural language processing models and deploy them in a scalable environment automatically
Stars: ✭ 263 (-7.39%)
Mutual labels:  natural-language-processing
Gopa
[WIP] GOPA, a spider written in Golang, for Elasticsearch. DEMO: http://index.elasticsearch.cn
Stars: ✭ 277 (-2.46%)
Mutual labels:  scraping
Textract
extract text from any document. no muss. no fuss.
Stars: ✭ 3,165 (+1014.44%)
Mutual labels:  natural-language-processing

clean-text Build Status PyPI PyPI - Python Version PyPI - Downloads

User-generated content on the Web and in social media is often dirty. Preprocess your scraped data with clean-text to create a normalized text representation. For instance, turn this corrupted input:

A bunch of \\u2018new\\u2019 references, including [Moana](https://en.wikipedia.org/wiki/Moana_%282016_film%29).


»Yóù àré     rïght <3!«

into this clean output:

A bunch of 'new' references, including [moana](<URL>).

"you are right <3!"

clean-text uses ftfy, unidecode and numerous hand-crafted rules, i.e., RegEx.

Installation

To install the GPL-licensed package unidecode alongside:

pip install clean-text[gpl]

You may want to abstain from GPL:

pip install clean-text

NB: This package is named clean-text and not cleantext.

If unidecode is not available, clean-text will resort to Python's unicodedata.normalize for transliteration. Transliteration to closest ASCII symbols involes manually mappings, i.e., ê to e. unidecode's mapping is superiour but unicodedata's are sufficent. However, you may want to disable this feature altogether depending on your data and use case.

To make it clear: There are inconsistencies between processing text with or without unidecode.

Usage

from cleantext import clean

clean("some input",
    fix_unicode=True,               # fix various unicode errors
    to_ascii=True,                  # transliterate to closest ASCII representation
    lower=True,                     # lowercase text
    no_line_breaks=False,           # fully strip line breaks as opposed to only normalizing them
    no_urls=False,                  # replace all URLs with a special token
    no_emails=False,                # replace all email addresses with a special token
    no_phone_numbers=False,         # replace all phone numbers with a special token
    no_numbers=False,               # replace all numbers with a special token
    no_digits=False,                # replace all digits with a special token
    no_currency_symbols=False,      # replace all currency symbols with a special token
    no_punct=False,                 # remove punctuations
    replace_with_punct="",          # instead of removing punctuations you may replace them
    replace_with_url="<URL>",
    replace_with_email="<EMAIL>",
    replace_with_phone_number="<PHONE>",
    replace_with_number="<NUMBER>",
    replace_with_digit="0",
    replace_with_currency_symbol="<CUR>",
    lang="en"                       # set to 'de' for German special handling
)

Carefully choose the arguments that fit your task. The default parameters are listed above.

You may also only use specific functions for cleaning. For this, take a look at the source code.

So far, only English and German are fully supported. It should work for the majority of western languages. If you need some special handling for your language, feel free to contribute. 🙃

Development

Install and use poetry.

Contributing

If you have a question, found a bug or want to propose a new feature, have a look at the issues page.

Pull requests are especially welcomed when they fix bugs or improve the code quality.

If you don't like the output of clean-text, consider adding a test with your specific input and desired output.

Related Work

Acknowledgements

Built upon the work by Burton DeWilde for Textacy.

License

Apache

Sponsoring

This work was created as part of a project that was funded by the German Federal Ministry of Education and Research.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].