<commit_before>Param(
  [string]$pathToSearch = $env:BUILD_SOURCESDIRECTORY,
  [string]$buildNumber = $env:BUILD_BUILDNUMBER,
  [regex]$pattern = "\d+\.\d+\.\d+\.\d+",
  [string]$makeReleaseVersion = [bool]::FalseString,
  [string]$preReleaseName = "",
  [string]$includeRevInPreRelease = [bool]::FalseString,
  [string]$patternSplitCharacters = ".",
  [string]$versionNumbersInAssemblyVersion = "2"
)

$ErrorActionPreference = "Stop"

if ([bool]::Parse($makeReleaseVersion)) {
    $preReleaseName = $null
    $includeRevInPreRelease = [bool]::FalseString
}
elseif ([string]::IsNullOrEmpty($preReleaseName)) {
    Write-Host "Prerelease name is not set"
    exit 1
}

$searchFilter = "AssemblyInfo.*"
if ($buildNumber -match $pattern -ne $true) {
    Write-Host "Could not extract a version from [$buildNumber] using pattern [$pattern]"
    exit 2
}

# Declare functions

function Replace-Version($content, $version, $attribute, $language) {
    if ($language = "cs") {
        $versionAttribute = "[assembly: $attribute(""$version"")]"
        $pattern = "\[assembly: $attribute\("".*""\)\]"
    }
    elseif ($language = "vb") {
        $versionAttribute = "<Assembly: $attribute(""$version"")>"
        $pattern = "\<Assembly: $attribute\("".*""\)\>"
    }

    $versionReplaced = $false

    $content = $content | %{
        if ($_ -match $pattern) {
            $versionReplaced = $true
            Write-Host "     * Replaced $($Matches[0]) with $versionAttribute"
            $_ = $_ -replace [regex]::Escape($Matches[0]),$versionAttribute
        }
        $_
    }
	
    if (-not $versionReplaced) {
        Write-Host "     * Added $versionAttribute to end of content"
        $content += [System.Environment]::NewLine + $versionAttribute
    }
    return $content
}

function Get-VersionString($numberOfVersions, $extractedBuildNumbers) {
    return [string]::Join(".",($extractedBuildNumbers | select -First ([int]::Parse($numberOfVersions))))
}
<commit_msg>Bug correction<commit_after>Param(
  [string]$pathToSearch = $env:BUILD_SOURCESDIRECTORY,
  [string]$buildNumber = $env:BUILD_BUILDNUMBER,
  [regex]$pattern = "\d+\.\d+\.\d+\.\d+",
  [string]$makeReleaseVersion = [bool]::FalseString,
  [string]$preReleaseName = "",
  [string]$includeRevInPreRelease = [bool]::FalseString,
  [string]$patternSplitCharacters = ".",
  [string]$versionNumbersInAssemblyVersion = "2"
)

$ErrorActionPreference = "Stop"

if ([bool]::Parse($makeReleaseVersion)) {
    $preReleaseName = $null
    $includeRevInPreRelease = [bool]::FalseString
}
elseif ([string]::IsNullOrEmpty($preReleaseName)) {
    Write-Host "Prerelease name is not set"
    exit 1
}

$searchFilter = "AssemblyInfo.*"
if ($buildNumber -match $pattern -ne $true) {
    Write-Host "Could not extract a version from [$buildNumber] using pattern [$pattern]"
    exit 2
}

# Declare functions

function Replace-Version($content, $version, $attribute, $language) {
    if ($language -eq "cs") {
        $versionAttribute = "[assembly: $attribute(""$version"")]"
        $pattern = "\[assembly: $attribute\("".*""\)\]"
    }
    elseif ($language -eq "vb") {
        $versionAttribute = "<Assembly: $attribute(""$version"")>"
        $pattern = "\<Assembly: $attribute\("".*""\)\>"
    }

    $versionReplaced = $false

    $content = $content | %{
        if ($_ -match $pattern) {
            $versionReplaced = $true
            Write-Host "     * Replaced $($Matches[0]) with $versionAttribute"
            $_ = $_ -replace [regex]::Escape($Matches[0]),$versionAttribute
        }
        $_
    }
	
    if (-not $versionReplaced) {
        Write-Host "     * Added $versionAttribute to end of content"
        $content += [System.Environment]::NewLine + $versionAttribute
    }
    return $content
}

function Get-VersionString($numberOfVersions, $extractedBuildNumbers) {
    return [string]::Join(".",($extractedBuildNumbers | select -First ([int]::Parse($numberOfVersions))))
}

{'fraction_non_alphanumeric': 0.1728770595690748, 'fraction_numerical': 0.0025348542458808617, 'mean_word_length': 3.6533018867924527, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1892897', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1207, 'n_words': 239}