可可数据检测器 [英] Data Detectors in Cocoa

查看:227
本文介绍了可可数据检测器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在邮件中添加一个NSTextField / NSTextView中的数据检测器(例如日期,电子邮件,URL等)。



有没有人知道如何去做这个 ?我认为我在TextEdit的源代码中看到它,但是当我检查它是2005的版本,我找不到新的源代码。



Alex

解决方案

您需要设置对象的格式化程序出口。内置格式化器是类。 Aaron Hillegass 中有一个章节,优秀的可编程的Max OS X 创建NSFormatters。



检测日期,URL,电子邮件地址等内容,您可以使用潜在语义映射框架。它是Leopard的公共API,但没有大量的文档。还有一个名为的命令行工具lsm ,这将允许您测试要使用的任何自定义提取器。据我所知,这是一个C API并没有整合到可可中,所以你需要自己连线。


I want to add a data detector in an NSTextField / NSTextView like in Mail (e.g. date, email, URL, etc).

Does anyone have an idea how to do this ? I think I saw it in TextEdit's source code but when I checked it was 2005's version and I can't find the new source code.

Alex

解决方案

You need to set the formatter outlet of the object. Built in formatters are NSDateFormatter and NSNumberFormatter.

You can define custom formatters by extending the NSFormatter class. There is a chapter in Aaron Hillegass excellent 'Cocoa Programming for Max OS X' on Creating NSFormatters.

To detect dates, url, email address, etc. within the body of some text, you can use the Latent Semantic Mapping Framework. It's a public API as of Leopard but there isn't a great deal of documentation for it. There is also a command line tool called lsm that would allow you to test any custom extractors you want to use. It is a C API and not integrated into Cocoa as far as I know so you'd need to wire it up yourself

这篇关于可可数据检测器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆