Quantcast
Channel: Adobe Community : All Content - All Communities
Viewing all articles
Browse latest Browse all 290743

Count the total number of specific words on each page

$
0
0

I have a script which counts the number of times the word "Manager" appears on each page of a report.

 

This is what is reported back into the console after the script is run:

 

Count No of Managers 1 Page Number 1

Count No of Managers 2 Page Number 1

Count No of Managers 3 Page Number 1

Count No of Managers 4 Page Number 1

Count No of Managers 5 Page Number 1

Count No of Managers 1 Page Number 2

Count No of Managers 2 Page Number 2

Count No of Managers 3 Page Number 2

 

I need the console to report back with only the total number of times the word manager appears on each page (once) and not iterate through each one.

 

Can any one please advise how this can be achieved?

 

Script as follows:

 

var numpages = this.numPages;

for (var k=0; k < numpages; k++)
{
{
var numWords = this.getPageNumWords(k);

var count = 0;

for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(k, i, true);
var q = this.getPageNthWordQuads(k, i);
// Convert quads in default user space to rotated
// User space used by Links.
m = (new Matrix2D).fromRotated(this,0);
mInv = m.invert()
r = mInv.transform(q)
r=r.toString()
r = r.split(",");
if ( ckWord === "Manager")
{
count++;
console.println("Count No of Managers " +  count + " Page Number " + (k+1));
}
}
}
}


Viewing all articles
Browse latest Browse all 290743

Trending Articles