• 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: Sorting characters of the text - script doesn't work as expected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting characters of the text - script doesn't work as expected


  • Subject: Re: Sorting characters of the text - script doesn't work as expected
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 30 Apr 2017 11:12:24 +0200


Le 30 avr. 2017 à 02:29, ILJA SHEBALIN <email@hidden> a écrit :

Hello,

I hadn't enough time to test until today when I finally got down to the script you provided. Yet, running it revealed that it still returns only unique characters count, not absolute one. The doc tested was the same TXT.txt file I attached earlier. The script think there're (only) 53 non-Greek characters which obviously is incorrect as the text is in English. Trying harder to compile my own script figuring out new ways.

Thanks anyway

Sincerely Yours,
Ilya Shebalin
E-mail: email@hidden,
           email@hidden 
Skype: llja.arbenin



18.04.2017, в 12:41, Yvan KOENIG написал(а):

Oops

I posted the wrong script. The posted one makes no difference between lowercase and uppercase.

Here is the correct version.

script o
property GreekCharacters : {"α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ", "λ", "μ", "ν", "ξ", "ό", "о", "π", "ρ", "ς", "Ύ", "φ", "χ", "ψ", "ω"}
property noGreekCharacters : {space, " ", "(", ")", "-", "+", "=", "|", "{", "}", "°", "[", "]", "^", "/", "·", "$", "€", "‡", "±", "*", "<", ">", "≥", "≤", "≠", ":", ";", ".", ",", "⁄", "‹", "›", "—", "_", "?", "!", "«", "»", "", linefeed, tab, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\\"}
property everyCharacters : {}
property uniqueCharacters : {}
property GreekYes : {}
property GreekNo : {}
property allNoGreek : {}
end script


tell application "TextEdit"
activate
set p2d to path to desktop as text
set theFile to p2d & "TXT.txt"
set theDoc to open file theFile
set MyDoc to text of theDoc
end tell

set o's everyCharacters to text items of MyDoc

considering case
# Build a list containing one occurrence of every characters available in the document
set o's uniqueCharacters to {}
repeat with aChar in o's everyCharacters
set aChar to aChar as text

if aChar is not in o's uniqueCharacters then copy aChar to end of o's uniqueCharacters
end repeat

# Build a list of greek characters available in the document
set o's GreekYes to {}
repeat with aGreek in o's GreekCharacters
set aGreek to aGreek as text
if aGreek is in o's uniqueCharacters then
copy aGreek to end of o's GreekYes
end if
end repeat

set o's allNoGreek to o's noGreekCharacters & o's GreekYes
# Build a list of non greek characters available in the document
set o's GreekNo to {}
repeat with noGreek in o's uniqueCharacters
set noGreek to noGreek as text
if noGreek is not in o's allNoGreek then
copy noGreek to end of o's GreekNo
end if
end repeat

end considering

{o's GreekYes, count o's GreekYes, linefeed, o's GreekNo, count o's GreekNo}


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mardi 18 avril 2017 11:41:39


Right, the last loop must be :

repeat with noGreek in o's uniqueCharacters
set noGreek to noGreek as text
if noGreek is not in (o's allNoGreek & o's GreekYes) then
copy noGreek to end of o's GreekNo
end if
end repeat


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) dimanche 30 avril 2017 11:11:47




 _______________________________________________
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: 
 >Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: Christopher Stone <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: Yvan KOENIG <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: Yvan KOENIG <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)

  • Prev by Date: Re: Copying the path of files selected in Finder
  • Next by Date: Re: Copying the path of files selected in Finder
  • Previous by thread: Re: Sorting characters of the text - script doesn't work as expected
  • Next by thread: Dash search ?
  • Index(es):
    • Date
    • Thread