<jupyter_start><jupyter_text>0005 Cohesive devices<jupyter_code>import pandas as pd

from features import acds, cdw
df = pd.read_pickle('0000_features_20201124.pkl')  # 465<jupyter_output><empty_output><jupyter_text>* acds -- Average number of Cohesive Devices (transition words and phrases) per Sentence (**new**)* cdw -- Number of Cohesive Devices (transition words and phrases) per total number of Words in text (**new**)<jupyter_code>with open('resources/transition_words-1.0.txt', 'r') as f:
    transition_words = f.read().splitlines()  # 316
%%time

df['acds'] = df.text.apply(acds, args=(transition_words,))
%%time

df['cdw'] = df.text.apply(cdw, args=(transition_words,))
df.acds.describe()
df.cdw.describe()<jupyter_output><empty_output><jupyter_text>Save to pickle file<jupyter_code>tmp = df[['acds', 'cdw']]
tmp.to_pickle('0005_cohesive_devices_20220130.pkl')   # 465<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1474147414741474, 'fraction_numerical': 0.0429042904290429, 'mean_word_length': 7.198198198198198, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '198904', 'license': 'Unlicense', 'n_tokens_mistral': 368, 'n_tokens_neox': 332, 'n_words': 68, 'path': '0005_cohesive_devices.ipynb', 'repo_name': 'korniichuk/cvr-features', 'size': '909'}