<jupyter_start><jupyter_text>NLP Text Analysis<jupyter_code>wordnet_lemmatizer = WordNetLemmatizer()
stop_words = set(stopwords.words('english'))

def process(line):
    find_link=line.find("https:")
    new_text=line[:find_link]
    return([wordnet_lemmatizer.lemmatize(t) for t in tokenizer.tokenize(new_text) if ((t not in stop_words) & (t.isnumeric()==False))])
    
tokenizer = RegexpTokenizer(r'\w+')
data['tokens']=data['text'].str.lower().apply(process)
data['tokens']
data['tokens'][0]
data[['text','Chinese','start','end','NumberOFDoc',"urls"]].to_csv(data_dir+'/Moss_20211108.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19131832797427653, 'fraction_numerical': 0.014469453376205787, 'mean_word_length': 9.21311475409836, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '252503', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 242, 'n_tokens_neox': 235, 'n_words': 27, 'path': 'assets/DigitalCollection/Text_Analysis_TwitterData.ipynb', 'repo_name': 'ngau9567/ngau9567.github.io', 'size': '622'}