Random word generator from a pdf document

Hi,

I work a lot with word collisions and the associations these generate.

I would like to be able to point to a folder in DevonThink Pro, which contains a series of single pdf pages that contain my initial list of associations and click something to pull up random words from those pages, preferably in a new document that I have opened in Devon Think Pro.

Is there anyone who could help here? Or is there an action script that I have overlooked?

Thanks,

Chris.

Here’s a simple example. Just select the documents and the script will return n random words (see property pWords):


property pWords : 10

tell application "DEVONthink Pro"
	set theRecords to the selection
	set numRecords to count of theRecords
	set num to random number from 1 to numRecords
	set theText to plain text of (item num of theRecords)
	set numWords to count of words of theText
	
	set theResult to ""
	repeat with i from 1 to pWords
		if i > 1 then set theResult to theResult & " "
		set theResult to theResult & (word (random number from 1 to numWords) of theText)
	end repeat
	
	return theResult
end tell

Wonderful. Works a treat.

Many thanks.

Best regards,

Chris.