<commit_before>﻿using System;
using System.Collections.Generic;
using droid.Runtime.Utilities.NeodroidCamera.Synthesis;
using droid.Runtime.Utilities.Structs;
using UnityEngine;
using UnityEngine.Serialization;
using Object = System.Object;
using Random = UnityEngine.Random;
using System.Linq;

namespace droid.Runtime.Utilities.NeodroidCamera.Segmentation
{
  /// <inheritdoc />
  /// <summary>
  /// </summary>
  [ExecuteInEditMode]
  public class CategorySegmenter : Segmenter
  {
    /// <summary>
    /// </summary>
    Renderer[] _all_renders;

    /// <summary>
    /// </summary>
    MaterialPropertyBlock _block;

    [SerializeField] Shader segmentation_shader;
    [SerializeField] Camera _camera;

    enum SegmentationMode
    {
      Tag,
      Layer
    }

    [SerializeField] ScriptableObjects.Segmentation _segmentation_preset;

    /// <summary>
    /// </summary>
    public bool _Replace_Untagged_Color = true;

    /// <summary>
    /// </summary>
    public Color _Untagged_Color = Color.black;

    /// <summary>
    /// </summary>
    public ColorByCategory[] ColorsByCategory
    {
      get { return this._colors_by_category; }
    }

    [SerializeField] protected ColorByCategory[] _colors_by_category;

    [SerializeField] SegmentationMode _segmentation_mode;

    /// <summary>
    /// </summary>
    public Dictionary<string, Color> ColorsDictGameObject { get; set; } = new Dictionary<string, Color>();

    /// <summary>
    /// </summary>
    public override Dictionary<string, Color> ColorsDict
    {
      get
      {
        var colors = new Dictionary<string, Color>();
        foreach (var key_val in this.ColorsDictGameObject)
        {
          colors.Add(key_val.Key, key_val.Value);
        }

        return colors;
      }
    }

    /// <summary>
    /// </summary>
    void Start()
    {
      //this.Setup();
    }

    /// <summary>
    /// </summary>
    void Awake()
    {
      this.Setup();
    }


    void CheckBlock()
    {
      if (this._block == null)
      {
        this._block = new MaterialPropertyBlock();
      }
    }

    SynthesisUtilities.CapturePass[] _capturePasses;

    /// <summary>
    /// </summary>
    void Setup()
    {
      if (this._colors_by_category != null && this._colors_by_category.Length > 0)
      {
        foreach (var tag_color in this._colors_by_category)
        {
          if (!this.ColorsDictGameObject.ContainsKey(tag_color._Tag))
          {
            this.ColorsDictGameObject.Add(tag_color._Tag, tag_color._Col);
          }
        }
      }

      if (this._segmentation_preset)
      {
        var segmentation_color_by_tags = this._segmentation_preset._color_by_categories;
        if (segmentation_color_by_tags != null)
        {
          foreach (var tag_color in segmentation_color_by_tags)
          {
            if (!this.ColorsDictGameObject.ContainsKey(tag_color._Tag))
            {
              this.ColorsDictGameObject.Add(tag_color._Tag, tag_color._Col);
            }
          }
        }
      }

      this._all_renders = FindObjectsOfType<Renderer>();
      if (!this._camera)
      {
        this._camera = this.GetComponent<Camera>();
      }

      if (this.ColorsDictGameObject == null)
      {
        this.ColorsDictGameObject = new Dictionary<string, Color>();
      }

      switch (this._segmentation_mode)
      {<commit_msg>rename<commit_after>﻿using System;
using System.Collections.Generic;
using droid.Runtime.Utilities.NeodroidCamera.Synthesis;
using droid.Runtime.Utilities.Structs;
using UnityEngine;
using UnityEngine.Serialization;
using Object = System.Object;
using Random = UnityEngine.Random;
using System.Linq;

namespace droid.Runtime.Utilities.NeodroidCamera.Segmentation
{
  /// <inheritdoc />
  /// <summary>
  /// </summary>
  [ExecuteInEditMode]
  public class CategorySegmenter : Segmenter
  {
    /// <summary>
    /// </summary>
    Renderer[] _all_renders;

    /// <summary>
    /// </summary>
    MaterialPropertyBlock _block;

    [SerializeField] Shader segmentation_shader;
    [SerializeField] Camera _camera;

    enum SegmentationMode
    {
      Tag,
      Layer
    }

    [SerializeField] ScriptableObjects.Segmentation _segmentation_preset;

    /// <summary>
    /// </summary>
    public bool _Replace_Untagged_Color = true;

    /// <summary>
    /// </summary>
    public Color _Untagged_Color = Color.black;

    /// <summary>
    /// </summary>
    public ColorByCategory[] ColorsByCategory
    {
      get { return this._colors_by_category; }
    }

    [SerializeField] protected ColorByCategory[] _colors_by_category;

    [SerializeField] SegmentationMode _segmentation_mode;

    /// <summary>
    /// </summary>
    public Dictionary<string, Color> ColorsDictGameObject { get; set; } = new Dictionary<string, Color>();

    /// <summary>
    /// </summary>
    public override Dictionary<string, Color> ColorsDict
    {
      get
      {
        var colors = new Dictionary<string, Color>();
        foreach (var key_val in this.ColorsDictGameObject)
        {
          colors.Add(key_val.Key, key_val.Value);
        }

        return colors;
      }
    }

    /// <summary>
    /// </summary>
    void Start()
    {
      //this.Setup();
    }

    /// <summary>
    /// </summary>
    void Awake()
    {
      this.Setup();
    }


    void CheckBlock()
    {
      if (this._block == null)
      {
        this._block = new MaterialPropertyBlock();
      }
    }

    SynthesisUtilities.CapturePass[] _capturePasses;

    /// <summary>
    /// </summary>
    void Setup()
    {
      if (this._colors_by_category != null && this._colors_by_category.Length > 0)
      {
        foreach (var tag_color in this._colors_by_category)
        {
          if (!this.ColorsDictGameObject.ContainsKey(tag_color._Category_Name))
          {
            this.ColorsDictGameObject.Add(tag_color._Category_Name, tag_color._Color);
          }
        }
      }

      if (this._segmentation_preset)
      {
        var segmentation_color_by_tags = this._segmentation_preset._color_by_categories;
        if (segmentation_color_by_tags != null)
        {
          foreach (var tag_color in segmentation_color_by_tags)
          {
            if (!this.ColorsDictGameObject.ContainsKey(tag_color._Category_Name))
            {
              this.ColorsDictGameObject.Add(tag_color._Category_Name, tag_color._Color);
            }
          }
        }
      }

      this._all_renders = FindObjectsOfType<Renderer>();
      if (!this._camera)
      {
        this._camera = this.GetComponent<Camera>();
      }

      if (this.ColorsDictGameObject == null)
      {
        this.ColorsDictGameObject = new Dictionary<string, Color>();
      }

      switch (this._segmentation_mode)
      {
{'fraction_non_alphanumeric': 0.11696942844483828, 'fraction_numerical': 0.0002953773445576724, 'mean_word_length': 2.2140484100616993, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 65, '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': '3750584', 'n_tokens_mistral': 2027, 'n_tokens_neox': 1999, 'n_words': 362}