Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

In Pages document, how do I search for word and view its frequency and page numbers in a sidebar?

I have a long document and I want to be able to search for certain key words and phrases, and then see how many times they appear in the document and exactly where. How do I conduct this sort of search and viewing? In the past, in Pages and Word, I've been able to view my "finds" in a sidebar but I can't figure out how to activate that service anymore.


Thanks!

iMac

Posted on Jan 14, 2014 7:00 AM

Reply
13 replies

Jan 14, 2014 8:17 AM in response to wendy4444

Feature isn't availeble. All Pages 5 seems to be able to do is this



Show word count

You can show the word count, character count, and number of paragraphs in a document.

Show word, character, and paragraph count

  1. Click View User uploaded file in the toolbar, then choose Show Word Count.The word count appears at the bottom of the page.
  2. Move the pointer over the right side of the word count, then click the arrows to see character and paragraph count.You can choose one of these counts to display it (instead of word count) at the bottom of the page.


Jan 15, 2014 1:20 PM in response to wendy4444

Here is a word frequency concordance Automator Service that works in both versions of Pages. It does not present a page number reference. It is by descending count, and alphabetically, within the repetitive counts as shown in the image here. In any document, you select the text to process, then Menu > Application Name > Services > Frequency. The Service will open TextEdit with the n-pages of scrollable results. It is 16 pt Helvetica Neue for legibility.

User uploaded file

Here is the code:


on run {input, parameters}
  
     try
          set mySelection to input as text
          set formatted_result to concordance(mySelection)
          if formatted_result is not null then
               set textHeading to "Word Frequency List"
               tell application "TextEdit"
               activate
                     set NewDoc to make new document with properties {name:"Concordance"}
                     make new paragraph at beginning of text of NewDoc with data textHeading & return
                     make new paragraph at end of text of NewDoc with data formatted_result
                     tell text of NewDoc
                           set font to "Helvetica Neue"
                           set size to 16
                           set color of paragraph 1 to {0, 0, 65535}
                     end tell
                    end tell
          else
                    display dialog with title ¬
                     "No input selected" with icon stop ¬
                      giving up after 15
          end if
  
     on error errmsg number errnum
                display alert ¬
                           "AppleScript Error" message errmsg & "[" & errnum & "]" as critical ¬
                              giving up after 30
     end try
     return input
end run


on concordance(mySelection)
 -- Use Ruby to count word frequency and alphabetically sort words
  
    set rb to ¬
    "selected = String.new\nfreqs = Hash.new(0)\nselected = ARGV.join('  ').gsub(/[,.]/, \"\")\n
     words = selected.split(/[^\\w-]+/)\nwords.each { |word| freqs[word] += 1 }\n
     freqs_sorted = freqs.sort do |a,b|\n\t
     a.last == b.last ? a.first <=> b.first : b.last <=> a.last\nend\n
     freqs_sorted.each { |k,v| printf \"[ %8s ]          %s\", v, k }"
  
    do shell script "/usr/bin/ruby -e " & rb's quoted form & space & mySelection's quoted form
  
end concordance


Launch /Applications/Automator and choose New Document, then click the Service icon, and then select the Choose button.


On the left, you will have a list of Libraries from which to choose workflow items. Find Library > Utilities. In the adjacent column, locate the Run Applescript workflow. Click on it, then drag and drop it in the large workflow window to your right.


At the top, you can select Service receives text in any application. Leave Output replaces selected text unchecked.


In your Run AppleScript workflow window, you will see AppleScript boilerplate. Click on it and press command+A, then backspace to delete this content. Copy and paste the above code into this Run AppleScript workflow window. Press the Run button in Automator's upper right corner. If (and it should) a TextEdit window pops up, you are good, and you want to press File > Save. A dialog box will pop-up where you can name your Service. I called my Frequency, you may wish to call it something else. Once you have save it, you can exit Automator. Services are deposited in yourlogin directory/Library/Services.


If you have a Pages document open with text, either select it, or command+a to select the entire document. Now, you select your Service via Pages > Services > Frequency. This will now pop-up a new TextEdit document with the results. If you want to save this new document, you must use option+File to Save as...

Feb 1, 2014 5:38 AM in response to VikingOSX

Hello Viking

I tried your script in automator but when I try to run it it answers with an error. It says that french quotation marks are expected and not english ones. I am french and use of course french in my text but I though Automator spoke english like all my system 😕

So may be I should correct my automatic preferences for entering caracters in my applications (I put change english quotation to frenche quotation. But it seems weird that this could affect automator.

If I may I have another question about Pages.

There is no simple way to type multilingual texts as it always put errors when I am typing english or german words in a globally french text. Is there a simple way you should know to avoid this? In Office Wort it is very simple. I am afraid Pages is not totally multilingual. (I did put all the languages I use in my keyboard preferences, and check "grammar and orthograph automatic by idiom" but it doesn't "do the job".


Thanks anyway

Constance

Feb 1, 2014 9:00 AM in response to CathyLapin

Constance,


Je vous demande pardon. 😊 I had not considered what you have discovered! Have you changed the automatic quotation preferences to English, and did that let the Automator Service run correctly and produce concordance output for you?


All of my machines are configured as English. It would be time-consuming for me to recode/test the AppleScript/Ruby concordance code to believe it is french complete with guillemets quotes.


Multilingual. I have no experience using Pages as you have mentioned. My recommendation is to post a new, main discussion here in the Pages community with your last paragraph as the body of your question. State the operating system version (OS X 10.8.5, 10.9.1 etc.) and Pages version (’08/’09/v5.01/v5.1) that you are using.


Use a brief subject: Help with multilingual text input. Other people that know, will respond.

Feb 3, 2014 8:04 AM in response to VikingOSX

Hello Viking

I tried but it didn't function either though the error message was different.

Here it is below

"Le gestionnaire run est spécifié plus d’une fois ou il y a eu des commandes de haut niveau en plus du gestionnaire run."


I must say that it is completely non understandable because this translation is appalling. More or less, the Run manager is specified more than once or there are high level commands with the Run Manager.


I just tell you for the fun of it, I'm not asking you to tell me how to do.

So much for the multiliguism in programation 😉 Fortunately as Pages has too many restrictions for my use I returned to my old Mac Office 2011 (it can count occurencies)

Thanks for the trouble anyway.

Cathy

In Pages document, how do I search for word and view its frequency and page numbers in a sidebar?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.