A text analytics library with support for codemixed data
Lingualytics is a Python library for dealing with indic text.
Lingualytics is powered by powerful libraries like Pytorch, Transformers, Texthero, NLTK and Scikit-learn.
Preprocessing
Representation
NLP
Checkout some codemix friendly models that we have trained using Lingualytics
Use the package manager pip to install lingualytics.
pip install lingualytics
from lingualytics.preprocessing import remove_lessthan, remove_punctuation, remove_stopwords
from lingualytics.stopwords import hi_stopwords,en_stopwords
from texthero.preprocessing import remove_digits
import pandas as pd
df = pd.read_csv(
"https://github.com/lingualytics/py-lingualytics/raw/master/datasets/SAIL_2017/Processed_Data/Devanagari/validation.txt", header=None, sep='\t', names=['text','label']
)
# pd.set_option('display.max_colwidth', None)
df['clean_text'] = df['text'].pipe(remove_digits) \
.pipe(remove_punctuation) \
.pipe(remove_lessthan,length=3) \
.pipe(remove_stopwords,stopwords=en_stopwords.union(hi_stopwords))
print(df)
Currently available datasets are
from lingualytics.learner import Learner
learner = Learner(model_type = 'bert',
model_name = 'bert-base-multilingual-cased',
dataset = 'SAIL_2017')
learner.fit()
The train data path should have 3 files
Any file should have the text and label in a line, separated by a tab. Then change the data_dir
to the path of your custom dataset.
from lingualytics.representation import get_ngrams
import pandas as pd
df = pd.read_csv(
"https://github.com/jbesomi/texthero/raw/master/dataset/bbcsport.csv"
)
ngrams = get_ngrams(df['text'],n=2)
print(ngrams[:10])
Documentation is a work in progress! Have a look at it here.
We plan to add the following functionality in the coming weeks:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.