forked from mazzzystar/Queryable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmbedding.swift
More file actions
31 lines (25 loc) · 745 Bytes
/
Embedding.swift
File metadata and controls
31 lines (25 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// Embedding.swift
// Queryable
//
// Created by Ke Fang on 2022/12/20.
//
import Foundation
import CoreML
class Embedding: NSObject, NSSecureCoding {
static var supportsSecureCoding: Bool = true
var id: String?
var embedding: MLMultiArray?
init(id: String, embedding: MLMultiArray) {
self.id = id
self.embedding = embedding
}
func encode(with aCoder: NSCoder) {
aCoder.encode(self.id, forKey: "id")
aCoder.encode(self.embedding, forKey: "embedding")
}
required init?(coder aDecoder: NSCoder) {
self.id = aDecoder.decodeObject(forKey: "id") as? String
self.embedding = aDecoder.decodeObject(forKey: "embedding") as? MLMultiArray
}
}