<commit_before>// Copyright (c) <NAME>. All rights reserved.
// Licensed under the BSD-Clause 2 license. 
// See license.txt file in the project root for full license information.
using System.Collections.Generic;
using Scriban.Parsing;
using Scriban.Syntax;

namespace Scriban.Runtime.Accessors
{
    public class StringAccessor : IListAccessor, IObjectAccessor
    {
        public static StringAccessor Default = new StringAccessor();

        private StringAccessor()
        {
        }

        public int GetLength(TemplateContext context, SourceSpan span, object target)
        {
            return ((string)target).Length;
        }

        public object GetValue(TemplateContext context, SourceSpan span, object target, int index)
        {
            return ((string)target)[index];
        }

        public void SetValue(TemplateContext context, SourceSpan span, object target, int index, object value)
        {
            throw new ScriptRuntimeException(span, "Cannot replace a character in a string");
        }<commit_msg>Make string accessor returning a string<commit_after>// Copyright (c) <NAME>. All rights reserved.
// Licensed under the BSD-Clause 2 license.
// See license.txt file in the project root for full license information.
using System.Collections.Generic;
using Scriban.Parsing;
using Scriban.Syntax;

namespace Scriban.Runtime.Accessors
{
    public class StringAccessor : IListAccessor, IObjectAccessor
    {
        public static StringAccessor Default = new StringAccessor();

        private StringAccessor()
        {
        }

        public int GetLength(TemplateContext context, SourceSpan span, object target)
        {
            return ((string)target).Length;
        }

        public object GetValue(TemplateContext context, SourceSpan span, object target, int index)
        {
            return ((string)target)[index].ToString();
        }

        public void SetValue(TemplateContext context, SourceSpan span, object target, int index, object value)
        {
            throw new ScriptRuntimeException(span, "Cannot replace a character in a string");
        }
{'fraction_non_alphanumeric': 0.07674199623352165, 'fraction_numerical': 0.0009416195856873823, 'mean_word_length': 2.8219424460431655, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5823531', 'n_tokens_mistral': 512, 'n_tokens_neox': 502, 'n_words': 185}