<commit_before>import * as React from 'react'
import * as ReactDOM from 'react-dom'

import {CachedDictionaryService, cachedDictionary, naiveDictionary} from '../../../src/core/dictionaryManagementService'
import Config from '../config'
import ConfigKeys from '../../../src/configKeys'

let dict = new CachedDictionaryService(new Config(), {
	global: ConfigKeys.official_dict,
	local: ConfigKeys.user_dict,
	cache: ConfigKeys.cached_dict
});

interface DictStates {
	global: naiveDictionary
	local: naiveDictionary
	cache: cachedDictionary
}

export class DictionaryJSON extends React.Component<void,DictStates> {
	state :DictStates = {global: {}, local: {}, cache: {cache: []}};
	constructor(){
		super();

		dict.cache.then(cache =>
			dict.global.then(global =>
				dict.local.then(local => this.setState({cache, global, local}))));
	}
	public render() {
		return <div>
			<DictStats
				globalCount={Object.keys(this.state.global).length}
				localCount={Object.keys(this.state.local).length}
				cacheCount={this.state.cache.cache.length}
			/>
			<DictJSON cache={this.state.cache.cache} />
		</div>
	}
}

class DictStats extends React.Component<{globalCount: number, localCount: number, cacheCount: number}, void> {
	public render() {
		return <div>
			<p>Global dictionary: {this.props.globalCount}</p>
			<p>User dictionary: {this.props.localCount}</p>
			<p>Combined dictionary: {this.props.cacheCount}</p>
		</div>
	}
}

class DictJSON extends React.Component<cachedDictionary,void> {
	protected get formattedCache() {
		let contents = this.props.cache.map(entry => `\t"${entry.key}":"${entry.value}"`).join(',\n');
		return `{\n${contents}\n}`
	}
	public render() {
		return <pre>
				{this.formattedCache}
			</pre>
	}
}
<commit_msg>replaced exported dict view with a textarea so we can select all more easily<commit_after>import * as React from 'react'
import * as ReactDOM from 'react-dom'

import {CachedDictionaryService, cachedDictionary, naiveDictionary} from '../../../src/core/dictionaryManagementService'
import Config from '../config'
import ConfigKeys from '../../../src/configKeys'

let dict = new CachedDictionaryService(new Config(), {
	global: ConfigKeys.official_dict,
	local: ConfigKeys.user_dict,
	cache: ConfigKeys.cached_dict
});

interface DictStates {
	global: naiveDictionary
	local: naiveDictionary
	cache: cachedDictionary
}

export class DictionaryJSON extends React.Component<void,DictStates> {
	state :DictStates = {global: {}, local: {}, cache: {cache: []}};

	style = {
		display: 'flex',
		'flex-direction': 'column',
	};

	constructor(){
		super();

		dict.cache.then(cache =>
			dict.global.then(global =>
				dict.local.then(local => this.setState({cache, global, local}))));
	}
	public render() {
		return <div style={this.style}>
			<DictStats
				globalCount={Object.keys(this.state.global).length}
				localCount={Object.keys(this.state.local).length}
				cacheCount={this.state.cache.cache.length}
			/>
			<DictJSON cache={this.state.cache.cache} />
		</div>
	}
}

class DictStats extends React.Component<{globalCount: number, localCount: number, cacheCount: number}, void> {
	public render() {
		return <div>
			<p>Global dictionary: {this.props.globalCount}</p>
			<p>User dictionary: {this.props.localCount}</p>
			<p>Combined dictionary: {this.props.cacheCount}</p>
		</div>
	}
}

class DictJSON extends React.Component<cachedDictionary,void> {
	protected get formattedCache() {
		let contents = this.props.cache.map(entry => `\t"${entry.key}":"${entry.value}"`).join(',\n');
		return `{\n${contents}\n}`
	}
	public render() {
		return <textarea rows="20" value={this.formattedCache}></textarea>
	}
}

{'fraction_non_alphanumeric': 0.16211044286495352, 'fraction_numerical': 0.0005467468562055768, 'mean_word_length': 4.611963190184049, 'pattern_counts': {'":': 2, '<': 37, '<?xml version=': 0, '>': 45, '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}}
{'dir': 'git-commits-cleaned', 'id': '5545196', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1153, 'n_words': 251}