<jupyter_start><jupyter_text>G2Engine Guide - StatsThe `stats()` method creates a JSON string with information about your Senzing workload.More information:1. [GitHub repository](https://github.com/Senzing/docker-jupyter)1. [Senzing documentation](http://docs.senzing.com/?pythong2config)1. [G2Engine Reference](senzing-G2Engine-reference.ipynb)<jupyter_code>import os
import sys
import json

# For RenderJSON

import uuid
from IPython.display import display_javascript, display_html, display<jupyter_output><empty_output><jupyter_text>Helper class for JSON rendering<jupyter_code>class RenderJSON(object):
    def __init__(self, json_data):
        if isinstance(json_data, dict):
            self.json_str = json.dumps(json_data)
        elif isinstance(json_data, bytearray):
            self.json_str = json_data.decode()
        else:
            self.json_str = json_data
        self.uuid = str(uuid.uuid4())

    def _ipython_display_(self):
        display_html('<div id="{}" style="height:100%; width:100%; background-color: LightCyan"></div>'.format(self.uuid), raw=True)
        display_javascript("""
        require(["https://rawgit.com/caldwell/renderjson/master/renderjson.js"], function() {
        document.getElementById('%s').appendChild(renderjson(%s))
        });
        """ % (self.uuid, self.json_str), raw=True)<jupyter_output><empty_output><jupyter_text>System pathUpdate system path.<jupyter_code>python_path = "{0}/python".format(
    os.environ.get("SENZING_G2_DIR", "/opt/senzing/g2"))
sys.path.append(python_path)<jupyter_output><empty_output><jupyter_text>Initialize variablesCreate variables needed to invoke `stats()`.Also, update system path.<jupyter_code>module_name = 'pyG2EngineForStats'

config_path = os.environ.get("SENZING_ETC_DIR", "/etc/opt/senzing")
support_path = os.environ.get("SENZING_DATA_VERSION_DIR", "/opt/senzing/data")

resource_path = "{0}/resources".format(
    os.environ.get("SENZING_G2_DIR", "/opt/senzing/g2"))

sql_connection = os.environ.get(
    "SENZING_SQL_CONNECTION", "sqlite3://na:na@/var/opt/senzing/sqlite/G2C.db")

verbose_logging = False

senzing_config_dictionary = {
    "PIPELINE": {
        "CONFIGPATH": config_path,        
        "SUPPORTPATH": support_path,
        "RESOURCEPATH": resource_path
    },
    "SQL": {
        "CONNECTION": sql_connection,
    }
}

senzing_config_json = json.dumps(senzing_config_dictionary)<jupyter_output><empty_output><jupyter_text>G2EngineThe G2Engine API...<jupyter_code>from G2Engine import G2Engine<jupyter_output><empty_output><jupyter_text>InitializationDetails at [G2Engine initialization](senzing-G2Engine-reference.ipynbG2Engine-initialization).<jupyter_code>g2_engine = G2Engine()

return_code = g2_engine.initV2(
    module_name,
    senzing_config_json,
    verbose_logging)

print("Return Code: {0}".format(return_code))<jupyter_output><empty_output><jupyter_text>StatisticsCall G2Engine's `stats()` method and pretty-print results.Details at [G2Engine.stats](senzing-G2Engine-reference.ipynbstats).<jupyter_code>response_bytearray = bytearray()

return_code = g2_engine.stats(response_bytearray)

print("Return Code: {0}".format(return_code))
RenderJSON(response_bytearray)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13079777365491652, 'fraction_numerical': 0.012368583797155226, 'mean_word_length': 5.444223107569721, 'pattern_counts': {'":': 6, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 2, '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': '28699', 'license': 'Apache-2.0', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1093, 'n_words': 154, 'path': 'notebooks/senzing-examples/python/senzing-G2Engine-stats.ipynb', 'repo_name': 'SamMacy/docker-jupyter', 'size': '3234'}