- 论坛徽章:
- 0
|
本帖最后由 perllover007 于 2014-05-23 08:45 编辑
写了一段代码,操作两个文本,想实现通过检索关键词在表格相邻两行显示搜索到的英汉语对应的句子,但是结果只显示汉语文本,请问什么原因?
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= <ZH>;
chomp(@zh);
open(EN,"EN.txt" ;
my @en= <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]);
}
谢谢!
在线等您回复!
|
|