<commit_before>--[[

  Copyright (C) 2013 <NAME>
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
 
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
 
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.

--]]
local pathc = require('path.pathc');

local function normalize( ... )
    local argv = {...};
    local path = argv[1];
    local seg = nil;
    local res = {};
    
    if #argv > 1 then
        path = table.concat( argv, '/' );
    else
        path = argv[1];
    end
    
    -- remove double slash
    path = path:gsub( '/+', '/' );
    for seg in string.gmatch( path, '[^/]+' ) do
        if seg == '..' then
            table.remove( res );
        elseif seg ~= '.' then
            table.insert( res, seg );
        end
    end
    
    return '/' .. table.concat( res, '/' );
end

local function dirname( path )
    return string.match( path, '^(.+)/[^/]+$' );
end

local function basename( path, suffix )
    path = string.match( path, '^.+/([^/]+)$' );
    if suffix and suffix ~= path then
        return string.gsub( path, string.gsub( suffix, '%.', '%%.' ) .. '$', '' );
    end
    
    return path;
end

local function extname( path )
    return string.match( path, '[^/%.](%.[%w]*)$' );
end

return {
    normalize = normalize,
    dirname = dirname,
    basename = basename,
    extname = extname,
    exists = pathc.exists,
    stat = pathc.stat,
    isReg = pathc.isReg,
    isDir = pathc.isDir,
    isChr = pathc.isChr,
    isBlk = pathc.isBlk,
    isFifo = pathc.isFifo,
    isLnk = pathc.isLnk,
    isSock = pathc.isSock
};
<commit_msg>change: lua function dirname/basename/extname has been removed.<commit_after>--[[

  Copyright (C) 2013 <NAME>
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
 
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
 
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.

--]]
local pathc = require('path.pathc');

local function normalize( ... )
    local argv = {...};
    local path = argv[1];
    local seg = nil;
    local res = {};
    
    if #argv > 1 then
        path = table.concat( argv, '/' );
    else
        path = argv[1];
    end
    
    -- remove double slash
    path = path:gsub( '/+', '/' );
    for seg in string.gmatch( path, '[^/]+' ) do
        if seg == '..' then
            table.remove( res );
        elseif seg ~= '.' then
            table.insert( res, seg );
        end
    end
    
    return '/' .. table.concat( res, '/' );
end

return {
    normalize = normalize,
    dirname = pathc.dirname,
    basename = pathc.basename,
    extname = pathc.extname,
    exists = pathc.exists,
    stat = pathc.stat,
    isReg = pathc.isReg,
    isDir = pathc.isDir,
    isChr = pathc.isChr,
    isBlk = pathc.isBlk,
    isFifo = pathc.isFifo,
    isLnk = pathc.isLnk,
    isSock = pathc.isSock
};

{'fraction_non_alphanumeric': 0.10467899891186072, 'fraction_numerical': 0.003046789989118607, 'mean_word_length': 2.6826923076923075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5839426', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1352, 'n_words': 544}