Skip to content

NaturalLanguage iOS xcode15.0 b1

Haritha Mohan edited this page Sep 18, 2023 · 3 revisions

#NaturalLanguage.framework https://github.com/xamarin/xamarin-macios/pull/19039

diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLContextualEmbedding.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLContextualEmbedding.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLContextualEmbedding.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLContextualEmbedding.h	2023-05-19 20:49:25
@@ -0,0 +1,89 @@
+/*    NLContextualEmbedding.h
+      Copyright (c) 2022-2023, Apple Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+#import <NaturalLanguage/NLEmbedding.h>
+#import <NaturalLanguage/NLLanguage.h>
+#import <NaturalLanguage/NLScript.h>
+#import <NaturalLanguage/NLTokenizer.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class NLContextualEmbeddingResult;
+
+/* NLContextualEmbedding is a class representing a model that computes sequences of embedding vectors for natural-language utterances. Predefined contextual embeddings are provided for certain languages/scripts.
+*/
+
+NS_CLASS_AVAILABLE(14_0, 17_0)
+@interface NLContextualEmbedding : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
+/* Each embedding model has a string identifier that uniquely identifies it. When an embedding is used for training, keep track of the identifier. It should be used to locate the same embedding at inference time.
+*/
++ (nullable instancetype)contextualEmbeddingWithModelIdentifier:(NSString *)modelIdentifier;
+
+typedef NSString *NLContextualEmbeddingKey NS_TYPED_EXTENSIBLE_ENUM;
+
+FOUNDATION_EXPORT NLContextualEmbeddingKey const NLContextualEmbeddingKeyLanguages;
+FOUNDATION_EXPORT NLContextualEmbeddingKey const NLContextualEmbeddingKeyScripts;
+FOUNDATION_EXPORT NLContextualEmbeddingKey const NLContextualEmbeddingKeyRevision;
+
+/* Search the catalog of available embeddings by languages, scripts, or revision numbers.
+*/
++ (NSArray<NLContextualEmbedding *> *)contextualEmbeddingsForValues:(NSDictionary<NLContextualEmbeddingKey, id> *)valuesDictionary;
+
+/* Convenience APIs for finding the most recent embedding suitable for handling the given language or script.
+*/
++ (nullable NLContextualEmbedding *)contextualEmbeddingWithLanguage:(NLLanguage)language;
++ (nullable NLContextualEmbedding *)contextualEmbeddingWithScript:(NLScript)script;
+
+/* Metadata associated with an embedding.
+*/
+@property (readonly, copy) NSString *modelIdentifier;
+@property (readonly, copy) NSArray <NLLanguage> *languages;
+@property (readonly, copy) NSArray <NLScript> *scripts;
+@property (readonly) NSUInteger revision;
+@property (readonly) NSUInteger dimension;
+
+/* When an NLContextualEmbedding is created, the model is not loaded by default until it is needed. The load and unload methods can be used to control when the model is loaded. The return value of load indicates whether it succeeded. The load method will fail if the necessary assets for the specified model are not present on device, in which case hasAvailableAssets and requestEmbeddingAssetsWithCompletionHandler: can be used to manage the loading of the assets.
+*/
+- (BOOL)loadWithError:(NSError **)error;
+- (void)unload;
+
+/* This is the method for applying an embedding to a string and obtaining the resulting embedding vectors, encapsulated in an NLContextualEmbeddingResult object. If the language of the string is known, it may be specified here, otherwise it will be inferred from the string.
+*/
+- (nullable NLContextualEmbeddingResult *)embeddingResultForString:(NSString *)string language:(nullable NLLanguage)language error:(NSError **)error;
+
+/* A given NLContextualEmbedding can be loaded and used only if the necessary assets have been loaded onto the current device. Clients may use hasAvailableAssets to determine whether they are, and if they have not been, clients may put in a request for those assets. If they are available for loading, then they will be requested and at some point will be loaded and made available on the device, and the completion handler will be called on an arbitrary queue. The completion handler may be called immediately if the state of the assets is already known or if an error occurs.
+*/
+
+typedef NS_ENUM(NSInteger, NLContextualEmbeddingAssetsResult) {
+   NLContextualEmbeddingAssetsResultAvailable,
+   NLContextualEmbeddingAssetsResultNotAvailable,
+   NLContextualEmbeddingAssetsResultError
+} NS_SWIFT_NAME(NLContextualEmbedding.AssetsResult);
+
+@property (readonly) BOOL hasAvailableAssets;
+- (void)requestEmbeddingAssetsWithCompletionHandler:(void (^)(NLContextualEmbeddingAssetsResult result, NSError * _Nullable error))completionHandler;
+
+@end
+
+/* NLContextualEmbeddingResult is a class representing the embedding vectors resulting from applying a contextual embedding to a given string. Each embedding vector represents a given range in the string.
+*/
+
+NS_CLASS_AVAILABLE(14_0, 17_0)
+@interface NLContextualEmbeddingResult : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
+@property (readonly, copy) NSString *string;
+@property (readonly, copy) NLLanguage language;
+
+- (nullable NSArray <NSNumber *> *)tokenVectorAtIndex:(NSUInteger)characterIndex tokenRange:(nullable NSRangePointer)tokenRange NS_REFINED_FOR_SWIFT;
+- (void)enumerateTokenVectorsInRange:(NSRange)range usingBlock:(void (NS_NOESCAPE ^)(NSArray <NSNumber *> *tokenVector, NSRange tokenRange, BOOL *stop))block NS_REFINED_FOR_SWIFT;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLScript.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLScript.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLScript.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NLScript.h	2023-05-19 21:03:24
@@ -0,0 +1,43 @@
+/*    NLScript.h
+      Copyright (c) 2022-2023, Apple Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+/* An NLScript is a BCP-47 script tag, such as "Latn" for Latin, "Cyrl" for Cyrillic, etc. Constants are provided for a set of scripts, but this list is by no means exhaustive; clients may specify their own values using any script tag.
+*/
+
+typedef NSString *NLScript NS_TYPED_EXTENSIBLE_ENUM;
+
+FOUNDATION_EXPORT NLScript const NLScriptUndetermined API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+
+FOUNDATION_EXPORT NLScript const NLScriptArabic API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptArmenian API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptBengali API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptCanadianAboriginalSyllabics API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptCherokee API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptCyrillic API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptDevanagari API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptEthiopic API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptGeorgian API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptGreek API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptGujarati API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptGurmukhi API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptHebrew API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptJapanese API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptKannada API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptKhmer API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptKorean API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptLao API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptLatin API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptMalayalam API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptMongolian API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptMyanmar API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptOriya API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptSimplifiedChinese API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptSinhala API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptTamil API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptTelugu API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptThai API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptTibetan API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
+FOUNDATION_EXPORT NLScript const NLScriptTraditionalChinese API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0));
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NaturalLanguage.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NaturalLanguage.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NaturalLanguage.h	2023-03-04 19:16:41
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/NaturalLanguage.framework/Headers/NaturalLanguage.h	2023-05-19 21:03:24
@@ -3,11 +3,13 @@
 */
 
 #import <Foundation/Foundation.h>
+#import <NaturalLanguage/NLContextualEmbedding.h>
 #import <NaturalLanguage/NLEmbedding.h>
 #import <NaturalLanguage/NLGazetteer.h>
 #import <NaturalLanguage/NLLanguage.h>
 #import <NaturalLanguage/NLLanguageRecognizer.h>
 #import <NaturalLanguage/NLModel.h>
+#import <NaturalLanguage/NLScript.h>
 #import <NaturalLanguage/NLTagger.h>
 #import <NaturalLanguage/NLTagScheme.h>
 #import <NaturalLanguage/NLTokenizer.h>
Clone this wiki locally