Skip to main content

Processing unicode text.

Project description

unicodetext

Processing Unicode Text

🌍 中文

How To Use

  1. Unicode's blocks (unicodetext.UnicodeBlocks), which can be quickly accessed through the IDE's auto-completion feature to obtain all the characters within the block.
import unicodetext
print (unicodetext.UnicodeBlocks.Emoticons)
  1. Unicode's categories (unicodetext.UnicodeCategories), which can be quickly accessed through the IDE's auto-completion feature to obtain all the characters within the category.
import unicodetext
print (unicodetext.UnicodeCategories.Punctuation)
  1. Character extraction.
import unicodetext
text =  "i am here 237 .! 3 *。、! +-23689068 发斯蒂芬改 23579 😄"
print (unicodetext.extract_emoticon(text))

Custom extraction can also be performed by providing specific Unicode blocks or categories:

import unicodetext
text =  "i am here 237 .! 3 *。、! +-23689068 发斯蒂芬改 23579 😄"
print (unicodetext.extract_chr(text, chrs=unicodetext.UnicodeCategories.Symbol))
  1. Character removal
import unicodetext
text =  "i am here 237 .! 3 *。、! +-23689068 发斯蒂芬改 23579 😄"
print (unicodetext.remove_punctuation(text))

The removed characters can be replaced with specified characters by replace_str:

import unicodetext
text =  "i am here 237 .! 3 *。、! +-23689068 发斯蒂芬改 23579 😄"
print (unicodetext.remove_punctuation(text, replace_str = '[del]'))

Custom removal can also be performed by providing specific Unicode blocks or categories:

import unicodetext
text =  "i am here 237 .! 3 *。、! +-23689068 发斯蒂芬改 23579 😄"
print (unicodetext.remove_chr(text, chrs=unicodetext.UnicodeCategories.Symbol))

Unicode character set

unicodetext.UnicodeBlocks

  • Unicode 15.1 defines 328 blocks. To enable automatic code completion for block names as variables, we remove all spaces and hyphens from their names.

unicodetext.UnicodeCategories

  • Letter = Lu | Ll | Lt | Lm | Lo
  • Mark = Mn | Mc | Me
  • Number = Nd | Nl | No
  • Punctuation = Pc | Pd | Ps | Pe | Pi | Pf | Po
  • Symbol = Sm | Sc | Sk | So
  • Separator = Zs | Zl | Zp
  • Other = Cc | Cf | Cs | Co | Cn
  • Cased_Letter = Lu | Ll | Lt
Abbr Long Description
Lu Uppercase_Letter an uppercase letter
Ll Lowercase_Letter a lowercase letter
Lt Titlecase_Letter a digraph encoded as a single character, with first part uppercase
Lm Modifier_Letter a modifier letter
Lo Other_Letter other letters, including syllables and ideographs
Mn Nonspacing_Mark a nonspacing combining mark (zero advance width)
Mc Spacing_Mark a spacing combining mark (positive advance width)
Me Enclosing_Mark an enclosing combining mark
Nd Decimal_Number a decimal digit
Nl Letter_Number a letterlike numeric character
No Other_Number a numeric character of other type
Pc Connector_Punctuation a connecting punctuation mark, like a tie
Pd Dash_Punctuation a dash or hyphen punctuation mark
Ps Open_Punctuation an opening punctuation mark (of a pair)
Pe Close_Punctuation a closing punctuation mark (of a pair)
Pi Initial_Punctuation an initial quotation mark
Pf Final_Punctuation a final quotation mark
Po Other_Punctuation a punctuation mark of other type
Sm Math_Symbol a symbol of mathematical use
Sc Currency_Symbol a currency sign
Sk Modifier_Symbol a non-letterlike modifier symbol
So Other_Symbol a symbol of other type
Zs Space_Separator a space character (of various non-zero widths)
Zl Line_Separator U+2028 LINE SEPARATOR only
Zp Paragraph_Separator U+2029 PARAGRAPH SEPARATOR only
Cc Control a C0 or C1 control code
Cf Format a format control character
Cs Surrogate a surrogate code point
Co Private_Use a private-use character
Cn Unassigned a reserved unassigned code point or a noncharacter

Install

Install the library with:

pip install -U unicodetext

You can also clone this repository and install:

git clone https://github.com/huang22/unicodetext.git
cd unicodetext
pip install .

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

unicodetext-1.3.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

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

unicodetext-1.3-py2.py3-none-any.whl (35.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file unicodetext-1.3.tar.gz.

File metadata

  • Download URL: unicodetext-1.3.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for unicodetext-1.3.tar.gz
Algorithm Hash digest
SHA256 6888a9dfcbdf6affb5c39e55eb8a958dd351122cf8c095167aa7e71aa5adc90c
MD5 f606ecac2523472af5e7bc6f9a22f500
BLAKE2b-256 8064e654338c2e42e123173e12f809cfa0f83628d3709404d2e5f7bddd25d715

See more details on using hashes here.

File details

Details for the file unicodetext-1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: unicodetext-1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for unicodetext-1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 27eb4f917409af33daf9a30b2b3aa2dd717a7b09fe4e9943727b181ee7c12706
MD5 d0a571af2a958a41ddd43a6ab5eb41fc
BLAKE2b-256 b3837950e4fed74a5a7fc857b98e6a3d4983db7ea1c8628442921e1a4cfe540a

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