macOS 12.3 Beta(21E5196i)が配信され、M1 Mac mini上で実験してみたところ、macOS 12でバグが出ていた「自然言語テキストからNSDataDetectorで電話番号を抽出しようとすると何も出てこない」件(日本語環境限定)が修正されているように見えます。
Thanks Shane!
AppleScript名:与えられたテキストから電話番号を抽出 v2 |
— Created 2015-08-21 by Shane Stanley — Modified 2015-08-21 by Takaaki Naganoya — Modified 2015-08-22 by Shane Stanley use AppleScript version "2.4" use scripting additions use framework "Foundation" set theString to "長野谷隆昌 (Takaaki Naganoya) maro@piyocast.com http://piyocast.com/as 2015年8月21日〜23日 080-1111-2222 030-1234-5678 東京都練馬区中村橋1-2-3 " set theDates to (extractPhoneNumberFromNaturalText(theString)) –> {"080-1111-2222"}–macOS 10.12 or other version –> {"080-1111-2222", "030-1234-5678"}–macOS 13.6 with Intel MacBook Air –> {"080-1111-2222", "030-1234-5678"}–macOS 14.6 with Intel MacBook Pro –> {"080-1111-2222", "030-1234-5678"}–macOS 15.7 with Intel MacBook Pro –> {} –macOS 12 beta 6 with M1 Mac mini –> {"080-1111-2222", "030-1234-5678"}–macOS 12.3beta1 with M1 Mac mini on extractPhoneNumberFromNaturalText(aString) set anNSString to current application’s NSString’s stringWithString:aString set {theDetector, theError} to current application’s NSDataDetector’s dataDetectorWithTypes:(current application’s NSTextCheckingTypePhoneNumber) |error|:(reference) set theMatches to theDetector’s matchesInString:anNSString options:0 range:{0, anNSString’s |length|()} set theResults to theMatches’s valueForKey:"phoneNumber" return theResults as list end extractPhoneNumberFromNaturalText |