Skip to main content

Text Aligner

Project description

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

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

text_aligner-0.0.4.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

text_aligner-0.0.4-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file text_aligner-0.0.4.tar.gz.

File metadata

  • Download URL: text_aligner-0.0.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for text_aligner-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c1c89e3731a6fdb6fd6ec07dbbe9c0d42691485a2649d394d76a412970ce193a
MD5 b9227a0439ae1fc5d6421bddee508559
BLAKE2b-256 47d471a98d1b0bb539cdf79994c6875e35a26e9d73a5a5baf5c1f5217670a479

See more details on using hashes here.

File details

Details for the file text_aligner-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: text_aligner-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for text_aligner-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f31ba88d0834d2f94fc06cd49b8335ee0e81c707ff2e77fed57bedf4c203054
MD5 7f19681fa80353e392e2eb1a017132b9
BLAKE2b-256 9997d1b5a39c96271b3403fd195926ac584ecfde9cb39ff45a04031e8b9b8305

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