using System;
using System.IO;
using System.Text;
namespace fx.meta.bgi.util
{
public sealed class ExtractText
{
public static void Main( string[ ] args ) {
if ( args.Length < 1 ) {
Console.WriteLine( "Give a valid script file as the first parameter." );
return;
}
string infilename = args[ 0 ];
string outfilename = args[ 0 ] + ".txt";
FileInfo infile = new FileInfo( infilename );
if ( !infile.Exists ) {
Console.WriteLine( "Give a valid script file as the first parameter." );
return;
}
long filelen = infile.Length;
// read all the text and write to output
Encoding utf16le = new UnicodeEncoding( false, true );
Encoding jis = Encoding.GetEncoding( 932 );
using ( BinaryReader reader = new BinaryReader( infile.OpenRead( ), jis ) ) {
using ( BinaryWriter writer = new BinaryWriter( File.Create( outfilename ), utf16le ) ) {
reader.BaseStream.Seek( 0x020, SeekOrigin.Begin );
uint opcode = reader.ReadUInt32( );
uint codeSize = reader.ReadUInt32( );
if ( opcode != 0x07F ) {
throw new Exception( "Unsupported script. Expecting 0x7F at 0x20, but found " + opcode.ToString( "X" ) );
}
if ( codeSize > filelen ) {
throw new Exception( "Bad script. Code size greater than file size." );
}
writer.Write( ( ushort ) 0xFEFF );
reader.BaseStream.Seek( ( long ) codeSize, SeekOrigin.Begin );
StringBuilder builder = null;
while ( reader.BaseStream.Position < reader.BaseStream.Length ) {
string position = reader.BaseStream.Position.ToString( "X" );
builder = new StringBuilder( );
char c = '\0';
while ( ( c = reader.ReadChar( ) ) != '\0' ) {
if ( c == '\n' ) {
builder.Append( @"\n" );
} else {
builder.Append( c );
}
}
string text = builder.ToString( );
string strlen = jis.GetByteCount( text ).ToString( );
writer.Write( utf16le.GetBytes( string.Format( "{0}, {1}, {2}{3}", position, strlen, text, Environment.NewLine ) ) );
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace fx.meta.bgi.util
{
public sealed class InsertText
{
public static void Main( string[ ] args ) {
if ( args.Length < 1 ) {
Console.WriteLine( "Give a valid script file as the first parameter." );
return;
}
string scriptName = args[ 0 ];
string textName = scriptName + ".txt";
string newScriptName = scriptName + ".new";
FileInfo scriptFile = new FileInfo( scriptName );
if ( !scriptFile.Exists ) {
Console.WriteLine( "Give a valid script file as the first parameter." );
return;
}
if ( !File.Exists( textName ) ) {
Console.WriteLine( "Correspoding text file not available." );
return;
}
long filelen = scriptFile.Length;
// read all the text and write to output
Encoding utf16le = new UnicodeEncoding( false, true );
Encoding jis = Encoding.GetEncoding( 932 );
Encoding gbk = Encoding.GetEncoding( 936 );
using ( BinaryReader script = new BinaryReader( scriptFile.OpenRead( ), jis ) ) {
using ( StreamReader text = new StreamReader( File.OpenRead( textName ), utf16le ) ) {
using ( BinaryWriter writer = new BinaryWriter( File.Create( newScriptName ), gbk ) ) {
Dictionary<uint, uint> offsetMapping = new Dictionary<uint, uint>( );
List<string> newTexts = new List<string>( );
int offsetDifference = 0;
script.BaseStream.Seek( 0x020, SeekOrigin.Begin );
uint opcode = script.ReadUInt32( );
uint codeSize = script.ReadUInt32( );
if ( opcode != 0x07F ) {
throw new Exception( "Unsupported script. Expecting 0x7F at 0x20, but found " + opcode.ToString( "X" ) );
}
if ( codeSize > filelen ) {
throw new Exception( "Bad script. Code size greater than file size." );
}
uint currentOffset = codeSize;
string line = text.ReadLine( );
while ( line != null && !line.Equals( string.Empty ) ) {
string[ ] elem = line.Split( new string[ ] { ", " }, StringSplitOptions.RemoveEmptyEntries );
uint oldOffset = UInt32.Parse( elem[ 0 ], NumberStyles.AllowHexSpecifier );
offsetMapping.Add( oldOffset, ( uint ) ( oldOffset + offsetDifference ) );
Console.WriteLine( "{0}, {1}, {2}",
oldOffset.ToString( "X" ),
( offsetMapping[ oldOffset ] ).ToString( "X" ),
offsetDifference.ToString( ) );
int oldTextLength = Int32.Parse( elem[ 1 ] );
int newTextLength = 0;
if ( 2 < elem.Length ) {
newTextLength = gbk.GetByteCount( elem[ 2 ] );
string s = elem[ 2 ].Replace( @"\n", "\n" );
newTexts.Add( s );
} else {
newTextLength = 0;
newTexts.Add( string.Empty );
}
offsetDifference += ( int ) ( newTextLength - oldTextLength );
line = text.ReadLine( );
}
script.BaseStream.Seek( 0, SeekOrigin.Begin );
byte[ ] scriptBuffer = script.ReadBytes( ( int ) codeSize );
for ( int dwptr = 0; dwptr < codeSize; dwptr += 4 ) {
uint currentDw = scriptBuffer[ dwptr ];
if ( currentDw != 0x03 && currentDw != 0x07F )
continue;
dwptr += 4;
currentDw = ToUInt32( scriptBuffer, dwptr );
if ( ( currentDw >= codeSize )
&& ( offsetMapping.ContainsKey( currentDw ) ) ) {
uint newOfs = offsetMapping[ currentDw ];
WriteUInt32( newOfs, scriptBuffer, dwptr );
} else {
dwptr -= 4;
}
}
writer.Write( scriptBuffer );
foreach ( string s in newTexts ) {
writer.Write( gbk.GetBytes( s ) );
writer.Write( ( byte ) 0 );
}
}
}
}
}
static uint ToUInt32( byte[ ] array, int beginOfs ) {
return ( uint ) (
( array[ beginOfs + 3 ] << 24 ) |
( array[ beginOfs + 2 ] << 16 ) |
( array[ beginOfs + 1 ] << 8 ) |
( array[ beginOfs ] ) );
}
static void WriteUInt32( uint data, byte[ ] array, int beginOfs ) {
array[ beginOfs ] = ( byte ) ( ( data ) & 0x0FF );
array[ beginOfs + 1 ] = ( byte ) ( ( data >> 8 ) & 0x0FF );
array[ beginOfs + 2 ] = ( byte ) ( ( data >> 16 ) & 0x0FF );
array[ beginOfs + 3 ] = ( byte ) ( ( data >> 24 ) & 0x0FF );
}
}
}
分享到:
相关推荐
哈希表源码
sun_3ck_03_0119
内容概要:本文档详细介绍了基于 MATLAB 实现的 LSTM-AdaBoost 时间序列预测模型,涵盖项目背景、目标、挑战、特点、应用领域以及模型架构和代码示例。随着大数据和AI的发展,时间序列预测变得至关重要。传统方法如 ARIMA 在复杂非线性序列中表现欠佳,因此引入了 LSTM 来捕捉长期依赖性。但 LSTM 存在易陷局部最优、对噪声鲁棒性差的问题,故加入 AdaBoost 提高模型准确性和鲁棒性。两者结合能更好应对非线性和长期依赖的数据,提供更稳定的预测。项目还展示了如何在 MATLAB 中具体实现模型的各个环节。 适用人群:对时间序列预测感兴趣的开发者、研究人员及学生,特别是有一定 MATLAB 编程经验和熟悉深度学习或机器学习基础知识的人群。 使用场景及目标:①适用于金融市场价格预测、气象预报、工业生产故障检测等多种需要时间序列分析的场合;②帮助使用者理解并掌握将LSTM与AdaBoost结合的实现细节及其在提高预测精度和抗噪方面的优势。 其他说明:尽管该模型有诸多优点,但仍存在训练时间长、计算成本高等挑战。文中提及通过优化数据预处理、调整超参数等方式改进性能。同时给出了完整的MATLAB代码实现,便于学习与复现。
1996-2019年各地级市平均工资数据 1、时间:1996-2019年 2、来源:城市nj、各地级市统计j 3、指标:平均工资(在岗职工) 4、范围:295个地级市
AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
内容概要:本文介绍了一种新颖的变压器模型C2Former(Calibrated and Complementary Transformer),专门用于解决RGB图像和红外图像之间的物体检测难题。传统方法在进行多模态融合时面临两个主要问题——模态错位(Modality miscalibration)和融合不准确(fusion imprecision)。作者针对这两个问题提出采用互模交叉注意力模块(Inter-modality Cross-Attention, ICA)以及自适应特征采样模块(Adaptive Feature Sampling, AFS)来改善。具体来说,ICA可以获取对齐并且互补的特性,在特征层面进行更好的整合;而AFS则减少了计算成本。通过实验验证了基于C2Former的一阶段和二阶段检测器均能在现有公开数据集上达到最先进的表现。 适合人群:计算机视觉领域的研究人员和技术人员,特别是从事跨模态目标检测的研究人员,对Transformer架构有一定了解的开发者。 使用场景及目标:适用于需要将可见光和热成像传感器相结合的应用场合,例如全天候的视频监控系统、无人驾驶汽车、无人
上海人工智能实验室:金融大模型应用评测报告-摘要版2024.pdf
malpass_02_0907
C++-自制学习辅助工具
内容概要:本文提供了有关微信生态系统的综合开发指导,具体涵盖了微信机器人的Java与Python开发、全套及特定应用的小程序源码(PHP后台、DeepSeek集成),以及微信公众号的基础开发与智能集成方法。文中不仅给出了各种应用的具体案例和技术要点如图灵API对接、DeepSeek大模型接入等的简述,还指出了相关资源链接以便深度探究或直接获取源码进行开发。 适合人群:有意开发微信应用程序或提升相应技能的技术爱好者和专业人士。不论是初涉者寻求基本理解和操作流程,还是进阶者期望利用提供的资源进行项目构建或是研究。 使用场景及目标:开发者能够根据自身兴趣选择不同方向深入学习微信平台的应用创建,如社交自动化(机器人)、移动互联网服务交付(小程序),或者公众信息服务(公众号)。特别是想要尝试引入AI能力到应用中的人士,文中介绍的内容非常有价值。 其他说明:文中提及的多个项目都涉及到了最新技术栈(如DeepSeek大模型),并且为不同层次的学习者提供从零开始的详细资料。对于那些想要迅速获得成果同时深入了解背后原理的人来说是个很好的起点。
pimpinella_3cd_01_0916
mellitz_3cd_01_0516
schube_3cd_01_0118
AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
智慧用电平台建设解决方案【28页】
lusted_3ck_01_0519
HCIP作业1 这里面是完成的ensp的拓扑图
会员式点餐小程序1.2.1 前端 会员卡点餐小程序 适用于书吧、咖啡书屋、健身房等有会员卡充值需求的场所。 小程序专属会员模式,可享受折扣为余额充值,稳定客流。 版本号:1.2.1 适配一个php兼容性错误 修改消息通知模板