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.

PyPI version Python versions License: MIT

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.1.0.tar.gz (6.3 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.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: humanize_ai-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 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.1.0.tar.gz
Algorithm Hash digest
SHA256 fc50b899051c3f77a1f7247e2cc85362e896a33b0130c6e1d114557095ca3319
MD5 2393ffaad11a60381a68b1ef0dced25a
BLAKE2b-256 8aa96df6766390bdef2495c478c08b62540ef975e6ddca31338a5de713d798f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: humanize_ai-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daceb19450a9472af551ae1b09f987baa7bcc4b1a4e04b7f0e30cdd0a9b44082
MD5 9c7a6209742d1e501d8f379f6201902b
BLAKE2b-256 06fca5571aad8e39124175f982d2ec8e0e38bd5ea3d8253c3c9b5862850d7078

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