Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Curio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jim Wallace
Curio
Commits
7e892787
Commit
7e892787
authored
1 year ago
by
Mingchung Xia
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation to HNSWCorpus
parent
f4b01ad6
No related branches found
No related tags found
1 merge request
!13
HNSW Implementation with Testcases
Pipeline
#110123
passed with warnings
1 year ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift
+3
-2
3 additions, 2 deletions
Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift
with
3 additions
and
2 deletions
Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift
+
3
−
2
View file @
7e892787
...
@@ -27,7 +27,7 @@ import PriorityHeapAlgorithms
...
@@ -27,7 +27,7 @@ import PriorityHeapAlgorithms
import
SimilarityMetric
import
SimilarityMetric
import
HNSWAlgorithm
import
HNSWAlgorithm
import
HNSWEphemeral
import
HNSWEphemeral
import
GameplayKit
import
GameplayKit
/// Not avaliable on Linux?
class
HNSWCorpus
<
Scalar
:
BinaryFloatingPoint
&
Codable
>
:
SNLPCorpus
{
class
HNSWCorpus
<
Scalar
:
BinaryFloatingPoint
&
Codable
>
:
SNLPCorpus
{
...
@@ -46,7 +46,7 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
...
@@ -46,7 +46,7 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
@inlinable
@inlinable
func
addUntokenizedDocument
(
_
document
:
String
)
{
func
addUntokenizedDocument
(
_
document
:
String
)
{
// Forced cast to [Scalar] is unnecessary
//
/
Forced cast to [Scalar] is unnecessary
encodedDocuments
.
insert
((
_documentEncoder
.
encodeSentence
(
document
)))
encodedDocuments
.
insert
((
_documentEncoder
.
encodeSentence
(
document
)))
}
}
}
}
...
@@ -78,6 +78,7 @@ public struct DeterministicSampleVectorIndex<Vector: Collection & Codable> where
...
@@ -78,6 +78,7 @@ public struct DeterministicSampleVectorIndex<Vector: Collection & Codable> where
public
mutating
func
insert
(
_
vector
:
Vector
)
{
public
mutating
func
insert
(
_
vector
:
Vector
)
{
let
convertedVector
:
[
Double
]
=
vector
.
map
{
Double
(
$0
)
}
let
convertedVector
:
[
Double
]
=
vector
.
map
{
Double
(
$0
)
}
if
let
metricVector
=
convertedVector
as?
CartesianDistanceMetric
<
Vector
>.
Vector
{
if
let
metricVector
=
convertedVector
as?
CartesianDistanceMetric
<
Vector
>.
Vector
{
/// Returns a Key (unused)
base
.
insert
(
metricVector
,
using
:
&
graphRNG
)
base
.
insert
(
metricVector
,
using
:
&
graphRNG
)
}
else
{
}
else
{
fatalError
(
"Unable to get metric vector"
)
fatalError
(
"Unable to get metric vector"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment