A library for processing Code Mixed Text. Still in development!
Project description
CMTT is a wrapper library that makes code-mixed text processing more efficient than ever. More documentation incoming!
Installation
pip install cmtt
Getting Started
How to use this library:
from cmtt.data import *
from cmtt.preprocessing import *
# Loading json files
result_json = load_url('https://world.openfoodfacts.org/api/v0/product/5060292302201.json')
# Loading csv files
result_csv = load_url('https://gist.githubusercontent.com/rnirmal/e01acfdaf54a6f9b24e91ba4cae63518/raw/b589a5c5a851711e20c5eb28f9d54742d1fe2dc/datasets.csv')
# List the key properties available for the datasets provided by the cmtt library
keys = list_dataset_keys()
# List all datasets provided by cmtt based on search_key and search_term
data = list_cmtt_datasets(search_key="task", search_term = "ner", isPrint=True)
# Download multiple datasets provided by cmtt, returning a list of paths where the datasets get downloaded
# The Datasets are downloaded into a new 'cmtt' directory inside the user profile directory of the operating system
lst = download_cmtt_datasets(["linc_ner_hineng", "L3Cube_HingLID_all", "linc_lid_spaeng"])
# Download a dataset from a url, returning the path where the dataset gets downloaded
# The Dataset is downloaded into a new directory 'datasets' inside the current working directory
path = download_dataset_url('https://world.openfoodfacts.org/api/v0/product/5060292302201.json')
# CMTT currently provides 3 tokenizers - basic, word and wordpiece tokenizers
# Whitespace Tokenizer
text = "This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment"
tokenized_text_whitespace = whitespace_tokenize(text)
# Word Tokenizer
WordT = WordTokenizer()
tokenized_text_word = WordT.tokenize(text)
# Wordpiece Tokenizer
WordpieceT = Wordpiece_tokenizer()
tokenized_text_wordpiece = WordpieceT.tokenize(text)
# Search functionality
instances, list_instances = search_word(text, 'this', tokenize = True, width = 3)
# Sentence piece based tokenizers for Hindi and Hinglish
# Download the models for the tokenizers. If already downloaded then cmtt does not download it again.
download_models('hi')
download_models('hi-en')
# Sentence piece based Tokenizer for Hindi
_hi = "मैं इनदोनों श्रेणियों के बीच कुछ भी० सामान्य नहीं देखता।"
lst = tokenize(_hi ,'hi-en')
# Output of tokenizer written on a txt file as terminal does not show devanagari text accurately.
with open(r"test_hi.txt", 'w', encoding = "utf-8") as f:
for i in lst:
f.write(i + "\n")
# Sentence piece based Tokenizer for Hinglish
_hien = "hi kya haal chaal? hum cmtt naam ki python library develop kar rahe hain"
lst = tokenize(_hien ,'hi-en')
with open(r"test_hien.txt", 'w', encoding = "utf-8") as f:
for i in lst:
f.write(i + "\n")
Contributors
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
cmtt-0.6.0.tar.gz
(523.9 kB
view details)
Built Distribution
cmtt-0.6.0-py3-none-any.whl
(1.0 MB
view details)
File details
Details for the file cmtt-0.6.0.tar.gz
.
File metadata
- Download URL: cmtt-0.6.0.tar.gz
- Upload date:
- Size: 523.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bd4d39ea39f32d012238aca316e0b940f75a986f5d981f81566b494bed3f50f |
|
MD5 | e813d9e90e2aecdab32fe014ec7ffe47 |
|
BLAKE2b-256 | 09d73bdeeb375a7666a67782027fc1b468dba6f8fc1e51dac786a4ff46fd8aa2 |
File details
Details for the file cmtt-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: cmtt-0.6.0-py3-none-any.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95b574059df5117eddd2f1e3dcfd865336aa9b500e75e0d072a960356141065f |
|
MD5 | b6f1d57b7a9eb9e1b893263d1b9ba842 |
|
BLAKE2b-256 | af9ef45358e699e4bb8339708f486ceafbd265e06e9ca459fa88e59f4ac7f9a8 |