Skip to main content

Python utility packages

Project description

Utility Functions for python

pip install chitti

Pretty print

from chitti import pprint, pprint_nl
brands = ['apple', 'samsung', 'pixel', 'one plus']

pprint(brands)
OUT:
apple
samsung
pixel
one plus

pprint_nl(brands)
OUT:
apple

samsung

pixel

one plus

Color Words in text

from chitti import color_words_in_text
text = 'camera is awesome and battery is good'
words = ['camera', 'battery']
color_words_in_text(text, words, color='green', text_color='white')

Train and Validation split

Splits dataframe into train and val dataframes
Split each category into 80% train and 20% val

from chitti.train_test_split import train_val_split

path = 'data.csv'
df = pd.read_csv(path)

text_col='Article_clean'
target_col='NewsType'
train_df, val_df = train_val_split(df, text_col=text_col, target_col=target_col, size=0.8)

print(train_df[target_col].value_counts())
print(val_df[target_col].value_counts())

Download pretrained word vectors

Supported Vectors:

  • GloVe.6B.50d
  • GloVe.6B.100d
  • GloVe.6B.200d
  • GloVe.6B.300d
  • GloVe.42B.300d
  • GloVe.840B.300d
  • GloVe.Twitter.25d
  • GloVe.Twitter.50d
  • GloVe.Twitter.100d
  • GloVe.Twitter.200d

This will download specified vector and creates two files

  • word_index.pkl => word2index dictionary
  • embedding_matrix.npy => Numpy matrix of size (vocab_size, embedding_size)
from chitti.nlp import download_pretrained_vectors, download_pretrained_vectors_
download_pretrained_vectors('GloVe.6B.50d')
download_pretrained_vectors_('glove.6B.50d.txt')

Text cleaning Utils

from chitti.nlp import stem_words, lemmatize_words
from chitti.nlp import remove_punctuation, remove_stopwords, space_punctuation

text = 'i, love. you    ..... ,,, !!! ?? ?> >> '
print(remove_punctuation(text))
OUT:
'i love you'

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

chitti-0.2.7.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

chitti-0.2.7-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file chitti-0.2.7.tar.gz.

File metadata

  • Download URL: chitti-0.2.7.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for chitti-0.2.7.tar.gz
Algorithm Hash digest
SHA256 1f4f40c3b8b5dbaa99ea593854f6279d842853ae788602316cd9e22bcf2306b7
MD5 1872c0b5f11fc23bf756301573ecbaa2
BLAKE2b-256 3e6d00e05827e107a5086073ef76fd3ab49a791901586cebd0b0a810448c1669

See more details on using hashes here.

File details

Details for the file chitti-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: chitti-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for chitti-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc94b40d96a21e188a55c0a6264e54bbbd3d11968e62d419b37cd56ded4e9aa
MD5 ec0f6eec3d2b2c2e3cb62815cea05320
BLAKE2b-256 af6267c19433236b7d65be8055773abe565e0c8c2973a3329bcfb1cba50a2c71

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page