<commit_before># Use the .NET Core APIs to determine the current platform; if a runtime
# exception is thrown, we are on FullCLR, not .NET Core.
#
# TODO: import Microsoft.PowerShell.Platform instead
try {
    $Runtime = [System.Runtime.InteropServices.RuntimeInformation]
    $OSPlatform = [System.Runtime.InteropServices.OSPlatform]

    $IsCore = $true
    $IsLinux = $Runtime::IsOSPlatform($OSPlatform::Linux)
    $IsOSX = $Runtime::IsOSPlatform($OSPlatform::OSX)
    $IsWindows = $Runtime::IsOSPlatform($OSPlatform::Windows)
} catch [System.Management.Automation.RuntimeException] {
    $IsCore = $false
    $IsLinux = $false
    $IsOSX = $false
    $IsWindows = $true
}

function Start-PSBuild {
    [CmdletBinding(DefaultParameterSetName='CoreCLR')]
    param(
        [switch]$Restore,
        [switch]$Clean,

        # These runtimes must match those in project.json
        # We do not use ValidateScript since we want tab completion
        [ValidateSet("ubuntu.14.04-x64",
                     "centos.7.1-x64",
                     "win7-x64",
                     "win81-x64",
                     "win10-x64",
                     "osx.10.10-x64",
                     "osx.10.11-x64")]
        [Parameter(ParameterSetName='CoreCLR')]
        [string]$Runtime,

        [Parameter(ParameterSetName='FullCLR')]
        [switch]$FullCLR,

        [Parameter(ParameterSetName='FullCLR')]
        [string]$cmakeGenerator = "Visual Studio 14 2015",

        [Parameter(ParameterSetName='FullCLR')]
        [ValidateSet("Debug",
                     "Release")]
        [string]$msbuildConfiguration = "Release"
    )

    function precheck([string]$command, [string]$missedMessage) {
        $c = Get-Command $command -ErrorAction SilentlyContinue
        if (-not $c) {
            Write-Warning $missedMessage
            return $false
        } else {
            return $true
        }
    }

    function log([string]$message) {
        Write-Host -Foreground Green $message
    }

    # simplify ParameterSetNames
    if ($PSCmdlet.ParameterSetName -eq 'FullCLR') {
        $FullCLR = $true
    }

    # verify we have all tools in place to do the build
    $precheck = precheck 'dotnet' "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/"
    if ($FullCLR) {
        # cmake is needed to build powershell.exe
        $precheck = $precheck -and (precheck 'cmake' 'cmake not found. You can install it from https://chocolatey.org/packages/cmake.portable')

        # msbuild is needed to build powershell.exe
        # msbuild is part of .NET Framework, we can try to get it from well-known location.
        if (-not (Get-Command -Name msbuild -ErrorAction Ignore)) {
            $env:path += ";${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319"
        }

        $precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.')
    } elseif ($IsLinux -Or $IsOSX) {
        $InstallCommand = if ($IsLinux) {
            'apt-get'
        } elseif ($IsOSX) {
            'brew'
        }

        foreach ($Dependency in 'cmake', 'make', 'g++') {
            $precheck = $precheck -and (precheck $Dependency "Build dependency '$Dependency' not found. Run '$InstallCommand install $Dependency'")
        }
    }

    if (-Not $Runtime) {
        $Runtime = dotnet --info | % {
            if ($_ -match "RID") {
                $_ -split "\s+" | Select-Object -Last 1
            }
        }

        if (-Not $Runtime) {
            Write-Warning "Could not determine Runtime Identifier, please update dotnet"
            $precheck = $false
        } else {
            log "Runtime not specified, using $Runtime"
        }
    }

    # Abort if any precheck failed
    if (-not $precheck) {
        return
    }

    # define key build variables
    if ($FullCLR) {
        $Top = "$PSScriptRoot\src\Microsoft.PowerShell.ConsoleHost"
        $Framework = 'net451'
    } else {
        $Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host"
        $Framework = 'netstandardapp1.5'
    }

    if ($IsLinux -Or $IsOSX) {
        $Configuration = "Linux"
        $Executable = "powershell"
    } else {
        $Configuration = "Debug"
        $Executable = "powershell.exe"
    }

    $Arguments = @()
    $Arguments += "--framework", $Framework
    $Arguments += "--configuration", $Configuration
    $Arguments += "--runtime", $Runtime
    $script:Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework, $Runtime, $Executable)
    Write-Verbose "script:Output is $script:Output"

    # handle Restore
    if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
        log "Run dotnet restore"

        $Arguments = @("--verbosity")
        if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
            $Arguments += "Info"
        } else {
            $Arguments += "Warning"
        }

        $Arguments += "$PSScriptRoot"

        dotnet restore $Arguments
    }

    # Build native components
    if ($IsLinux -Or $IsOSX) {
        $Ext = if ($IsLinux) {
            "so"
        } elseif ($IsOSX) {
            "dylib"
        }

        $Native = "$PSScriptRoot/src/libpsl-native"<commit_msg>Rename dotnet restore arguments variable<commit_after># Use the .NET Core APIs to determine the current platform; if a runtime
# exception is thrown, we are on FullCLR, not .NET Core.
#
# TODO: import Microsoft.PowerShell.Platform instead
try {
    $Runtime = [System.Runtime.InteropServices.RuntimeInformation]
    $OSPlatform = [System.Runtime.InteropServices.OSPlatform]

    $IsCore = $true
    $IsLinux = $Runtime::IsOSPlatform($OSPlatform::Linux)
    $IsOSX = $Runtime::IsOSPlatform($OSPlatform::OSX)
    $IsWindows = $Runtime::IsOSPlatform($OSPlatform::Windows)
} catch [System.Management.Automation.RuntimeException] {
    $IsCore = $false
    $IsLinux = $false
    $IsOSX = $false
    $IsWindows = $true
}

function Start-PSBuild {
    [CmdletBinding(DefaultParameterSetName='CoreCLR')]
    param(
        [switch]$Restore,
        [switch]$Clean,

        # These runtimes must match those in project.json
        # We do not use ValidateScript since we want tab completion
        [ValidateSet("ubuntu.14.04-x64",
                     "centos.7.1-x64",
                     "win7-x64",
                     "win81-x64",
                     "win10-x64",
                     "osx.10.10-x64",
                     "osx.10.11-x64")]
        [Parameter(ParameterSetName='CoreCLR')]
        [string]$Runtime,

        [Parameter(ParameterSetName='FullCLR')]
        [switch]$FullCLR,

        [Parameter(ParameterSetName='FullCLR')]
        [string]$cmakeGenerator = "Visual Studio 14 2015",

        [Parameter(ParameterSetName='FullCLR')]
        [ValidateSet("Debug",
                     "Release")]
        [string]$msbuildConfiguration = "Release"
    )

    function precheck([string]$command, [string]$missedMessage) {
        $c = Get-Command $command -ErrorAction SilentlyContinue
        if (-not $c) {
            Write-Warning $missedMessage
            return $false
        } else {
            return $true
        }
    }

    function log([string]$message) {
        Write-Host -Foreground Green $message
    }

    # simplify ParameterSetNames
    if ($PSCmdlet.ParameterSetName -eq 'FullCLR') {
        $FullCLR = $true
    }

    # verify we have all tools in place to do the build
    $precheck = precheck 'dotnet' "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/"
    if ($FullCLR) {
        # cmake is needed to build powershell.exe
        $precheck = $precheck -and (precheck 'cmake' 'cmake not found. You can install it from https://chocolatey.org/packages/cmake.portable')

        # msbuild is needed to build powershell.exe
        # msbuild is part of .NET Framework, we can try to get it from well-known location.
        if (-not (Get-Command -Name msbuild -ErrorAction Ignore)) {
            $env:path += ";${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319"
        }

        $precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.')
    } elseif ($IsLinux -Or $IsOSX) {
        $InstallCommand = if ($IsLinux) {
            'apt-get'
        } elseif ($IsOSX) {
            'brew'
        }

        foreach ($Dependency in 'cmake', 'make', 'g++') {
            $precheck = $precheck -and (precheck $Dependency "Build dependency '$Dependency' not found. Run '$InstallCommand install $Dependency'")
        }
    }

    if (-Not $Runtime) {
        $Runtime = dotnet --info | % {
            if ($_ -match "RID") {
                $_ -split "\s+" | Select-Object -Last 1
            }
        }

        if (-Not $Runtime) {
            Write-Warning "Could not determine Runtime Identifier, please update dotnet"
            $precheck = $false
        } else {
            log "Runtime not specified, using $Runtime"
        }
    }

    # Abort if any precheck failed
    if (-not $precheck) {
        return
    }

    # define key build variables
    if ($FullCLR) {
        $Top = "$PSScriptRoot\src\Microsoft.PowerShell.ConsoleHost"
        $Framework = 'net451'
    } else {
        $Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host"
        $Framework = 'netstandardapp1.5'
    }

    if ($IsLinux -Or $IsOSX) {
        $Configuration = "Linux"
        $Executable = "powershell"
    } else {
        $Configuration = "Debug"
        $Executable = "powershell.exe"
    }

    $Arguments = @()
    $Arguments += "--framework", $Framework
    $Arguments += "--configuration", $Configuration
    $Arguments += "--runtime", $Runtime
    $script:Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework, $Runtime, $Executable)
    Write-Verbose "script:Output is $script:Output"

    # handle Restore
    if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
        log "Run dotnet restore"

        $RestoreArguments = @("--verbosity")
        if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
            $RestoreArguments += "Info"
        } else {
            $RestoreArguments += "Warning"
        }

        $RestoreArguments += "$PSScriptRoot"

        dotnet restore $RestoreArguments
    }

    # Build native components
    if ($IsLinux -Or $IsOSX) {
        $Ext = if ($IsLinux) {
            "so"
        } elseif ($IsOSX) {
            "dylib"
        }

        $Native = "$PSScriptRoot/src/libpsl-native"
{'fraction_non_alphanumeric': 0.12708966565349544, 'fraction_numerical': 0.010638297872340425, 'mean_word_length': 2.1857791225416037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '5770587', 'n_tokens_mistral': 3253, 'n_tokens_neox': 3072, 'n_words': 765}