Skip to main content

Humanize AI-generated text by normalizing Unicode characters

Project description

Humanize AI

A Python library to humanize AI-generated text by normalizing Unicode characters to standard keyboard equivalents.

Why Clean Up AI Text?

AI-generated content often contains subtle markers that make it obvious to readers (and algorithms) that the text wasn't written by a human:

  • Em-dashes (—) instead of regular dash (-)
  • Fancy quotes (" ") instead of standard ones (")
  • Unnecessary whitespace or hidden Unicode characters
  • And other symbols

Cleaning these up makes the text flow more naturally, improving readability and keeping readers engaged.

Installation

pip install humanize-ai

Usage

As a Library

from humanize_ai import humanize_string, HumanizeOptions

# With default options
result = humanize_string(input_text)

# Or with custom options
options = HumanizeOptions(
    transform_hidden=True,
    transform_trailing_whitespace=True,
    transform_nbs=True,
    transform_dashes=True,
    transform_quotes=True,
    transform_other=True,
    keyboard_only=False
)
result = humanize_string(input_text, options)

print(result['text'])  # Humanized text
print(result['count'])  # Number of changed symbols

Command Line

After installation, you can use the humanize-ai command:

# Basic usage
humanize-ai "Hello — world with fancy "quotes" and…more"

# Read from stdin
cat fancy_text.txt | humanize-ai

# Show count of transformed characters
humanize-ai --show-count "Hello — world"

# Only keep keyboard-typeable characters
humanize-ai --keyboard-only "Hello — world with 💪 emoji"

Available options:

  • --no-hidden: Don't remove hidden Unicode characters
  • --no-trailing: Don't remove trailing whitespace
  • --no-nbs: Don't transform non-breaking spaces
  • --no-dashes: Don't transform fancy dashes
  • --no-quotes: Don't transform fancy quotes
  • --no-other: Don't transform other symbols like ellipsis
  • --keyboard-only: Only keep keyboard-typeable characters
  • --show-count: Show the number of transformed characters

Options

Parameter Type Default Description
transform_hidden bool True Removes hidden unicode symbols
transform_trailing_whitespace bool True Removes spaces at the end of line
transform_nbs bool True Replaces Non-Breaking Space character with regular space
transform_dashes bool True Replaces fancy dashes with regular dash (-)
transform_quotes bool True Replaces fancy single and double quotes with regular quotes (' and ")
transform_other bool True Replaces with ...
keyboard_only bool False Removes all symbols that cannot be typed with regular keyboard. Applied after all other transformations

Dependencies

  • Python 3.6+
  • regex (for Unicode property support)

License

MIT

Credits

This project was inspired by the need to improve the readability of AI-generated text and make it more human-friendly. It uses Unicode normalization techniques to achieve this. The project is python port of humanize-ai-lib.

Project details


Download files

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

Source Distribution

humanize_ai-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

humanize_ai-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file humanize_ai-1.0.0.tar.gz.

File metadata

  • Download URL: humanize_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for humanize_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 de5537490ed562c83e3d3a649fe58533d03df19e6cf488c180284990a3fddfb6
MD5 f53a4c690c3c212da8827f6bc955a847
BLAKE2b-256 c484e4a72b9551f6835df04b9f7f759d481996262d835c550ddb0f947be11496

See more details on using hashes here.

File details

Details for the file humanize_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: humanize_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for humanize_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 316fafa2928e3b5c59010d8f2559e404e6a14aba81ffbd2d59241c9fa45c2d1c
MD5 ff2b254ce9dfac990284338f506ecdb6
BLAKE2b-256 4237fbe661a206e91aca0273dd30a8932b28fd4873362eb5bc89d2cda3455a5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page