<commit_before>﻿namespace Markify.Document

open System
open System.IO

open Markify.Models.Documents
open Markify.Models.Definitions

module DocumentHelper =
    let convertNameToPath (fullname : string) =
        let parts = fullname.Split ('.')
        let path = String.Join ("\\", parts, 0, parts.Length - 1)
        sprintf @"%s\" path

    let cleanExtension (ext : string) = 
        match ext with
        | ext when ext.StartsWith(".") -> ext.Substring(1)
        | _ -> ext

    let createPage project ext definition =
        let path = Path.Combine (project, convertNameToPath definition.Identity.Fullname)
        let cleanExt = cleanExtension ext
        let page = {
            Name = sprintf "%s.%s" definition.Identity.Name cleanExt
            Folder = Uri (path, UriKind.Relative)
            Content = definition }
        page<commit_msg>Fix wrong folder page when a file is at the root directory of a project<commit_after>﻿namespace Markify.Document

open System
open System.IO

open Markify.Models.Documents
open Markify.Models.Definitions

module DocumentHelper =
    let convertNameToPath (fullname : string) =
        let parts = fullname.Split ('.')
        match parts.Length with
        | 1 -> String.Empty
        | _ -> sprintf @"%s\" <| String.Join (@"\", parts, 0, parts.Length - 1)

    let cleanExtension (ext : string) = 
        match ext with
        | ext when ext.StartsWith(".") -> ext.Substring(1)
        | _ -> ext

    let createPage project ext definition =
        let path = Path.Combine (project, convertNameToPath definition.Identity.Fullname)
        let cleanExt = cleanExtension ext
        let page = {
            Name = sprintf "%s.%s" definition.Identity.Name cleanExt
            Folder = Uri (path, UriKind.Relative)
            Content = definition }
        page
{'fraction_non_alphanumeric': 0.09802847754654984, 'fraction_numerical': 0.0038335158817086527, 'mean_word_length': 2.3896103896103895, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, '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': '6190872', 'n_tokens_mistral': 508, 'n_tokens_neox': 490, 'n_words': 155}