<commit_before>﻿using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using myoddweb.classifier.core;
using Classifier.Interfaces;
using System.Reflection;
using myoddweb.classifier.utils;

namespace myoddweb.classifierUnitTest
{
  [TestFixture]
  public class TestCommon
  {
    /// <summary>
    /// Name for logging in the event viewer,
    /// </summary>
    private const string EventViewSource = "myoddweb.classifier";

    // the engine
    private Engine _engine;

    protected static string DbName = "ctest_database.classifier";
    protected static string CleandbName = "clean_ctest_database.classifier";

    protected Engine TheEngine => _engine ?? (_engine = CreateEngine());

    public static string DirectoryPath { get; private set; }
    public static string DatabaseFullPath { get; private set; }
    public static string CleanDatabaseFullPath { get; private set; }

    protected static string GetDirectory()
    {
      // the paths we will be using.
      var directoryName = AppDomain.CurrentDomain.BaseDirectory;
      if (File.Exists($"{directoryName}\\x64\\classifier.engine.dll"))
      {
        return directoryName;
      }

      var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
      foreach (var loadedAssembly in loadedAssemblies)
      {
        directoryName = Path.GetDirectoryName(loadedAssembly.Location);
        for (; directoryName!= null;)
        {
          if (File.Exists($"{directoryName}\\x64\\classifier.engine.dll"))
          {
            return directoryName;
          }

          try
          {
            directoryName = Directory.GetParent(directoryName).FullName;
          }
          catch
          {
            break;<commit_msg>Changed the way the common tests 'looks' for directories.<commit_after>﻿using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using myoddweb.classifier.core;
using Classifier.Interfaces;
using System.Reflection;
using myoddweb.classifier.utils;

namespace myoddweb.classifierUnitTest
{
  [TestFixture]
  public class TestCommon
  {
    /// <summary>
    /// Name for logging in the event viewer,
    /// </summary>
    private const string EventViewSource = "myoddweb.classifier";

    // the engine
    private Engine _engine;

    protected static string DbName = "ctest_database.classifier";
    protected static string CleandbName = "clean_ctest_database.classifier";

    protected Engine TheEngine => _engine ?? (_engine = CreateEngine());

    public static string DirectoryPath { get; private set; }
    public static string DatabaseFullPath { get; private set; }
    public static string CleanDatabaseFullPath { get; private set; }

    protected static string GetDirectoryInCurrentDomain()
    {
      var architecture = "86";
      if (Environment.Is64BitOperatingSystem)
      {
        architecture = "64";
      }

      // the paths we will be using.
      var directoryName = AppDomain.CurrentDomain.BaseDirectory;
      if (File.Exists($"{directoryName}\\x{architecture}\\classifier.engine.dll"))
      {
        return directoryName;
      }

      directoryName = Directory.GetParent(directoryName).FullName;
      if (File.Exists($"{directoryName}\\x{architecture}\\classifier.engine.dll"))
      {
        return directoryName;
      }

      // not found.
      return null;
    }

    protected static string GetDirectory()
    {
      var posibleDirectory = GetDirectoryInCurrentDomain();
      if (null != posibleDirectory)
      {
        return posibleDirectory;
      }


      // look in the current domain.
      var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
      foreach (var loadedAssembly in loadedAssemblies)
      {
        var directoryName = Path.GetDirectoryName(loadedAssembly.Location);
        for (; directoryName!= null;)
        {
          if (File.Exists($"{directoryName}\\x64\\classifier.engine.dll"))
          {
            return directoryName;
          }

          try
          {
            directoryName = Directory.GetParent(directoryName).FullName;
          }
          catch
          {
            break;
{'fraction_non_alphanumeric': 0.09409772617319787, 'fraction_numerical': 0.002902757619738752, 'mean_word_length': 2.6303775241439857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7550828', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1080, 'n_words': 276}