Skip to main content

Junk, Not-Junk Detector

This tool is built to do just one simple task: detect junk and not-junk texts from a variety of languages. Just like that famous hotdog not-hotdog, but applied on natural language text. It can be very useful to test tools that extract, decompress, and/or decrypt natural language texts.

Setup

Uses fairseq

# Optionally create a brand new conda environment for this
#conda create -n junkdetect python=3.7
#conda activate junkdetect

# Install: use only one of these methods
# 1. from pypi; recommended
pip install junkdetect

# 2. latest master branch
pip install git+https://github.com/thammegowda/junkdetect

# 3. for development
git clone https://github.com/thammegowda/junkdetect \
     && cd junkdetect \
     && pip install --editable .

How to use

Once you install it via pip, junkdetect or python -m junkdetect can be used to invoke from commandline

printf "This is a good sentence. \nT6785*&^T is 747658 you T&*^\n" | junkdetect
0.999824	This is a good sentence.
0.0747487	T6785*&^T is 747658 you T&*^

The output is one line per input, with two column separated by \t. The first column has perplexity: a lower value (i.e close to 0.0) means junk and an higher value (close to 1.0) means not-junk. If you dont want input sentences back in the output, please cut them out -- just use junkdetect | cut -f1 > scores.txt

How does this work

junkdetect looks like only a few lines of python code, but under the hood, it hides a great deal of complexity.
It uses perplexity from neural (masked/auto-regressive) language models that were trained on tera bytes of web text from 100s of languages.
Specifically, it uses Facebookresearch's XML-R retrieved from torch.hub. Quoting the original developers of XML-R and their paper, (see Table 6)

XLM-R handles the following 100 languages: Afrikaans, Albanian, Amharic, Arabic, Armenian, Assamese, Azerbaijani, Basque, Belarusian, Bengali, Bengali Romanized, Bosnian, Breton, Bulgarian, Burmese, Burmese, Catalan, Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Danish, Dutch, English, Esperanto, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Hausa, Hebrew, Hindi, Hindi Romanized, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kazakh, Khmer, Korean, Kurdish (Kurmanji), Kyrgyz, Lao, Latin, Latvian, Lithuanian, Macedonian, Malagasy, Malay, Malayalam, Marathi, Mongolian, Nepali, Norwegian, Oriya, Oromo, Pashto, Persian, Polish, Portuguese, Punjabi, Romanian, Russian, Sanskri, Scottish, Gaelic, Serbian, Sindhi, Sinhala, Slovak, Slovenian, Somali, Spanish, Sundanese, Swahili, Swedish, Tamil, Tamil Romanized, Telugu, Telugu Romanized, Thai, Turkish, Ukrainian, Urdu, Urdu Romanized, Uyghur, Uzbek, Vietnamese, Welsh, Western, Frisian, Xhosa, Yiddish.

Back Story and Acknowledgements:

Developers:

Release files for junkdetect 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for junkdetect 0.1.2
File Size Uploaded
junkdetect-0.1.2.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for junkdetect 0.1.2
File Interpreter ABI Platform
junkdetect-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / junkdetect-0.1.2.tar.gz

Download URL junkdetect-0.1.2.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
72e901d8033429ead7a243214220773374384e4b24ff53056fdbab7a67e8b4e1
BLAKE2b-256 checksum
How to use checksums
ff595e574e54d352ad0fa00e225e4a0d29c8276bac76b53cf79d212443581528
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.0.post20200616 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release files / junkdetect-0.1.2-py3-none-any.whl

Download URL junkdetect-0.1.2-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a8cb6b431d5595e6b79b147dd10d77435b96412fcc294a931c6582258687254
BLAKE2b-256 checksum
How to use checksums
b73e153a91f52f0a3c277ca2cd608d3d59ca1e7b50258c12afcfccc8c438d91b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.0.post20200616 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page