<commit_before>import sys
import unittest
from io import StringIO
import antlr4
from sdoc.antlr.sdoc1Lexer import sdoc1Lexer
from sdoc.antlr.sdoc1Parser import sdoc1Parser
from sdoc.sdoc1.SDoc1visitor import SDoc1Visitor


class SDocTestCase(unittest.TestCase):
    # ------------------------------------------------------------------------------------------------------------------
    def run_output_test(self, sdoc):
        self.old_stdout, sys.stdout = sys.stdout, StringIO()

        stream = antlr4.InputStream(sdoc)
        lexer = sdoc1Lexer(stream)
        tokens = antlr4.CommonTokenStream(lexer)
        parser = sdoc1Parser(tokens)
        tree = parser.sdoc()
        visitor = SDoc1Visitor()
        visitor.set_output(sys.stdout)
        visitor.visit(tree)

        output = sys.stdout.getvalue().trim()

        sys.stdout = self.old_stdout

        return output

# ----------------------------------------------------------------------------------------------------------------------<commit_msg>changed 'trim' to 'strip' function in testcase<commit_after>import sys
import unittest
from io import StringIO
import antlr4
from sdoc.antlr.sdoc1Lexer import sdoc1Lexer
from sdoc.antlr.sdoc1Parser import sdoc1Parser
from sdoc.sdoc1.SDoc1visitor import SDoc1Visitor


class SDocTestCase(unittest.TestCase):
    # ------------------------------------------------------------------------------------------------------------------
    def run_output_test(self, sdoc):
        self.old_stdout, sys.stdout = sys.stdout, StringIO()

        stream = antlr4.InputStream(sdoc)
        lexer = sdoc1Lexer(stream)
        tokens = antlr4.CommonTokenStream(lexer)
        parser = sdoc1Parser(tokens)
        tree = parser.sdoc()
        visitor = SDoc1Visitor()
        visitor.set_output(sys.stdout)
        visitor.visit(tree)

        output = sys.stdout.getvalue().strip()

        sys.stdout = self.old_stdout

        return output

# ----------------------------------------------------------------------------------------------------------------------
{'fraction_non_alphanumeric': 0.29069767441860467, 'fraction_numerical': 0.012596899224806201, 'mean_word_length': 1.3983739837398375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7018099', 'n_tokens_mistral': 532, 'n_tokens_neox': 519, 'n_words': 108}