Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/scripts/ConvertTo-HL.ps1 @ 17143

Last change on this file since 17143 was 16620, checked in by hmaislin, 6 years ago

#2929: Reorganized folder structure for make script, removed explicit marshalling, erased go-side logging

File size: 1.5 KB
Line 
1[cmdletbinding()]
2param(
3  [string]$bench = [string]::Empty
4)
5
6$p = "..\src\go-pge\data\benchmark\"
7$OutPath = "..\src\go-pge\data\hlbenchmark\"
8
9if(-not $(Test-Path -Path $p)) {
10  Write-Error "Benchmark $p not found!"
11  exit 2
12}
13
14if($bench -eq [string]::Empty) {
15  $i = Get-ChildItem -Path $p -Filter *.trn
16} else {
17  $i = Get-ChildItem -Path $p -Filter "$($bench).trn"
18}
19foreach($it in $i) {
20  $bench = $it.BaseName
21    $OutFile = Join-Path $OutPath "$($it.BaseName).csv"
22    $TrnCont = Get-Content $(Join-Path -Path $it.DirectoryName -ChildPath "$($it.BaseName).trn")
23    $TrnContNew = @()
24    $Count = 0
25
26    $VarHead = "$($TrnCont[0].Trim());$($TrnCont[1].Trim())"
27    $VarHead = $VarHead -replace ' ', ';'
28    $TrnContNew += $VarHead
29    foreach($line in $TrnCont) {
30        if($Count -ge 2) {
31            $TrnContNew += $line.Trim().Replace('.',',').Replace(' ',';')
32        }
33        $Count++
34    }
35
36    $TrainEnd = $Count
37    $TestStart = $TrainEnd + 1
38
39    $TestCont = Get-Content $(Join-Path -Path $it.DirectoryName -ChildPath "$($it.BaseName).tst")
40    $Count = 0
41    foreach($line in $TestCont) {
42        if($Count -ge 2) {
43            $TrnContNew += $line.Trim().Replace('.',',').Replace(' ',';')
44        }
45        $Count++
46    }
47
48    $TrnContNew | Out-File -FilePath $OutFile
49
50    $TestEnd = $TestStart + $Count
51
52    Write-Host "$($bench): TestPartition Start: $TestStart, $TestEnd"
53    Write-Host "$($bench): TrainingPartition Start: 0, $TrainEnd `n"
54}
Note: See TracBrowser for help on using the repository browser.