<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace TextParser.Tests
{
    [TestClass]
    public class ParsedTextTests
    {
        private static readonly string[] Xhtml = { "<p>", "Hello, ", "<b>", "w", "</b>", "orld", "</p>" };        
        private static readonly ISet<int> PlainTextInXhtml = new HashSet<int> { 1, 3, 5 };

        // Public

        [TestMethod]
        public void TokenInSinglePlainTextElement()
        {
            ParsedText parsedText = CreateParsedText(Xhtml, PlainTextInXhtml);
            Token testToken = new Token
            {
                XhtmlIndex = 1,
                StringPosition = 0,
                StringLength = 5,
                TokenKind = TokenKind.Alphabetic
            };

            string expected = "Hello";
            string actual = parsedText.GetPlainText(testToken);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void CompoundToken()
        {
            ParsedText parsedText = CreateParsedText(Xhtml, PlainTextInXhtml);
            Token testToken = new Token
            {
                XhtmlIndex = 3,
                StringPosition = 0,
                StringLength = 5
            };

            string expected = "world";
            string actual = parsedText.GetPlainText(testToken);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void PlainText()
        {
            ParsedText parsedText = CreateParsedText(Xhtml, PlainTextInXhtml);

            string expected = "Hello, world";
            string actual = parsedText.GetAllPlainText();

            Assert.AreEqual(expected, actual);;
        }
<commit_msg>Improve ParsedText test for compound token<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace TextParser.Tests
{
    [TestClass]
    public class ParsedTextTests
    {
        private static readonly string[] Xhtml = { "<p>", "Hello, ", "<b>", "my w", "</b>", "orld!", "</p>" };        
        private static readonly ISet<int> PlainTextInXhtml = new HashSet<int> { 1, 3, 5 };

        // Public

        [TestMethod]
        public void TokenInSinglePlainTextElement()
        {
            ParsedText parsedText = CreateParsedText(Xhtml, PlainTextInXhtml);
            Token testToken = new Token
            {
                XhtmlIndex = 1,
                StringPosition = 0,
                StringLength = 5,
                TokenKind = TokenKind.Alphabetic
            };

            string expected = "Hello";
            string actual = parsedText.GetPlainText(testToken);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void CompoundToken()
        {
            ParsedText parsedText = CreateParsedText(Xhtml, PlainTextInXhtml);
            Token testToken = new Token
            {
                XhtmlIndex = 3,
                StringPosition = 3,
                StringLength = 5
            };

            string expected = "world";
            string actual = parsedText.GetPlainText(testToken);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void PlainText()
        {
            ParsedText parsedText = CreateParsedText(Xhtml, PlainTextInXhtml);

            string expected = "Hello, my world!";
            string actual = parsedText.GetAllPlainText();

            Assert.AreEqual(expected, actual);;
        }

{'fraction_non_alphanumeric': 0.09247251198195658, 'fraction_numerical': 0.005074711023400056, 'mean_word_length': 1.763239875389408, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5438158', 'n_tokens_mistral': 962, 'n_tokens_neox': 892, 'n_words': 215}