<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Saxon.Api;

namespace sandcastle_md {
   
   class Program {

      static void Main(string[] args) {

         var proc = new Processor();
         proc.RegisterExtensionFunction(new MakeRelativeUriExtensionFunction());

         var compiler = proc.NewXsltCompiler();

         var baseUri = new Uri(AppDomain.CurrentDomain.BaseDirectory, UriKind.Absolute);

         var exec = compiler.Compile(new Uri(baseUri, "sandcastle-md-all.xsl"));

         var transformer = exec.Load();
         transformer.InitialTemplate = new QName("main");
         transformer.SetParameter(new QName("source-dir"), new XdmAtomicValue(new Uri(baseUri, args[0])));

         if (args.Length > 1) {
            transformer.SetParameter(new QName("output-dir"), new XdmAtomicValue(new Uri(baseUri, args[1])));
         }

         var serializer = new Serializer();
         serializer.SetOutputWriter(Console.Out);

         transformer.Run(serializer);<commit_msg>resolve arguments against current directory<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Saxon.Api;

namespace sandcastle_md {
   
   class Program {

      static void Main(string[] args) {

         var proc = new Processor();
         proc.RegisterExtensionFunction(new MakeRelativeUriExtensionFunction());

         var compiler = proc.NewXsltCompiler();

         string currentDir = Environment.CurrentDirectory;
         string inputDir = args[0];
         string outputDir = args[1];

         if (currentDir.Last() != Path.DirectorySeparatorChar) {
            currentDir += Path.DirectorySeparatorChar;
         }

         if (inputDir.Last() != Path.DirectorySeparatorChar) {
            inputDir += Path.DirectorySeparatorChar;
         }

         if (outputDir.Last() != Path.DirectorySeparatorChar) {
            outputDir += Path.DirectorySeparatorChar;
         }

         var baseUri = new Uri(AppDomain.CurrentDomain.BaseDirectory, UriKind.Absolute);
         var callerBaseUri = new Uri(currentDir, UriKind.Absolute);

         var exec = compiler.Compile(new Uri(baseUri, "sandcastle-md-all.xsl"));

         var transformer = exec.Load();
         transformer.InitialTemplate = new QName("main");
         transformer.SetParameter(new QName("source-dir"), new XdmAtomicValue(new Uri(callerBaseUri, inputDir)));

         if (args.Length > 1) {
            transformer.SetParameter(new QName("output-dir"), new XdmAtomicValue(new Uri(callerBaseUri, outputDir)));
         }

         var serializer = new Serializer();
         serializer.SetOutputWriter(Console.Out);

         transformer.Run(serializer);
{'fraction_non_alphanumeric': 0.10899280575539569, 'fraction_numerical': 0.002158273381294964, 'mean_word_length': 2.9671897289586306, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5498169', 'n_tokens_mistral': 779, 'n_tokens_neox': 742, 'n_words': 164}