<commit_before>﻿namespace ShapefileSharp
{
    public struct WordCount
    {
        public WordCount(int words)
        {
            Words = words;
        }

        /// <summary>
        /// The number of 16-bit words.
        /// </summary>
        public int Words { get; set; }

        /// <summary>
        /// The number of bytes.
        /// </summary>
        public int Bytes {
            get
            {
                return Words * 2;
            }
        }

        public static WordCount operator +(WordCount wc1, WordCount wc2)
        {
            return new WordCount(wc1.Words + wc2.Words);
        }

        public static WordCount operator *(WordCount wc, int factor)
        {
            return new WordCount(wc.Words * factor);
        }

        public static WordCount operator *(int factor, WordCount wc)
        {
            return wc * factor;
        }<commit_msg>* WordCount -- Add FromBytes() and FromWords() methods<commit_after>﻿using System;

namespace ShapefileSharp
{
    public struct WordCount
    {
        private const int BytesPerWord = 2;

        public WordCount(int words)
        {
            Words = words;
        }

        /// <summary>
        /// Create a <see cref="WordCount"/> based on the specified number of bytes.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown when the specified number of bytes is odd (i.e. un-even).</exception>
        public static WordCount FromBytes(int bytes)
        {
            if (bytes % BytesPerWord != 0)
            {
                throw new ArgumentException("Cannot determine number of words from odd number of bytes.", nameof(bytes));
            }

            return new WordCount(bytes / BytesPerWord);
        }

        public static WordCount FromWords(int words)
        {
            return new WordCount(words);
        }

        /// <summary>
        /// The number of 16-bit words.
        /// </summary>
        public int Words { get; set; }

        /// <summary>
        /// The number of bytes.
        /// </summary>
        public int Bytes {
            get
            {
                return Words * BytesPerWord;
            }
        }

        public static WordCount operator +(WordCount wc1, WordCount wc2)
        {
            return new WordCount(wc1.Words + wc2.Words);
        }

        public static WordCount operator *(WordCount wc, int factor)
        {
            return new WordCount(wc.Words * factor);
        }

        public static WordCount operator *(int factor, WordCount wc)
        {
            return wc * factor;
        }
{'fraction_non_alphanumeric': 0.09434682964094729, 'fraction_numerical': 0.005729564553093965, 'mean_word_length': 1.4093836246550138, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4303146', 'n_tokens_mistral': 712, 'n_tokens_neox': 665, 'n_words': 212}