Skip to main content

Text Aligner

PyPI License

A Python library for aligning texts based on edit distance algorithms. This tool is particularly useful for comparing and aligning reference texts with hypothesis texts, such as in speech recognition evaluation.

Features

  • Edit Distance Alignment: Uses sequence matching algorithms to align texts based on similarity
  • Space Agnostic Mode: Option to ignore differences in spacing during alignment
  • Punctuation Agnostic Mode: Option to ignore differences in punctuation during alignment

Installation

pip install text-aligner

Usage

Command Line Interface

# Align two individual text strings
align-text "AI cannot replace human creativity" "AI can not replace human creativity."
# Output: AI cannot replace human creativity

align-text "AI can not replace human creativity." "AI cannot replace human creativity"
# Output: AI can not replace human creativity.

align-text "He is a well-known writer." "She is a well known writer"
# Output: She is a well-known writer.

align-text "She is a well known writer" "He is a well-known writer."
# Output: He is a well known writer

# Align texts from scp format files (e.g., `utt_id text`)
align-text ref.txt hyp.txt output.txt

Python API

from text_aligner import align

# Preserve reference formatting with hypothesis content
align("AI cannot replace human creativity", "AI can not replace human creativity.")
# Output: "AI cannot replace human creativity"

align("He is a well-known writer.", "She is a well known writer")
# Output: "She is a well-known writer."

Options

  • -s, --space-agnostic: Ignore differences in spacing (default: True)
  • -p, --punctuation-agnostic: Ignore differences in punctuation (default: True)
  • output-file: Optional output file path (default: stdout)

License

Apache License 2.0

Metadata

Release files for text-aligner 0.0.4

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

Source distribution (sdist)

Source distribution for text-aligner 0.0.4
File Size Uploaded
text_aligner-0.0.4.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for text-aligner 0.0.4
File Interpreter ABI Platform
text_aligner-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / text_aligner-0.0.4.tar.gz

Download URL text_aligner-0.0.4.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c1c89e3731a6fdb6fd6ec07dbbe9c0d42691485a2649d394d76a412970ce193a
BLAKE2b-256 checksum
How to use checksums
47d471a98d1b0bb539cdf79994c6875e35a26e9d73a5a5baf5c1f5217670a479
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / text_aligner-0.0.4-py3-none-any.whl

Download URL text_aligner-0.0.4-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f31ba88d0834d2f94fc06cd49b8335ee0e81c707ff2e77fed57bedf4c203054
BLAKE2b-256 checksum
How to use checksums
9997d1b5a39c96271b3403fd195926ac584ecfde9cb39ff45a04031e8b9b8305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.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