<jupyter_start><jupyter_text>Script Development - addTokensAndCats.pyDevelopment notebook for script to add tokens and categories to review data. Setup<jupyter_code>from pyspark.sql import SparkSession
from sentimentAnalysis import dataProcessing as dp
# create spark session
spark = SparkSession(sc)
# get dataframes
# specify s3 as sourc with s3a://
#df = spark.read.json("s3a://amazon-review-data/user_dedup.json.gz")
#df_meta = spark.read.json("s3a://amazon-review-data/metadata.json.gz")
df = spark.read.json("s3a://amazon-review-data/reviews_Musical_Instruments_5.json.gz")
# subset asin, reviewText
df_subset = df.select("asin", "reviewText")
# add tokens
df_tokens = dp.add_tokens(df_subset)
# add categories
df_cats = dp.add_categories(df_tokens, df_meta)
df_tokens.write.json("s3a://amazon-review-data/review-data.json")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12325581395348838, 'fraction_numerical': 0.00813953488372093, 'mean_word_length': 6.296610169491525, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '232132', 'license': 'MIT', 'n_tokens_mistral': 299, 'n_tokens_neox': 291, 'n_words': 59, 'path': 'src/scriptDev-groupByProd_AddFeatures.ipynb', 'repo_name': 'rob-dalton/amazonfeatures-feature-extraction', 'size': '860'}