Searching Text

  • Thread starter Thread starter js
  • Start date Start date
J

js

HI,
Is there anyway of searching text, putting all of the like words
together, then giving you a count of the number of times that word
appears in Access?
Thanks, David
 
What do you mean the like words?

If I want to find how many times "Nebinger" occurs in a
text field:

DCount("TextField","Table","TextField Like '*Nebinger*'")

would work.

Chris Nebinger
 
js said:
HI,
Is there anyway of searching text, putting all of the like words
together, then giving you a count of the number of times that word
appears in Access?
Thanks, David

Yes.
 
Hi David,

This can be done, but Access and VBA don't have good tools for doing it:
the code has to read the text, split it into words without being
confused by quote marks, punctuation, etc, and then work through them
keeping count of each.

When I need to do this I export the data to a textfile and use this Perl
script to get the counts (Perl is free from www.activetate.com) :

#BEGIN
#take text input, parse into words, return list of words with number of
occurrences

use Text::ParseWords; #module with parse_line function

my $ignorecase = 1; #change this to 0 to be case sensitive

while (<>) { #read lines from STDIN or file(s) on command line
chomp;
@line = parse_line(qr/\W+/, 0, $_); #parse into words
if ($ignorecase) { map {$_ = ucfirst $_} @line }; #adjust case
foreach $word (@line) { $words{$word}++ }; #store count of words
}

foreach $word (sort keys %words) { #output sorted list of words
print "$word\t$words{$word}\n";
}
#END


If you need to do it entirely within Access, search Google for
"count words" vb OR vba
and you'll probably find some downloadable Visual Basic code that you
can modify to work in your database.
 
John,
Great!!! Thank You.
David

John said:
Hi David,

This can be done, but Access and VBA don't have good tools for doing it:
the code has to read the text, split it into words without being
confused by quote marks, punctuation, etc, and then work through them
keeping count of each.

When I need to do this I export the data to a textfile and use this Perl
script to get the counts (Perl is free from www.activetate.com) :

#BEGIN
#take text input, parse into words, return list of words with number of
occurrences

use Text::ParseWords; #module with parse_line function

my $ignorecase = 1; #change this to 0 to be case sensitive

while (<>) { #read lines from STDIN or file(s) on command line
chomp;
@line = parse_line(qr/\W+/, 0, $_); #parse into words
if ($ignorecase) { map {$_ = ucfirst $_} @line }; #adjust case
foreach $word (@line) { $words{$word}++ }; #store count of words
}

foreach $word (sort keys %words) { #output sorted list of words
print "$word\t$words{$word}\n";
}
#END


If you need to do it entirely within Access, search Google for
"count words" vb OR vba
and you'll probably find some downloadable Visual Basic code that you
can modify to work in your database.
 
Back
Top