Skip to main content

No project description provided

Project description

Split words

Implementation of tools helps to convert the rect of sentence-level and phrase-level to word-level by using linear interpolation.

Installation

From PyPi

pip install split-vnm-words

From source

cd <this-repo>
pip install .

Usage

from splitwords import Splitter
import re

splitter = Splitter(languages=['vi', 'en', 'teencode'])
paragraph = "Chất liệudẻo. Màu sắcđen đen. Dép đẹp lắm luônn ạ. Miksăn được k thikquá tr. shipperthân thiện"

sentence_ls = []
pat = re.compile(r"([.()!])")

paragraph = pat.sub(" \\1 ", paragraph)
new_paragraph = []
new_w = None
for w in paragraph.split():
    if len(w) > 3: # simple threshold 
        new_w = splitter.split(w.upper())
    else:
        new_w = None
    new_paragraph += [
        ' '.join(new_w).lower() if new_w is not None else w.lower()
    ]
new_paragraph = ' '.join(new_paragraph)
new_paragraph = new_paragraph.replace(' .', '.')
print(new_paragraph)

Expected output:

chất liệu dẻo. màu sắc đen đen. dép đẹp lắm luôn n ạ. mik săn được k thik quá tr. shipper thân thiện

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

split-vnm-words-1.0.1.tar.gz (1.5 MB view details)

Uploaded Source

File details

Details for the file split-vnm-words-1.0.1.tar.gz.

File metadata

  • Download URL: split-vnm-words-1.0.1.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for split-vnm-words-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f23dee6bae0160266aef0d60bd64b66871cd44c190df66c36c048348325cc293
MD5 26feeaba6722c547eede3f021b050bd3
BLAKE2b-256 b24fe8e98e3696bb1c569d0b6aa81c6e13e403b75b47196b528026cfe93366e4

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