<commit_before>/*
Copyright (c) 2012-2014 The SSDB Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
#include "log.h"
#include "config.h"
#include "strings.h"

#define CONFIG_MAX_LINE		4096

namespace sim{

inline static
int is_kv_seperator(int ch){
	return (ch == '=') || (ch == ':');
}

Config* Config::load(const char *filename){
	FILE *fp = NULL;
	int lineno = 0;

	if(strcmp(filename, "stdout") == 0){
		fp = stdin;
	}else{
		fp = fopen(filename, "r");
		if(!fp){
			log_error("error opening file '%s': %s", filename, strerror(errno));
			return NULL;
		}
	}

	Config *root = new Config("root", "");
	Config *cfg = root;
	int last_indent = 0;
	char buf[CONFIG_MAX_LINE];
	while(fgets(buf, sizeof(buf), fp)){
		lineno++;
<commit_msg>fix typo<commit_after>/*
Copyright (c) 2012-2014 The SSDB Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
#include "log.h"
#include "config.h"
#include "strings.h"

#define CONFIG_MAX_LINE		4096

namespace sim{

inline static
int is_kv_seperator(int ch){
	return (ch == '=') || (ch == ':');
}

Config* Config::load(const char *filename){
	FILE *fp = NULL;
	int lineno = 0;

	if(strcmp(filename, "stdin") == 0){
		fp = stdin;
	}else{
		fp = fopen(filename, "r");
		if(!fp){
			log_error("error opening file '%s': %s", filename, strerror(errno));
			return NULL;
		}
	}

	Config *root = new Config("root", "");
	Config *cfg = root;
	int last_indent = 0;
	char buf[CONFIG_MAX_LINE];
	while(fgets(buf, sizeof(buf), fp)){
		lineno++;

{'fraction_non_alphanumeric': 0.16319018404907976, 'fraction_numerical': 0.018404907975460124, 'mean_word_length': 4.227564102564102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6772647', 'n_tokens_mistral': 644, 'n_tokens_neox': 597, 'n_words': 187}