[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Forum] Complexed perl problem.



Complexed perl problem.

Hi, I have the following problem:
I need to do the following operation on a (huge) data file see sample
below :
Strip the first row of the < & > and print it into a output file 
then I have to read the the rest of the data and to be able to 
and put it into a hash ??(if that’s the best way to go) and associate
the <PRON(pers,sing)> with the value I and <V(montr,pres)> with think
and so forth so that I can analyse the values depending on if it’s PRON
or V or something else.
The following:
**[main <ADJ(ge)>]**
is a match and need’s to be stripped of the 
**[ & ]**  and printed to the output file. 

Everything printed (I need to print more on each row but that I can
handle myself) has to be delimited by 
|| (double pipe)

Further below is a perlprog that I started to make until I realized that
I needed some help.

<ICE-GB:S2A-016 #2:1:B>
I <PRON(pers,sing)> think <V(montr,pres)> the <ART(def)> **[main
<ADJ(ge)>]** things <N(com,plu)> that <PRON(rel)> I <PRON(pers,sing)>
saw <V(cxtr,past)> as <PREP(ge)> <,> <PAUSE(short)> as <PREP(ge)>
**[absent <ADJ(ge)>]** from <PREP(ge)> disa <UNTAG> from <PREP(ge)> work
<N(com,sing)> with <PREP(ge)> with <PREP(ge)> disabled <ADJ(edp)> people
<N(com,plu)> was <V(cop,past)>
<ICE-GB:S3A-051 #8:1:A>
**[medium <ADJ(ge)>]** speed <N(com,sing)>

NB! Data filerows  above can vary in length (see row 2 & 4)

#!/usr/bin/perl
$faktor1 = "<ICE-GB:";
$icedata = "icedata.data";

open(FILE, "$icedata");
while(<FILE>) {
	$file = $_;
	chomp $file;
	if ($file =~ /$faktor1/) {
		$file =~ s/$faktor1/ /;
		$file =~ s/>/ /;
		print "$file\n";
	}
	elsif ($file !~ /$faktor1/	){
	@db_fields = split (/>/, $file); 
	foreach $field (@db_fields) { print "$field\n"; } 
	}
	else{
		print "No match\n";
	}
}
close(FILE);

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org