<jupyter_start><jupyter_text>Import Libraries<jupyter_code>import sys
import json
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
collection_name = sys.argv[1]<jupyter_output><empty_output><jupyter_text>Read Config Files<jupyter_code>import configparser 
config = configparser.ConfigParser()
config.read('config.ini')
ip = config['DEFAULT']['IP']
port = config['DEFAULT']['MongoDB-Port']
db_name = config['DEFAULT']['DB-Name']<jupyter_output><empty_output><jupyter_text>Connect MongoDB<jupyter_code>from pymongo import MongoClient
client = MongoClient(ip, int(port))
db = client[db_name]<jupyter_output><empty_output><jupyter_text>Pipeline<jupyter_code># For language field
pipeline_lang = [
    {"$match": {"lang" : "en"}},
    {"$count": "number_english"}
]
# For geoname field
pipeline_geoname = [
    {"$match": {"geoname": {"$exists":True}}},
    {"$count": "number_geoname"}
]<jupyter_output><empty_output><jupyter_text>Aggregation<jupyter_code>lang = list(db[collection_name].aggregate(pipeline_lang,allowDiskUse=True))
if len(lang) > 0:
    number_lang = lang[0]["number_english"]
else:
    number_lang = 0
geoname = list(db[collection_name].aggregate(pipeline_geoname,allowDiskUse=True))
if len(geoname) > 0:
    number_geoname = geoname[0]["number_geoname"]
else:
    number_geoname = 0<jupyter_output><empty_output><jupyter_text>Get Report Value<jupyter_code>count = db[collection_name].count()
index = db[collection_name].index_information()
report = {"record_count":count,"Indexes":[index],"en_tweets_count":number_lang,"geoname_count":number_geoname}<jupyter_output><empty_output><jupyter_text>Write into JSON<jupyter_code>json_string = json.dumps(report)
datastore = json.loads(json_string)
with open(collection_name+".json", 'w') as f:
    json.dump(datastore, f)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1483695652173913, 'fraction_numerical': 0.0038043478260869567, 'mean_word_length': 9.958333333333334, 'pattern_counts': {'":': 10, '<': 29, '<?xml version=': 0, '>': 31, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '595672', 'license': 'Unlicense', 'n_tokens_mistral': 665, 'n_tokens_neox': 656, 'n_words': 89, 'path': 'f0015/f0015-c.ipynb', 'repo_name': 'soda-lab/Features', 'size': '1840'}