Skip to content
Snippets Groups Projects
Commit 095f0aa0 authored by Jim Wallace's avatar Jim Wallace
Browse files

Commenting out AnnoyTest code

parent 131b61ec
No related branches found
No related tags found
No related merge requests found
Pipeline #108402 passed with warnings
......@@ -22,7 +22,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
import Foundation
#if os(Darwin)
import SwiftAnnoy
#else
#warning("Need an alternative to SwiftAnnoy for Linux")
#endif
class KeyedVectorDictionary: SNLPDictionary {
......@@ -192,22 +197,22 @@ class KeyedVectorDictionary: SNLPDictionary {
}
}
func AnnoyTest() -> (AnnoyIndex<Double>, [Int : String]) {
let index = AnnoyIndex<Double>(itemLength: width, metric: .euclidean)
var map = [Int : String]()
var idx = 0;
for (key, _ ) in token2id {
map[idx] = key
try! index.addItem(index: idx, vector: &token2id[key]!)
idx += 1
}
// You can make the number of trees larger number to make the results more accurate
try? index.build(numTrees: 10)
return (index, map)
}
// func AnnoyTest() -> (AnnoyIndex<Double>, [Int : String]) {
// let index = AnnoyIndex<Double>(itemLength: width, metric: .euclidean)
//
// var map = [Int : String]()
// var idx = 0;
//
// for (key, _ ) in token2id {
// map[idx] = key
// try! index.addItem(index: idx, vector: &token2id[key]!)
// idx += 1
// }
//
// // You can make the number of trees larger number to make the results more accurate
// try? index.build(numTrees: 10)
//
// return (index, map)
// }
}
......@@ -34,7 +34,7 @@ final class SwiftAnnoyTest: XCTestCase {
let dictionary = corpus.dictionary
let (myIndex,_) = dictionary.AnnoyTest()
//let (myIndex,_) = dictionary.AnnoyTest()
var frog = dictionary["frog"]
......@@ -44,7 +44,7 @@ final class SwiftAnnoyTest: XCTestCase {
// Change the number of neighbors below
let (_, _) = myIndex.getNNsForVector(vector: &frog, neighbors: 10)!
//let (_, _) = myIndex.getNNsForVector(vector: &frog, neighbors: 10)!
// for (id, distance) in zip(ids, distances) {
// debugPrint("\(myMap[id]!) was \(distance)")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment