<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using SystemInteract;
using IPTables.Net.Exceptions;

namespace IPTables.Net.IpUtils.Utils
{
    public abstract class IpController
    {
        protected ISystemFactory _system;
        protected String _module;

        public IpController(String module, ISystemFactory system)
        {
            _module = module;
            _system = system;
        }

        protected virtual bool IsSingle(String key)
        {
            return false;
        }

        internal virtual String[] ExportObject(IpObject obj)
        {
            var ret = new List<string>(obj.Singles);
            foreach (var kv in obj.Pairs)
            {
                ret.Add(kv.Key);
                ret.Add(kv.Value);
            }
            return ret.ToArray();
        }

        protected IpObject ParseObject(String str, String firstKey, char[] firstTrimChars = null)
        {
            IpObject ret = new IpObject();
            String[] strs = str.Split(new char[] {' ','\t'}, StringSplitOptions.RemoveEmptyEntries);
            if (strs.Length == 0)
            {
                return null;
            }
            int i = 0;
            if (firstKey != null)
            {
                var v = strs[i];
                if (firstTrimChars != null)
                {
                    v = v.TrimEnd(firstTrimChars);
                }
                ret.Pairs.Add(firstKey, v);
                i++;
            }
            for (; i < strs.Length; i++)
            {
                var k = strs[i];<commit_msg>allow singles before<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using SystemInteract;
using IPTables.Net.Exceptions;

namespace IPTables.Net.IpUtils.Utils
{
    public abstract class IpController
    {
        protected ISystemFactory _system;
        protected String _module;

        public IpController(String module, ISystemFactory system)
        {
            _module = module;
            _system = system;
        }

        protected virtual bool IsSingle(String key)
        {
            return false;
        }

        internal virtual String[] ExportObject(IpObject obj)
        {
            var ret = new List<string>(obj.Singles);
            foreach (var kv in obj.Pairs)
            {
                ret.Add(kv.Key);
                ret.Add(kv.Value);
            }
            return ret.ToArray();
        }

        protected IpObject ParseObject(String str, String firstKey, char[] firstTrimChars = null)
        {
            IpObject ret = new IpObject();
            String[] strs = str.Split(new char[] {' ','\t'}, StringSplitOptions.RemoveEmptyEntries);
            if (strs.Length == 0)
            {
                return null;
            }
            int i = 0;
            for (; i < strs.Length; i++)
            {
                var k = strs[i];
                if (IsSingle(k))
                {
                    ret.Singles.Add(k);
                }
                else
                {
                    break;
                }
            }
            if (firstKey != null)
            {
                var v = strs[i];
                if (firstTrimChars != null)
                {
                    v = v.TrimEnd(firstTrimChars);
                }
                ret.Pairs.Add(firstKey, v);
                i++;
            }
            for (; i < strs.Length; i++)
            {
                var k = strs[i];
{'fraction_non_alphanumeric': 0.09385665529010238, 'fraction_numerical': 0.0011376564277588168, 'mean_word_length': 1.2189274447949527, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, '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': '3301295', 'n_tokens_mistral': 965, 'n_tokens_neox': 902, 'n_words': 221}