<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Http;
using System.Threading;
using System.IO;
using System.Xml.Linq;
using System.Diagnostics;
using System.Text.RegularExpressions;

// TODO:
// (2) Write a TestGPS function which uses Bing
// (3) Alter Bing to prefer landmarks if they're nearby

static partial class Program
{
    static void Test()
    {
        var fns = Directory.GetFiles("test");
        foreach (var fn in fns)
        {
            var ft = FilestampTime(fn);
            var mt = MetadataTimeAndGps(fn);
            Console.WriteLine($"{fn}\r\n    ft={ft?.Item1}\r\n    mt={mt?.Item1}\r\n    gps={mt?.Item3}");
        }
    }


    static void Main(string[] args)
    {
        if (BingMapsKey == "") Console.WriteLine("THIS VERSION HAS BEEN BUILT WITHOUT GPS SUPPORT");

        string cmdPattern = "", cmdError = ""; TimeSpan? cmdOffset = null;
        var cmdFns = new List<string>();
        var cmdArgs = new LinkedList<string>(args);
        //
        while (cmdError == "" && cmdArgs.Count > 0)
        {
            var cmd = cmdArgs.First.Value; cmdArgs.RemoveFirst();
            if (cmd == "-rename" || cmd=="/rename")
            {
                if (cmdPattern != "") { cmdError = "duplicate /rename"; break; }
                cmdPattern = "%{datetime} - %{fn} - %{place}";
                if (cmdArgs.Count > 0 && !cmdArgs.First.Value.StartsWith("/") && !cmdArgs.First.Value.StartsWith("-")) { cmdPattern = cmdArgs.First.Value; cmdArgs.RemoveFirst(); }
            }
            else if (cmd.StartsWith("/day") || cmd.StartsWith("/hour") || cmd.StartsWith("/minute")
                || cmd.StartsWith("-day") || cmd.StartsWith("-hour") || cmd.StartsWith("-minute"))
            {
                var len = 0; Func<int, TimeSpan> mkts = (n) => default(TimeSpan);
                if (cmd.StartsWith("/day") || cmd.StartsWith("-day")) { len = 4; mkts = (n) => TimeSpan.FromDays(n); }
                if (cmd.StartsWith("/hour") || cmd.StartsWith("-hour")) { len = 5; mkts = (n) => TimeSpan.FromHours(n); }
                if (cmd.StartsWith("/minute") || cmd.StartsWith("-minute")) { len = 7; mkts = (n) => TimeSpan.FromMinutes(n); }
                var snum = cmd.Substring(len);
                if (!snum.StartsWith("+") && !snum.StartsWith("-")) { cmdError = cmd; break; }
                var num = 0; if (!int.TryParse(snum, out num)) { cmdError = cmd; break; }
                cmdOffset = cmdOffset.HasValue ? cmdOffset : new TimeSpan(0);
                cmdOffset = cmdOffset + mkts(num);
            }
            else if (cmd == "/?" || cmd=="/help" || cmd=="-help" || cmd=="--help")
            {
                cmdFns.Clear(); break;
            }
            else if (cmd.StartsWith("-"))
            {
                // unknown option, so error out:
                cmdError = cmd; break;
                // We'd also like to error out on unknown options that start with "/",
                // but can't, because that's a valid filename in unix.
            }
            else
            {
                if (cmd.Contains("*") || cmd.Contains("?"))
                {
                    string globPath = Path.GetDirectoryName(cmd), globMatch = Path.GetFileName(cmd);
                    if (globPath.Contains("*") || globPath.Contains("?")) { cmdError = "Can't match wildcard directory names"; break; }
                    if (globPath == "") globPath = Directory.GetCurrentDirectory();
                    var fns = Directory.GetFiles(globPath, globMatch);
                    if (fns.Length == 0) Console.WriteLine($"Not found - \"{cmd}\"");
                    cmdFns.AddRange(fns);
                }
                else
                {
                    if (File.Exists(cmd)) cmdFns.Add(cmd);
                    else Console.WriteLine($"Not found - \"{cmd}\"");
                }
            }
        }


        Console.WriteLine($"cmdOffset: {cmdOffset}");
        Console.WriteLine($"cmdPattern: {cmdPattern}");
        Console.WriteLine("cmdFiles:");
        foreach (var fn in cmdFns) Console.WriteLine($"   {fn}");
        return;<commit_msg>Verified that command-line works on OS X<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Http;
using System.Threading;
using System.IO;
using System.Xml.Linq;
using System.Diagnostics;
using System.Text.RegularExpressions;

// TODO:
// (2) Write a TestGPS function which uses Bing
// (3) Alter Bing to prefer landmarks if they're nearby

static partial class Program
{
    static void Test()
    {
        var fns = Directory.GetFiles("test");
        foreach (var fn in fns)
        {
            var ft = FilestampTime(fn);
            var mt = MetadataTimeAndGps(fn);
            Console.WriteLine($"{fn}\r\n    ft={ft?.Item1}\r\n    mt={mt?.Item1}\r\n    gps={mt?.Item3}");
        }
    }


    static void Main(string[] args)
    {
        if (BingMapsKey == "") Console.WriteLine("THIS VERSION HAS BEEN BUILT WITHOUT GPS SUPPORT");

        string cmdPattern = "", cmdError = ""; TimeSpan? cmdOffset = null;
        var cmdFns = new List<string>();
        var cmdArgs = new LinkedList<string>(args);
        //
        while (cmdError == "" && cmdArgs.Count > 0)
        {
            var cmd = cmdArgs.First.Value; cmdArgs.RemoveFirst();
            if (cmd == "-rename" || cmd=="/rename")
            {
                if (cmdPattern != "") { cmdError = "duplicate /rename"; break; }
                cmdPattern = "%{datetime} - %{fn} - %{place}";
                if (cmdArgs.Count > 0 && !cmdArgs.First.Value.StartsWith("/") && !cmdArgs.First.Value.StartsWith("-")) { cmdPattern = cmdArgs.First.Value; cmdArgs.RemoveFirst(); }
            }
            else if (cmd.StartsWith("/day") || cmd.StartsWith("/hour") || cmd.StartsWith("/minute")
                || cmd.StartsWith("-day") || cmd.StartsWith("-hour") || cmd.StartsWith("-minute"))
            {
                var len = 0; Func<int, TimeSpan> mkts = (n) => default(TimeSpan);
                if (cmd.StartsWith("/day") || cmd.StartsWith("-day")) { len = 4; mkts = (n) => TimeSpan.FromDays(n); }
                if (cmd.StartsWith("/hour") || cmd.StartsWith("-hour")) { len = 5; mkts = (n) => TimeSpan.FromHours(n); }
                if (cmd.StartsWith("/minute") || cmd.StartsWith("-minute")) { len = 7; mkts = (n) => TimeSpan.FromMinutes(n); }
                var snum = cmd.Substring(len);
                if (!snum.StartsWith("+") && !snum.StartsWith("-")) { cmdError = cmd; break; }
                var num = 0; if (!int.TryParse(snum, out num)) { cmdError = cmd; break; }
                cmdOffset = cmdOffset.HasValue ? cmdOffset : new TimeSpan(0);
                cmdOffset = cmdOffset + mkts(num);
            }
            else if (cmd == "/?" || cmd=="/help" || cmd=="-help" || cmd=="--help")
            {
                cmdFns.Clear(); break;
            }
            else if (cmd.StartsWith("-"))
            {
                // unknown option, so error out:
                cmdError = cmd; break;
                // We'd also like to error out on unknown options that start with "/",
                // but can't, because that's a valid filename in unix.
            }
            else
            {
                if (cmd.Contains("*") || cmd.Contains("?"))
                {
                    string globPath = Path.GetDirectoryName(cmd), globMatch = Path.GetFileName(cmd);
                    if (globPath.Contains("*") || globPath.Contains("?")) { cmdError = "Can't match wildcard directory names"; break; }
                    if (globPath == "") globPath = Directory.GetCurrentDirectory();
                    var fns = Directory.GetFiles(globPath, globMatch);
                    if (fns.Length == 0) Console.WriteLine($"Not found - \"{cmd}\"");
                    cmdFns.AddRange(fns);
                }
                else
                {
                    if (File.Exists(cmd)) cmdFns.Add(cmd);
                    else Console.WriteLine($"Not found - \"{cmd}\"");
                }
            }
        }

{'fraction_non_alphanumeric': 0.15813953488372093, 'fraction_numerical': 0.003427172582619339, 'mean_word_length': 1.8137052341597797, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '6475171', 'n_tokens_mistral': 2422, 'n_tokens_neox': 2356, 'n_words': 558}