<commit_before>/**
 * This file is part of the MonVoisinFaitDuBio project.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright Copyright (c) 2016 <NAME> - <EMAIL>
 * @license    MIT License
 * @Last Modified time: 2016-12-13
 */

import { AppModule, AppStates, AppModes } from "../app.module";
import { Category } from "../classes/category.class";
import { Option } from "../classes/option.class";

export { Category } from "../classes/category.class";
export { Option } from "../classes/option.class";

declare let App : AppModule;
declare let $ : any;


export class CategoriesModule
{
	categories : Category[] = [];
	options : Option[] = [];

	mainCategory : Category;
	openHoursCategory : Category;

	constructor() 
	{
		this.options = [];
		this.categories = [];
	}

	createCategoriesFromJson(mainCatgeoryJson, openHoursCategoryJson)
	{
		this.mainCategory = this.recursivelyCreateCategoryAndOptions(mainCatgeoryJson);
		this.openHoursCategory = this.recursivelyCreateCategoryAndOptions(openHoursCategoryJson);

		console.log(this.mainCategory);
	}

	private recursivelyCreateCategoryAndOptions(categoryJson : any) : Category
	{
		let category = new Category(categoryJson);

		for(let optionJson of categoryJson.options)
		{
			let option = new Option(optionJson);
			option.ownerId = categoryJson.id;

			if (category.depth == 0) option.mainOwnerId = "all";
			else if (category.depth == -1) option.mainOwnerId = "openhours";
			else option.mainOwnerId = category.mainOwnerId;

			for(let subcategoryJson of optionJson.subcategories)
			{				
				if (category.depth <= 0) subcategoryJson.mainOwnerId = option.id;
				else subcategoryJson.mainOwnerId = option.mainOwnerId;

				let subcategory = this.recursivelyCreateCategoryAndOptions(subcategoryJson);
				subcategory.ownerId = option.id;				

				option.addCategory(subcategory);
			}<commit_msg>Clear comment<commit_after>/**
 * This file is part of the MonVoisinFaitDuBio project.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright Copyright (c) 2016 <NAME> - <EMAIL>
 * @license    MIT License
 * @Last Modified time: 2016-12-13
 */

import { AppModule, AppStates, AppModes } from "../app.module";
import { Category } from "../classes/category.class";
import { Option } from "../classes/option.class";

export { Category } from "../classes/category.class";
export { Option } from "../classes/option.class";

declare let App : AppModule;
declare let $ : any;


export class CategoriesModule
{
	categories : Category[] = [];
	options : Option[] = [];

	mainCategory : Category;
	openHoursCategory : Category;

	constructor() 
	{
		this.options = [];
		this.categories = [];
	}

	createCategoriesFromJson(mainCatgeoryJson, openHoursCategoryJson)
	{
		this.mainCategory = this.recursivelyCreateCategoryAndOptions(mainCatgeoryJson);
		this.openHoursCategory = this.recursivelyCreateCategoryAndOptions(openHoursCategoryJson);

		//console.log(this.mainCategory);
	}

	private recursivelyCreateCategoryAndOptions(categoryJson : any) : Category
	{
		let category = new Category(categoryJson);

		for(let optionJson of categoryJson.options)
		{
			let option = new Option(optionJson);
			option.ownerId = categoryJson.id;

			if (category.depth == 0) option.mainOwnerId = "all";
			else if (category.depth == -1) option.mainOwnerId = "openhours";
			else option.mainOwnerId = category.mainOwnerId;

			for(let subcategoryJson of optionJson.subcategories)
			{				
				if (category.depth <= 0) subcategoryJson.mainOwnerId = option.id;
				else subcategoryJson.mainOwnerId = option.mainOwnerId;

				let subcategory = this.recursivelyCreateCategoryAndOptions(subcategoryJson);
				subcategory.ownerId = option.id;				

				option.addCategory(subcategory);
			}
{'fraction_non_alphanumeric': 0.11293634496919917, 'fraction_numerical': 0.0077002053388090345, 'mean_word_length': 4.294836956521739, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '143241', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1115, 'n_words': 283}