Skip to main content

Vinorm compatible for Windows 64-bit

Vietnamese Text Normalization System - Pure Python Implementation

Giới thiệu

Đây là phiên bản vinorm được viết lại hoàn toàn bằng Python, tương thích với Windows 64-bit và các hệ điều hành khác. Phiên bản này giải quyết lỗi WinError 193 mà nhiều người gặp phải khi sử dụng vinorm gốc trên Windows.

Tại sao cần phiên bản này?

Vinorm gốc sử dụng một file thực thi C++ được compile cho Linux, không thể chạy trên Windows. Phiên bản này:

  • ✅ 100% Pure Python - không cần file thực thi C++
  • ✅ Cross-platform - chạy trên Windows, macOS, Linux
  • ✅ Không dependencies - chỉ sử dụng thư viện chuẩn Python
  • ✅ API tương thích - drop-in replacement cho vinorm gốc
  • ✅ Performance tốt - tối ưu hóa cho tốc độ xử lý

Cài đặt

Cách 1: Cài đặt trực tiếp từ file

pip install vinormx

Cách 2: Cài đặt từ source code

  1. Download file vinormx.py
  2. Đặt vào thư mục project của bạn
  3. Import và sử dụng:
from vinormx import TTSnorm

text = "Hàm này được phát triển từ 8/2019. Có phải tháng 12/2020 đã có vaccine phòng ngừa Covid-19 xmz ?"
normalized = TTSnorm(text)
print(normalized)

Sử dụng

Cách sử dụng cơ bản

from vinormx import TTSnorm

# Chuẩn hóa văn bản cơ bản
text = "Tôi có 100 USD và 2.5 triệu VND ngày 25/12/2023"
result = TTSnorm(text)
print(result)
# Output: tôi có một trăm usd và hai phẩy năm triệu vnd ngày hai mười lăm tháng mười hai năm hai nghìn không trăm hai mười ba .

Các tùy chọn nâng cao

# Giữ nguyên dấu câu
TTSnorm(text, punc=True)

# Giữ nguyên chữ hoa
TTSnorm(text, lower=False)

# Xử lý từ không xác định (spell out)
TTSnorm(text, unknown=False)

# Chỉ sử dụng regex (không dùng từ điển)
TTSnorm(text, rule=True)

Ví dụ chi tiết

from vinormx import TTSnorm

test_cases = [
    "Dr. Smith vs Mr. Johnson @ 15:30",
    "Nhiệt độ hôm nay là 37°C, độ ẩm 85%",
    "Công ty ABC có 1,234 nhân viên",
    "COVID-19 bắt đầu từ 12/2019",
    "Giá cả tăng 15% so với năm 2020"
]

for text in test_cases:
    print(f"Input:  {text}")
    print(f"Output: {TTSnorm(text)}")
    print()

Tính năng

✅ Chuẩn hóa số

  • Số nguyên: 123 → một trăm hai mười ba
  • Số thập phân: 12.5 → mười hai phẩy năm
  • Năm: 2023 → hai nghìn không trăm hai mười ba

✅ Chuẩn hóa ngày tháng

  • 25/12/2023 → ngày hai mười lăm tháng mười hai năm hai nghìn không trăm hai mười ba
  • 12/2020 → tháng mười hai năm hai nghìn không trăm hai mười

✅ Chuẩn hóa từ viết tắt

  • Dr. → bác sĩ
  • COVID-19 → covid mười chín
  • USA → hoa kỳ
  • WHO → tổ chức y tế thế giới

✅ Chuẩn hóa ký tự đặc biệt

  • & → và
  • % → phần trăm
  • @ → a còng
  • °C → độ c
  • $ → đô la

✅ Xử lý từ không xác định

  • xmz → ích em giét (spell out từng ký tự)

So sánh với vinorm gốc

Tính năng Vinorm gốc Vinorm X
Hỗ trợ Windows 64-bit ❌ (WinError 193) ✅
Dependencies C++ executable Pure Python
Cross-platform ❌ ✅
Performance Rất nhanh Nhanh
API compatibility - ✅ 100% tương thích

API Reference

TTSnorm(text, punc=False, unknown=True, lower=True, rule=False)

Parameters:

  • text (str): Văn bản cần chuẩn hóa
  • punc (bool, optional): Nếu True, giữ nguyên dấu câu. Default: False
  • unknown (bool, optional): Nếu True, giữ nguyên từ không xác định. Default: True
  • lower (bool, optional): Nếu True, chuyển về chữ thường. Default: True
  • rule (bool, optional): Nếu True, chỉ sử dụng regex. Default: False

Returns:

  • str: Văn bản đã được chuẩn hóa

Troubleshooting

Lỗi WinError 193 với vinorm gốc

Nếu bạn gặp lỗi này:

OSError: [WinError 193] %1 is not a valid Win32 application

Giải pháp: Sử dụng vinormx này thay thế!

Migration từ vinorm gốc

# Cũ
from vinorm import TTSnorm

# Mới - chỉ cần thay đổi import
from vinormx import TTSnorm

# API hoàn toàn giống nhau!

Performance

Benchmarks trên Windows 10 64-bit:

Text length Vinorm X
100 chars ~0.01s
1,000 chars ~0.05s
10,000 chars ~0.3s

Requirements

  • Python 3.6+
  • Windows, macOS, hoặc Linux
  • Không cần dependencies ngoài

Contributing

Contributions welcome! Please feel free to submit a Pull Request.

License

MIT License - Dựa trên vinorm gốc của v-nhandt21 và NoahDrisort.

Credits


🎯 Giải pháp hoàn hảo cho lỗi WinError 193 trên Windows!

Release files for vinormx 1.0.8

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

Source distribution (sdist)

Source distribution for vinormx 1.0.8
File Size Uploaded
vinormx-1.0.8.tar.gz 109.6 kB Details

Built distribution (wheel)

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

Total release size: 227.6 kB

Release files / vinormx-1.0.8.tar.gz

Download URL vinormx-1.0.8.tar.gz
Size 109.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cc36fc27922df59faa440a1afa1ab482a60fc8460d692b6beafa396ef3732f3d
BLAKE2b-256 checksum
How to use checksums
f3dba2f0828003b03994e5072f6541e1565236d95b388e18c8870ece9cd46c7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.0

Release files / vinormx-1.0.8-py3-none-any.whl

Download URL vinormx-1.0.8-py3-none-any.whl
Size 118.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5fabca038070837abe9cee499987c00829cd33f18d3ac77235d40bf298bd2f0
BLAKE2b-256 checksum
How to use checksums
2ffa3734d13a1a7e864cdca7e9dc5271199b9621aa7dc905546aa16a38996fd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

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