返回列表 发帖

请求删除此帖,废弃无用了请求删除此帖,废弃无用了请求删除此帖,废弃无用了

本帖最后由 cl2039996 于 2022-5-8 16:08 编辑

请求删除此帖,废弃无用了请求删除此帖,废弃无用了请求删除此帖,废弃无用了请求删除此帖,废弃无用了请求删除此帖,废弃无用了
1

评分人数

报酬有点少,双倍还差不多
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 2# zaqmlp


    大佬,按照您的建议,双倍,共120元红包!您受累

TOP

回复 2# zaqmlp


    期待您今天给写好!

TOP

本帖最后由 zaqmlp 于 2022-3-26 23:12 编辑

bat存为ANSI/GB2312编码
<# :
cls&echo off&cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
pause
exit
#>
$txtfile=".\黑名单单词列表.txt";
$newfolder="E:\单词归类";
if(-not (test-path -literal $txtfile)){write-host ('"'+$txtfile+'" 未找到');exit;}
$enc=[Text.Encoding]::GetEncoding('GB2312');
$dic=New-Object 'System.Collections.Generic.Dictionary[string, string]';
$text=[IO.File]::ReadAllLines($txtfile, $enc);
for($i=0;$i -lt $text.length;$i++){
    $key=$text[$i].trimend().ToLower();
    if(-not $dic.ContainsKey($key)){
        $dic.add($key, '');
    }
}
$folders=@(dir -literal "."|?{$_ -is [System.IO.DirectoryInfo]});
for($i=0;$i -lt $folders.length;$i++){
    write-host $folders[$i].FullName;
    $files=@(dir -literal $folders[$i].FullName|?{('.srt' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
    for($j=0;$j -lt $files.length;$j++){
        write-host $files[$j].Name;
        $oldtext=[IO.File]::ReadAllText($files[$j].FullName, $enc);
        $arr=$oldtext.trim() -split '[\r\n]+';
        if($arr.length -ge 3){
            $oldline=$arr[2] -replace '<[^>]+?>','中';
            $mm=[regex]::matches($arr[2], '<[^>]+?>');
            $m=[regex]::matches($oldline, "(?i)[a-z'_\-\d]+");
            foreach($it in $m){
                $isexist=$false;
                $word=$it.groups[0].value;
                $key=$word.ToLower();
                if($dic.ContainsKey($key)){
                    $isexist=$true;
                }
                if((-not $isexist) -and ($word -match '[a-z]')){
                    $newpath=$newfolder.trimend('\')+'\'+$word;
                    if(-not (test-path -literal $newpath)){[void][IO.Directory]::CreateDirectory($newpath);}
                    $newbasename="[{0}][{1}][{2}]" -f $word,$folders[$i].Name,(get-date).ToString('yyyy-MM-dd HH点mm分ss秒fff毫秒');
                    $newsrt=$newpath+'\'+$newbasename+$files[$j].Extension;
                    $reg="(?i)(?<=^|[^a-z'_\-\d])"+[regex]::Escape($word)+"(?=[^a-z'_\-\d]|$)";
                    $newline=[regex]::replace($oldline, $reg, {
                        param($z);
                        '[b]<font color="#ff0000">'+$z.groups[0].value+'</font>[\b]';
                    });
                    if($mm.Count -ge 1){
                        $global:n=0;
                        $newline=[regex]::replace($newline, '中', {
                            param($z);
                            $mm[$global:n].groups[0].value;
                            $global:n++;
                        });
                    }
                    $brr=$arr.Clone();
                    $brr[2]=$newline;
                    $newtext=($brr -join "`r`n")+"`r`n`r`n"+'2'+"`r`n"+$arr[1]+"`r`n"+'{\an9}[b]<font color="#cccccc">'+$folders[$i].Name+'</font>[\b]';
                    [IO.File]::WriteAllText($newsrt, $newtext, $enc);
                    $newmp4=$newpath+'\'+$newbasename+'.mp4';
                    $oldmp4=$folders[$i].FullName+'\'+$files[$j].BaseName+'..mp4';
                    if(test-path -liter $oldmp4){
                        copy-item -literal $oldmp4 $newmp4 -force;
                    }else{
                        $oldmp4=$folders[$i].FullName+'\'+$files[$j].BaseName+'.mp4';
                        if(test-path -liter $oldmp4){
                            copy-item -literal $oldmp4 $newmp4 -force;
                        }
                    }
                }
            }
        }
    }
}COPY
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

需求5有问题吧,假设有句话
I take the ball which is on the table
难道这也算?
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 6# zaqmlp


    您真是为我想到了我考虑不周的地方,需求5的算法确实我想简单了。我再研究一下英语的各种例句,去琢磨一下怎么能够避免您说的那种问题。
需求5的迭代升级,容我过几天请您给与完善。

TOP

返回列表