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

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

问题描述

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



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



Alex

解决方案

您需要设置对象的格式化输出。内置格式器是类。 Aaron Hillegass 中有一个章节,介绍了关于创建NSFormatter的Cocoa编程Max OS X



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


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

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

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