<jupyter_start><jupyter_text>Importing Packages<jupyter_code>'''If packages are not found then use: pip install package_name'''
import pandas as pd
import re
import string
from textblob import TextBlob
import nltk<jupyter_output><empty_output><jupyter_text>Data pre processing and data cleaning<jupyter_code>class dataPreProcessing:
    def __init__(self,path):
        self.data=pd.read_csv(path,delimiter = ",")
        self.data.columns = ((self.data.columns.str).replace("^ ","")).str.replace(" $","")   #removing cloumns spaces
        self.data["Article"].fillna("To be added", inplace = True)
        self.data["Headline"].fillna("To be added", inplace = True)       #replacing NaN values with some text
        self.data["Label"].fillna("To be added", inplace = True)
        self.data["Publisher"].fillna("To be added", inplace = True)
    def read_data(self):
        return self.data
    def clean_article(self,article):
        article=article.lower()
        article = re.sub('\[.*?\]', '', article)
        article = re.sub('[%s]' % re.escape(string.punctuation), '', article)
        article = re.sub('\w*\d\w*', '', article)
        return article
    def clean_dataset(self):
        for i in range(len(self.data)):
            self.data['Article'][i]=self.clean_article(self.data['Article'][i])
            self.data['Headline'][i]=self.clean_article(self.data['Headline'][i])
            self.data['Label'][i]=self.data['Label'][i].lower()
        return self.data
    def tokenize(self):
        pass
    def remove_stopwords(self):
        pass
        
data = dataPreProcessing('data/data.csv')
print(data.read_data()['Article'][0])              # for comparison of articles
data.read_data().head()
print(data.clean_dataset()['Article'][0])    #for comparison of articles
data.clean_dataset().head()
data.read_data()
events=pd.read_excel('data/Political Events.xlsx')
events
class features:
    def _init_(self):
        pass
    def subjectivity(self):
        pass
    def objectivity(self):
        pass<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15306122448979592, 'fraction_numerical': 0.0009718172983479105, 'mean_word_length': 3.485838779956427, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '216348', 'license': 'MIT', 'n_tokens_mistral': 645, 'n_tokens_neox': 640, 'n_words': 131, 'path': '.ipynb_checkpoints/PoliticalBiasnessDetection-checkpoint.ipynb', 'repo_name': 'jklu-jaipur/Political-Biasness-Detection', 'size': '2058'}