<commit_before>﻿using DataParser.Enums;
using FormulasCollection.Interfaces;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Tools;

namespace FormulasCollection.Realizations
{
    public class TwoOutComeForkFormulas : IForkFormulas
    {

        private bool CheckIsFork(double? coef1, double? coef2)
        {
            if (coef1 == 0 || coef2 == 0)
                return false;
            return 1 > (1 / coef1.Value + 1 / coef2.Value);
        }

        public double getRate(double rate, double kof1, double kof2)
        {
            return ((rate * kof1) / kof2);
        }

        public List<Fork> getAllForks(List<ResultForForks> events, int defaultRate)
        {
            List<Fork> buffDic = new List<Fork>();
            var marafon = events.Where(e => e.Bookmaker == Site.MarathonBet.ToString());
            var pinacle = events.Where(e => e.Bookmaker == Site.PinnacleSports.ToString());
                    foreach (var buff in marafon)
                    {
                        foreach (var buff2 in pinacle){
                        if (isTheSame(buff.Event,buff2.Event) && checkForType(buff.Type,buff2.Type) && CheckIsFork(buff.Coef.ConvertToDoubleOrNull(), buff2.Coef.ConvertToDoubleOrNull()))
                        {
                            buffDic.Add(new Fork() {
                                Event = buff2.Event,
                                TypeFirst = buff.Type,
                                CoefFirst = buff.Coef,
                                TypeSecond = buff2.Type,
                                CoefSecond = buff2.Coef,
                                Sport = buff.SportType,
                                MatchDateTime = buff2.MatchDateTime,
                                BookmakerFirst = buff.Bookmaker,
                                BookmakerSecond = buff2.Bookmaker,
                                Profit = getRate(defaultRate,buff.Coef.ConvertToDouble(),buff2.Coef.ConvertToDouble()).ToString()
                            });
                        }
                        }
                    }
            return buffDic;
            }
        public bool checkForType(string type1, string type2)
        {
            if (type1 == "1")
            {
                switch (type2)
                {
                    case "X2":
                        return true;
                        break;
                    default:
                        return false;
                        break;
                }
            }
            if (type1 == "2")
            {
                switch (type2)
                {
                    case "X1":
                        return true;
                        break;
                    default:
                        return false;
                        break;
                }
            }
            if (type1 == "X1")
            {
                switch (type2)
                {
                    case "2":
                        return true;
                        break;
                    default:
                        return false;
                        break;
                }
            }
            if (type1 == "X2")
            {
                switch (type2)
                {
                    case "1":
                        return true;
                        break;
                    default:
                        return false;
                        break;
                }
            }
            if (type1 == "Меньше" && type2 == "Больше")
                return true;
            if (type2 == "Меньше" && type1 == "Больше")
                return true;
            return false;
<commit_msg>CheckType new version<commit_after>﻿using DataParser.Enums;
using FormulasCollection.Interfaces;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Tools;

namespace FormulasCollection.Realizations
{
    public class TwoOutComeForkFormulas : IForkFormulas
    {

        private bool CheckIsFork(double? coef1, double? coef2)
        {
            if (coef1 == 0 || coef2 == 0)
                return false;
            return 1 > (1 / coef1.Value + 1 / coef2.Value);
        }

        public double getRate(double rate, double kof1, double kof2)
        {
            return ((rate * kof1) / kof2);
        }

        public List<Fork> getAllForks(List<ResultForForks> events, int defaultRate)
        {
            List<Fork> buffDic = new List<Fork>();
            var marafon = events.Where(e => e.Bookmaker == Site.MarathonBet.ToString());
            var pinacle = events.Where(e => e.Bookmaker == Site.PinnacleSports.ToString());
                    foreach (var buff in marafon)
                    {
                        foreach (var buff2 in pinacle){
                        if (isTheSame(buff.Event,buff2.Event) && checkForType(buff.Type,buff2.Type) && CheckIsFork(buff.Coef.ConvertToDoubleOrNull(), buff2.Coef.ConvertToDoubleOrNull()))
                        {
                            buffDic.Add(new Fork() {
                                Event = buff2.Event,
                                TypeFirst = buff.Type,
                                CoefFirst = buff.Coef,
                                TypeSecond = buff2.Type,
                                CoefSecond = buff2.Coef,
                                Sport = buff.SportType,
                                MatchDateTime = buff2.MatchDateTime,
                                BookmakerFirst = buff.Bookmaker,
                                BookmakerSecond = buff2.Bookmaker,
                                Profit = getRate(defaultRate,buff.Coef.ConvertToDouble(),buff2.Coef.ConvertToDouble()).ToString()
                            });
                        }
                        }
                    }
            return buffDic;
            }
        public bool checkForType(string type1, string type2)
        {
            if (type1 == "1")
            {
                switch (type2)
                {
                    case "X2":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type1 == "2")
            {
                switch (type2)
                {
                    case "X1":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type1 == "X1")
            {
                switch (type2)
                {
                    case "2":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type1 == "X2")
            {
                switch (type2)
                {
                    case "1":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type2 == "1")
            {
                switch (type1)
                {
                    case "X2":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type2 == "2")
            {
                switch (type1)
                {
                    case "X1":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type2 == "X1")
            {
                switch (type1)
                {
                    case "2":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type2 == "X2")
            {
                switch (type1)
                {
                    case "1":
                        return true;
                        break;
                    default:
                        break;
                }
            }
            if (type1 == "Меньше" && type2 == "Больше")
                return true;
            if (type2 == "Меньше" && type1 == "Больше")
                return true;
            return false;

{'fraction_non_alphanumeric': 0.08047337278106509, 'fraction_numerical': 0.01301775147928994, 'mean_word_length': 0.7720696162717551, 'pattern_counts': {'":': 12, '<': 11, '<?xml version=': 0, '>': 17, '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': '2145931', 'n_tokens_mistral': 2084, 'n_tokens_neox': 1919, 'n_words': 414}