⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit3.~pas

📁 基于libsvm
💻 ~PAS
字号:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm3 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var dims_filterred : array of integer;
function CountStrNum(str:string):integer;
procedure  Convert2Array(var substr:array of String; str : string);

var
  Form3: TForm3;

implementation

uses main,MaxMin;

function CountStrNum(str:string):integer;
var numOfspace,m : integer;
    tempstr : string;
begin

   numOfspace := 0;

   tempstr := trim(str);
   while Pos(' ',tempstr)<>0  do
   begin
     m := Pos(' ',tempstr);
     numOfspace := numOfspace + 1;
     Delete(tempstr, 1, m-1);
     tempstr := trim(tempstr);
   end;
   numOfspace := numOfspace + 1;
   Result := numOfspace;


end;

procedure  Convert2Array(var substr:array of String; str : string); //讲用空格隔开的字符串
var m,i:integer;                                                    //分成若干子字符串
  space_pos:array[1..10] of integer;
  array_str:array[1..10] of string;
  numOfspace:integer;
  position : integer;
  tempstr:string;
begin
   numOfspace := 0;
   position := 1;
   tempstr := trim(str);
   while Pos(' ',tempstr)<>0  do
   begin
     m := Pos(' ',tempstr);
     numOfspace := numOfspace + 1;
     array_str[numOfspace] := Copy(tempstr, position,m-1);
     Delete(tempstr, 1, m-1);
     tempstr := trim(tempstr);
   end;
   numOfspace := numOfspace + 1;
   array_str[numOfspace] := tempstr;

 //  SetLength(sst,4);

   for i:=1 to numOfspace do
   begin
     substr[i] := array_str[i];
   end

end;

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var
 dims_str_filterred : array of string;
  dims_num, i : integer;
  tempChar : PChar;

begin
 if( input_file_loaded and test_file_loaded ) then
 begin
  dims_num :=   CountStrNum(Edit1.Text);
  SetLength(dims_filterred, dims_num + 1);
  SetLength(dims_str_filterred, dims_num + 1);
  Convert2Array(dims_str_filterred,trim(Edit1.Text));

  for  i := 0 to dims_num-1 do
      dims_filterred[i] := strtoint(dims_str_filterred[i+1]);

   dims_filterred[dims_num] := 0;


//   tempChar := '_filter';
  input_file_filterred := PChar(string(input_file_name) + '_filter');
  test_file_filterred :=  PChar(string(test_file_name) + '_filter');
  filtering2file(input_file_name, input_file_filterred, dims_filterred);
  filtering2file(test_file_name, test_file_filterred, dims_filterred);

  input_file_name := input_file_filterred;
  test_file_name := test_file_filterred;
 // main.input_file_name
  Form3.Visible := false;

 end
 else
 Application.MessageBox(PChar('尚未导入需要选择特征的训练集和测试集'),PChar('提示'), MB_OK);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -