Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Data Detectors in NSTextView (similar to the recognition of dates)

Is there a way to implement custom data detectors in NSTextView (like the one that recognizes dates or telephone numbers)?

I think there is an API Reference, but the whole process is not documented. Is there anything that can help me understand what's the right thing to implement?

like image 570
Donovan Avatar asked Aug 11 '11 22:08

Donovan


1 Answers

The LSM is well suited for training/evaluation/categorization of text (think spam filtering). The LSMSmartCategorizer sample code shows how to train and use a LSM map against news feeds.

You can also try to use the NSRegularExpression/NSDataDetector classes (available starting with Lion). They are designed to match on a text input. Once the matches are available, iterate (with a custom block) over the result and perform some highlighting or style modification.

Hope it helps.

like image 84
Laurent Etiemble Avatar answered Sep 24 '22 08:09

Laurent Etiemble