- 论坛徽章:
- 0
|
赞同!有个问题可以请教吗?
能否帮忙检查一下这个代码啊?先谢了!
这段代码为了实现操作两个文本,通过检索关键词在表格相邻两行显示搜索到的英汉语对应的句子,但是结果不理想,请问什么原因?麻烦给诊断一下,谢谢!
use strict;
use warnings;
use UTF8;
use Win32::GUI qw(DT_RIGHT DT_LEFT DT_CENTER DT_VCENTER);
use Win32::GUI::Grid qw(GVS_DATA);
my $main = Win32::GUI::Window->new(
-name => ‘Main’,
-title => “arallel Corpus”,
-pos => [ 0, 0 ],
-size => [ 1200, 840 ],
);
$main->AddLabel(
-text => “lease fill the search word in the following blank”,
-top => 20,
-align => ‘center’,
-left => 35,
width => 300,
height => 30,
);
my $f1=$main->AddTextfield(
-name => “searchword”,
-align => ‘center’,
-left => 20,
-top => 60,
-width => 160,
-height => 30,
);
$main->AddButton(
-name => “search”,
-text => “GO”,
-pos => [ 190, 60 ],
-width => 110,
-height => 30,
-ok => 1,
);
my $grid=$main->AddGrid(
-name => ‘grid’,
-left => 20,
-top => 90,
-width => 1120,
-height => 560,
-rows => 1,
-columns => 2,
-fixedrows => 1,
);
$grid->SetRows(1);
$grid->SetCellText(0, 0, ‘No.’);
$grid->SetCellFormat(0, 1, DT_CENTER);
$grid->SetCellText(0, 1, ‘Result’);
$grid->SetColumnWidth(0, 50);
$grid->SetListMode();
$grid->SetFixedColumnSelection(0);
$main->Show();
Win32::GUI:ialog();
exit(0);
sub search_Click{
open(ZH,”ZH.txt”;
my @zh= ;
chomp(@zh);
open(EN,”EN.txt”;
my @en= ;
chomp(@en);
close ZH;
close EN;
foreach my $i(0..$#zh){
my $j=$i+1;
my %match;
$match{$zh[$i]}=$en[$i];
my $node = $main->searchword->Text();
if ( $en[$i] =~ /$node/i)
{
my $row = $grid->GetRows();
$grid->InsertRow(-1);
$grid->SetCellText($j, 0, $j);
$grid->SetCellText($j, 1, $en[$i]);
$grid->InsertRow(-2);
$grid->SetCellText($j, 0, $j);
$grid->SetCellText($j, 1, $zh[$i]);
}
回复 30# MMMIX
|
|