I do appreciate your comments/help on this
I have a table that is multi line tab delimitted with records separate by 'EOU'. like below
I want to extract utterance(u),related phrase(s)(p), and related mapped concept(s)(mc)
00000000.tx.1 1 u CHIEF COMPLAINT:
00000000.tx.1 2 p CHIEF COMPLAINT
00000000.tx.2 1 u Mental status change over the last 5 days.
00000000.tx.2 2 p Mental status change
00000000.tx.2 3 c 1 1
00000000.tx.2 4 m 1 1 1000
00000000.tx.2 5 mc 1 1 1 1 1000 MENTAL STATUS CHANGE ALTERED MENTAL STATUS mental,status,change mobd
00000000.tx.2 6 p over the last 5 days
00000000.tx.2 7 c 0 0
00000000.tx.2 8 m 0 0
'EOU'.
my questions are
1. using local $/="'EOU'." in order to introduce my block generates incorrect ouput. How should I use this correctly?
2. The output of my code currently generates
CHIEF COMPLAINT:
CHIEF COMPLAINT
Mental status change over the last 5 days.
Mental status change
over the last 5 days
how can I change the output to generate this format?
CHIEF COMPLAINT: <tab> CHIEF COMPLAINT
Mental status change over the last 5 days. <tab> Mental staus change
................................................................<tab>over the last 5 days
in other words how can I generate an output like this
u<tab>p
and if there are multiple phrases per utterence I get multiple line of phrases
u<tab>p
...........p
...........p
3.How can I add another joined "aggregated fields" infront of "p" if an "mc" field is present.
I mean by adding this line to the code
$field3=join("\t",@data[7,8,9,10,11])
I could get an output like this
u<tab>p
...........p
...........p<tab>mc
Thanks again for your help
code
#!/usr/bin/perl<br>
$file = "fielded.txt";
open IN, "<", $file or die "Unable to open $file: $!";
while($line=<IN>)
{
@data=split(/\t/,$line);
if ($data[2] eq "u")
{$field1=$data[3]; print "\n$field1";}
if ($data[2] eq "p")
{$field2=$data[3]; print "$field2\n";}
}
close IN;