hi all,
I have three files.
The first file (FILE_INFO in my code) consists of four parameters for each line.
0.00765600 0.08450704 M3 E3
0.00441931 0.04878049 M4 E5
0.01904574 0.21022727 M5 E10
0.00510400 0.05633803 M6 E12
0.00905960 0.10000000 M7 E16
0.00799376 0.08823529 M8 E17
0.00424669 0.04687500 M9 E18
I want to write out the corresponding sentences from 2nd file (M_IN in my code) and 3rd file (E_IN in my code) based on the 3rd column and 4th column parameters of first file. The M# and E# are the sentence numbers in 2nd and 3rd files.
The format of 2nd and 3rd files is : [where M# and E# are for sentence numbers in 2nd and 3rd files]
M4 asd
M4 dfgg
M4 rtyt
M4 rtytry
M4 etrert
M4 EOS
M5 tyuty
M5 ertert
M5 yuyu
M5 EOS
M6 iui
M6 jkjk
M6 EOS
EOS means the fullstop .(End of sentence)
Please correct the script I have written. The E_OUT and M_OUT are the output files where the corresponding sentences will be written.
while(my $m_text = <$FILE_INFO> ){
@me_text = split /\s+/, $m_text;
while(my $m_input= <$M_IN>)
{
@m_no = split /\s+/, $m_input;
if($m_no[0] eq $me_text[2])
{
chomp;
s/^M\d[ ]+//g;
s/[ ]*$//;
$x .= " ".$_;
$x =~ s/^ //;
$x =~ s/ EOS[ ]*/.\n/g;
}
}
print M_OUT $_;
while(my $e_input = <$E_IN>)
{
@e_no = split /\s+/, $e_input;
if($e_no[0] eq $me_text[3])
{
chomp;
s/^E\d[ ]+//g;
s/[ ]*$//;
$x .= " ".$_;
$x =~ s/^ //;
$x =~ s/ EOS[ ]*/.\n/g;
}
}
print E_OUT $_;
Expected output in the M_OUT
asd dfgg rtyt rtytry etrert .
tyuty ertert yuyu .
iui jkjk.
Similarly same format in the E_OUT will appear picking up the corresponding sentences from E_IN file based on the parameter in FILE_INFO file.
Thanks in advance.