Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Word Occurance in String Field 2

Status
Not open for further replies.

MJRBIM

MIS
May 30, 2003
1,579
CA
CR-10 running against Oracle 9i.

I'm think that SQL or a SP is probably the best way to do this, but wanted to see if anyone had a slick way of doing it in CR-10.

There is a table with records and document titles in it, we would like to know which individual words are used most in the "Titles" field. The field is manual-text entry by the users - so there is no field standard for format, number of words, spelling, Case, etc.

(SAMPLE DATA)

RECORD TITLE
----------------------------
123 LETTER OF AGREEMENT
124 Final Agreement
125 Letter of Understanding
126 common sales agent agreement


Desired Results, sorted by ocurrence then alphabet...

WORD OCURRENCE
----------------------------
AGREEMENT 3
LETTER 2
OF 2
AGENT 1
COMMON 1
FINAL 1
SALES 1

If anyone has a formula (maybe a looping array?) that could tackle this without having to involve the DBAs it would be appreciated.

TIA for the help!
 
You'll need to store EVERY word in an array (perhaps the uppercase of each), and simultaneously store the count in another, fairly complex stuff. As for spellings, that's a different story and you need to run it through some external process for that.

So we nab the words:

stringvar array Currentwords;
Stringvar array AllWords;
Numbervar array WordCount;
Numbervar Counter;
numbervar counter2;
Currentwords:=split({table.field}," ");
For Counter:= 1 to ubound(Currentwords) do(
if not(Currentwords[counter] in Allwords) then
redim preserve Allwords[ubound(Allwords)+1);
redim preserve Wordcount[ubound(Allwords)+1);
Allwords[ubound(allwords)]:=Currentwords[Counter];
Wordcount[ubound(allwords)]:=Wordcount[ubound(allwords)]+1
else
for counter2 := 1 to ubound[Allwords] do(
if Allwords[counter2] = Currentwords[counter] then
Wordcount[counter2]:=Wordcount[counter2]+1
);
);

Something like that, I can't test right now.

-k
 
I'm not worried about the spellings for now...just the count would do.

In meetings all afternoon, but I'll try to review your formula suggestion later.

Thx.
 
You can use the uppcase around each word to eliminate that aspect anyway, the theory is sound, I just don't have Crystal right now so you'll have to tweak it.

Good luck with it, MJRBIM.

-k
 
I'm having trouble working out the syntax errors. Can anyone help?
 
I haven't had a chance to check it yet....
 
It may help if you provide more info on what error messages are appearing and where the cursor is pointing to when the error message appears...

ShortyA
 
See thread767-967452 for another solution.

-dave
 
Dave -

Thanks for the linked solution, I have posted a follow-up on that thread.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top