RE: RE: Re: Tri-grams?

------_=_NextPart_001_01C6380E.13FCCC91
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

-----Original Message-----
From: amit hetawal [mailto:amit_h123@rediffmail.com]
Sent: Wednesday, February 22, 2006 16:00
To: Wagner, David --- Senior Programmer Analyst --- WGO
Subject: Re: RE: Re: Tri-grams?



hi there
the sequnce with alpha _ _ is valid but not _ _ _



   I replaced the 4 four lines in your program with the following four line=
s.
=20
      next if ( $char !~ /[a-z]/i );
      my $char2 =3D substr $_, $ii+1, 1;
      next if ( $char2 !~ /[a-z ]/i );
      my $char3 =3D substr $_, $ii+2, 1;
      next if ( $char3 !~ /[a-z ]/i );

=20
Changed the input to
=20
$_ =3D ' hello. how  a,re you hel?lo ';
=20
Output:
$\%hash =3D {
  'e y' =3D> 1,
  'ell' =3D> 1,
  'hel' =3D> 2,
  'how' =3D> 1,
  'llo' =3D> 1,
  'lo ' =3D> 1,
  'ou ' =3D> 1,
  'ow ' =3D> 1,
  're ' =3D> 1,
  'u h' =3D> 1,
  'w  ' =3D> 1,
  'you' =3D> 1
};
=20
Wags ;)



On Thu, 23 Feb 2006 Wagner,David --- Senior Programmer Analyst --- WGO wrot=
e :
>Unclear in that are you saying? Is a__ where _ is a space is valid or can =
three spaces be valid? So are you working with only alpha and spaces or alp=
ha, numbers and spaces?
>
>Wags ;)
>
>-----Original Message-----
> From: perl-win32-users-bounces@listserv.ActiveState.com [mailto:perl-win3=
2-users-bounces@listserv.ActiveState.com]On Behalf Of amit hetawal
>Sent: Wednesday, February 22, 2006 12:09
>To: $Bill Luebkert
>Cc: perl-win32-users@listserv.ActiveState.com
>Subject: Re: Re: Tri-grams?
>
>
>
>
>
>
>On Wed, 22 Feb 2006 $Bill Luebkert wrote :
> >amit hetawal wrote:
> >
> > >
> > > Hello All,
> > >  I needed some logic behind the code for text analysis. its like i ha=
ve
> > > to calculate the frequency of the each of the tri-grams present in a
> > > given piece of text
> > > i.e i need a way to get the number of occurence of 't' follwoed by 'h=
e'
> > > for the word 'the' in whole of the text.
> > >
> > > for text : ' hello how are you '
> > > i need to get occurences of 'h' follwed by 'el' then 'e' follwed by '=
ll'...
> > > and so on for each of the words present if a space is present then it=
 is
> > > considered as a type of character only...
> > > Can you please help me with this...
> > > I was able to do it for bigrams where i had only 2 characters and use=
d 2
> > > d arrays...but for 3 charcters i am still lost...
> > > Can anybody help me with this...
> >
> >I would just make a hash and walk the string char by char using substr.
> >You could make it more generic if 3 isn't the only ossible length - I
> >just checked each char to make sure it wasn't a space rather than adding
> >a second length loop.
> >
> >use strict;
> >use warnings;
> >use Data::Dumper; $Data::Dumper::Indent=3D1; $Data::Dumper::Sortkeys=3D1;
> >
> >$_ =3D ' hello how are you hello ';
> >
> >my %hash;
> >my $len =3D length $_;
> >for (my $ii =3D 0; $ii < $len; ++$ii) {
> >      my $char =3D substr $_, $ii, 1;
> >      next if $char eq ' ';
> >      my $char2 =3D substr $_, $ii+1, 1;
> >      next if $char2 eq ' ';
> >      my $char3 =3D substr $_, $ii+2, 1;
> >      next if $char3 eq ' ';
> >      ++$hash{$char.$char2.$char3};
> >}
> >print Data::Dumper->Dump([\%hash], [qw(\%hash)]);
> >
> >__END__
> >
> >Result:
> >
> >$\%hash =3D {
> >  'are' =3D> 1,
> >  'ell' =3D> 2,
> >  'hel' =3D> 2,
> >  'how' =3D> 1,
> >  'llo' =3D> 2,
> >  'you' =3D> 1
> >};
> >
>
>Hello Bill
>Thanks for your help...
>i got the initial part running but now i have so read the text from a larg=
e text file havin all the sentences and special characters and in that i ha=
ve to get the trigrams working and not only for the above text ...can you p=
lease suggest how should i format the file and access the hash values which=
 i store for all of the whole text ...
>a tri gram with 'ab_' will also work since i have to consider the space as=
 a character ...too..
>please help :(
>thanks..
>
>
>
>
>  <http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/s=
ignature-home.htm/1507191490@Middle5?PARTNER=3D3>
>
>
>
>*******************************************************
>This message contains information that is confidential
>and proprietary to FedEx Freight or its affiliates.
>It is intended only for the recipient named and for
>the express purpose(s) described therein.
>Any other use is prohibited.
>*******************************************************
>




 <http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/sig=
nature-home.htm/1507191490@Middle5?PARTNER=3D3> =20



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


------_=_NextPart_001_01C6380E.13FCCC91--
0
David
2/23/2006 12:14:14 AM
perl.beginners 29388 articles. 4 followers. Follow

0 Replies
1146 Views

Similar Articles

[PageSpeed] 13
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

RE : RE : RE : RE : Regular expressions
Here is a sample of what your piece of code returns on my Aix box. 44520 -> /prog/gena/8.1.1/bin/dispatch 44650 -> reproject 45176 -> aioserver 45432 -> aioserver 45724 -> -ksh 46002 -> /bin/bsh 46232 -> /usr/dt/bin/dtterm 46584 -> /usr/bin/ksh 46820 -> /usr/dt/bin/ttsession 47060 -> /bin/bsh 47304 -> /usr/dt/bin/dtlogin 47396 -> /usr/dt/bin/dtterm 47722 -> dtfile 47942 -> /usr/dt/bin/dtsession 48272 -> dtfile 48568 -> ora_cjq0_gist 48758 -> gxtrackd 49032 -> dtwm 49330 -> /usr/lib/lpd/pio/etc/piohpnpf 49592 -> b...

Re: Re:
Sorry about that, my mistake, the patched method goes like this: procedure DeallocateHWnd(Wnd: HWND); var Instance: Pointer; begin Instance := Pointer(GetWindowLong(Wnd, GWL_WNDPROC)); if Instance <> @DefWindowProc then begin { make sure we restore the default windows procedure before freeing memory } SetWindowLong(Wnd, GWL_WNDPROC, Longint(@DefWindowProc)); FreeObjectInstance(Instance); end; DestroyWindow(Wnd); end; "Andreas Hausladen" <AndreasDOTHausladen@gObviousToBeRemovedmx.de> wrote in message news:99620@f...

RE: Re: [wxperl-users] Re: Re: EVT_QUERY_END_SESSION
you putted the EVT_CLOSE to the wrong place... or do you have a reason why you need it to be there? $app ist not the window, but you could use EVT_CLOSE on $frame too. i changed your minimal sample that it works. hope it helps greeting Marco ---- use Wx; ########################### package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my( $this ) = @_; my( $frame ) = MyFrame->new( "Minimal wxPerl app", Wx::Point->new( 50, 50 ), Wx::Size->new( 450, 350 ) ); ...

RE : RE : RE : RE : Regular expressions #2
No worries :-) It works now, thanks a lot :-) Best regards, Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Foresti=E8res La Tuque, P.Q. Tel.: (819) 676-8100 X2833 shemond@smurfit.com=20 > -----Original Message----- > From: drieux [mailto:drieux@wetware.com]=20 > Sent: Wednesday, December 17, 2003 1:38 PM > To: Perl Perl > Subject: Re: RE : RE : RE : Regular expressions >=20 >=20 >=20 > On Dec 17, 2003, at 10:24 AM, drieux wrote: >=20 > > > > open(PS, "ps -efA|") or...

Re: Re: Re: RE: capture a website and process its data
--Next_1077222091---0-202.54.124.153-17281 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Rob,=0AI implemented your code and it gave perfectly desired answers. Bu= t I couldn't understand most of it. So, currently I went ahead with Dan's t= ips on my code only and would try to understand your code later after I mee= t a deadline for a small project of mine in college for tomorrow! So, no qu= estions as of now. =0A=0Acheers.=0AK(ay).=0A=0A=0AOn Thu, 19 Feb 2004 Rob D= ixon wrote :=0A>Scott E Robinso...

Re: Re: Re: Re: cross cluster read fails
--Boundary_(ID_HDBIpKP7HBB79jluGvYvuw) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT Content-disposition: inline �Hi Alan One more thing before we go further :) I wrote a simple perl script that accepts a file name, prints it out, opens the file (dies if open unsuccessful or prints �open successful�) 1>I passed my local directory filename, it prints �open successful� 2> Now I just add �abcd::� in front of it, and the perl script fails with Remote node is unknown D...

RE: Re: Re: Sub not working as it should
You don't need to be sorry - it's the right choice ;-) Philipp > -----Original Message----- > > I am sorry I am migrating over to perl (love the built > in debugger) > --- Saadat Saeed <saadat_saeed@yahoo.com> wrote: > > Thanks for the quick reponse - looks like I confuse > > my > > vbscript skills a bit... I am new to perl and am > > migrating over to vbscript! > > > > Regards > > > > > > --- Jeff 'japhy' Pinyan <japhy@perlmonk.org> wrote: > > > On Jan 21, Saadat S...

RE : RE : RE : Regular expressions
I am issuing this command on an Aix box and running allright :-) Forgive my curiosity.. are you running Solaris on a x86 box?=20 Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Foresti=E8res La Tuque, P.Q. Tel.: (819) 676-8100 X2833 shemond@smurfit.com=20 > -----Original Message----- > From: drieux [mailto:drieux@wetware.com]=20 > Sent: Wednesday, December 17, 2003 1:14 PM > To: Perl Perl > Subject: Re: RE : RE : Regular expressions >=20 >=20 >=20 > On Dec 17, 2003, at 8:47 AM, Hemond, Steve wrote: ...

RE: RE: RE: RE: [wxperl-users] wxTreeCtrl, edit an treeItem
>>Found a fix ( I hope ); download the modified wx22_9.dll from >>http://wwwstud.dsi.unive.it/~mbarbon/wx/wx22_9.dll.gz >>uncompress it and put it in $PERL/site/lib/auto/Wx >>( make a backup of the original one, of course ). >>This fixes your problem with tree control, but may introduce >>new ones ( it is a fix backported from wxWIndows 2.3 ). >> >>Regards >>Mattia > >hey thanks man! >i had no time to work on my application but i checked the wxwindows >mailinglist archive. you asked for a code change as workaround......

Re: Re-inventing the wheel [was RE: Why not gmp? [was Re: pdd14 -- bignums] ]
Simon Cozens <simon@netthink.c To: Shlomi Fish <shlomif@vipe.technion.ac.il> o.uk> cc: perl6-internals@perl.org ...

RE : RE : RE : Regular expressions #2
drieux is right about me being exploring Perl. In fact, that is a good = exercice to play with regular expressions and data types as I had to = build a hash of hashes to do the thing. However, I wouldn't let a script in that stat if I knew of a = better/quicker/shorter method. I will then have to improve my script soon. What would be the best way to put values returned by the ps command you = just mentionned in variables? Thanks again for your great help.=20 P.S : I look like the typical lazy guy who don`t even read and try by = himself. This is because I am at work, ...

Re: Re: Re: Re: counting tr thinks it's modifying
I was talking about the behavior of the operator, not how it is implemented =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >De:Jarkko Hietaniemi <jhi@iki.fi> >Para:Daniel Ruoso <daniel@ruoso.com> >Assunto:Re: Re: Re: counting tr thinks it's modifying > >> so tr becomes a {if (r=3D=3Ds) {"COUNTING ONLY"} >else {"COUNTING AND REPLACEMENT"}} operator.=20 > >It's not like this is new behaviour: for example >5.004_05 has code >like this in doop.c: > > if (SvREADONLY(sv) && !(op->op_pri...

RE: Re: Editor
Couldn't agree more, but... didn't you forget to close your subtitution with a trailing slash? :25,45 s/^/#/ vi Rocks > ---------- > From: Luke Bakken > Reply To: luke_bakken@yahoo.com > Sent: Friday, July 6, 2001 1:47 PM > Cc: anton; beginners@perl.org > Subject: RE: Re: Editor > > You know at the risk of starting a huge flamewar here (tho I doubt it'll > happen - people seem really reasonable on this list) I'm going to put in > my $0.02 for not just learning vi, but becoming fluent with it: > > 1. It's uni...

Re: Re: comments
below is the code in which the comments behave wierdly the code does not run properly with them else it is fine #!/usr/bin/perl # compiler directives use strict; use diagnostics; use Switch; use warnings; use Cwd; use vars; my $current_line; my $line_number=0; open (VERFILE,"<smaster.ver") || die "Unable to open/create smaster.ver.\n"; while(!eof(VERFILE)){ $current_line = &next_line(\*VERFILE); if($current_line =~ m/\Q*compare\E/i) { $line_number = &getLineNumber(\*VERFILE,"smaster.ver"); print "$line_...

Web resources about - RE: RE: Re: Tri-grams? - perl.beginners

Resources last updated: 1/16/2016 1:34:56 PM