From 3a30f7f3059bc4cc7e01df349bae5ceb564ea54c Mon Sep 17 00:00:00 2001 From: Mingchung Xia <mingchung.xia@gmail.com> Date: Fri, 26 Jan 2024 14:41:43 -0500 Subject: [PATCH] Minor comment changes --- .../SwiftNLP/1. Data Collection/HNSWCorpus.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift b/Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift index aac8534c..ca466ba4 100644 --- a/Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift +++ b/Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift @@ -27,7 +27,7 @@ import PriorityHeapAlgorithms import SimilarityMetric import HNSWAlgorithm import HNSWEphemeral -import GameplayKit /// Not avaliable on Linux? +import GameplayKit // Not avaliable on Linux? - try to change to other random class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus { @@ -36,9 +36,11 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus { var zeroes: [Scalar] var count: Int { 0 } - /// typicalNeighbourhoodSize = 20 is a standard benchmark + // typicalNeighbourhoodSize = 20 is a standard benchmark var encodedDocuments: DeterministicSampleVectorIndex = DeterministicSampleVectorIndex<[Scalar]>(typicalNeighborhoodSize: 20) + // Map from Key to documentId - similar to DictionaryCorpus + init(_documentEncoder: ContextFreeEncoder<Scalar>) { self._documentEncoder = _documentEncoder zeroes = Array(repeating: Scalar(0), count: 384) @@ -46,15 +48,13 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus { @inlinable func addUntokenizedDocument(_ document: String) { - /// Forced cast to [Scalar] is unnecessary - encodedDocuments.insert((_documentEncoder.encodeSentence(document))) + encodedDocuments.insert((_documentEncoder.encodeSentence(document))) /// as! [Scalar] not needed } } public struct DeterministicSampleVectorIndex<Vector: Collection & Codable> where Vector.Element: BinaryFloatingPoint { - /// EmphermalVectorIndex<Key: BinaryInteger, Level: BinaryInteger, Metric: SimilarityMetric, Metadata> public typealias Index = EphemeralVectorIndex<Int, Int, CartesianDistanceMetric<Vector>, Void> public var base: Index @@ -78,8 +78,7 @@ public struct DeterministicSampleVectorIndex<Vector: Collection & Codable> where public mutating func insert(_ vector: Vector) { let convertedVector: [Double] = vector.map{ Double($0) } if let metricVector = convertedVector as? CartesianDistanceMetric<Vector>.Vector { - /// Returns a Key (unused) - base.insert(metricVector, using: &graphRNG) + base.insert(metricVector, using: &graphRNG) /// returns an unused 'Key' type } else { fatalError("Unable to get metric vector") } @@ -97,6 +96,7 @@ public struct CartesianDistanceMetric<Vector: Collection & Codable>: SimilarityM } struct DeterministicRandomNumberGenerator: RandomNumberGenerator { + // Try another package for this... private let randomSource: GKMersenneTwisterRandomSource init(seed: UInt64) { -- GitLab