• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Count word's occurences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Count word's occurences


  • Subject: Re: Count word's occurences
  • From: Guido Tangorra <email@hidden>
  • Date: Tue, 09 Sep 2014 12:41:32 +0200

Thank you all for the advices!
My file is generated at runtime, so maybe the TextWrangler filter should be a good solution but I don't know how to use it in my script...

#!/usr/bin/perl -w
use strict;

my %occurrences = (); # set up empty hash
while (<STDIN>){ # read lines of file or present document
chomp; # remove linefeed and/or return
$occurrences{$_} ++; # fill hash with count of occurences
print "$_\t$occurrences{$_}\n";
}


How I can put this in my Counter handler to return the 'fruitQuantity'?

My script looks like this:

global myFruit, mySource
set theDocName to "My Fruit List"
set mySource to "htt
​p​
://..."

tell application "TextWrangler"
    activate
    set myDocument to make new text document with properties {name:theDocName}
end tell

on idle
tell application "JSON Helper" to set myFruit to fetch JSON from mySource
set fruitQuantity to my Counter(myFruit)
tell application "TextWrangler" to make new line at end of text of document theDocName with data (myFruit & return)

return 0.5
end idle

on Counter(theFruit)
...
end Counter
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Count word's occurences (From: Guido Tangorra <email@hidden>)
 >Re: Count word's occurences (From: Christopher Stone <email@hidden>)
 >Re: Count word's occurences (From: Christopher Stone <email@hidden>)

  • Prev by Date: RE: Count word's occurrences
  • Next by Date: Re: Count word's occurences
  • Previous by thread: Re: Count word's occurences
  • Next by thread: Re: Count word's occurences
  • Index(es):
    • Date
    • Thread