• 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: Christopher Stone <email@hidden>
  • Date: Sun, 16 Apr 2017 17:03:53 -0500

On 04/15/2017, at 18:50, ILJA SHEBALIN <email@hidden> wrote:
I already have posted here asking how could I create a script that would determine what language a given particular document is in. Since I wasn't able to chew on  some of your recommendations because of overly complex nature at that point for me, I decided to find a workaround on my own using tools I'm already familiar with rather than going with a very sophisticated AppleScriptObjC language.


Hey Ilja,

I think you're better off using Shane's AppleScriptObjC handler myself.  It's not all that difficult to manage.

------------------------------------------------------------------------------
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
------------------------------------------------------------------------------

set theText to "Οἱ δὲ Φοίνιϰες"
set textLanguage to its guessLanguageOf:theText

------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on guessLanguageOf:theString
    set theTagger to current application's NSLinguisticTagger's alloc()'s initWithTagSchemes:{current application's NSLinguisticTagSchemeLanguage} options:0
    theTagger's setString:theString
    set languageID to theTagger's tagAtIndex:0 |scheme|:(current application's NSLinguisticTagSchemeLanguage) tokenRange:(missing value) sentenceRange:(missing value)
    return ((current application's NSLocale's localeWithLocaleIdentifier:"en")'s localizedStringForLanguageCode:languageID) as text
end guessLanguageOf:
------------------------------------------------------------------------------

If you really want to use a found alphabet solution then the simplest method will be to use the Satimage.osax find text command.

The most recent version may be installed from here:

http://tinyurl.com/smile-beta-page

------------------------------------------------------------------------------

set _data to "Οἱ δὲ Φοίνιϰες οὗτοι οἱ σὺν Κάδμῳ ἀπιϰόμενοι.. ἐσήγαγον διδασϰάλια ἐς τοὺς ῞Ελληνας ϰαὶ δὴ ϰαὶ γράμματα, οὐϰ ἐόντα πρὶν ῞Ελλησι ὡς ἐμοὶ δοϰέειν, πρῶτα μὲν τοῖσι ϰαὶ ἅπαντες"
set foundGreek to fnd("(α|β|γ|δ|ε|ζ|η|θ|ι|κ|λ|μ|ν|ξ|ό|о|π|ρ|ς|Ύ|φ|χ|ψaω)+", _data, true, true) of me

------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on fnd(_find, _data, _all, strRslt)
    try
        find text _find in _data all occurrences _all string result strRslt with regexp without case sensitive
    on error
        return false
    end try
end fnd
------------------------------------------------------------------------------

This will produce a list of found contiguous strings of Greek letters.

--
Best Regards,
Chris

 _______________________________________________
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

  • Follow-Ups:
    • Re: Sorting characters of the text - script doesn't work as expected
      • From: ILJA SHEBALIN <email@hidden>
References: 
 >Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)

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