[Sc-devel] Spelling NSSpellChecker Cocoa[Collider?]
Ryan Brown
ryan at wabdo.com
Thu May 31 18:10:36 PDT 2007
I posted another version that fixes the NSRange problem.
The following now works:
NSSpellChecker.sharedSpellChecker.checkSpellingOfString_startingAt_
("hello there innit", 0)
// => Range(12, 5)
NSSpellChecker.sharedSpellChecker.countWordsInString_language_("hello
there innit", "English")
// => 3
NSSpellChecker.sharedSpellChecker.guessesForWord_("innit")
// => CCArray[ innate, in-nit, inn-it ]
Best,
Ryan
On May 31, 2007, at 10:08 AM, Ryan Brown wrote:
> The correct syntax is:
> NSSpellChecker.sharedSpellChecker.checkSpellingOfString_startingAt_
> ("hello
> there innit", 0)
>
> But that is crashing on me right now (at least on PPC). I'll look
> into it
> later tonight. NSRange is a C structure, and every C structure has
> to have
> special code written to bind it to an SC type (Range in this case). I
> don't think I tested NSRange->Range (I did test the other direction
> though) when I wrote the handler for it... which probably wasn't
> the the
> best idea.
>
>>
>> On 31 May 2007, at 16:36, Ryan Brown wrote:
>>
>>> In CocoaCollider:
>>>
>>> NSSpellChecker.sharedSpellChecker.guessesForWord_("poarly")
>>> // => CCArray[ poorly, pearly ]
>>
>> Thanks Ryan, most welcome information, works here.
>>
>>> You could easily write an extension to String to add your checkSp,
>>> guessSp and replaceSp methods.
>>
>> Yes, I can see that, but does this mean that other methods as such as
>>
>> checkSpellingOfString:startingAt:
>> Starts the search for a misspelled word in stringToCheck starting at
>> startingOffset within the string object.
>> - (NSRange)checkSpellingOfString:(NSString *)stringToCheck
>> startingAt:
>> (int)startingOffset
>>
>> won't work? - I'm not used to reading Cocoa specs:
>>
>> NSSpellChecker.sharedSpellChecker.checkSpellingOfString_("hello there
>> innit")_startingAt(0)
>>
>> => ERROR: Primitive '_ObjC_Invoke' failed.
>> Failed.
>> RECEIVER:
>> class CCTrampoline (05266710)
>> ...
>>
>>> Also, I just posted a new version of CocoaCollider here: http://
>>> www.wabdo.com/CocoaCollider/
>>> It removes some debugging messages that were left in
>>> accidentally...so if you had already downloaded v0.1 you should get
>>> this newer version.
>>
>> Great, good news.
>>
>>
>> Regards
>>
>> Tom
>>
>>
>>>
>>> Best,
>>> Ryan
>>>
>>> On May 31, 2007, at 6:44 AM, Tom Hall wrote:
>>>
>>>>
>>>> Hello List
>>>>
>>>> how difficult would it be to get the results of SC spelling
>>>> features into sclang? (I've been doing most of my university
>>>> marking using a SC database for a while now, it could be a useful
>>>> feature on top of cmd-; ).
>>>>
>>>> I'm assuming that sclang doesn't know anything about the existing
>>>> Spelling features?
>>>>
>>>> Would it require CocoaCollider to do something like this?
>>>>
>>>> a = "A poarly written piece oef work"
>>>>
>>>> a.checkSp // would split the string
>>>> // => [["poarly", 1], ["oef", 4]]
>>>>
>>>> b = a.guessSp
>>>> // => [ ["poarly", 1] -> ["poorly", "pearly"], ["oef", 4] ->
>>>> ["of"]] ]
>>>>
>>>> a.replaceSp(b[0].key, b[0].value[0])
>>>> // => "A poorly written piece oef work"
>>>>
>>>>
>>>> Regards
>>>>
>>>> Tom
>>>>
>>>> _______________________________________________
>>>> Sc-devel mailing list
>>>> Sc-devel at create.ucsb.edu
>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>>>
>>>
>>> _______________________________________________
>>> Sc-devel mailing list
>>> Sc-devel at create.ucsb.edu
>>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>
>> _______________________________________________
>> Sc-devel mailing list
>> Sc-devel at create.ucsb.edu
>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>
>>
>
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel at create.ucsb.edu
> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>
More information about the Sc-devel
mailing list